:root {
    color-scheme: light;
    --ink: #17221f;
    --muted: #66736f;
    --line: #dce5e1;
    --canvas: #f2f6f4;
    --paper: #ffffff;
    --night: #10241f;
    --night-2: #17322b;
    --teal: #087d6e;
    --teal-soft: #dff3ed;
    --cyan: #277c9c;
    --cyan-soft: #e1f1f7;
    --amber: #a86a00;
    --amber-soft: #fff0cf;
    --coral: #b84d5b;
    --coral-soft: #fae7ea;
    --shadow: 0 14px 34px rgba(17, 48, 40, .08);
}

:root[data-theme="dark"] {
    color-scheme: dark;
    --ink: #e9f1ee;
    --muted: #9aacA6;
    --line: #30463f;
    --canvas: #0d1c18;
    --paper: #162923;
    --night: #091511;
    --night-2: #142d26;
    --teal: #59cdb4;
    --teal-soft: #1c4036;
    --cyan: #76b9d3;
    --cyan-soft: #193946;
    --amber: #f0bb5b;
    --amber-soft: #44361d;
    --coral: #ef8791;
    --coral-soft: #45262b;
    --shadow: 0 14px 36px rgba(0, 0, 0, .28);
}

* { box-sizing: border-box; }
html { min-width: 320px; }
body { margin: 0; background: var(--canvas); color: var(--ink); font: 14px/1.5 Inter, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }

