/* ==========================================================================
   FinancialsAce Control Plane — design system
   Dark neutral surfaces, teal for filled actions, cyan as a sparing signal.
   Palette base: #212121 / #323232 / #0D7377 / #14FFEC.

   Contrast rules this file keeps (WCAG):
   - --primary (#0D7377) is a fill only: white text on it is 5.6:1, but as text
     or a thin line on the greys it is under 3:1, so it is never used that way.
   - --signal (#14FFEC) is for small high-signal marks (active bar, focus ring,
     switch, progress). Text links use the calmer --accent.
   - Every text token is at least 4.5:1 on every surface token.
   ========================================================================== */

:root {
    color-scheme: dark;

    --bg: #212121;
    --surface: #323232;
    --surface-2: #292929;
    --surface-hover: #3c3c3c;
    --sidebar: #1b1b1b;
    --border: #444444;
    --border-strong: #7b8484;

    --text: #edefef;
    --text-2: #b6bebe;
    --text-3: #a4adad;

    --primary: #0d7377;
    --primary-hover: #0e7f84;
    --on-primary: #ffffff;

    --signal: #14ffec;
    --accent: #5fe6da;
    --accent-hover: #8cf0e7;
    --accent-soft: rgba(20, 255, 236, 0.10);
    --accent-line: rgba(20, 255, 236, 0.38);
    --on-accent: #ffffff;

    --success: #7adb8e;
    --success-soft: #1f3a28;
    --warning: #f0b955;
    --warning-soft: #3d321a;
    --danger: #ff8278;
    --danger-soft: #44221f;
    --info: #8ab4f8;
    --info-soft: #233247;

    --focus: rgba(20, 255, 236, 0.32);
    --overlay: rgba(0, 0, 0, 0.62);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.28);
    --shadow-pop: 0 18px 44px -10px rgba(0, 0, 0, 0.75), 0 0 0 1px rgba(255, 255, 255, 0.04);

    --sidebar-w: 240px;
    --topbar-h: 52px;
    --radius: 8px;
    --radius-lg: 12px;

    --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
    --fast: 0.12s;
    --med: 0.18s;

    --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: ui-monospace, "Cascadia Mono", "SF Mono", Menlo, Consolas, monospace;
}

/* ---- Reset / base ------------------------------------------------------ */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scrollbar-color: #5a5a5a transparent; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, p { margin: 0; }

::selection { background: rgba(20, 255, 236, 0.28); color: #fff; }

/* Links: the underline draws in from the left instead of snapping on. */
a {
    color: var(--accent);
    text-decoration: none;
    background-image: linear-gradient(currentColor, currentColor);
    background-repeat: no-repeat;
    background-position: 0 100%;
    background-size: 0 1px;
    transition: background-size var(--med) var(--ease), color var(--fast);
}

a:hover { color: var(--accent-hover); background-size: 100% 1px; }

code, .mono { font-family: var(--mono); font-size: 12.5px; }

:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; border-radius: 4px; }

/* The router focuses the page heading after navigation; that is for screen readers, not a visible ring. */
h1:focus-visible { outline: none; }

button { font: inherit; color: inherit; }

.icon { flex: none; display: inline-block; vertical-align: middle; }

/* ---- Motion ------------------------------------------------------------ */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
@keyframes drop { from { opacity: 0; transform: translateY(-6px); } }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes pop { from { opacity: 0; transform: scale(0.6); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes pulse { 50% { opacity: 0.35; } }
@keyframes shimmer { to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* ---- App shell --------------------------------------------------------- */

.app { min-height: 100vh; }

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 40;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    height: var(--topbar-h);
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(140deg, #109096 0%, var(--primary) 60%, #0a5c5f 100%);
    color: #fff;
    box-shadow: inset 0 0 0 1px rgba(20, 255, 236, 0.35);
    display: grid;
    place-items: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.brand-name { font-size: 14px; font-weight: 600; line-height: 1.2; }
.brand-sub { font-size: 12px; color: var(--text-3); line-height: 1.2; }

.nav { flex: 1; overflow-y: auto; padding: 6px 10px 12px; }

.nav-label {
    padding: 16px 10px 6px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-3);
}

.nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px 8px 14px;
    margin-bottom: 2px;
    border-radius: var(--radius);
    color: var(--text-2);
    font-weight: 500;
    background-image: none;
    transition: background-color var(--fast), color var(--fast);
}

/* Active marker: grows out from the centre. */
.nav-link::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--signal);
    transform: scaleY(0);
    transition: transform var(--med) var(--ease);
}

