/* ==========================================================================
   Amaar Soft — shared design system (storefront, customer portal, admin)
   ========================================================================== */

:root {
    --font: "IBM Plex Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --ink-900: #0b1220;
    --ink-800: #172033;
    --ink-700: #2a3446;
    --ink-600: #475467;
    --ink-500: #5d6779;
    --ink-400: #8a93a3;
    --ink-300: #b3bac6;

    --line: #e4e7ec;
    --line-strong: #d0d5dd;
    --bg: #f5f6f8;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f2f4f7;

    --brand-950: #081a3a;
    --brand-900: #0e2a5c;
    --brand-800: #133a7c;
    --brand-700: #1a4b9c;
    --brand-600: #1d5fd1;
    --brand-100: #e6eefb;
    --brand-50: #f2f6fd;
    --cyan: #0e8fb0;

    --success: #0f7b4b;
    --success-bg: #e8f5ee;
    --success-line: #bfe3cf;
    --warning: #8a5300;
    --warning-bg: #fff5e3;
    --warning-line: #f3dcae;
    --danger: #b42318;
    --danger-bg: #fdeeec;
    --danger-line: #f6cbc5;
    --info: #1a4b9c;
    --info-bg: #edf3fd;
    --info-line: #c9daf6;
    --neutral: #475467;
    --neutral-bg: #f2f4f7;

    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .04);
    --shadow-lg: 0 12px 32px -8px rgba(16, 24, 40, .18), 0 4px 8px -4px rgba(16, 24, 40, .06);

    --focus: 0 0 0 3px rgba(29, 95, 209, .22);
    --sidebar-w: 248px;
    --topbar-h: 60px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink-700);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
