:root {
  color-scheme: light;
  --shc-color-navy-950: #0957a3;
  --shc-color-navy-900: #0957a3;
  --shc-color-navy-800: #0c447c;
  --shc-color-blue-700: #0957a3;
  --shc-color-blue-100: #e6f1fb;
  --shc-color-green-700: #3b6d11;
  --shc-color-green-100: #eaf3de;
  --shc-color-amber-700: #854f0b;
  --shc-color-amber-100: #faeeda;
  --shc-color-red-700: #a32d2d;
  --shc-color-red-100: #fcebeb;
  --shc-color-ink: #1a1a18;
  --shc-color-text: #5f5e5a;
  --shc-color-muted: #8f8d87;
  --shc-color-border: rgb(0 0 0 / 12%);
  --shc-color-border-strong: rgb(0 0 0 / 22%);
  --shc-color-surface: #ffffff;
  --shc-color-surface-muted: #f7f7f6;
  --shc-color-page: #f0efec;
  --shc-color-sidebar-text: #ffffff;
  --shc-color-sidebar-muted: rgb(255 255 255 / 72%);
  --shc-color-sidebar-soft: rgb(255 255 255 / 11%);
  --shc-color-sidebar-active: rgb(255 255 255 / 18%);
  --shc-color-sidebar-border: rgb(255 255 255 / 18%);
  --shc-radius-sm: 3px;
  --shc-radius-md: 6px;
  --shc-shadow-panel: 0 1px 2px rgb(26 26 24 / 10%), 0 4px 14px rgb(26 26 24 / 7%);
  --shc-sidebar-width: 236px;
  --shc-topbar-height: 58px;

  /* Compatibility aliases for the original single-file app. */
  --bg: var(--shc-color-surface);
  --bg2: var(--shc-color-surface-muted);
  --bg3: var(--shc-color-page);
  --text: var(--shc-color-ink);
  --text2: var(--shc-color-text);
  --text3: var(--shc-color-muted);
  --border: var(--shc-color-border);
  --border2: var(--shc-color-border-strong);
  --blue: var(--shc-color-blue-700);
  --blue-bg: var(--shc-color-blue-100);
  --blue-text: var(--shc-color-navy-800);
  --green: var(--shc-color-green-700);
  --green-bg: var(--shc-color-green-100);
  --green-text: #27500a;
  --amber: var(--shc-color-amber-700);
  --amber-bg: var(--shc-color-amber-100);
  --amber-text: #633806;
  --coral: #993c1d;
  --coral-bg: #faece7;
  --coral-text: #712b13;
  --red: var(--shc-color-red-700);
  --red-bg: var(--shc-color-red-100);
  --red-text: #791f1f;
  --gray-bg: #f1efe8;
  --gray-text: var(--shc-color-text);
  --radius: var(--shc-radius-sm);
  --radius-lg: var(--shc-radius-md);
}

body {
  min-width: 320px;
  background: var(--shc-color-page);
  color: var(--shc-color-ink);
  letter-spacing: 0;
}

button,
input,
select,
textarea {
  letter-spacing: 0;
}

.app {
  min-height: 100vh;
}

.sidebar {
  width: var(--shc-sidebar-width);
  background: var(--shc-color-navy-900);
  border-right: 0;
  color: var(--shc-color-sidebar-text);
}

.logo {
  min-height: var(--shc-topbar-height);
  padding: 10px 14px;
  border-bottom-color: var(--shc-color-sidebar-border);
  display: flex;
  align-items: center;
}

.logo-mark {
  gap: 10px;
  margin: 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  border: 1px solid var(--shc-color-sidebar-border);
  border-radius: var(--shc-radius-sm);
  background: var(--shc-color-sidebar-soft);
  display: grid;
  place-items: center;
  flex: 0 0 36px;
}

.brand-icon svg {
  width: 20px;
  height: 20px;
}

.logo h2,
.logo p,
.nav-section,
.sc-label,
.sc-val,
thead th,
.routing-label,
.topbar h1 {
  letter-spacing: 0;
}

.logo h2 {
  color: var(--shc-color-sidebar-text);
  font-size: 0.94rem;
  font-weight: 720;
  line-height: 1.2;
}

.logo p {
  color: var(--shc-color-sidebar-muted);
  font-size: 0.68rem;
  line-height: 1.35;
}