.nav-link .icon { transition: transform var(--med) var(--ease); }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link:hover .icon { transform: translateX(2px); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link.active::before { transform: scaleY(1); }

.sidebar-foot {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-3);
}

.env-tag {
    padding: 1px 9px;
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--text-2);
}

.env-tag.prod { color: var(--danger); border-color: var(--danger); background: var(--danger-soft); }

.main { margin-left: var(--sidebar-w); min-width: 0; }

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--topbar-h);
    padding: 0 32px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.topbar form { margin: 0; }
.topbar-title { font-weight: 600; display: none; }
.topbar-spacer { flex: 1; }
.topbar .topbar-menu { display: none; }

.page { max-width: 1280px; padding: 28px 32px 56px; }

/* New page content eases in. Opacity/transform only, and no fill mode, so nothing is left
   transformed afterwards (a lingering transform would trap position:fixed modals inside it). */
.page > *, .portal-main > * { animation: rise var(--med) var(--ease); }

.scrim { display: none; }

@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.22s var(--ease); box-shadow: var(--shadow-pop); }
    .sidebar.open { transform: none; }
    .scrim.open { display: block; position: fixed; inset: 0; background: var(--overlay); z-index: 30; animation: fade-in var(--med); }
    .main { margin-left: 0; }
    .topbar { padding: 0 12px; }
    .topbar .topbar-menu { display: inline-flex; }
    .topbar-title { display: block; }
    .page { padding: 20px 16px 48px; }
}

/* ---- Page header ------------------------------------------------------- */

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px 24px;
    margin-bottom: 22px;
}

.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.3; }
.page-desc { margin-top: 3px; color: var(--text-2); max-width: 70ch; }
.page-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.breadcrumb {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 8px;
    font-size: 13px;
    color: var(--text-3);
}

.breadcrumb a { color: var(--text-2); }
.breadcrumb a:hover { color: var(--accent); }

/* ---- Cards / stats ----------------------------------------------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    margin-bottom: 20px;
    min-width: 0;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}

.card-title { font-size: 14px; font-weight: 600; }
.card-sub { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.card-body { padding: 18px; }
.card-footer { padding: 10px 18px; border-top: 1px solid var(--border); font-size: 12.5px; color: var(--text-3); }

/* Clip square children (table heads, toolbars) to the rounded card without overflow:hidden,
   which would cut off focus rings. */
.card > :first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); border-top-right-radius: calc(var(--radius-lg) - 1px); }
.card > :last-child:not(.modal-backdrop) { border-bottom-left-radius: calc(var(--radius-lg) - 1px); border-bottom-right-radius: calc(var(--radius-lg) - 1px); }
.card > .table-wrap:first-child .table th:first-child { border-top-left-radius: calc(var(--radius-lg) - 1px); }
.card > .table-wrap:first-child .table th:last-child { border-top-right-radius: calc(var(--radius-lg) - 1px); }

.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat {
    padding: 14px 16px 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    transition: transform var(--med) var(--ease), border-color var(--med), box-shadow var(--med);
}

.stat:hover { transform: translateY(-2px); border-color: var(--accent-line); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6); }

.stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: var(--text-3); }
.stat-value { margin-top: 6px; font-size: 26px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat-meta { margin-top: 3px; font-size: 12px; color: var(--text-2); }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; align-items: start; }
.grid-2 > .card, .grid-3 > .card { margin-bottom: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 16px; margin-bottom: 20px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; margin-bottom: 20px; }
.grid-main > .card { margin-bottom: 0; }

/* Plan / pack cards: no transform here on purpose. These cards can host a modal, and a
   transformed ancestor would re-anchor its fixed positioning. */
.grid-3 > .card { transition: border-color var(--med), box-shadow var(--med); }
.grid-3 > .card:hover { border-color: var(--accent-line); box-shadow: 0 8px 20px -8px rgba(0, 0, 0, 0.6); }