img, svg, video { max-width: 100%; }
img { height: auto; display: block; }
a { color: var(--brand-600); text-decoration: none; }
a:hover { color: var(--brand-800); text-decoration: underline; text-underline-offset: 2px; }
h1, h2, h3, h4, h5 { color: var(--ink-900); margin: 0; line-height: 1.25; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 28px; }
h2 { font-size: 22px; }
h3 { font-size: 17px; }
h4 { font-size: 15px; }
p { margin: 0 0 12px; }
p:last-child { margin-bottom: 0; }
small, .text-sm { font-size: 13px; }
.text-xs { font-size: 12px; }
.text-lg { font-size: 17px; }
strong, b { font-weight: 600; color: var(--ink-900); }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
code, kbd, pre, .mono { font-family: var(--mono); font-size: .92em; }
code { background: var(--surface-3); border: 1px solid var(--line); border-radius: 4px; padding: 1px 5px; color: var(--ink-800); }
pre { background: var(--ink-900); color: #e6e9ef; border-radius: var(--radius); padding: 14px 16px; overflow-x: auto; font-size: 13px; line-height: 1.6; }
pre code { background: none; border: 0; padding: 0; color: inherit; }
::selection { background: rgba(29, 95, 209, .18); }
.icon { flex: 0 0 auto; display: inline-block; vertical-align: middle; }
[hidden] { display: none !important; }
[x-cloak] { display: none !important; }

.skip-link { position: absolute; left: -9999px; top: 8px; z-index: 1000; background: var(--ink-900); color: #fff; padding: 8px 12px; border-radius: var(--radius-sm); }
.skip-link:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* ---------- Layout helpers ---------- */
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 24px; }
.container-sm { max-width: 760px; }
.container-md { max-width: 960px; }
.stack > * + * { margin-top: 16px; }
.stack-sm > * + * { margin-top: 8px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; align-items: center; gap: 12px; }
.row-wrap { flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.row-top { align-items: flex-start; }
.grow { flex: 1 1 auto; min-width: 0; }
.gap-xs { gap: 4px; } .gap-sm { gap: 8px; } .gap-lg { gap: 20px; }
.grid { display: grid; gap: 16px; }
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { display: grid; gap: 16px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { display: grid; gap: 20px; grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.span-2 { grid-column: span 2; }
.mt-0 { margin-top: 0 !important; } .mt-xs { margin-top: 4px; } .mt-sm { margin-top: 8px; } .mt { margin-top: 16px; } .mt-lg { margin-top: 24px; } .mt-xl { margin-top: 40px; }
.mb-0 { margin-bottom: 0 !important; } .mb-sm { margin-bottom: 8px; } .mb { margin-bottom: 16px; } .mb-lg { margin-bottom: 24px; }
.muted { color: var(--ink-500); }
.subtle { color: var(--ink-400); }
.text-success { color: var(--success); } .text-danger { color: var(--danger); } .text-warning { color: var(--warning); }
.text-right { text-align: right; } .text-center { text-align: center; }
.nowrap { white-space: nowrap; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.break { word-break: break-word; overflow-wrap: anywhere; }
.w-full { width: 100%; }
.fw-500 { font-weight: 500; } .fw-600 { font-weight: 600; }
.divider { height: 1px; background: var(--line); margin: 16px 0; }

/* ---------- Buttons ---------- */
.btn {
    --btn-h: 38px;
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: var(--btn-h); padding: 0 14px;
    font: 500 14px/1 var(--font); letter-spacing: 0;
    border-radius: var(--radius-sm); border: 1px solid transparent;
    cursor: pointer; white-space: nowrap; text-decoration: none !important;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease, box-shadow .12s ease;
    -webkit-user-select: none; user-select: none;
}
.btn:focus-visible { outline: none; box-shadow: var(--focus); }
.btn:disabled, .btn.is-disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.btn-primary:hover { background: var(--brand-900); border-color: var(--brand-900); color: #fff; }
.btn-secondary { background: var(--surface); border-color: var(--line-strong); color: var(--ink-800); box-shadow: var(--shadow-sm); }
.btn-secondary:hover { background: var(--surface-2); border-color: var(--ink-300); color: var(--ink-900); }
.btn-ghost { background: transparent; color: var(--ink-700); }
.btn-ghost:hover { background: var(--surface-3); color: var(--ink-900); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #912018; border-color: #912018; color: #fff; }
.btn-danger-soft { background: var(--surface); border-color: var(--danger-line); color: var(--danger); }
.btn-danger-soft:hover { background: var(--danger-bg); color: var(--danger); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0b623b; color: #fff; }
.btn-link { background: none; border: 0; padding: 0; height: auto; color: var(--brand-600); }
.btn-link:hover { text-decoration: underline !important; color: var(--brand-800); }
.btn-sm { --btn-h: 32px; padding: 0 10px; font-size: 13px; gap: 6px; }
.btn-xs { --btn-h: 26px; padding: 0 8px; font-size: 12px; gap: 4px; border-radius: 5px; }
.btn-lg { --btn-h: 46px; padding: 0 20px; font-size: 15px; }
.btn-block { width: 100%; }
.btn-icon { width: var(--btn-h); padding: 0; }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
form.inline { display: inline; }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); min-width: 0; }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-header h2, .card-header h3, .card-title { font-size: 15px; font-weight: 600; color: var(--ink-900); margin: 0; }
.card-header p { margin: 2px 0 0; font-size: 13px; color: var(--ink-500); }
.card-body { padding: 18px; }
.card-body-lg { padding: 24px; }
.card-footer { padding: 12px 18px; border-top: 1px solid var(--line); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 8px; align-items: center; justify-content: flex-end; flex-wrap: wrap; }
.card-flush .card-body { padding: 0; }
.card + .card { margin-top: 16px; }
.card-muted { background: var(--surface-2); }
.card-link { display: block; color: inherit; transition: border-color .12s ease, box-shadow .12s ease; }
.card-link:hover { border-color: var(--line-strong); box-shadow: var(--shadow); text-decoration: none; color: inherit; }

/* ---------- Page header ---------- */
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-header h1 { font-size: 22px; }
.page-header p { margin: 4px 0 0; color: var(--ink-500); font-size: 14px; max-width: 720px; }
.page-header .btn-group { margin-left: auto; }
.breadcrumb { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-500); margin-bottom: 8px; }
.breadcrumb a { color: var(--ink-500); }
.breadcrumb a:hover { color: var(--ink-900); }
.breadcrumb .sep { color: var(--ink-300); }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--ink-500); margin-bottom: 8px; }
.back-link:hover { color: var(--ink-900); text-decoration: none; }

/* ---------- Forms ---------- */
.field { display: block; min-width: 0; }
.field + .field { margin-top: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 16px; }
.form-grid .field + .field { margin-top: 0; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.label, .field > label { display: block; font-size: 13px; font-weight: 500; color: var(--ink-800); margin-bottom: 6px; }
.label .req { color: var(--danger); margin-left: 2px; }
.label-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.input, .select, .textarea,
.field input[type=text], .field input[type=email], .field input[type=password], .field input[type=number], .field input[type=url], .field input[type=tel], .field input[type=date], .field input[type=datetime-local], .field input[type=search], .field input[type=file], .field select, .field textarea {
    display: block; width: 100%; min-height: 40px;
    padding: 8px 12px;
    font: 400 14px/1.4 var(--font); color: var(--ink-900);
    background: var(--surface); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
    box-shadow: var(--shadow-sm);
    transition: border-color .12s ease, box-shadow .12s ease;
}
.field input[type=file] { padding: 7px 10px; font-size: 13px; }
.textarea, .field textarea { min-height: 96px; resize: vertical; line-height: 1.55; }
.select, .field select { appearance: none; -webkit-appearance: none; padding-right: 34px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%235d6779' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; }
.input:focus, .select:focus, .textarea:focus,
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand-600); box-shadow: var(--focus); }
.input::placeholder, .field input::placeholder, .field textarea::placeholder { color: var(--ink-400); }
.input[readonly], .field input[readonly] { background: var(--surface-2); }
.input:disabled, .field input:disabled, .field select:disabled { background: var(--surface-3); color: var(--ink-500); cursor: not-allowed; }
.input-sm { min-height: 34px; padding: 5px 10px; font-size: 13px; }
.mono-input { font-family: var(--mono) !important; letter-spacing: .02em; }
.help { display: block; margin-top: 6px; font-size: 12.5px; color: var(--ink-500); line-height: 1.45; }
.error, .field-error { display: block; margin-top: 6px; font-size: 12.5px; color: var(--danger); }
.is-invalid, .field .is-invalid { border-color: var(--danger) !important; }
.input-group { display: flex; align-items: stretch; }
.input-group > .input, .input-group > input { border-top-right-radius: 0; border-bottom-right-radius: 0; flex: 1 1 auto; min-width: 0; }
.input-group > .btn { border-top-left-radius: 0; border-bottom-left-radius: 0; height: auto; margin-left: -1px; }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--ink-400); pointer-events: none; }
.input-icon > .input, .input-icon > input { padding-left: 36px; }
.password-field { position: relative; }
.password-field input { padding-right: 42px !important; }
.password-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; background: transparent; color: var(--ink-500); cursor: pointer; border-radius: 5px; }
.password-toggle:hover { color: var(--ink-900); background: var(--surface-3); }