.nav-section {
  color: var(--shc-color-sidebar-muted);
  font-size: 0.68rem;
  font-weight: 700;
  padding: 17px 16px 6px;
}

.nav {
  min-height: 40px;
  margin: 2px 8px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--shc-radius-sm);
  color: var(--shc-color-sidebar-muted);
  font-size: 0.82rem;
  transition: background-color 120ms ease, color 120ms ease;
}

.nav:hover {
  background: var(--shc-color-sidebar-soft);
  color: var(--shc-color-sidebar-text);
}

.nav.active {
  background: var(--shc-color-sidebar-active);
  color: var(--shc-color-sidebar-text);
  border: 0;
  font-weight: 700;
}

.nav svg {
  width: 17px;
  height: 17px;
}

.nav .badge-count {
  background: var(--shc-color-amber-100);
  color: var(--shc-color-amber-700);
}

.sidebar-footer {
  border-top-color: var(--shc-color-sidebar-border);
  padding: 14px;
}

#user-info {
  margin-bottom: 10px;
  color: var(--shc-color-sidebar-text);
  font-size: 0.72rem;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.routing-label,
.routing-row {
  color: var(--shc-color-sidebar-muted);
}

.sidebar-signout {
  width: 100%;
  margin-top: 11px;
  justify-content: center;
  border-color: var(--shc-color-sidebar-border);
  background: transparent;
  color: var(--shc-color-sidebar-text);
}

.sidebar-signout:hover {
  background: var(--shc-color-sidebar-soft);
}

.main {
  min-width: 0;
  background: var(--shc-color-page);
}

.topbar {
  min-height: var(--shc-topbar-height);
  padding: 10px 24px;
  background: var(--shc-color-surface-muted);
  border-bottom-color: var(--shc-color-border);
}

.topbar-trail {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--shc-color-muted);
  font-size: 0.76rem;
  white-space: nowrap;
}

.topbar-trail strong {
  min-width: 0;
  max-width: 360px;
  overflow: hidden;
  color: var(--shc-color-ink);
  font-weight: 700;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.content {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 22px 24px 32px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  min-height: 74px;
  margin-bottom: 18px;
}

.eyebrow {
  margin-bottom: 3px;
  color: var(--shc-color-blue-700);
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.page-heading h1 {
  color: var(--shc-color-ink);
  font-size: 1.65rem;
  font-weight: 720;
  line-height: 1.2;
  letter-spacing: 0;
}

.page-heading p:last-child {
  max-width: 700px;
  margin-top: 4px;
  color: var(--shc-color-text);
  font-size: 0.82rem;
}

.stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  margin-bottom: 18px;
  overflow: hidden;
  background: var(--shc-color-surface);
  border: 1px solid var(--shc-color-border);
  border-radius: var(--shc-radius-md);
  box-shadow: var(--shc-shadow-panel);
}

.sc {
  min-width: 0;
  padding: 15px 17px;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--shc-color-border);
  border-radius: 0;
}

.sc:last-child {
  border-right: 0;
}

.sc-label {
  color: var(--shc-color-muted);
  font-size: 0.67rem;
  font-weight: 750;
}

.sc-val {
  color: var(--shc-color-ink);
  font-size: 1.45rem;
  font-weight: 720;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(260px, 1fr);
  gap: 16px;
}

.panel {
  overflow-x: auto;
  background: var(--shc-color-surface);
  border-color: var(--shc-color-border);
  border-radius: var(--shc-radius-md);
  box-shadow: var(--shc-shadow-panel);
}

.ph {
  min-height: 47px;
  padding: 11px 15px;
  border-bottom-color: var(--shc-color-border);
}

.ph h3 {
  color: var(--shc-color-ink);
  font-size: 0.8rem;
  font-weight: 720;
  letter-spacing: 0;
}

.pb {
  padding: 15px;
}

table {
  min-width: 620px;
  font-size: 0.76rem;
}

thead th {
  padding: 9px 12px;
  background: var(--shc-color-surface-muted);
  color: var(--shc-color-muted);
  font-size: 0.66rem;
  font-weight: 750;
}

tbody tr:hover {
  background: var(--shc-color-surface-muted);
}

tbody td {
  padding: 10px 12px;
}

.badge {
  min-height: 22px;
  padding: 4px 8px;
  font-size: 0.69rem;
  font-weight: 750;
}