@media (max-width: 1000px) {
    .grid-2, .grid-main { grid-template-columns: minmax(0, 1fr); }
}

.stack { display: flex; flex-direction: column; gap: 20px; }

/* ---- Tables ------------------------------------------------------------ */

.table-wrap { width: 100%; overflow-x: auto; }

.table { width: 100%; border-collapse: collapse; font-size: 13px; }

.table th {
    position: sticky;
    top: 0;
    padding: 10px 18px;
    text-align: left;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-3);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.table td {
    height: 44px;
    padding: 9px 18px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    color: var(--text-2);
    transition: background-color var(--fast);
}

.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: var(--surface-hover); }

.table .primary { color: var(--text); font-weight: 500; }
.table .primary a { color: var(--text); }
.table .primary a:hover { color: var(--accent); }
.table .num, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table th.num { text-align: right; }
.table .muted, .muted { color: var(--text-3); }
.table .actions { text-align: right; white-space: nowrap; }

/* Row actions stay visible (keyboard and touch need them); they just step forward on hover. */
.table td.actions .btn, .table .row-actions .btn { opacity: 0.72; transition: opacity var(--fast), background-color var(--fast), border-color var(--fast), transform var(--fast); }
.table tr:hover td.actions .btn, .table tr:hover .row-actions .btn,
.table td.actions .btn:focus-visible, .table .row-actions .btn:focus-visible { opacity: 1; }

.table .state-row td { padding: 36px 18px; text-align: center; color: var(--text-3); }
.table .state-row:hover td { background: transparent; }

/* A table that is still loading shows a shimmer bar rather than a lone spinner. */
.table .state-row .spinner {
    display: block;
    width: min(360px, 70%);
    height: 10px;
    margin: 0 auto;
    border: 0;
    border-radius: 5px;
    background: linear-gradient(90deg, var(--surface-hover) 25%, #505050 50%, var(--surface-hover) 75%) 0 0 / 200% 100%;
    animation: shimmer 1.4s linear infinite;
}

.table tfoot td { border-top: 1px solid var(--border); border-bottom: 0; color: var(--text); }

/* ---- Badges ------------------------------------------------------------ */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 1px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
    white-space: nowrap;
    background: var(--surface-hover);
    color: var(--text-2);
}

.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.badge.plain::before { display: none; }

.badge.success { background: var(--success-soft); color: var(--success); }
.badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger); }
.badge.info    { background: var(--info-soft);    color: var(--info); }

/* Things that are waiting on someone breathe slowly; settled states stay still. */
.badge.warning::before, .badge.danger::before { animation: pulse 2.4s ease-in-out infinite; }

.tag {
    display: inline-block;
    padding: 0 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    background: var(--surface-2);
    font-family: var(--mono);
    font-size: 12px;
    line-height: 20px;
    color: var(--text-2);
    white-space: nowrap;
}

/* ---- Buttons ----------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-hover);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    user-select: none;
    transition: background-color var(--fast), border-color var(--fast), color var(--fast), box-shadow var(--med), transform var(--fast) var(--ease);
}

.btn:hover { background: #474747; border-color: var(--border-strong); color: var(--text); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); color: var(--on-primary); box-shadow: 0 0 0 1px var(--accent-line), 0 6px 18px -6px rgba(20, 255, 236, 0.45); }
.btn.primary:disabled:hover { background: var(--primary); border-color: var(--primary); box-shadow: none; }

.btn.ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn.ghost:hover { background: var(--surface-hover); border-color: transparent; color: var(--text); }

.btn.danger { color: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 6px; }
.btn.icon-only { width: 34px; padding: 0; }
.btn.sm.icon-only { width: 28px; }

/* ---- Forms ------------------------------------------------------------- */

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field label { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 500; color: var(--text); }
.hint { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.inline-form { display: flex; align-items: flex-end; gap: 10px; }
.inline-form .field { flex: 1; margin-bottom: 0; }

.input, .select, .textarea {
    width: 100%;
    height: 34px;
    padding: 0 11px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: 13px;
    box-shadow: 0 0 0 0 var(--focus);
    transition: border-color var(--fast), box-shadow var(--med) var(--ease), background-color var(--fast);
}

.textarea { height: auto; padding: 8px 11px; resize: vertical; font-family: var(--mono); font-size: 12.5px; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: #98a1a1; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px var(--focus); background: var(--bg); }
.input:disabled, .select:disabled, .textarea:disabled { opacity: 0.55; cursor: not-allowed; }

input[type="checkbox"], input[type="radio"] { accent-color: var(--signal); width: 15px; height: 15px; }

.search { position: relative; width: 280px; max-width: 100%; }
.search .icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; transition: color var(--fast); }
.search:focus-within .icon { color: var(--accent); }
.search .input { padding-left: 32px; }

.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
}