.check { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; color: var(--ink-700); cursor: pointer; line-height: 1.45; }
.check input[type=checkbox], .check input[type=radio] { width: 16px; height: 16px; margin: 2px 0 0; flex: 0 0 auto; accent-color: var(--brand-800); }
.check + .check { margin-top: 10px; }
.check small { display: block; color: var(--ink-500); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 36px; height: 20px; border-radius: 999px; background: var(--line-strong); transition: background .15s ease; position: relative; flex: 0 0 auto; }
.switch .track::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,.2); transition: transform .15s ease; }
.switch input:checked + .track { background: var(--brand-800); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { box-shadow: var(--focus); }

.form-section { padding: 20px 0; border-top: 1px solid var(--line); display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 24px; }
.form-section:first-child { border-top: 0; padding-top: 0; }
.form-section-head h3 { font-size: 15px; }
.form-section-head p { margin-top: 4px; font-size: 13px; color: var(--ink-500); }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; padding-top: 16px; border-top: 1px solid var(--line); margin-top: 20px; flex-wrap: wrap; }
.form-actions.sticky { position: sticky; bottom: 0; background: rgba(245,246,248,.94); backdrop-filter: blur(6px); padding: 12px 0; z-index: 5; }

.choice-cards { display: grid; gap: 10px; }
.choice-card { position: relative; display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line-strong); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .12s ease, box-shadow .12s ease, background .12s ease; }
.choice-card:hover { border-color: var(--ink-300); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card .dot { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--ink-300); flex: 0 0 auto; margin-top: 2px; position: relative; background: #fff; }
.choice-card:has(input:checked) { border-color: var(--brand-800); box-shadow: 0 0 0 1px var(--brand-800); background: var(--brand-50); }
.choice-card:has(input:checked) .dot { border-color: var(--brand-800); }
.choice-card:has(input:checked) .dot::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--brand-800); }
.choice-card:has(input:focus-visible) { box-shadow: var(--focus); }
.choice-card .choice-body { flex: 1 1 auto; min-width: 0; }
.choice-card .choice-title { font-weight: 600; color: var(--ink-900); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.choice-card .choice-desc { font-size: 13px; color: var(--ink-500); margin-top: 2px; }
.choice-card .choice-price { font-weight: 600; color: var(--ink-900); white-space: nowrap; text-align: right; }
.choice-card .choice-price small { display: block; font-weight: 400; color: var(--ink-500); }

/* ---------- Badges & pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge-plain::before { display: none; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.badge-info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge-neutral { background: var(--neutral-bg); color: var(--neutral); border-color: var(--line); }
.badge-brand { background: var(--brand-900); color: #fff; }
.badge-brand::before { display: none; }
.tag { display: inline-flex; align-items: center; gap: 4px; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 500; color: var(--ink-600); background: var(--surface-3); border: 1px solid var(--line); white-space: nowrap; }
.count { display: inline-flex; align-items: center; justify-content: center; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 999px; background: var(--brand-800); color: #fff; font-size: 11px; font-weight: 600; line-height: 1; }
.count-muted { background: var(--surface-3); color: var(--ink-600); }

/* ---------- Alerts ---------- */
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); border: 1px solid; font-size: 14px; line-height: 1.5; }
.alert > .icon { margin-top: 1px; }
.alert .alert-body { flex: 1 1 auto; min-width: 0; }
.alert .alert-title { font-weight: 600; margin-bottom: 2px; color: inherit; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.alert-success { background: var(--success-bg); border-color: var(--success-line); color: #0b5c38; }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-line); color: #6b4100; }
.alert-danger { background: var(--danger-bg); border-color: var(--danger-line); color: #8f1c13; }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: #143a78; }
.alert-neutral { background: var(--surface-2); border-color: var(--line); color: var(--ink-700); }
.alert .alert-close { margin-left: auto; background: none; border: 0; color: inherit; opacity: .6; cursor: pointer; padding: 2px; border-radius: 4px; }
.alert .alert-close:hover { opacity: 1; }
.flash-stack { display: grid; gap: 10px; margin-bottom: 20px; }

/* ---------- Tables ---------- */
.table-wrap { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; font-weight: 500; color: var(--ink-500); text-transform: none; letter-spacing: 0; background: var(--surface-2); padding: 10px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-700); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fbfcfd; }
.table .cell-main { font-weight: 500; color: var(--ink-900); }
.table .cell-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions .btn + .btn, .table .actions form + .btn, .table .actions .btn + form, .table .actions form + form { margin-left: 4px; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-compact td { padding: 9px 14px; }
.table a.row-link { color: var(--ink-900); font-weight: 500; }
.table a.row-link:hover { color: var(--brand-600); }

/* ---------- Key/value lists ---------- */
.kv { display: grid; grid-template-columns: minmax(120px, 38%) minmax(0, 1fr); gap: 0; font-size: 14px; }
.kv > dt, .kv > .k { color: var(--ink-500); padding: 9px 0; border-bottom: 1px solid var(--line); }
.kv > dd, .kv > .v { margin: 0; padding: 9px 0; border-bottom: 1px solid var(--line); color: var(--ink-900); font-weight: 500; text-align: right; min-width: 0; overflow-wrap: anywhere; }
.kv > dt:last-of-type, .kv > dd:last-of-type { border-bottom: 0; }
.kv-left > dd { text-align: left; }

/* ---------- Stats ---------- */
.stats { display: grid; gap: 16px; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow-sm); min-width: 0; }
.stat-label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-500); }
.stat-value { font-size: 24px; font-weight: 600; color: var(--ink-900); margin-top: 6px; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-meta { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.stat-link { color: inherit; }
.stat-link:hover { text-decoration: none; color: inherit; border-color: var(--line-strong); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 24px; }
.empty .empty-icon { width: 44px; height: 44px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; background: var(--surface-3); color: var(--ink-500); margin-bottom: 12px; border: 1px solid var(--line); }
.empty h3 { font-size: 15px; }
.empty p { color: var(--ink-500); font-size: 14px; max-width: 420px; margin: 6px auto 16px; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; margin-bottom: 20px; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 10px 12px; font-size: 14px; font-weight: 500; color: var(--ink-500); border: 0; background: none; border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--ink-900); }
.tab.active, .tab[aria-selected="true"] { color: var(--ink-900); border-bottom-color: var(--brand-800); }
.tab-panel[hidden] { display: none; }
.segmented { display: inline-flex; padding: 3px; background: var(--surface-3); border: 1px solid var(--line); border-radius: var(--radius); gap: 2px; flex-wrap: wrap; }
.segmented a, .segmented button { padding: 5px 12px; border-radius: 6px; font-size: 13px; font-weight: 500; color: var(--ink-600); background: none; border: 0; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.segmented a.active, .segmented button.active { background: var(--surface); color: var(--ink-900); box-shadow: var(--shadow-sm); }

/* ---------- Dropdown ---------- */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; z-index: 60; display: none; }
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 6px; font: 400 14px/1.3 var(--font); color: var(--ink-700); background: none; border: 0; cursor: pointer; text-align: left; text-decoration: none !important; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-3); color: var(--ink-900); }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu .sep { height: 1px; background: var(--line); margin: 6px 0; }
.dropdown-header { padding: 8px 10px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.dropdown-header strong { display: block; font-size: 14px; }
.dropdown-header span { font-size: 12.5px; color: var(--ink-500); }

/* ---------- Modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(11, 18, 32, .5); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 16px; opacity: 0; pointer-events: none; transition: opacity .15s ease; }
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal { width: 100%; max-width: 440px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); transform: translateY(6px); transition: transform .15s ease; }
.modal-backdrop.open .modal { transform: none; }
.modal-body { padding: 22px 22px 8px; }
.modal-body h3 { font-size: 17px; margin-bottom: 6px; }
.modal-body p { color: var(--ink-500); font-size: 14px; }
.modal-footer { padding: 16px 22px 20px; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }

/* ---------- License key / copy field ---------- */
.key-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; background: var(--surface-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); min-width: 0; }
.key-field code, .key-field .key-value { flex: 1 1 auto; min-width: 0; background: none; border: 0; padding: 0; font: 500 14px/1.4 var(--mono); color: var(--ink-900); letter-spacing: .03em; overflow-x: auto; white-space: nowrap; scrollbar-width: none; }
.key-field .key-value::-webkit-scrollbar { display: none; }
.key-field .btn { flex: 0 0 auto; }
.key-field.is-masked .key-value { letter-spacing: .08em; color: var(--ink-600); }
.copy-btn.copied { color: var(--success) !important; border-color: var(--success-line) !important; }

