:root {
  --ink: #111821;
  --muted: #647080;
  --line: #d8dee6;
  --paper: #edf1f4;
  --white: #ffffff;
  --graphite: #0f1822;
  --graphite-2: #182330;
  --panel: #f8fafb;
  --copper: #b96932;
  --copper-dark: #8f4f27;
  --green: #247056;
  --gold: #d5a34b;
  --red: #b94b41;
  --blue: #315a85;
  --shadow: 0 18px 44px rgba(17, 24, 33, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.42), rgba(255, 255, 255, 0) 32%),
    var(--paper);
  font-family: Inter, "Segoe UI", Arial, sans-serif;
}

body.auth-pending .admin-sidebar,
body.auth-pending .admin-main,
body.auth-locked .admin-sidebar,
body.auth-locked .admin-main {
  display: none;
}

body.authenticated .auth-screen {
  display: none;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
a,
input,
select,
textarea {
  border-radius: 0;
}

.admin-sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 292px;
  display: flex;
  flex-direction: column;
  padding: 24px;
  color: var(--white);
  background:
    linear-gradient(180deg, rgba(185, 105, 50, 0.12), rgba(185, 105, 50, 0) 32%),
    var(--graphite);
}

.admin-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 34px;
}

.admin-brand span {
  display: grid;
  place-items: center;
  width: 98px;
  height: 52px;
  overflow: hidden;
}

.admin-brand img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.admin-brand strong {
  font-size: 1rem;
}

.admin-nav {
  display: grid;
  gap: 7px;
}

.admin-nav a,
.public-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 46px;
  padding: 12px 14px;
  color: rgba(255, 255, 255, 0.76);
  font-weight: 760;
}

.admin-nav a:hover,
.admin-nav a.active {
  color: var(--white);
  background: rgba(255, 255, 255, 0.1);
}

.admin-nav em {
  min-width: 25px;
  padding: 4px 7px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
  font-style: normal;
  text-align: center;
}

.public-link {
  margin-top: auto;
  border: 1px solid rgba(255, 255, 255, 0.22);
  justify-content: center;
}

.auth-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--white);
  background:
    linear-gradient(135deg, rgba(185, 105, 50, 0.2), rgba(15, 24, 34, 0.82)),
    var(--graphite);
}

.auth-card {
  width: min(440px, 100%);
  padding: 32px;
  background: rgba(15, 24, 34, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

.auth-logo {
  display: grid;
  place-items: center;
  width: 170px;
  height: 84px;
  margin-bottom: 26px;
}

.auth-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-card h1 {
  font-size: clamp(2rem, 6vw, 3rem);
}

.auth-card p:not(.kicker) {
  color: rgba(255, 255, 255, 0.76);
  line-height: 1.6;
}

.auth-card label {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  color: rgba(255, 255, 255, 0.82);
  font-weight: 800;
}

.auth-card input {
  width: 100%;
  min-height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(255, 255, 255, 0.08);
  color: var(--white);
  padding: 12px 14px;
  outline: none;
}

.auth-card input:focus {
  border-color: var(--gold);
}

.auth-card .primary-button {
  width: 100%;
  margin-top: 22px;
}

.auth-error {
  display: block;
  min-height: 22px;
  margin-top: 14px;
  color: #ffd5cf;
}

.admin-main {
  margin-left: 292px;
  padding: 34px;
}

.admin-topbar,
.panel-header,
.topbar-actions,
.message-list header,
.post-list header,
.notification-list header,
.document-grid header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.admin-topbar {
  align-items: center;
}

.kicker {
  margin: 0 0 7px;
  color: var(--copper);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.25rem, 4vw, 3.55rem);
}

h2 {
  font-size: 1.25rem;
}

.sync-status {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.9rem;
}

.primary-button,
.ghost-button,
.small-button,
.row-actions button,
td button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  color: var(--white);
  background: var(--copper);
}

.primary-button:hover {
  background: var(--copper-dark);
}

.ghost-button,
.small-button,
.row-actions button,
td button {
  color: var(--ink);
  background: var(--white);
  border-color: var(--line);
}

.ghost-button:hover,
.small-button:hover,
.row-actions button:hover,
td button:hover {
  border-color: rgba(185, 105, 50, 0.5);
}

.status-grid,
.insight-grid,
.dashboard-grid {
  display: grid;
  gap: 18px;
}

.status-grid {
  grid-template-columns: repeat(4, 1fr);
  margin: 30px 0 18px;
}

.insight-grid {
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 18px;
}

.dashboard-grid {
  grid-template-columns: minmax(0, 1.35fr) minmax(360px, 0.65fr);
}

.metric-card,
.panel {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.metric-card {
  min-height: 170px;
  padding: 22px;
}

.metric-card span,
.document-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin: 18px 0 8px;
  font-size: 2.6rem;
  line-height: 1;
}

.metric-card p,
.document-grid p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.metric-card b {
  color: var(--ink);
}