/* ---- Feedback ---------------------------------------------------------- */

.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    border-left-width: 3px;
    border-radius: var(--radius);
    font-size: 13px;
    background: var(--surface);
    animation: drop 0.2s var(--ease);
}

.alert .icon { margin-top: 2px; }
.alert.success { background: var(--success-soft); border-color: transparent; border-left-color: var(--success); color: var(--success); }
.alert.danger  { background: var(--danger-soft);  border-color: transparent; border-left-color: var(--danger);  color: var(--danger); }
.alert.warning { background: var(--warning-soft); border-color: transparent; border-left-color: var(--warning); color: var(--warning); }
.alert .alert-body { flex: 1; color: var(--text); }
.alert .btn { margin: -4px -6px -4px 0; }

.empty { padding: 44px 16px; text-align: center; color: var(--text-3); }
.empty strong { display: block; color: var(--text); font-weight: 500; margin-bottom: 2px; }

.spinner {
    width: 16px;
    height: 16px;
    border: 2px solid var(--border);
    border-top-color: var(--signal);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 40px 16px; color: var(--text-3); }

.progress { height: 6px; border-radius: 3px; background: var(--surface-hover); overflow: hidden; min-width: 90px; }
.progress > span { display: block; height: 100%; background: var(--signal); border-radius: 3px; }
.progress.warning > span { background: var(--warning); }
.progress.danger > span { background: var(--danger); }

/* Fills grow from zero when first shown, then ease to any new value. */
.progress > span, .meter-fill { transform-origin: left center; animation: grow 0.6s var(--ease); transition: width 0.3s var(--ease), background-color var(--med); }

.meter-row { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 4px; font-variant-numeric: tabular-nums; }

/* ---- Description list / switch / code block ---------------------------- */

.kv { display: grid; grid-template-columns: 130px minmax(0, 1fr); gap: 10px 16px; margin: 0; font-size: 13px; }
.kv dt { color: var(--text-3); }
.kv dd { margin: 0; color: var(--text); word-break: break-word; }

.codeblock {
    margin-top: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--bg);
    font-family: var(--mono);
    font-size: 12.5px;
    word-break: break-all;
    color: var(--text);
}

.feature-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }

.feature {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 18px;
    border-bottom: 1px solid var(--border);
    transition: background-color var(--fast);
}

.feature:hover { background: var(--surface-hover); }
.feature-name { font-weight: 500; font-size: 13px; }
.feature-state { font-size: 12px; color: var(--text-3); }

.switch {
    position: relative;
    flex: none;
    width: 36px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: #666e6e;
    cursor: pointer;
    transition: background-color var(--med);
}

.switch::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: transform 0.22s var(--ease-spring), background-color var(--med);
}

.switch:active::after { transform: scale(0.9); }
.switch[aria-checked="true"] { background: var(--signal); }
.switch[aria-checked="true"]::after { transform: translateX(16px); background: var(--bg); }
.switch[aria-checked="true"]:active::after { transform: translateX(16px) scale(0.9); }

.big-number { display: flex; align-items: baseline; gap: 6px; font-variant-numeric: tabular-nums; }
.big-number strong { font-size: 28px; font-weight: 600; letter-spacing: -0.02em; }
.big-number span { color: var(--text-3); }

.plan-name { font-size: 15px; font-weight: 600; }
.divider { height: 1px; background: var(--border); margin: 16px 0; border: 0; }

/* ---- Modal ------------------------------------------------------------- */