/* ---------- Progress / meter ---------- */
.meter { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; border: 1px solid var(--line); }
.meter > span { display: block; height: 100%; background: var(--brand-800); border-radius: inherit; }
.meter.warning > span { background: #c27c0e; }
.meter.danger > span { background: var(--danger); }

/* ---------- Steps ---------- */
.steps { list-style: none; margin: 0; padding: 0; counter-reset: step; }
.steps > li { position: relative; padding: 0 0 18px 40px; counter-increment: step; }
.steps > li:last-child { padding-bottom: 0; }
.steps > li::before { content: counter(step); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--surface); border: 1px solid var(--line-strong); color: var(--ink-800); font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; }
.steps > li::after { content: ""; position: absolute; left: 12.5px; top: 30px; bottom: 4px; width: 1px; background: var(--line); }
.steps > li:last-child::after { display: none; }
.steps > li.done::before { content: ""; background: var(--success) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 6 9 17l-5-5'/%3E%3C/svg%3E") center no-repeat; border-color: var(--success); }
.steps h4 { font-size: 14px; margin-bottom: 2px; }
.steps p { font-size: 13.5px; color: var(--ink-500); }

/* ---------- Timeline / activity ---------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; gap: 12px; align-items: flex-start; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list .list-main { flex: 1 1 auto; min-width: 0; }
.list .list-title { font-weight: 500; color: var(--ink-900); font-size: 14px; }
.list .list-sub { font-size: 12.5px; color: var(--ink-500); margin-top: 2px; }
.list .list-aside { text-align: right; flex: 0 0 auto; font-size: 13px; }
.list a.list-title:hover { color: var(--brand-600); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--brand-100); color: var(--brand-800); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex: 0 0 auto; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-lg { width: 48px; height: 48px; font-size: 16px; }
.thumb { width: 44px; height: 44px; border-radius: 6px; background: var(--surface-3); border: 1px solid var(--line); overflow: hidden; flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; color: var(--ink-400); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.icon-box { width: 36px; height: 36px; border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; background: var(--brand-50); color: var(--brand-800); border: 1px solid var(--brand-100); flex: 0 0 auto; }
.icon-box.success { background: var(--success-bg); color: var(--success); border-color: var(--success-line); }
.icon-box.warning { background: var(--warning-bg); color: var(--warning); border-color: var(--warning-line); }
.icon-box.danger { background: var(--danger-bg); color: var(--danger); border-color: var(--danger-line); }
.icon-box.neutral { background: var(--surface-3); color: var(--ink-600); border-color: var(--line); }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.toolbar .input-icon { flex: 1 1 260px; max-width: 360px; }
.toolbar .select, .toolbar select { width: auto; min-width: 150px; }
.toolbar .input, .toolbar .select { min-height: 36px; padding-top: 6px; padding-bottom: 6px; }
.filter-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; width: 100%; }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); flex-wrap: wrap; font-size: 13px; color: var(--ink-500); }
.pagination-pages { display: flex; gap: 4px; flex-wrap: wrap; }
.pagination-pages a, .pagination-pages span { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-700); font-weight: 500; text-decoration: none !important; }
.pagination-pages a:hover { border-color: var(--line-strong); background: var(--surface-2); color: var(--ink-900); }
.pagination-pages .active { background: var(--brand-800); border-color: var(--brand-800); color: #fff; }
.pagination-pages .disabled { color: var(--ink-300); background: var(--surface-2); }
.pagination.plain { border-top: 0; padding: 16px 0 0; }

/* ---------- Content (rich text) ---------- */
.prose { color: var(--ink-700); font-size: 15px; line-height: 1.7; }
.prose h1, .prose h2, .prose h3 { margin: 1.6em 0 .6em; }
.prose h2 { font-size: 20px; } .prose h3 { font-size: 17px; }
.prose p, .prose ul, .prose ol { margin: 0 0 1em; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li + li { margin-top: .35em; }
.prose a { text-decoration: underline; text-underline-offset: 2px; }
.prose img { border-radius: var(--radius); margin: 1em 0; }
.prose blockquote { margin: 1em 0; padding: 4px 16px; border-left: 3px solid var(--line-strong); color: var(--ink-600); }
.prose table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
.prose th, .prose td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; }
.prose > :first-child { margin-top: 0; }
.check-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.check-list li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-700); }
.check-list li .icon { color: var(--success); margin-top: 2px; }

