:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17202a;
  background: #f4f6f8;
  font-synthesis: none;
  --ink: #17202a;
  --muted: #66727f;
  --line: #dfe4e8;
  --panel: #ffffff;
  --nav: #172b3d;
  --brand: #16766f;
  --brand-dark: #0f5f5a;
  --brand-soft: #e8f5f3;
  --danger: #b42318;
  --danger-soft: #fef0ee;
  --warning: #a15c00;
  --warning-soft: #fff4df;
  --shadow: 0 1px 2px rgba(23, 32, 42, .04), 0 8px 24px rgba(23, 32, 42, .05);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: #f4f6f8; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 26px 18px; color: #dce5eb; background: var(--nav); }
.brand { display: flex; align-items: center; gap: 11px; margin: 0 8px 30px; color: #fff; font-size: 19px; font-weight: 750; letter-spacing: -.02em; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: #fff; background: var(--brand); font-size: 17px; }
.sidebar-label { margin: 0 12px 9px; color: #8293a1; font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; }
.nav { display: grid; gap: 5px; }
.nav a { display: flex; gap: 11px; align-items: center; padding: 11px 12px; border-radius: 8px; color: #cad5dd; text-decoration: none; font-size: 14px; font-weight: 600; }
.nav a:hover, .nav a.active { color: #fff; background: rgba(255, 255, 255, .09); }
.nav-icon { width: 19px; text-align: center; opacity: .9; }
.workspace { min-width: 0; }
.topbar { min-height: 72px; padding: 0 34px; display: flex; align-items: center; justify-content: space-between; gap: 20px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar-leading { min-width: 0; display: flex; align-items: center; gap: 12px; }
.topbar-context { min-width: 0; }
.topbar-title { font-size: 14px; font-weight: 700; }
.topbar-subtitle { margin-top: 2px; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 14px; color: var(--muted); font-size: 13px; }
.menu-toggle { display: none; width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 8px; color: var(--ink); background: #fff; font-size: 20px; }
.sidebar-overlay { display: none; }
.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: 10px; padding: 7px 9px; border-radius: 9px; color: var(--ink); cursor: pointer; list-style: none; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover, .user-menu[open] summary { background: #f3f5f6; }
.user-avatar { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; color: #fff; background: var(--brand); font-weight: 750; }
.user-copy { max-width: 220px; display: grid; gap: 2px; text-align: left; }
.user-copy strong, .user-copy small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-copy strong { font-size: 13px; }
.user-copy small { color: var(--muted); font-size: 11px; font-weight: 500; }
.user-caret { color: var(--muted); font-size: 11px; }
.user-dropdown { position: absolute; z-index: 25; top: calc(100% + 7px); right: 0; width: 210px; padding: 7px; background: #fff; border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 16px 40px rgba(18, 31, 43, .16); }
.user-dropdown a, .user-dropdown button { width: 100%; display: flex; padding: 10px 11px; border: 0; border-radius: 7px; color: var(--ink); background: transparent; font-size: 13px; font-weight: 650; text-align: left; text-decoration: none; }
.user-dropdown a:hover, .user-dropdown button:hover { background: #f3f5f6; }
.user-dropdown button { color: var(--danger); }
.content { width: 100%; max-width: 1500px; margin: 0 auto; padding: 30px 34px 54px; }
.page-heading { margin-bottom: 23px; display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-heading h1 { margin: 0; font-size: 27px; line-height: 1.2; letter-spacing: -.025em; }
.page-heading p { margin: 7px 0 0; color: var(--muted); font-size: 14px; }

.grid { display: grid; gap: 18px; }
.metrics { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.two-columns { grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); }
.card { min-width: 0; padding: 22px; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 17px; font-size: 17px; letter-spacing: -.012em; }
.card-header { margin-bottom: 17px; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.card-header h2 { margin: 0; }
.metric-label { color: var(--muted); font-size: 13px; font-weight: 650; }
.metric-value { margin-top: 12px; font-size: 30px; line-height: 1; font-weight: 750; letter-spacing: -.035em; }
.metric-note { margin-top: 10px; color: var(--muted); font-size: 12px; }
.metric.good .metric-value { color: var(--brand-dark); }
.metric.bad .metric-value { color: var(--danger); }

.table-wrap { width: 100%; overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th { padding: 10px 12px; color: var(--muted); background: #f8f9fa; border-top: 1px solid #edf0f2; border-bottom: 1px solid var(--line); text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; white-space: nowrap; }
td { padding: 13px 12px; border-bottom: 1px solid #edf0f2; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafbfb; }
.primary-link { color: #116861; font-weight: 700; text-decoration: none; }
.primary-link:hover { text-decoration: underline; }
.subline { display: block; margin-top: 3px; color: var(--muted); font-size: 12px; }
.empty { padding: 34px 18px; color: var(--muted); text-align: center; }

.badge { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 3px 9px; border-radius: 999px; background: #eef1f3; color: #4d5a65; font-size: 11px; font-weight: 750; white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { color: #0d6b52; background: #e7f5ef; }
.badge.warn { color: var(--warning); background: var(--warning-soft); }
.badge.bad { color: var(--danger); background: var(--danger-soft); }
.badge.neutral { color: #596673; background: #eef1f3; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 9px 15px; border: 1px solid transparent; border-radius: 8px; color: #fff; background: var(--brand); font-size: 13px; font-weight: 700; text-decoration: none; }
.button:hover { background: var(--brand-dark); }
.button.secondary { color: var(--ink); background: #fff; border-color: #cfd6dc; }
.button.secondary:hover { background: #f7f8f9; }
.button.ghost { min-height: 34px; padding: 6px 10px; color: #31515d; background: transparent; border-color: #d8dfe4; }
.button.danger { color: var(--danger); background: #fff; border-color: #efc5c1; }
.button.danger:hover { background: var(--danger-soft); }
.button:disabled { opacity: .55; cursor: default; }
.link-button { padding: 5px 0; border: 0; color: #fff; background: transparent; font-size: 13px; font-weight: 650; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px 18px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-title { color: #34414c; font-size: 13px; font-weight: 650; }
.field input, .field select { width: 100%; min-height: 42px; padding: 9px 11px; border: 1px solid #cbd3d9; border-radius: 8px; color: var(--ink); background: #fff; outline: none; }
.field input:focus, .field select:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22, 118, 111, .12); }
.field small { color: var(--muted); font-size: 11px; line-height: 1.4; }
.checkbox { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; }
.checkbox input { width: 18px; height: 18px; accent-color: var(--brand); }
.form-actions { grid-column: 1 / -1; margin-top: 3px; display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.form-message { grid-column: 1 / -1; min-height: 18px; margin: 0; font-size: 12px; }
.error { color: var(--danger); }
.success { color: #0d6b52; }
.muted { color: var(--muted); }

.details { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px 24px; }
.detail-label { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .035em; text-transform: uppercase; }
.detail-value { margin-top: 6px; font-size: 14px; font-weight: 650; overflow-wrap: anywhere; }
.tabs { margin: -4px 0 20px; display: flex; gap: 4px; overflow-x: auto; border-bottom: 1px solid var(--line); }
.tabs a { padding: 10px 12px; color: var(--muted); border-bottom: 2px solid transparent; font-size: 13px; font-weight: 650; text-decoration: none; white-space: nowrap; }
.tabs a:hover { color: var(--brand-dark); border-color: var(--brand); }
.section-stack { display: grid; gap: 18px; }
.status-list { display: grid; gap: 13px; }
.status-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding-bottom: 12px; border-bottom: 1px solid #edf0f2; }
.status-row:last-child { padding-bottom: 0; border: 0; }
.status-row span:first-child { color: var(--muted); font-size: 13px; }
.status-row strong { font-size: 14px; text-align: right; }

.modal { position: fixed; inset: 0; z-index: 30; display: none; place-items: center; padding: 22px; background: rgba(18, 31, 43, .48); }
.modal.open { display: grid; }
.modal-panel { width: min(650px, 100%); max-height: calc(100vh - 44px); overflow-y: auto; padding: 25px; background: #fff; border-radius: 13px; box-shadow: 0 24px 70px rgba(7, 17, 27, .25); }
.modal-head { margin-bottom: 20px; display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; }
.modal-head h2 { margin: 0; font-size: 20px; }
.close { width: 34px; height: 34px; border: 0; border-radius: 7px; color: var(--muted); background: #f1f3f5; font-size: 20px; }
.activation-code { margin: 18px 0 8px; padding: 17px; border: 1px dashed #87b9b4; border-radius: 10px; color: var(--brand-dark); background: var(--brand-soft); text-align: center; font: 750 26px ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: .07em; }

.auth-page { min-height: 100vh; display: grid; grid-template-columns: minmax(320px, 430px) minmax(0, 1fr); background: #fff; }
.auth-panel { padding: 48px; display: flex; flex-direction: column; justify-content: center; }
.auth-card { width: 100%; max-width: 360px; margin: auto; }
.auth-card .brand { margin: 0 0 44px; color: var(--ink); }
.auth-card h1 { margin: 0 0 8px; font-size: 28px; letter-spacing: -.025em; }
.auth-card > p { margin: 0 0 26px; color: var(--muted); font-size: 14px; line-height: 1.55; }
.auth-card form { display: grid; gap: 16px; }
.auth-card .button { width: 100%; margin-top: 4px; }
.auth-secondary { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; text-align: center; }
.auth-secondary a { color: var(--brand-dark); font-weight: 700; }
.auth-visual { position: relative; display: flex; flex-direction: column; justify-content: flex-end; min-height: 100vh; padding: 58px; overflow: hidden; color: #e8f1f4; background: #183447; }
.auth-visual::before { content: ""; position: absolute; width: 580px; height: 580px; top: -240px; right: -140px; border: 120px solid rgba(44, 157, 146, .22); border-radius: 50%; }
.auth-visual::after { content: ""; position: absolute; width: 360px; height: 360px; bottom: -180px; left: -90px; border: 80px solid rgba(255, 255, 255, .06); border-radius: 50%; }
.auth-visual-content { position: relative; z-index: 1; max-width: 600px; }
.auth-visual h2 { margin: 0 0 14px; font-size: clamp(28px, 3vw, 44px); letter-spacing: -.035em; }
.auth-visual p { margin: 0; color: #bdd0d9; font-size: 17px; line-height: 1.6; }
.loading { padding: 80px 20px; color: var(--muted); text-align: center; }
.toast { position: fixed; right: 24px; bottom: 24px; z-index: 40; max-width: 380px; padding: 13px 16px; color: #fff; background: #243642; border-radius: 9px; box-shadow: 0 10px 35px rgba(0,0,0,.2); font-size: 13px; }

@media (max-width: 1080px) {
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-columns { grid-template-columns: 1fr; }
}
@media (max-width: 780px) {
  .app-shell { display: block; }
  .sidebar { position: fixed; z-index: 50; left: 0; width: 260px; padding: 26px 18px; transform: translateX(-105%); transition: transform .2s ease; box-shadow: 16px 0 50px rgba(10, 23, 34, .25); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { position: fixed; inset: 0; z-index: 45; display: block; border: 0; background: rgba(18, 31, 43, .42); }
  .brand { margin: 0 8px 30px; justify-content: flex-start; }
  .brand-text, .sidebar-label, .nav-text { display: initial; }
  .nav a { justify-content: flex-start; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .topbar { padding: 0 20px; }
  .content { padding: 24px 20px 44px; }
  .details { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .auth-page { grid-template-columns: 1fr; }
  .auth-visual { display: none; }
}
@media (max-width: 560px) {
  .metrics, .form-grid, .details { grid-template-columns: 1fr; }
  .page-heading { align-items: stretch; flex-direction: column; }
  .user-copy { display: none; }
  .user-menu summary { padding: 5px; }
  .user-caret { display: none; }
  .auth-panel { padding: 30px 22px; }
}
