/* VDS Billing — light SaaS design system. IBM Plex (Sans + Mono), indigo accent. */

:root {
    /* Rice-paper warm background + navy accent */
    --bg: #efe9db;
    --surface: #fbf9f3;
    --surface-2: #f4efe3;
    --border: #e3dbc9;
    --border-strong: #d3c9b2;
    --text: #20242c;
    --muted: #6a675c;
    --faint: #9a9585;

    --accent: #1f4e79;
    --accent-600: #163a5c;
    --accent-soft: #e6edf4;

    --ok: #067a5b;
    --ok-bg: #e7f7f0;
    --warn: #b45309;
    --warn-bg: #fdf4e3;
    --err: #c22a2a;
    --err-bg: #fdecec;
    --info: #1d6fb8;
    --info-bg: #e8f2fb;
    --neutral: #5b6370;
    --neutral-bg: #eef0f3;

    --r: 10px;
    --r-sm: 7px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 2px 6px rgba(16, 24, 40, .06);
    --shadow-lg: 0 10px 30px rgba(16, 24, 40, .10);

    --sans: 'IBM Plex Sans', -apple-system, Segoe UI, sans-serif;
    --mono: 'IBM Plex Mono', ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
    background-color: var(--bg);
    /* faint rice-paper grain */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
    color: var(--text);
    font-family: var(--sans);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1 { font-size: 22px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 4px; }
h2 { font-size: 15px; font-weight: 600; margin: 22px 0 10px; letter-spacing: .01em; }
p { margin: 0 0 12px; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: .92em; }
.right { margin-left: auto; }

/* ---- Top navigation (site + cabinet) ---- */
.topbar {
    position: sticky; top: 0; z-index: 20;
    background: rgba(251, 249, 243, .82);
    backdrop-filter: saturate(1.4) blur(8px);
    border-bottom: 1px solid var(--border);
}
.topbar-inner { display: flex; align-items: center; gap: 22px; height: 58px; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 600; font-size: 15px; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .dot {
    width: 22px; height: 22px; border-radius: 6px;
    background: linear-gradient(135deg, var(--accent), #3a78ad);
    box-shadow: 0 2px 8px rgba(31, 78, 121, .35);
}
.navlinks { display: flex; gap: 4px; }
.navlinks a {
    color: var(--muted); padding: 7px 11px; border-radius: var(--r-sm); font-weight: 500;
}
.navlinks a:hover { color: var(--text); background: var(--surface-2); text-decoration: none; }
.navlinks a.active { color: var(--accent-600); background: var(--accent-soft); }

/* ---- Layout ---- */
.container { max-width: 1080px; margin: 0 auto; padding: 0 22px; }
.page { padding: 28px 22px 60px; animation: rise .4s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Admin shell (sidebar) ---- */
.admin-shell { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.sidebar {
    background: #14263b; color: #c2cad6; padding: 18px 14px;
    display: flex; flex-direction: column; gap: 2px; position: sticky; top: 0; height: 100vh;
}
.sidebar .brand { color: #fff; margin: 4px 8px 18px; }
.sidebar a {
    color: #aab1bd; padding: 9px 12px; border-radius: var(--r-sm); font-weight: 500;
    display: flex; align-items: center; gap: 9px;
}
.sidebar a:hover { color: #fff; background: rgba(255, 255, 255, .06); text-decoration: none; }
.sidebar a.active { color: #fff; background: var(--accent); }
.sidebar .sep { margin: 12px 8px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #6b7280; }
.admin-main { padding: 26px 30px 60px; min-width: 0; animation: rise .4s ease both; }

/* ---- Cards ---- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--shadow); padding: 18px 20px; margin-bottom: 18px;
}
.card-tight { padding: 14px 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); padding: 16px 18px; box-shadow: var(--shadow); }
.stat .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.stat .v { font-size: 26px; font-weight: 600; margin-top: 4px; letter-spacing: -.02em; }
.stat .v.mono { font-family: var(--mono); font-size: 22px; }

/* ---- Tables ---- */
.tbl { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; box-shadow: var(--shadow); }
.tbl th {
    text-align: left; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); padding: 11px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border);
}
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr:hover td, .tbl tr:hover td { background: var(--surface-2); }

/* ---- Buttons ---- */
.btn, button, input[type=submit] {
    font-family: var(--sans); font-size: 13px; font-weight: 500; cursor: pointer;
    background: var(--accent); color: #fff; border: 1px solid var(--accent);
    padding: 8px 14px; border-radius: var(--r-sm); transition: background .12s, box-shadow .12s;
}
.btn:hover, button:hover, input[type=submit]:hover { background: var(--accent-600); border-color: var(--accent-600); }
.btn:hover { text-decoration: none; }
.btn-ghost { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--faint); }
.btn-danger { background: var(--err); border-color: var(--err); }
.btn-danger:hover { background: #a81f1f; border-color: #a81f1f; }
.btn-sm, button.sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ---- Forms ---- */
label { display: inline-block; font-size: 13px; color: var(--muted); }
input, select, textarea {
    font-family: var(--sans); font-size: 13px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    padding: 8px 10px; outline: none; transition: border-color .12s, box-shadow .12s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input::placeholder { color: var(--faint); }

/* Custom select: strip native chrome, draw our own chevron */
select {
    appearance: none; -webkit-appearance: none; -moz-appearance: none;
    padding-right: 32px; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%236a675c' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
}
select:hover { border-color: var(--faint); }
select:focus {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1.5 6 6.5 11 1.5' stroke='%231f4e79' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
select::-ms-expand { display: none; }

/* Custom dropdown (JS-enhanced select) */
.cselect { position: relative; display: inline-block; }
.cselect-native { display: none; }
.dlg-grid .cselect, .form-narrow .cselect, .dialog-body > .cselect { display: block; width: 100%; }
.dialog-body > select { width: 100%; }
.cselect-btn {
    display: inline-flex; align-items: center; justify-content: space-between; gap: 10px;
    width: 100%; min-width: 132px; text-align: left; font-weight: 400;
    font-family: var(--sans); font-size: 13px; color: var(--text);
    background: var(--surface); border: 1px solid var(--border-strong); border-radius: var(--r-sm);
    padding: 8px 10px; cursor: pointer; transition: border-color .12s, box-shadow .12s;
}
.cselect-btn:hover { background: var(--surface); border-color: var(--faint); }
.cselect.open .cselect-btn, .cselect-btn:focus {
    background: var(--surface); border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); outline: none;
}
.cselect-chev { color: var(--muted); flex: none; transition: transform .15s; }
.cselect.open .cselect-chev { transform: rotate(180deg); color: var(--accent); }
.cselect-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cselect-label.is-placeholder { color: var(--faint); }
.cselect-list {
    position: absolute; z-index: 50; top: calc(100% + 4px); left: 0; min-width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
    box-shadow: var(--shadow-lg); padding: 4px; max-height: 260px; overflow-y: auto;
    animation: pop .12s ease both;
}
.cselect-opt { padding: 7px 10px; border-radius: 5px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.cselect-opt:hover { background: var(--surface-2); }
.cselect-opt.sel { color: var(--accent); font-weight: 500; background: var(--accent-soft); }
.form-narrow { max-width: 380px; }
.form-narrow p { margin: 0 0 10px; }
.form-narrow input, .form-narrow select { width: 100%; }
.field-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 10px; }

/* ---- Badges (status) ---- */
.badge {
    display: inline-block; font-family: var(--mono); font-size: 11px; font-weight: 500;
    padding: 2px 9px; border-radius: 999px; text-transform: lowercase; letter-spacing: .01em;
    background: var(--neutral-bg); color: var(--neutral);
}
.badge.ok, .badge.active, .badge.paid, .badge.running, .badge.on, .badge.up { background: var(--ok-bg); color: var(--ok); }
.badge.warn, .badge.pending, .badge.unpaid { background: var(--warn-bg); color: var(--warn); }
.badge.err, .badge.suspended, .badge.overdue, .badge.terminated, .badge.failed, .badge.off, .badge.down, .badge.stopped { background: var(--err-bg); color: var(--err); }
.badge.info { background: var(--info-bg); color: var(--info); }

/* ---- Misc ---- */
.wallet { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.wallet .amt { font-family: var(--mono); font-size: 18px; font-weight: 600; }
.alert { padding: 10px 14px; border-radius: var(--r-sm); margin-bottom: 14px; font-size: 13px; }
.alert.error, .alert-error { background: var(--err-bg); color: var(--err); border: 1px solid #f3caca; }
.empty { color: var(--muted); text-align: center; padding: 22px; }
hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.stack > * + * { margin-top: 10px; }

[x-cloak] { display: none !important; }

/* ---- Cabinet ---- */
.page-head { margin-bottom: 18px; }
.page-head p { margin: 2px 0 0; }
.small { font-size: 12px; }
.ta-r { text-align: right; }

/* Language switcher */
.lang-switch { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--r-sm); overflow: hidden; }
.lang-switch a { font-size: 11px; font-weight: 600; color: var(--muted); padding: 5px 8px; line-height: 1; }
.lang-switch a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.lang-switch a.on { background: var(--accent); color: #fff; }
.lang-switch-side { align-self: flex-start; margin: 0 8px 10px; border-color: rgba(255, 255, 255, .16); }
.lang-switch-side a { color: #aab1bd; }
.lang-switch-side a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.lang-switch-side a.on { background: var(--accent); color: #fff; }

.user-chip {
    font-size: 12px; color: var(--muted); max-width: 200px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 24px 0 10px; }
.section-head h2 { margin: 0; }
.section-head h1 { margin: 0; }
.count-badge {
    display: inline-block; font-size: 12px; font-weight: 600; color: var(--muted);
    background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px;
    padding: 1px 9px; margin-left: 6px; vertical-align: middle;
}
.filter-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.filter-form label { font-size: 12px; color: var(--muted); }

/* Pagination */
.pager-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.perpage-form { display: inline-flex; align-items: center; gap: 8px; margin: 0; }
.perpage-form label { font-size: 12px; color: var(--muted); }
.pager { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.pager a, .pager .pager-gap {
    font-size: 13px; color: var(--muted); padding: 6px 11px; border-radius: var(--r-sm);
    border: 1px solid transparent; min-width: 34px; text-align: center;
}
.pager a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.pager .pager-num.on { background: var(--accent); color: #fff; border-color: var(--accent); font-weight: 500; }
.pager .pager-btn { border-color: var(--border-strong); background: var(--surface); }
.pager .pager-btn.disabled { opacity: .45; pointer-events: none; }
.pager .pager-gap { pointer-events: none; padding: 6px 4px; min-width: 0; }

/* Dialog form grid (labeled fields, 2-col) */
.dialog.dialog-wide { width: 480px; }
.dlg-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; }
.dlg-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); margin: 0; }
.dlg-grid label input, .dlg-grid label select { width: 100%; }
.dlg-grid .col-2 { grid-column: 1 / -1; }

/* Overview stat strip */
.overview { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 8px; }
.overview .stat { display: flex; flex-direction: column; gap: 3px; }
.overview .stat .v { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.overview .stat .v .of { font-size: 15px; color: var(--faint); font-weight: 500; margin-left: 3px; }
.overview .stat .sub { font-size: 12px; color: var(--muted); }
.overview .stat-wallet button { align-self: flex-start; margin-top: 8px; }
.stat-due { border-color: #edc7a0; background: linear-gradient(0deg, var(--warn-bg), var(--surface)); }
.stat-due .v { color: var(--warn); }
.stat-overdue { border-color: #eeb3b3; background: linear-gradient(0deg, var(--err-bg), var(--surface)); }
.stat-overdue .v { color: var(--err); }

/* Service name cell */
.svc-name { font-weight: 500; }
.tag {
    display: inline-block; margin-top: 3px; font-family: var(--mono);
    font-size: 10px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted); background: var(--surface-2);
    border: 1px solid var(--border); border-radius: 5px; padding: 1px 6px;
}

/* Disclosure (account / ssh) */
.disclosure {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--r); box-shadow: var(--shadow); margin-top: 24px;
}
.disclosure > summary {
    list-style: none; cursor: pointer; padding: 14px 18px;
    display: flex; align-items: center; gap: 10px; font-weight: 600;
}
.disclosure > summary > span:first-child { margin-right: auto; }
.disclosure > summary::-webkit-details-marker { display: none; }
.disclosure > summary::after {
    content: '⌄'; color: var(--faint); font-size: 16px; line-height: 1;
    transition: transform .15s;
}
.disclosure[open] > summary::after { transform: rotate(180deg); }
.disclosure > summary:hover { background: var(--surface-2); border-radius: var(--r) var(--r) 0 0; }
.disclosure-body { padding: 4px 18px 18px; border-top: 1px solid var(--border); }

/* Clickable table rows */
.row-link { cursor: pointer; }

/* ---- Detail pages (service / invoice) ---- */
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.detail-head h1 { display: flex; align-items: center; gap: 10px; }
.detail-head .tag { margin-top: 0; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: 1fr; } }

.dl { display: grid; grid-template-columns: 130px 1fr; gap: 8px 14px; margin: 0; }
.dl dt { color: var(--muted); font-size: 13px; }
.dl dd { margin: 0; }

/* IP address map (subnet view) */
.ipmap { display: flex; flex-wrap: wrap; gap: 3px; }
.ipcell { width: 14px; height: 14px; border-radius: 3px; background: var(--surface-2); border: 1px solid var(--border); cursor: default; }
.ipcell.assigned { background: var(--accent); border-color: var(--accent); }
.ipcell.reserved { background: #e2a24d; border-color: #cf8b30; }
.ipcell.free { background: var(--surface-2); }
.ipmap-legend { display: flex; gap: 18px; margin-bottom: 12px; font-size: 12px; color: var(--muted); }
.ipdot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: middle; margin-right: 5px; border: 1px solid var(--border); }
.ipdot.assigned { background: var(--accent); }
.ipdot.reserved { background: #e2a24d; }
.ipdot.free { background: var(--surface-2); }

/* Resource meters (node view) */
.meter-row { margin-bottom: 14px; }
.meter-head { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
.meter { height: 8px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; overflow: hidden; }
.meter-fill { height: 100%; background: linear-gradient(90deg, var(--accent), #3a78ad); border-radius: 999px; transition: width .3s; }

.invoice-amount { display: flex; align-items: baseline; justify-content: space-between; }
.invoice-amount .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.invoice-amount .amt { font-size: 26px; font-weight: 600; letter-spacing: -.02em; }

.alert.alert-ok { background: var(--ok-bg); color: var(--ok); border: 1px solid #bfe6d6; }

/* ---- Dashboard charts ---- */
.period-switch { display: inline-flex; align-items: center; gap: 6px; }
.period-switch .period-label { font-size: 12px; color: var(--muted); margin-right: 4px; }
.period-switch a {
    font-size: 12px; font-weight: 500; color: var(--muted); padding: 5px 11px;
    border: 1px solid var(--border-strong); border-radius: var(--r-sm); background: var(--surface);
}
.period-switch a:hover { border-color: var(--faint); text-decoration: none; color: var(--text); }
.period-switch a.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.dash-section { margin: 26px 0 12px; font-size: 15px; }
.dash-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }
.dash-grid .col-span { grid-column: 1 / -1; }
@media (max-width: 860px) { .dash-grid { grid-template-columns: 1fr; } }
.chart-card { margin-bottom: 0; }
.chart-card h3 { font-size: 13px; font-weight: 600; margin: 0 0 10px; color: var(--text); }
.chart-box { position: relative; height: 240px; }

/* ---- Home / landing ---- */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 40px; align-items: center; padding: 30px 0 40px; }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; gap: 26px; } }
.hero-eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.hero-title { font-size: 40px; line-height: 1.08; font-weight: 600; letter-spacing: -.02em; margin: 12px 0 14px; }
@media (max-width: 820px) { .hero-title { font-size: 30px; } }
.hero-sub { font-size: 16px; color: var(--muted); max-width: 30em; margin: 0 0 20px; }
.hero-trust { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* terminal mockup */
.term { background: #0f1d2e; border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; border: 1px solid #14263b; }
.term-bar { display: flex; align-items: center; gap: 7px; padding: 11px 14px; background: #14263b; }
.term-bar i { width: 11px; height: 11px; border-radius: 50%; background: #3a4a5e; }
.term-bar i:first-child { background: #e0574f; } .term-bar i:nth-child(2) { background: #e2a24d; } .term-bar i:nth-child(3) { background: #35c08a; }
.term-title { margin-left: 8px; font-family: var(--mono); font-size: 12px; color: #7d8ba0; }
.term-body { margin: 0; padding: 18px 18px 20px; font-family: var(--mono); font-size: 13px; line-height: 1.7; color: #cdd6e2; white-space: pre-wrap; }
.term-body .c-ok { color: #35c08a; } .term-body .c-muted { color: #6b7a90; } .term-body .c-accent { color: #6ea9dc; font-weight: 600; }

.home-section { padding: 26px 0; }
.feat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 820px) { .feat-grid { grid-template-columns: 1fr; } }
.feat { display: flex; gap: 13px; }
.feat-ico { flex: none; width: 34px; height: 34px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    background: var(--accent-soft); color: var(--accent); }
.feat-title { font-weight: 600; margin-bottom: 3px; }
.feat-text { margin: 0; font-size: 13px; color: var(--muted); line-height: 1.5; }

.cta-band { display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap;
    background: linear-gradient(135deg, #1b3b5a, #14263b); color: #fff; border-radius: 14px; padding: 28px 32px; margin: 20px 0 10px; }
.cta-band h2 { margin: 0 0 4px; color: #fff; font-size: 20px; }
.cta-band p { margin: 0; color: #c2ccd8; }
.cta-band .btn { background: #fff; color: var(--accent); border-color: #fff; }
.cta-band .btn:hover { background: #eef2f6; border-color: #eef2f6; }

/* ---- Plans (pricing cards) ---- */
.plans-hero { text-align: center; max-width: 560px; margin: 8px auto 26px; }
.plans-hero h1 { font-size: 26px; }
.plans-hero p { margin: 6px 0 0; }
.plans-section { margin: 26px 0 12px; }

.plan-grid { display: flex; flex-wrap: wrap; gap: 16px; }
.plan-card {
    flex: 1 1 260px; max-width: 360px; position: relative;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r);
    box-shadow: var(--shadow); padding: 20px; display: flex; flex-direction: column;
    transition: border-color .12s, box-shadow .12s, transform .12s;
}
.plan-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.plan-card.featured { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent), var(--shadow-lg); }
.plan-flag {
    position: absolute; top: -10px; left: 20px; background: var(--accent); color: #fff;
    font-size: 10px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
    padding: 3px 10px; border-radius: 999px; box-shadow: var(--shadow);
}
.plan-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.plan-name { font-size: 16px; font-weight: 600; }
.plan-top .tag { margin-top: 0; }
.plan-price { margin: 14px 0 4px; display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.plan-price .amt { font-size: 23px; font-weight: 600; color: var(--accent); letter-spacing: -.02em; white-space: nowrap; }
.plan-price .per { color: var(--muted); font-size: 13px; flex-basis: 100%; }
.plan-specs { list-style: none; margin: 12px 0 18px; padding: 14px 0 0; border-top: 1px solid var(--border); }
.plan-specs li { display: flex; justify-content: space-between; padding: 5px 0; font-size: 13px; }
.plan-specs li span { color: var(--muted); }
.plan-cta { width: 100%; text-align: center; margin-top: auto; padding: 10px; }

/* ---- Checkout ---- */
.checkout-pay { display: flex; flex-direction: column; }
.checkout-pay .k { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.checkout-pay .amt { font-size: 30px; font-weight: 600; letter-spacing: -.02em; margin-top: 2px; }
.pay-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 16px; }
.pay-actions form { display: contents; }
.pay-primary { width: 100%; text-align: center; padding: 11px; }

/* ---- Payment redirect ---- */
.redir-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.redir-card {
    width: 400px; max-width: 100%; text-align: center; background: var(--surface);
    border: 1px solid var(--border); border-radius: var(--r); box-shadow: var(--shadow-lg); padding: 34px 28px;
}
.redir-card h1 { font-size: 19px; margin: 16px 0 6px; }
.spinner {
    width: 34px; height: 34px; margin: 0 auto; border-radius: 50%;
    border: 3px solid var(--accent-soft); border-top-color: var(--accent);
    animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Error page ---- */
.error-page { max-width: 480px; margin: 48px auto; text-align: center; }
.error-page h1 { font-size: 24px; margin: 4px 0 8px; }
.error-page .error-code {
    font-family: var(--mono); font-size: 68px; font-weight: 500; line-height: 1;
    color: var(--accent); opacity: .9; letter-spacing: -.02em;
}
.error-detail { margin-top: 26px; text-align: left; }
.error-trace {
    margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border);
    border-radius: var(--r-sm); font-size: 12px; white-space: pre-wrap; word-break: break-word; color: var(--err);
}

/* ---- Dialog (native <dialog>) ---- */
dialog.dialog {
    border: 1px solid var(--border); border-radius: var(--r); padding: 0;
    width: 420px; max-width: calc(100vw - 32px);
    background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
dialog.dialog::backdrop { background: rgba(20, 24, 32, .45); backdrop-filter: blur(2px); }
dialog.dialog[open] { animation: pop .16s ease both; }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dialog-head { padding: 14px 18px; border-bottom: 1px solid var(--border); font-weight: 600; }
.dialog-body { padding: 18px; }
.dialog-body label { display: block; margin-bottom: 5px; font-size: 12px; }
.dialog-body input { width: 100%; }
.dialog-actions { padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); display: flex; gap: 8px; justify-content: flex-end; }
.danger-note { margin: 0; padding: 10px 12px; border-radius: 8px; background: var(--err-bg); color: var(--err); font-size: 13px; }

/* ---- Notice / termination banner ---- */
.notice { padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--border); font-size: 14px; margin-bottom: 18px; }
.notice-info { background: var(--warn-bg); border-color: #e7d5ab; color: var(--warn); }
.term-banner {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px;
    padding: 13px 16px; border-radius: var(--r);
    background: var(--err-bg); border: 1px solid #f0c9c9; color: var(--err);
    text-decoration: none; transition: border-color .12s, transform .12s;
}
.term-banner:hover { border-color: var(--err); text-decoration: none; }
.term-banner-icon { font-size: 18px; line-height: 1; }
.term-banner-text { font-weight: 600; }
.term-banner-cta { margin-left: auto; font-weight: 600; white-space: nowrap; }

/* ---- Auth screen (split: brand panel + form) ---- */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-split {
    display: grid; grid-template-columns: 1.05fr 1fr; width: 840px; max-width: 100%;
    background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
    box-shadow: var(--shadow-lg); overflow: hidden; animation: pop .2s ease both;
}

/* Left brand panel */
.auth-hero {
    background:
        radial-gradient(120% 120% at 0% 0%, rgba(58,120,173,.35), transparent 55%),
        linear-gradient(160deg, #1b3b5a 0%, #14263b 60%, #0f1d2e 100%);
    background-color: #14263b;
    color: #dfe6ef; padding: 34px 30px; display: flex; flex-direction: column; gap: 26px;
}
.auth-hero-brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 16px; color: #fff; }
.auth-hero-brand:hover { text-decoration: none; }
.auth-hero-body { margin-top: 6px; }
.auth-hero h2 { font-size: 26px; line-height: 1.2; font-weight: 600; letter-spacing: -.01em; color: #fff; margin: 0 0 18px; }
.auth-feats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 11px; }
.auth-feats li { position: relative; padding-left: 24px; font-size: 13px; color: #c2ccd8; line-height: 1.4; }
.auth-feats li::before {
    content: '✓'; position: absolute; left: 0; top: -1px; color: #6ea9dc; font-weight: 700;
}
.auth-hero-back { margin-top: auto; color: #9db8d6; font-size: 13px; }
.auth-hero-back:hover { color: #fff; }

/* Right form panel */
.auth-form-panel { padding: 30px 30px 28px; display: flex; flex-direction: column; }
.auth-title { font-size: 20px; margin: 6px 0 2px; }
.auth-sub { margin: 0 0 16px; font-size: 13px; }
.tabs { display: flex; gap: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 3px; margin: 0 0 20px; }
.tabs button { flex: 1; background: transparent; color: var(--muted); border: none; padding: 8px; border-radius: 5px; font-weight: 500; }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.auth-form-panel .field { margin-bottom: 13px; }
.auth-form-panel .field label { display: block; margin-bottom: 5px; font-size: 12px; color: var(--muted); }
.auth-form-panel .field input { width: 100%; }
.auth-form-panel .submit { width: 100%; margin-top: 6px; padding: 10px; }

@media (max-width: 720px) {
    .auth-split { grid-template-columns: 1fr; width: 400px; }
    .auth-hero { display: none; }
}

/* ---- Flash toasts ---- */
.flash-stack {
    position: fixed; top: 16px; right: 16px; z-index: 1000;
    display: flex; flex-direction: column; gap: 10px;
    width: 360px; max-width: calc(100vw - 32px);
}
.flash {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border-radius: var(--r);
    background: var(--surface); border: 1px solid var(--border);
    box-shadow: var(--shadow-lg); font-size: 14px;
    animation: flash-in .18s ease both;
}
@keyframes flash-in { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: none; } }
.flash-icon {
    flex: none; width: 20px; height: 20px; border-radius: 50%;
    display: grid; place-items: center; font-size: 12px; font-weight: 700; color: #fff; margin-top: 1px;
}
.flash-msg { flex: 1; line-height: 1.4; }
.flash-close {
    flex: none; background: none; border: none; cursor: pointer;
    font-size: 18px; line-height: 1; color: var(--faint); padding: 0 2px;
}
.flash-close:hover { color: var(--text); }
.flash-success { border-color: #bfe6d6; background: var(--ok-bg); }
.flash-success .flash-icon { background: var(--ok); }
.flash-error { border-color: #f0c9c9; background: var(--err-bg); }
.flash-error .flash-icon { background: var(--err); }
.flash-warning { border-color: #e7d5ab; background: var(--warn-bg); }
.flash-warning .flash-icon { background: var(--warn); }
.flash-info { border-color: #c6e0f5; background: var(--info-bg); }
.flash-info .flash-icon { background: var(--info); }

/* ---- Admin logs ---- */
.nowrap { white-space: nowrap; }
.log-msg { line-height: 1.4; }
.log-ctx { margin-top: 4px; }
.log-ctx summary {
    cursor: pointer; font-size: 12px; color: var(--muted); user-select: none;
}
.log-ctx summary:hover { color: var(--text); }
.log-ctx pre {
    margin: 6px 0 0; padding: 10px 12px; border-radius: var(--r-sm);
    background: var(--surface-2); border: 1px solid var(--border);
    font-size: 12px; line-height: 1.45; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
}
.filter-form input[type="search"] {
    padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--r-sm);
    background: var(--surface); font: inherit; font-size: 13px; min-width: 180px;
}

/* ---- Auth: forgot / reset (single-panel) ---- */
.auth-split-single {
    grid-template-columns: 1fr; width: 420px; max-width: 100%;
}
.auth-brand-inline { display: inline-flex; align-items: center; gap: 8px; margin-bottom: 22px; color: var(--text); text-decoration: none; font-weight: 600; }
.auth-forgot { margin: 0 0 10px; text-align: right; font-size: 13px; }
.auth-alt { margin: 18px 0 0; text-align: center; font-size: 13px; }

/* ---- Divider inside disclosure/cards ---- */
.sep-line { border: none; border-top: 1px solid var(--border); margin: 20px 0 16px; }

/* ============================================================
   RESPONSIVE / MOBILE POLISH
   Preserves the rice-paper + navy system; additive only.
   ============================================================ */

/* Tables scroll horizontally within a wrapper (added by app.js) so column
   alignment is preserved (unlike display:block on the table itself). No-op on
   desktop where the table already fits. */
.tbl-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.col-util { min-width: 180px; }

/* Admin mobile top bar + drawer scaffolding (shown only on narrow screens). */
.admin-topbar { display: none; align-items: center; gap: 12px; height: 52px; padding: 0 14px;
    background: #14263b; position: sticky; top: 0; z-index: 120; border-bottom: 1px solid rgba(255,255,255,.08); }
.admin-topbar .brand { color: #fff; font-size: 15px; }
.admin-topbar .brand:hover { text-decoration: none; }
.admin-hamburger { background: none; border: none; color: #c2cad6; padding: 6px; margin: -6px 0 -6px -6px;
    border-radius: var(--r-sm); cursor: pointer; display: flex; align-items: center; }
.admin-hamburger:hover { background: rgba(255,255,255,.08); color: #fff; }
.admin-overlay { display: none; position: fixed; inset: 0; background: rgba(20,24,32,.5); z-index: 110; backdrop-filter: blur(2px); }

/* ---- Tablet / small laptop: admin sidebar becomes an off-canvas drawer ---- */
@media (max-width: 900px) {
    .admin-topbar { display: flex; }
    .admin-shell { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; top: 0; left: 0; width: 240px; height: 100vh; height: 100dvh;
        z-index: 130; overflow-y: auto; transform: translateX(-100%);
        transition: transform .22s cubic-bezier(.4, 0, .2, 1); box-shadow: var(--shadow-lg);
    }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .admin-overlay { display: block; }
    .admin-main { padding: 20px 16px 48px; }

    .section-head { flex-wrap: wrap; gap: 10px; align-items: flex-start; }
    .detail-head { flex-direction: column; align-items: flex-start; }
    .filter-form { flex-wrap: wrap; }
    .filter-form input[type="search"] { min-width: 0; flex: 1 1 140px; }
    .period-switch { flex-wrap: wrap; }
    .ipmap-legend { flex-wrap: wrap; gap: 8px 14px; }
    .dlg-grid { grid-template-columns: 1fr; }
    .dlg-grid .col-2 { grid-column: 1; }
    dialog.dialog, dialog.dialog.dialog-wide {
        width: calc(100vw - 24px); max-width: calc(100vw - 24px); max-height: 90vh; max-height: 90dvh; overflow-y: auto;
    }
}

/* ---- Phones / small tablets: public chrome + shared components ---- */
@media (max-width: 768px) {
    .topbar-inner { height: auto; flex-wrap: wrap; gap: 10px 14px; padding: 10px 0; }
    .navlinks { flex-wrap: wrap; gap: 2px; }
    .topbar-inner .right { margin-left: auto; flex-wrap: wrap; gap: 6px; }

    .plan-card { max-width: 100%; }
    .cta-band { flex-direction: column; align-items: stretch; text-align: center; padding: 22px 20px; }
    .cta-band .btn { width: 100%; }
    .dl dd { overflow-wrap: break-word; word-break: break-word; min-width: 0; }
    .flash-stack { left: 14px; right: 14px; width: auto; }
    .pager a { min-width: 40px; padding: 9px 12px; }
}

/* ---- Small phones: reclaim horizontal space, stack dense components ---- */
@media (max-width: 430px) {
    .container { padding: 0 14px; }
    .page { padding: 20px 14px 48px; }
    .admin-main { padding: 16px 12px 40px; }
    .user-chip { display: none; }                 /* email still shown in cabinet heading */
    .hero-title { font-size: 26px; }
    .dl { grid-template-columns: 1fr; gap: 1px 0; }
    .dl dt { margin-top: 9px; }
    .dl dt:first-child { margin-top: 0; }
    .pager-bar { flex-direction: column; align-items: stretch; gap: 10px; }
    .invoice-amount { flex-direction: column; gap: 4px; }
}

/* ---- Client verification ---- */
.verify-status { display: flex; flex-direction: column; gap: 4px; }
.verify-status .label { color: var(--muted); font-size: 12px; margin-right: 8px; }
.verify-verified { border-left: 3px solid var(--ok); }
.verify-pending { border-left: 3px solid var(--warn); }
.verify-rejected { border-left: 3px solid var(--err); }
.doc-list { margin: 4px 0 0; padding-left: 18px; }
.doc-list li { margin: 3px 0; }

/* ---- Offer acceptance checkbox (registration) ---- */
.offer-accept { display: flex; align-items: flex-start; gap: 8px; margin: 4px 0 14px; font-size: 13px; color: var(--muted); }
.offer-accept input { margin-top: 2px; flex: none; }
.offer-accept a { color: var(--accent); }

/* ---- Public offer document ---- */
.offer-doc { max-width: 760px; margin: 0 auto; }
.offer-doc h1 { font-size: 24px; margin-bottom: 4px; }
.offer-meta { margin-top: 0; }
.offer-body { line-height: 1.65; }
.offer-body h2 { font-size: 17px; margin: 22px 0 6px; }
.offer-body h3 { font-size: 15px; margin: 16px 0 4px; }
.offer-body p { margin: 6px 0; }
.offer-body ul { margin: 6px 0 6px 18px; }
.offer-requisites { margin-top: 26px; padding-top: 16px; border-top: 1px solid var(--border); }
.offer-requisites h2 { font-size: 16px; }
.site-footer { border-top: 1px solid var(--border); padding: 18px 0; margin-top: 40px; font-size: 13px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---- Brand colours (admin) ---- */
.color-field { display: flex; align-items: center; gap: 8px; }
.color-field input[type=color] { width: 44px; height: 32px; padding: 2px; flex: none; cursor: pointer; }
.color-field code { font-size: 12px; color: var(--muted); }
.brand-dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 6px; }
.brand-dots i { width: 12px; height: 12px; border-radius: 50%; border: 1px solid var(--border-strong); display: inline-block; }