.btn {
  min-height: 36px;
  padding: 7px 12px;
  border-radius: var(--shc-radius-sm);
  background: var(--shc-color-surface);
  color: var(--shc-color-ink);
  font-weight: 650;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}

.btn:hover {
  background: var(--shc-color-surface-muted);
}

.btn:active {
  transform: none;
}

.btn-primary {
  background: var(--shc-color-blue-700);
  border-color: var(--shc-color-blue-700);
  color: #fff;
}

.btn-primary:hover {
  background: var(--shc-color-navy-800);
  opacity: 1;
}

.btn-sm,
.btn-xs {
  min-height: 32px;
  padding: 6px 10px;
  font-size: 0.72rem;
}

.fg label {
  color: var(--shc-color-ink);
  font-size: 0.76rem;
  font-weight: 700;
}

.fg input,
.fg select,
.fg textarea {
  min-height: 38px;
  border-radius: var(--shc-radius-sm);
  background: var(--shc-color-surface);
  color: var(--shc-color-ink);
}

.fg input:focus,
.fg select:focus,
.fg textarea:focus {
  outline: 2px solid rgb(9 87 163 / 18%);
  outline-offset: 1px;
}

.risk-banner,
.config-warning,
.sync-error,
.pend-card,
.audit-row,
.history-entry {
  border-radius: var(--shc-radius-sm);
}

.pend-card {
  background: var(--shc-color-surface-muted);
}

.sync-status {
  min-height: 30px;
  padding: 5px 8px;
  border: 1px solid var(--shc-color-border);
  border-radius: 999px;
  background: var(--shc-color-surface);
}

.auth-screen {
  padding: 20px;
  background: var(--shc-color-page);
}

.auth-card {
  max-width: 420px;
  padding: 30px;
  background: var(--shc-color-surface);
  border-color: var(--shc-color-border);
  border-top: 4px solid var(--shc-color-blue-700);
  border-radius: var(--shc-radius-md);
  box-shadow: var(--shc-shadow-panel);
}

.auth-card h2 {
  color: var(--shc-color-ink);
  font-size: 1.08rem;
  font-weight: 720;
}

.modal {
  background: var(--shc-color-surface);
  border-color: var(--shc-color-border);
  border-radius: var(--shc-radius-md);
  box-shadow: 0 18px 50px rgb(26 26 24 / 28%);
}

@media (max-width: 1100px) {
  .topbar-trail span:first-child,
  .topbar-trail span:nth-child(2) {
    display: none;
  }

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

@media (max-width: 820px) {
  :root {
    --shc-sidebar-width: 64px;
  }

  .sidebar {
    width: var(--shc-sidebar-width);
  }

  .logo {
    justify-content: center;
    padding-inline: 8px;
  }

  .logo-copy,
  .nav span:not(.badge-count),
  .nav-section,
  .sidebar-footer {
    display: none;
  }

  .nav {
    justify-content: center;
    margin-inline: 8px;
    padding-inline: 8px;
  }

  .nav .badge-count {
    position: absolute;
    transform: translate(12px, -12px);
  }

  .topbar {
    padding-inline: 14px;
  }

  .topbar .btn:not(.btn-primary) .action-label {
    display: none;
  }

  .content {
    padding: 18px 16px 28px;
  }

  .dashboard-grid table {
    min-width: 0;
    table-layout: fixed;
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .sc:nth-child(2) {
    border-right: 0;
  }

  .sc:nth-child(-n + 2) {
    border-bottom: 1px solid var(--shc-color-border);
  }
}

@media (max-width: 560px) {
  .topbar {
    align-items: flex-start;
    gap: 8px;
  }

  .topbar-actions {
    gap: 5px;
  }

  .topbar .action-label {
    display: none;
  }

  .topbar .btn {
    width: 34px;
    min-height: 34px;
    padding: 0;
    justify-content: center;
  }

  .sync-status span {
    display: none;
  }

  .sync-status {
    width: 30px;
    justify-content: center;
    padding: 0;
  }

  .page-heading {
    min-height: 62px;
  }

  .page-heading h1 {
    font-size: 1.35rem;
  }

  .dashboard-grid th:nth-child(3),
  .dashboard-grid td:nth-child(3) {
    display: none;
  }

  .dashboard-grid th:first-child {
    width: 68px !important;
  }

  .dashboard-grid th:last-child {
    width: 116px !important;
  }

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