.metric-card.warning {
  border-color: rgba(185, 75, 65, 0.28);
}

.metric-card.warning strong {
  color: var(--red);
}

.panel {
  padding: 22px;
  min-width: 0;
}

.wide-panel {
  grid-column: span 1;
}

.panel-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 12px;
  margin-top: 18px;
}

.panel-tools input,
.panel-tools select,
.content-form input,
.content-form select,
.content-form textarea,
.inline-form input,
.inline-form select,
.settings-form input[type="text"] {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  padding: 12px 13px;
  outline: none;
}

.panel-tools input:focus,
.panel-tools select:focus,
.content-form input:focus,
.content-form select:focus,
.content-form textarea:focus,
.inline-form input:focus,
.inline-form select:focus,
.settings-form input[type="text"]:focus {
  border-color: var(--copper);
}

.content-form,
.inline-form,
.progress-form,
.post-list,
.notification-list,
.message-list,
.activity-log,
.document-grid,
.settings-form,
.progress-list,
.chart-bars {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.content-form,
.inline-form {
  padding: 16px;
  background: var(--panel);
  border: 1px solid var(--line);
}

.inline-form {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.document-form {
  grid-template-columns: minmax(0, 1fr) 160px 150px 120px;
}

.compact-form {
  grid-template-columns: 1fr 130px;
}

.compact-form .primary-button {
  grid-column: 1 / -1;
}

.content-form textarea {
  resize: vertical;
}

.toggle-row {
  display: flex !important;
  align-items: center;
  gap: 10px !important;
  color: var(--muted);
  font-weight: 800;
}

.progress-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.progress-form input {
  width: 100%;
  accent-color: var(--copper);
}

.progress-list div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 12px;
  align-items: center;
}

.meter-line {
  grid-column: 1 / -1;
  height: 10px;
  overflow: hidden;
  background: #e4e9ee;
}

.meter-line i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--gold));
}

.chart-row {
  display: grid;
  grid-template-columns: 96px 1fr 28px;
  gap: 10px;
  align-items: center;
  color: var(--muted);
  font-size: 0.92rem;
}

.chart-track {
  height: 12px;
  background: #e4e9ee;
  overflow: hidden;
}

.chart-track i {
  display: block;
  height: 100%;
  background: var(--copper);
}

.activity-log article,
.message-list article,
.post-list article,
.notification-list article,
.document-grid article {
  border: 1px solid var(--line);
  background: var(--panel);
  padding: 15px;
}

.activity-log article {
  display: grid;
  gap: 4px;
}

.activity-log strong,
.message-list strong,
.post-list strong,
.notification-list strong,
.document-grid strong {
  font-size: 0.98rem;
}

.activity-log span,
.message-list p,
.post-list p,
.notification-list p,
.document-grid p {
  margin: 7px 0 0;
  color: var(--muted);
  line-height: 1.55;
}

.message-list article.is-read {
  opacity: 0.72;
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.row-actions button,
td button {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 0.82rem;
}

.empty-state {
  padding: 18px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--line);
}

.table-wrap {
  overflow-x: auto;
  margin-top: 18px;
}

table {
  width: 100%;
  min-width: 780px;
  border-collapse: collapse;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--muted);
  font-size: 0.76rem;
  text-transform: uppercase;
}

.table-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
}

.table-progress span {
  flex: 1;
  height: 8px;
  background: #e4e9ee;
}

.table-progress i {
  display: block;
  height: 100%;
  background: var(--green);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-weight: 850;
}

.badge.good {
  color: #1d5d45;
  background: #dff1e9;
}

.badge.info {
  color: var(--blue);
  background: #e1edf8;
}

.badge.warn {
  color: #8f4f27;
  background: #f5e5d8;
}

.badge.danger {
  color: #8d3831;
  background: #f7dddd;
}

.document-grid {
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}

.settings-form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 80;
  max-width: 360px;
  padding: 14px 16px;
  color: var(--white);
  background: var(--graphite);
  box-shadow: var(--shadow);
  font-weight: 800;
}

@media (max-width: 1220px) {
  .status-grid,
  .insight-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .dashboard-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 940px) {
  .admin-sidebar {
    position: static;
    width: auto;
    padding: 14px;
  }

  .admin-brand {
    margin-bottom: 14px;
  }

  .admin-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
  }

  .admin-nav a {
    flex: 0 0 auto;
    gap: 10px;
  }

  .public-link {
    display: inline-flex;
    margin-top: 8px;
    min-height: 40px;
  }

  .admin-main {
    margin-left: 0;
    padding: 20px 14px;
  }

  .admin-topbar,
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions,
  .panel-tools,
  .inline-form,
  .document-form,
  .compact-form {
    width: 100%;
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  .status-grid,
  .insight-grid {
    grid-template-columns: 1fr;
  }

  .admin-topbar {
    gap: 18px;
  }

  h1 {
    font-size: 2.1rem;
  }

  .topbar-actions {
    display: grid;
  }
}