.modal-backdrop {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 16px;
    background: var(--overlay);
    backdrop-filter: blur(3px);
    animation: fade-in 0.16s ease-out;
}

.modal {
    width: 100%;
    max-width: 480px;
    max-height: calc(100vh - 32px);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    outline: none;
    animation: dialog-in 0.2s var(--ease);
}

.modal-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 18px 18px 0; }
.modal-title { font-size: 16px; font-weight: 600; }
.modal-desc { margin-top: 2px; font-size: 13px; color: var(--text-2); }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

/* ---- Blazor error boundary -------------------------------------------- */

#blazor-error-ui {
    display: none;
    position: fixed;
    inset: auto 0 0 0;
    z-index: 1000;
    padding: 10px 16px;
    background: var(--danger-soft);
    color: var(--text);
    border-top: 1px solid var(--danger);
    font-size: 13px;
}

#blazor-error-ui .reload { margin-left: 8px; font-weight: 500; }
#blazor-error-ui .dismiss { float: right; cursor: pointer; }

/* ---- Section tabs / misc ---------------------------------------------- */

.tabs { display: flex; gap: 2px; margin-bottom: 20px; border-bottom: 1px solid var(--border); overflow-x: auto; }

.tab {
    position: relative;
    padding: 9px 13px;
    color: var(--text-2);
    font-weight: 500;
    white-space: nowrap;
    background: none;
    border: 0;
    cursor: pointer;
    transition: color var(--fast);
}

/* Underline draws from the left. */
.tab::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    border-radius: 2px 2px 0 0;
    background: var(--signal);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.2s var(--ease), opacity var(--fast);
}

.tab:hover { color: var(--text); }
.tab:hover::after { transform: scaleX(1); opacity: 0.4; }
.tab.active { color: var(--accent); }
.tab.active::after { transform: scaleX(1); opacity: 1; }

.row-actions { display: inline-flex; gap: 6px; }
.stack-sm { display: flex; flex-direction: column; gap: 4px; }
.right { margin-left: auto; }
.text-danger { color: var(--danger); }
.card-body > .table-wrap { margin: -18px; width: calc(100% + 36px); }

/* ---- Public + portal --------------------------------------------------- */

.public-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
    gap: 22px;
    background:
        radial-gradient(640px 420px at 50% -6%, rgba(13, 115, 119, 0.42), transparent 70%),
        radial-gradient(520px 360px at 85% 108%, rgba(20, 255, 236, 0.07), transparent 70%),
        var(--bg);
}

.public-brand { display: flex; align-items: center; gap: 10px; animation: rise 0.3s var(--ease); }

.public-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-pop);
    padding: 30px;
    animation: dialog-in 0.3s var(--ease);
}

.auth-title { font-size: 20px; font-weight: 600; letter-spacing: -0.01em; }
.auth-sub { margin: 4px 0 20px; color: var(--text-2); }
.auth-foot { margin-top: 18px; text-align: center; color: var(--text-2); font-size: 13px; }

.portal { min-height: 100vh; }

.portal-bar {
    position: sticky;
    top: 0;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
    min-height: var(--topbar-h);
    padding: 8px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.portal-brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 600; background-image: none; }
.portal-brand:hover { color: var(--text); }
.portal-nav { display: flex; gap: 4px; flex: 1; }

.portal-link {
    position: relative;
    padding: 7px 11px;
    border-radius: var(--radius);
    color: var(--text-2);
    font-weight: 500;
    background-image: none;
    transition: background-color var(--fast), color var(--fast);
}

.portal-link::after {
    content: "";
    position: absolute;
    left: 11px;
    right: 11px;
    bottom: 1px;
    height: 2px;
    border-radius: 2px;
    background: var(--signal);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform 0.2s var(--ease);
}

.portal-link:hover { background: var(--surface-hover); color: var(--text); }
.portal-link.active { color: var(--accent); }
.portal-link.active::after { transform: scaleX(1); }