/* ---------- Shell (customer portal + admin) ---------- */
.shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--line); display: flex; flex-direction: column; z-index: 90; transition: transform .2s ease; }
.sidebar-brand { height: var(--topbar-h); display: flex; align-items: center; gap: 10px; padding: 0 18px; border-bottom: 1px solid var(--line); flex: 0 0 auto; color: var(--ink-900); text-decoration: none !important; }
.sidebar-brand:hover { color: var(--ink-900); }
.brand-mark { width: 30px; height: 30px; border-radius: 7px; background: var(--brand-900); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12.5px; letter-spacing: .02em; flex: 0 0 auto; overflow: hidden; }
.brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand-text strong { font-size: 15px; font-weight: 600; color: inherit; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { font-size: 11.5px; color: var(--ink-500); font-weight: 500; }
.sidebar-nav { flex: 1 1 auto; overflow-y: auto; padding: 12px 10px 16px; scrollbar-width: thin; }
.nav-section { padding: 14px 10px 6px; font-size: 11.5px; font-weight: 600; color: var(--ink-400); text-transform: uppercase; letter-spacing: .06em; }
.nav-section:first-child { padding-top: 4px; }
.nav-link { display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 6px; font-size: 14px; font-weight: 500; color: var(--ink-600); text-decoration: none !important; margin-bottom: 1px; }
.nav-link .icon { color: var(--ink-400); }
.nav-link:hover { background: var(--surface-3); color: var(--ink-900); }
.nav-link:hover .icon { color: var(--ink-700); }
.nav-link.active { background: var(--brand-50); color: var(--brand-900); }
.nav-link.active .icon { color: var(--brand-800); }
.nav-link .count { margin-left: auto; }
.sidebar-footer { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 12px 14px; font-size: 12px; color: var(--ink-400); }
.sidebar-footer a { color: var(--ink-500); }

.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; min-width: 0; }
.topbar { position: sticky; top: 0; z-index: 50; height: var(--topbar-h); background: rgba(255,255,255,.92); backdrop-filter: saturate(180%) blur(8px); border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; padding: 0 24px; }
.topbar-title { font-size: 15px; font-weight: 600; color: var(--ink-900); min-width: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.topbar .menu-toggle { display: none; }
.topbar-search { flex: 0 1 320px; }
.topbar-search .input { min-height: 36px; background: var(--surface-2); box-shadow: none; }
.icon-btn { position: relative; width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; color: var(--ink-600); background: transparent; border: 0; cursor: pointer; text-decoration: none !important; }
.icon-btn:hover { background: var(--surface-3); color: var(--ink-900); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid #fff; }
.user-chip { display: inline-flex; align-items: center; gap: 8px; padding: 3px 8px 3px 3px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); cursor: pointer; font: 500 13.5px var(--font); color: var(--ink-800); }
.user-chip:hover { border-color: var(--line-strong); }
.user-chip .avatar { width: 28px; height: 28px; font-size: 11px; }
.content { padding: 24px; flex: 1 1 auto; width: 100%; max-width: 1280px; }
.content-narrow { max-width: 980px; }
.shell-footer { padding: 16px 24px 24px; font-size: 12.5px; color: var(--ink-400); display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.shell-footer a { color: var(--ink-500); }
.sidebar-backdrop { display: none; }

/* Admin flavour: dark sidebar */
.shell-admin .sidebar { background: var(--brand-950); border-right-color: var(--brand-950); }
.shell-admin .sidebar-brand { border-bottom-color: rgba(255,255,255,.08); color: #fff; }
.shell-admin .sidebar-brand:hover { color: #fff; }
.shell-admin .brand-mark { background: #fff; color: var(--brand-900); }
.shell-admin .brand-text span { color: rgba(255,255,255,.55); }
.shell-admin .nav-section { color: rgba(255,255,255,.38); }
.shell-admin .nav-link { color: rgba(255,255,255,.72); }
.shell-admin .nav-link .icon { color: rgba(255,255,255,.45); }
.shell-admin .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.shell-admin .nav-link:hover .icon { color: rgba(255,255,255,.8); }
.shell-admin .nav-link.active { background: rgba(255,255,255,.12); color: #fff; }
.shell-admin .nav-link.active .icon { color: #fff; }
.shell-admin .nav-link .count { background: rgba(255,255,255,.18); }
.shell-admin .sidebar-footer { border-top-color: rgba(255,255,255,.08); color: rgba(255,255,255,.4); }
.shell-admin .sidebar-footer a { color: rgba(255,255,255,.6); }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
    .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1fr); }
    .form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}
@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(11, 18, 32, .45); z-index: 80; }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .topbar .menu-toggle { display: inline-flex; }
    .topbar-search { display: none; }
}
@media (max-width: 760px) {
    body { font-size: 14.5px; }
    h1 { font-size: 24px; }
    .container { padding: 0 16px; }
    .content { padding: 16px; }
    .shell-footer { padding: 12px 16px 20px; }
    .grid-2, .grid-3, .grid-4, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .span-2 { grid-column: auto; }
    .stats { gap: 10px; }
    .stat { padding: 12px 14px; }
    .stat-value { font-size: 20px; }
    .page-header { align-items: flex-start; }
    .page-header .btn-group { margin-left: 0; width: 100%; }
    .card-body { padding: 16px; }
    .card-header { padding: 12px 16px; }
    .toolbar { padding: 12px; }
    .toolbar .input-icon, .toolbar .select, .toolbar select, .toolbar .btn { flex: 1 1 100%; max-width: none; width: 100%; }
    .hide-sm { display: none !important; }
    .user-chip .user-name { display: none; }

    /* Stack tables into cards */
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr { padding: 12px 16px; border-bottom: 1px solid var(--line); }
    .table-stack tbody tr:last-child { border-bottom: 0; }
    .table-stack td { border: 0; padding: 4px 0; display: flow-root; text-align: right; overflow-wrap: anywhere; }
    .table-stack td::before { content: attr(data-label); float: left; margin-right: 12px; color: var(--ink-500); font-size: 12.5px; text-align: left; padding-top: 1px; }
    .table-stack td .cell-sub { display: block; }
    .table-stack td[data-label=""]::before, .table-stack td:not([data-label])::before { display: none; }
    .table-stack td.cell-primary { display: block; text-align: left; padding-bottom: 8px; }
    .table-stack td.cell-primary::before { display: none; }
    .table-stack td.actions { display: flex; justify-content: flex-start; padding-top: 10px; flex-wrap: wrap; gap: 6px; }
    .table-stack td.actions::before { display: none; }
    .table-stack td.actions .btn, .table-stack td.actions form { margin-left: 0 !important; }
    .table-stack tbody tr:hover td { background: transparent; }
    .kv { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); }
}
@media (min-width: 761px) { .show-sm { display: none !important; } }

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .no-print, .shell-footer, .site-header, .site-footer { display: none !important; }
    .main { margin: 0 !important; }
    body { background: #fff; }
    .card { box-shadow: none; border-color: #ddd; }
}
.grid-main > .card, .grid-2 > .card, .grid-3 > .card, .grid-4 > .card, .grid-main > aside, .grid-2 > aside { margin-top: 0; }
.field > label.switch, label.switch { display: inline-flex; margin-bottom: 0; font-weight: 400; color: var(--ink-700); font-size: 14px; }
.switch .track { display: inline-block; }
.field > label.check { display: flex; font-weight: 400; }
.kv { margin: 0; }