.portal-shell { --workspace-gutter: clamp(16px, 2vw, 48px); width: 100%; max-width: none; min-height: 100vh; display: grid; grid-template-columns: 248px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 22px 15px; color: #fff; background: var(--night); display: flex; flex-direction: column; z-index: 20; }
.brand { display: flex; align-items: center; gap: 12px; padding: 3px 9px 26px; text-decoration: none; }
.brand img { width: 46px; height: 46px; object-fit: contain; }
.brand span { display: grid; line-height: 1.17; }
.brand strong { font-size: 18px; }
.brand small { color: #a9c8bf; font-size: 12px; }
.brand em { margin-top: 4px; color: #68a596; font-size: 9px; font-style: normal; }
.sidebar nav { display: grid; gap: 4px; }
.sidebar nav a, .settings-link { min-height: 44px; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 6px; color: #b7cbc5; text-decoration: none; font-weight: 650; transition: color .18s ease, background-color .18s ease, transform .18s ease; }
.sidebar nav a span { width: 8px; height: 8px; border: 1px solid #628d82; border-radius: 50%; transition: background-color .18s ease, border-color .18s ease, box-shadow .18s ease; }
.sidebar nav a:hover, .settings-link:hover { color: #fff; background: #1b3931; transform: translateX(3px); }
.sidebar nav a.active, .settings-link.active { color: #fff; background: #24443b; }
.sidebar nav a:hover span, .sidebar nav a.active span { border-color: #65d2b5; background: #65d2b5; box-shadow: 0 0 0 3px rgba(101, 210, 181, .14); }
.sidebar-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 17px; border-top: 1px solid #28483f; color: #789b92; font-size: 11px; }
.settings-link { margin: -8px -8px 2px; font-size: 13px; }
.environment { display: flex; align-items: center; gap: 7px; }
.environment i { width: 7px; height: 7px; border-radius: 50%; background: #ebb84e; }

.workspace { width: 100%; min-width: 0; }
.topbar { height: 78px; padding: 0 var(--workspace-gutter); border-bottom: 1px solid var(--line); background: var(--paper); display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.topbar h1 { margin: 1px 0 0; font-size: 20px; letter-spacing: 0; }
.crumb { color: var(--muted); font-size: 10px; text-transform: uppercase; font-weight: 750; }
.top-actions { display: flex; align-items: center; gap: 10px; }
.admin-chip { display: flex; align-items: center; gap: 9px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 7px; }
.admin-chip > span { width: 30px; height: 30px; border-radius: 50%; background: var(--teal-soft); color: var(--teal); display: grid; place-items: center; font-weight: 800; }
.admin-chip div { display: grid; line-height: 1.2; }
.admin-chip small { color: var(--muted); font-size: 10px; }
.icon-button, .mobile-menu { width: 40px; height: 40px; border: 1px solid var(--line); border-radius: 6px; background: var(--paper); color: var(--ink); cursor: pointer; }
.mobile-menu { display: none; }
.content { width: 100%; max-width: none; min-width: 0; padding: 30px var(--workspace-gutter) 54px; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 20px; margin-bottom: 22px; }
.page-heading h2 { margin: 2px 0 4px; font-size: 28px; letter-spacing: 0; }
.page-heading p { margin: 0; color: var(--muted); }
.eyebrow { color: var(--teal); font-size: 10px; text-transform: uppercase; font-weight: 850; }

.button { min-height: 38px; padding: 9px 13px; border: 1px solid transparent; border-radius: 6px; background: var(--paper); color: var(--ink); font-weight: 750; text-decoration: none; cursor: pointer; transition: color .18s ease, background-color .18s ease, border-color .18s ease, transform .18s ease; }
.button.primary { background: var(--teal); color: #fff; }
.button.quiet { border-color: var(--line); }
.button:not(:disabled):hover { transform: translateY(-1px); border-color: var(--teal); color: var(--teal); background: var(--teal-soft); }
.button.primary:not(:disabled):hover { color: #fff; background: #075f55; }
.button:disabled { cursor: not-allowed; opacity: .55; }
.panel, .metric { border: 1px solid var(--line); border-radius: 8px; background: var(--paper); box-shadow: var(--shadow); }
.panel { padding: 20px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head h3 { margin: 1px 0 0; font-size: 16px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.metric { position: relative; min-height: 128px; padding: 18px; overflow: hidden; }
.metric::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: var(--teal); }
.metric.accent-blue::before { background: var(--cyan); }
.metric.accent-amber::before { background: var(--amber); }
.metric.accent-coral::before { background: var(--coral); }
.metric > span { color: var(--muted); font-size: 11px; text-transform: uppercase; font-weight: 750; }
.metric strong { display: block; margin: 13px 0 3px; font-size: 27px; }
.metric small { color: var(--muted); }
.dashboard-grid { display: grid; grid-template-columns: 1.25fr .75fr; gap: 16px; margin-top: 16px; }
.activity-panel { grid-column: 1 / -1; }
.release-version { display: grid; padding: 18px; border-left: 4px solid var(--teal); background: var(--canvas); }
.release-version span, .release-version small { color: var(--muted); }
.release-version strong { font-size: 31px; }
.progress-line { height: 7px; margin: 18px 0 10px; border-radius: 4px; background: var(--line); overflow: hidden; }
.progress-line i { display: block; height: 100%; background: var(--teal); }
.release-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; color: var(--muted); font-size: 12px; }
.release-meta b { display: block; color: var(--ink); }
.next-steps ol { display: grid; gap: 13px; margin: 0; padding: 0; list-style: none; }
.next-steps li { display: flex; align-items: center; gap: 11px; }
.next-steps li > span { width: 11px; height: 11px; flex-shrink: 0; border: 2px solid var(--line); border-radius: 50%; }
.next-steps li.done > span { border-color: var(--teal); background: var(--teal); box-shadow: 0 0 0 4px var(--teal-soft); }
.next-steps li div { display: grid; }
.next-steps small { color: var(--muted); }
.customer-admin-account { padding: 16px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.customer-admin-account summary { cursor: pointer; font-weight: 700; }
.customer-admin-account .form-stack { margin-top: 16px; max-width: 720px; }
.customer-admin-table td { vertical-align: top; }
@media (max-width: 650px) {
    .customer-admin-table, .customer-admin-table tbody, .customer-admin-table tr, .customer-admin-table td { display: block; min-width: 0; width: 100%; }
    .customer-admin-table thead { display: none; }
    .customer-admin-table td { padding: 10px 0; overflow-wrap: anywhere; }
    .customer-admin-table .form-stack { min-width: 0; }
    .customer-admin-table .button { white-space: normal; }
}
.activity-list { display: grid; }
.activity-list > div { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 11px 2px; border-bottom: 1px solid var(--line); }
.activity-list > div:last-child { border-bottom: 0; }
.activity-list i { width: 8px; height: 8px; border-radius: 50%; background: var(--cyan); }
.activity-list span { display: grid; }
.activity-list small { color: var(--muted); }
.activity-list code { color: var(--muted); font-size: 10px; }

.status, .count-badge { display: inline-flex; align-items: center; min-height: 25px; padding: 4px 9px; border-radius: 13px; font-size: 10px; font-weight: 850; white-space: nowrap; }
.status.neutral, .count-badge { background: var(--canvas); color: var(--muted); }
.status.success { background: var(--teal-soft); color: var(--teal); }
.status.progress { background: var(--cyan-soft); color: var(--cyan); }
.notice { margin-bottom: 18px; padding: 12px 14px; border: 1px solid var(--line); border-left: 4px solid var(--teal); border-radius: 6px; background: var(--paper); overflow-wrap: anywhere; }
.notice.error { border-left-color: var(--coral); color: var(--coral); }

.two-column { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(300px, .65fr); gap: 16px; align-items: start; }
.table-panel { padding: 0; overflow: hidden; }
.table-panel > .panel-head { padding: 19px 20px 0; }
.table-scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 620px; }
th, td { padding: 12px 16px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--canvas); font-size: 10px; text-transform: uppercase; }
td strong, td small { display: block; }
td small { color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
.form-stack { display: grid; gap: 14px; }
.form-stack label.finance-confirmation { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.finance-confirmation input { width: 18px; height: 18px; flex: 0 0 18px; padding: 0; margin: 0; accent-color: var(--teal); }
.finance-confirmation span { font-weight: 500; line-height: 1.5; }
.form-stack label { display: grid; gap: 6px; color: var(--ink); font-size: 12px; font-weight: 750; }
input, textarea, select { width: 100%; border: 1px solid #c8d4d0; border-radius: 6px; padding: 10px 11px; background: var(--paper); color: var(--ink); outline: none; }
input:focus, textarea:focus, select:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
textarea { resize: vertical; }
.form-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-note { padding: 11px 12px; border-left: 3px solid var(--cyan); background: var(--cyan-soft); color: var(--ink); font-size: 12px; }
.field-note.warning { border-left-color: var(--amber); background: var(--amber-soft); }
.empty-state { min-height: 180px; padding: 34px; display: grid; place-items: center; align-content: center; gap: 7px; color: var(--muted); text-align: center; }
.empty-state.tall { min-height: 360px; }
.empty-state strong { color: var(--ink); font-size: 16px; }
.empty-mark { width: 52px; height: 52px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; color: var(--teal); font-size: 22px; font-weight: 850; }
.release-list { display: grid; }
.release-list article { padding: 17px 20px; border-top: 1px solid var(--line); }
.release-list-top { display: flex; justify-content: space-between; align-items: center; }
.release-list-top > div { display: flex; align-items: center; gap: 9px; }
.release-list-top strong { font-size: 18px; }
.release-list article p { color: var(--muted); }
.release-list article footer { display: flex; gap: 18px; color: var(--muted); font-size: 11px; }
.license-band { margin-bottom: 16px; display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--line); border-radius: 8px; background: var(--night-2); color: #fff; overflow: hidden; }
.license-band div { min-height: 105px; padding: 20px; border-right: 1px solid #315047; display: grid; align-content: center; }
.license-band div:last-child { border-right: 0; }
.license-band span { color: #9dbbb3; font-size: 11px; text-transform: uppercase; }
.license-band strong { margin-top: 5px; font-size: 18px; }
.license-issue-panel { margin-bottom: 16px; }
.license-issue-panel > p { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.license-issue-panel .license-warning { padding: 12px 14px; border-left: 3px solid var(--amber); background: var(--amber-soft); color: var(--ink); }
.license-issue-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.license-feature-list { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 0; padding: 14px; border: 1px solid var(--line); border-radius: 6px; }
.license-feature-list legend { padding: 0 5px; font-size: 12px; font-weight: 750; }
.form-stack .license-feature-list label { display: flex; align-items: center; gap: 8px; }
.license-feature-list input { width: 18px; height: 18px; margin: 0; accent-color: var(--teal); }
.settings-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.settings-detail { margin-top: 16px; grid-template-columns: minmax(240px, .65fr) minmax(0, 1.35fr); }
.settings-detail > .panel { min-width: 0; }
.settings-detail .form-pair { grid-template-columns: repeat(auto-fit, minmax(min(100%, 280px), 1fr)); align-items: start; }
.settings-detail .form-stack label, .settings-detail input, .settings-detail select { min-width: 0; }
.commercial-settings { margin-top: 16px; }
.commercial-settings .panel-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.commercial-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.switch-row { position: relative; min-height: 66px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 7px; display: grid !important; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 18px !important; background: var(--canvas); cursor: pointer; }
.switch-row > span { display: grid; gap: 2px; }
.switch-row strong { color: var(--ink); font-size: 13px; }
.switch-row small { color: var(--muted); font-size: 11px; font-weight: 500; }
.switch-row input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.switch-control { position: relative; width: 46px; height: 25px; border: 1px solid #91a49e; border-radius: 13px; background: var(--paper); transition: background-color .18s ease, border-color .18s ease; }
.switch-control::after { content: ""; position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; border-radius: 50%; background: #81938e; transition: transform .18s ease, background-color .18s ease; }
.switch-row input:checked + .switch-control { border-color: var(--teal); background: var(--teal); }
.switch-row input:checked + .switch-control::after { background: #fff; transform: translateX(21px); }
.switch-row input:focus-visible + .switch-control { outline: 3px solid var(--teal-soft); outline-offset: 2px; }
.form-stack label small { color: var(--muted); font-weight: 500; }
.mail-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }
.mail-metrics div { padding: 16px; border: 1px solid var(--line); border-radius: 6px; background: var(--canvas); }
.mail-metrics span { display: block; color: var(--muted); font-size: 11px; }
.mail-metrics strong { font-size: 24px; }
.setting-block { min-height: 160px; display: grid; grid-template-columns: 42px 1fr; gap: 14px; }
.setting-index { width: 38px; height: 28px; display: grid; place-items: center; border-radius: 4px; background: var(--teal-soft); color: var(--teal); font: 700 11px Consolas, monospace; }
.setting-block h3 { margin: 2px 0 13px; }
.setting-block p { color: var(--muted); }
.setting-block code { word-break: break-all; }

.auth-body { min-height: 100vh; background: var(--night); }
.auth-shell { min-height: 100vh; display: grid; grid-template-columns: minmax(340px, .82fr) minmax(500px, 1.18fr); }
.auth-brand { position: relative; padding: clamp(34px, 6vw, 78px); display: flex; align-items: flex-start; gap: 16px; color: #fff; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; left: clamp(34px, 6vw, 78px); right: 15%; bottom: 22%; height: 1px; background: #34564c; box-shadow: 0 28px 0 #2b4941, 0 56px 0 #223d36; }
.auth-brand img { width: 62px; height: 62px; object-fit: contain; }
.auth-brand > div:first-of-type { display: grid; line-height: 1.12; }
.product-wordmark { font-size: 30px; font-weight: 850; }
.auth-brand strong { color: #9fd8c8; font-size: 15px; }
.auth-brand small { margin-top: 7px; color: #6e9d91; font-size: 10px; }
.auth-context { position: absolute; left: clamp(34px, 6vw, 78px); right: 18%; bottom: 30%; }
.auth-context p { max-width: 440px; color: #b5cdc6; font-size: 17px; }
.signal-lines { height: 34px; display: flex; align-items: end; gap: 5px; }
.signal-lines i { width: 6px; background: #53c5a7; border-radius: 2px 2px 0 0; }
.signal-lines i:nth-child(1) { height: 9px; }.signal-lines i:nth-child(2) { height: 16px; }.signal-lines i:nth-child(3) { height: 24px; }.signal-lines i:nth-child(4) { height: 32px; }
.auth-panel { padding: 28px; display: grid; place-items: center; background: var(--canvas); }
.auth-form-wrap { width: min(440px, 100%); }
.auth-form-wrap h1 { margin: 5px 0 7px; font-size: 32px; }
.auth-form-wrap .lead { margin: 0 0 23px; color: var(--muted); }
.auth-form-wrap .button { margin-top: 3px; min-height: 44px; }
.security-note { margin-top: 20px; color: var(--muted); font-size: 11px; text-align: center; }
.security-note span { margin-right: 5px; color: var(--teal); }

:root[data-theme="dark"] input, :root[data-theme="dark"] textarea, :root[data-theme="dark"] select { border-color: var(--line); }

@media (min-width: 1100px) {
    body { font-size: 16px; }
    .sidebar nav a, .settings-link { font-size: 15px; }
    .sidebar-foot { font-size: 13px; }
    .form-stack label, .field-note { font-size: 14px; }
    .panel-head h3 { font-size: 19px; }
    .status, .count-badge, th { font-size: 12px; }
    .release-meta, .release-list article footer { font-size: 14px; }
}

@media (max-width: 1050px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .two-column { grid-template-columns: 1fr; }
    .commercial-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 820px) {
    .portal-shell { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: -260px; transition: left .2s ease; box-shadow: 18px 0 40px rgba(0, 0, 0, .3); }
    .sidebar.open { left: 0; }
    .mobile-menu { display: inline-grid; place-items: center; }
    .admin-chip { display: none; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .activity-panel { grid-column: auto; }
    .auth-shell { grid-template-columns: 1fr; }
    .auth-brand { min-height: 255px; }
    .auth-context { bottom: 12%; }
    .auth-brand::after { display: none; }
}

@media (max-width: 600px) {
    .topbar { height: 68px; padding: 0 14px; }
    .topbar .quiet { display: none; }
    .content { padding: 23px 14px 42px; }
    .page-heading { align-items: flex-start; flex-direction: column; }
    .page-heading h2 { font-size: 24px; }
    .metric-grid, .settings-grid, .license-band, .license-issue-grid { grid-template-columns: 1fr; }
    .license-feature-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .license-band div { min-height: 82px; border-right: 0; border-bottom: 1px solid #315047; }
    .license-band div:last-child { border-bottom: 0; }
    .release-meta { grid-template-columns: 1fr; }
    .form-pair { grid-template-columns: 1fr; }
    .commercial-grid { grid-template-columns: 1fr; }
    .auth-brand { padding: 28px; }
    .auth-context { left: 28px; right: 28px; }
    .auth-panel { padding: 28px 20px; }
}