.portal-user { display: flex; align-items: center; gap: 12px; }
.portal-user form { margin: 0; }
.portal-main { max-width: 1040px; margin: 0 auto; padding: 28px 24px 56px; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 16px; counter-reset: step; }
.steps li { position: relative; padding-left: 34px; counter-increment: step; }
.steps li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-strong); display: grid; place-items: center; font-size: 12px; color: var(--text-2); animation: pop 0.25s var(--ease-spring); }
.steps li.done::before { content: "\2713"; background: var(--success-soft); border-color: transparent; color: var(--success); }
.module-list { margin: 0; padding-left: 18px; columns: 2; }

.choice-list { list-style: none; margin: 0; padding: 0; }
.choice { border-bottom: 1px solid var(--border); box-shadow: inset 0 0 0 0 var(--signal); transition: background-color var(--fast), box-shadow var(--med) var(--ease); }
.choice:last-child { border-bottom: 0; }
.choice:hover { background: var(--surface-hover); }
.choice label { display: flex; align-items: center; gap: 12px; padding: 12px 18px; cursor: pointer; }
.choice.on { background: var(--accent-soft); box-shadow: inset 3px 0 0 0 var(--signal); }
/* Muted text is 4.3:1 on the selected tint, so step it up one level there. */
.choice.on .muted { color: var(--text-2); }
.choice-text { flex: 1; display: flex; flex-direction: column; }
.choice-price { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 500; }
.order-summary td { height: auto; padding: 6px 0; border: 0; }
.order-summary tbody tr:hover td { background: transparent; }
.order-summary tr.total td { border-top: 1px solid var(--border); padding-top: 10px; font-weight: 600; color: var(--text); }
.bank { white-space: pre-wrap; }

@media (max-width: 700px) { .module-list { columns: 1; } .portal-bar { padding: 8px 16px; } .portal-main { padding: 20px 16px 48px; } .form-row { grid-template-columns: 1fr; } }

.checklist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.checklist li { position: relative; padding-left: 28px; display: flex; flex-direction: column; }
.checklist li::before { position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%; display: grid; place-items: center; font-size: 11px; animation: pop 0.25s var(--ease-spring); }
.checklist li.ok::before { content: "\2713"; background: var(--success-soft); color: var(--success); }
.checklist li.todo::before { content: "!"; background: var(--warning-soft); color: var(--warning); font-weight: 700; }

/* Usage meter (portal quotas) */
.meter { height: 6px; margin-top: 6px; border-radius: 3px; background: var(--surface-hover); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 3px; background: var(--signal); }
.meter-fill.high { background: var(--warning); }
.meter-fill.full { background: var(--danger); }

/* ---- Utilities --------------------------------------------------------- */

.row { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; }
.row.tight { gap: 8px; }
label.check, .field label.check { display: flex; align-items: center; gap: 6px; margin: 0; cursor: pointer; }
label.row, .field label.row { display: flex; margin: 0; }
.w-full { width: 100%; }
.w-150 { width: 150px; }
.mt-0 { margin-top: 0; }
.mt-6 { margin-top: 6px; }
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-14 { margin-top: 14px; }
.mt-16 { margin-top: 16px; }
.mb-6 { margin-bottom: 6px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 20px; }

/* ---- Print (invoices) -------------------------------------------------- */

@media print {
    :root {
        color-scheme: light;
        --bg: #ffffff;
        --surface: #ffffff;
        --surface-2: #f4f5f5;
        --surface-hover: #eceeee;
        --border: #cfd4d4;
        --border-strong: #8a9292;
        --text: #111111;
        --text-2: #333a3a;
        --text-3: #586060;
        --accent: #0a5c5f;
        --accent-hover: #0a5c5f;
        --signal: #0d7377;
        --accent-soft: #e3f3f3;
        --success: #17693a;
        --success-soft: #e4f4ea;
        --warning: #8a5200;
        --warning-soft: #fdf1d9;
        --danger: #a8231a;
        --danger-soft: #fdeceb;
        --info: #1d5fa8;
        --info-soft: #e6f0fb;
        --shadow-card: none;
    }

    *, *::before, *::after { animation: none !important; transition: none !important; }
    .sidebar, .topbar, .portal-bar, .scrim, .btn, .tabs, #blazor-error-ui { display: none !important; }
    .main { margin-left: 0; }
    .page, .portal-main { max-width: none; padding: 0; }
    .card { break-inside: avoid; }
}
