/* SM Restaurant Billing — Central Admin. One stylesheet, no external assets (the page's content security policy
   allows only this site). Colours follow the product's design tokens (Desktop\Design\DesignTokens.cs); the admin panel
   uses a deep teal accent so it is never mistaken for the restaurant POS. Contrast of every text pair is 4.5:1 or more. */
:root {
    --primary: #0f5c7a;
    --primary-hover: #0b4a63;
    --primary-soft: #e6f2f6;
    --rail: #0f172a;
    --rail-hover: #1e293b;
    --rail-selected: #0f5c7a;
    --rail-text: #cbd5e1;
    --bg: #f4f6fa;
    --surface: #ffffff;
    --sunken: #f8fafc;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-2: #475569;
    --muted: #64748b;
    --success: #15803d;
    --success-soft: #dcfce7;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --danger: #b91c1c;
    --danger-soft: #fee2e2;
    --info-soft: #dbeafe;
    --focus: #3b82f6;
    --radius: 10px;
    --sidebar: 248px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h1, h2 { margin: 0; line-height: 1.25; }
h2 { font-size: 17px; font-weight: 600; margin-bottom: 16px; }
p { margin: 0 0 12px; }
a { color: var(--primary); }
code { font-family: Consolas, "Cascadia Mono", monospace; font-size: 13px; background: var(--sunken); border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; }
code.id { font-size: 12px; color: var(--text-2); white-space: nowrap; }
.muted { color: var(--muted); font-size: 14px; }
.lead { color: var(--text-2); margin-bottom: 20px; }
.nowrap { white-space: nowrap; }
.inline { display: inline; margin: 0; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--surface); padding: 8px 12px; border-radius: 6px; z-index: 20; }
.skip-link:focus { left: 8px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar);
    flex: 0 0 var(--sidebar);
    background: var(--rail);
    color: var(--rail-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.brand { display: flex; align-items: center; gap: 12px; padding: 20px 18px; border-bottom: 1px solid var(--rail-hover); }
.brand-mark { width: 40px; height: 40px; border-radius: 10px; background: var(--primary); color: #fff; font-weight: 700; display: grid; place-items: center; letter-spacing: .5px; }
.brand-mark.large { width: 64px; height: 64px; font-size: 24px; border-radius: 16px; }
.brand-name { color: #fff; font-weight: 600; font-size: 14px; }
.brand-sub { font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }

#navigation { flex: 1; padding: 14px 10px; overflow-y: auto; }
.nav-section { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: #94a3b8; padding: 16px 12px 6px; }
.nav-item { display: block; padding: 10px 12px; border-radius: 8px; color: var(--rail-text); text-decoration: none; font-weight: 500; }
.nav-item:hover { background: var(--rail-hover); color: #fff; }
.nav-item.active { background: var(--rail-selected); color: #fff; }
.sidebar-foot { padding: 14px 18px; font-size: 12px; color: #94a3b8; border-top: 1px solid var(--rail-hover); }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 14px 28px; position: sticky; top: 0; z-index: 5;
}
.page-title { font-size: 22px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who { display: flex; align-items: center; gap: 14px; text-align: right; flex: 0 0 auto; }
.who-name { font-weight: 600; font-size: 14px; }
.who-role { font-size: 12px; color: var(--muted); }

.page { padding: 24px 28px 40px; max-width: 1560px; width: 100%; }

/* ---- surfaces ---- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.panel { padding: 22px 24px; margin-bottom: 20px; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { display: flex; flex-direction: column; gap: 4px; padding: 18px 20px; text-decoration: none; color: inherit; border-left: 4px solid var(--primary); }
a.stat:hover { border-color: var(--primary); box-shadow: 0 2px 10px rgba(15, 23, 42, .08); }
.stat.tone-success { border-left-color: var(--success); }
.stat.tone-warning { border-left-color: var(--warning); }
.stat.tone-muted { border-left-color: var(--muted); }
.stat-label { font-size: 13px; color: var(--text-2); font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 700; line-height: 1.1; }
.stat-note { font-size: 12px; color: var(--muted); }

.summary, .facts { margin: 0; display: grid; gap: 10px; }
.summary { grid-template-columns: repeat(2, minmax(0, 260px)); margin-bottom: 12px; }
.summary dt, .facts dt { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.summary dd, .facts dd { margin: 0; font-weight: 600; }
.summary dd { font-size: 22px; }

.empty { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius); text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty h2 { margin-bottom: 8px; color: var(--text); }
.empty .btn { margin-top: 8px; }

.alert { border-radius: 8px; padding: 12px 16px; margin-bottom: 16px; border: 1px solid transparent; font-weight: 500; }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: #fecaca; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: #bbf7d0; }
.alert-info { background: var(--info-soft); color: #1e40af; border-color: #bfdbfe; }
.alert-warning { background: var(--warning-soft); color: #92400e; border-color: #fcd34d; font-weight: 400; }
.alert ul { margin: 8px 0 0; padding-left: 20px; }
.alert a { color: inherit; font-weight: 600; }

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.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-muted { background: #e2e8f0; color: var(--text-2); }

.crumbs { color: var(--muted); font-size: 13px; margin-bottom: 14px; }

.context { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; background: var(--primary-soft); border: 1px solid #c4dfe8; border-radius: var(--radius); padding: 14px 18px; margin-bottom: 16px; }
.context > div { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.context-label { font-size: 11px; letter-spacing: 1.5px; color: var(--primary); font-weight: 700; }
.context-name { font-size: 18px; font-weight: 700; }

/* ---- buttons ---- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 40px; padding: 0 18px; border-radius: 8px; border: 1px solid transparent;
    font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-small { min-height: 32px; padding: 0 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn-secondary:hover { background: var(--sunken); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-danger { background: var(--surface); color: var(--danger); border-color: #fca5a5; }
.btn-danger:hover { background: var(--danger-soft); }
.btn[disabled], .btn.busy { opacity: .65; cursor: progress; }

/* ---- forms ---- */
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }
.filters { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px 20px; }
.span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; margin-bottom: 10px; }
.field.compact { margin-bottom: 0; }
.field label { font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.req { color: var(--danger); }
.field input, .field select {
    height: 40px; padding: 0 12px; border: 1px solid var(--border-strong); border-radius: 8px;
    font: inherit; color: var(--text); background: var(--surface); min-width: 0;
}
.field.compact input { width: 300px; }
.field input:disabled, .field select:disabled { background: var(--sunken); color: var(--text-2); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field-hint { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field-error { font-size: 13px; color: var(--danger); min-height: 18px; margin-top: 2px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; padding-top: 16px; border-top: 1px solid var(--border); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 20px; align-items: start; }
.facts > div { padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.facts > div:last-child { border-bottom: 0; }
.context-actions { display: flex; gap: 10px; }

/* ---- onboarding wizard ---- */
.steps { list-style: none; margin: 0 0 18px; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.step { display: flex; align-items: center; gap: 10px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--border); border-radius: 8px; color: var(--text-2); font-size: 14px; font-weight: 600; min-width: 0; }
.step > a, .step > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: inherit; text-decoration: none; }
.step > a:hover { text-decoration: underline; }
.step-number { flex: 0 0 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; background: #e2e8f0; color: var(--text-2); font-size: 13px; }
.step.done { color: var(--success); border-color: #bbf7d0; }
.step.done .step-number { background: var(--success); color: #fff; }
.step.current { color: var(--primary); border-color: var(--primary); box-shadow: inset 0 -3px 0 var(--primary); }
.step.current .step-number { background: var(--primary); color: #fff; }
.opt { color: var(--muted); font-weight: 400; }
.field input[type="file"] { height: auto; padding: 8px; }
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; color: var(--text); margin: 8px 0 2px; }
.check input, .field .check input { width: 18px; height: 18px; flex: 0 0 18px; padding: 0; }
.logo-row { display: flex; gap: 16px; align-items: flex-start; }
.logo-box { flex: 0 0 120px; width: 120px; height: 120px; border: 1px dashed var(--border-strong); border-radius: 10px; background: var(--sunken); display: grid; place-items: center; overflow: hidden; }
.logo-box img, .logo-thumb { max-width: 100%; max-height: 100%; object-fit: contain; }
.logo-thumb { width: 72px; height: 72px; border: 1px solid var(--border); border-radius: 8px; background: var(--sunken); display: block; }
.logo-controls { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.review { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.review-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.review-head h2 { margin: 0; }
.review-list { margin: 0 0 4px; display: grid; gap: 8px; }
.review-list > div { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.review-list > div:last-child { border-bottom: 0; }
.review-list dt { font-size: 13px; color: var(--muted); }
.review-list dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }
.done { text-align: left; }
.done-mark { width: 52px; height: 52px; border-radius: 50%; background: var(--success-soft); color: var(--success); font-size: 28px; font-weight: 700; display: grid; place-items: center; margin-bottom: 14px; }
.table-head { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; padding: 16px 16px 12px; }
.table-head h2 { margin: 0; }
.open-onboardings { margin-bottom: 16px; }

/* ---- menu import ---- */
.section-title { margin: 8px 0 12px; }
.stat.tone-danger { border-left-color: var(--danger); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.drop-zone { border: 2px dashed var(--border-strong); border-radius: 10px; background: var(--sunken); padding: 16px; display: flex; flex-direction: column; gap: 6px; }
.drop-zone p { margin: 0; }
.drop-zone.dragging { border-color: var(--primary); background: var(--primary-soft); }
.choices { border: 0; margin: 0 0 12px; padding: 0; display: grid; gap: 8px; }
.choice { display: flex; gap: 12px; align-items: flex-start; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.choice input { width: 18px; height: 18px; flex: 0 0 18px; margin-top: 3px; }
.progress { height: 6px; border-radius: 3px; background: var(--border); overflow: hidden; margin: 12px 0 0; }
.progress-bar { width: 35%; height: 100%; background: var(--primary); border-radius: 3px; animation: progress-slide 1.2s ease-in-out infinite; }
@keyframes progress-slide { 0% { margin-left: -35%; } 100% { margin-left: 100%; } }
.msg { font-size: 13px; padding: 1px 0; }
.msg-error { color: var(--danger); font-weight: 600; }
.msg-warning { color: var(--warning); }
.msg-change { color: var(--text-2); }
.table tr.row-error td { background: #fff7f7; }
.table-empty { padding: 0 16px 16px; }
#preview .table td { padding: 8px 12px; font-size: 14px; }
#preview .table th { padding: 10px 12px; }

/* ---- tables ---- */
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); background: var(--sunken); padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: var(--sunken); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table td.detail { color: var(--text-2); font-size: 13px; max-width: 420px; overflow-wrap: anywhere; }
.table a { font-weight: 600; text-decoration: none; }
.table a:hover { text-decoration: underline; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 13px; }
.pager { display: flex; align-items: center; gap: 10px; }

/* ---- plain pages (sign-in, error, not available) ---- */
body.plain { display: grid; place-items: center; min-height: 100vh; padding: 24px; }
.plain-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 36px 40px; max-width: 520px; width: 100%; }
.plain-card h1 { font-size: 22px; margin-bottom: 12px; }
.login { display: grid; grid-template-columns: 1fr 1fr; width: min(940px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; overflow: hidden; box-shadow: 0 10px 40px rgba(15, 23, 42, .08); }
.login-brand { background: var(--rail); color: var(--rail-text); padding: 44px 40px; display: flex; flex-direction: column; gap: 6px; }
.login-brand h2 { color: #fff; font-size: 22px; margin: 18px 0 0; }
.login-note { margin-top: 28px; font-size: 14px; }
.login-foot { margin-top: auto; font-size: 12px; color: #94a3b8; }
.login-form { padding: 44px 40px; }
.login-form h1 { font-size: 24px; margin-bottom: 6px; }
.login-form form { margin-top: 20px; }

/* ---- confirmation dialog ---- */
dialog.confirm { border: 0; border-radius: 14px; padding: 0; width: min(460px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(15, 23, 42, .3); }
dialog.confirm::backdrop { background: rgba(15, 23, 42, .5); }
.confirm-body { padding: 24px 26px 8px; }
.confirm-body h2 { margin-bottom: 10px; }
.confirm-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 14px 26px 22px; }

/* ---- customer configuration and branding ---- */
.subnav { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.subnav a { padding: 7px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 13px; font-weight: 600; text-decoration: none; }
.subnav a:hover { background: var(--primary-soft); border-color: #c4dfe8; }
.section { scroll-margin-top: 16px; }
.section h3 { font-size: 15px; margin: 20px 0 6px; }
.section-error { border-color: var(--danger); }
.section.unsaved { border-color: var(--warning); }
.section.unsaved > h2::after, .section.unsaved h2:first-child::after { content: "Unsaved changes"; margin-left: 12px; padding: 2px 10px; border-radius: 999px; background: var(--warning-soft); color: var(--warning); font-size: 12px; font-weight: 700; vertical-align: middle; }
fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.logo-thumb-small { width: 40px; height: 40px; }
.bill-preview { background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 6px; padding: 18px 16px; font-family: Consolas, "Courier New", monospace; font-size: 13px; color: #111; }
.bill-name { text-align: center; font-size: 17px; font-weight: 700; overflow-wrap: anywhere; }
.bill-line { text-align: center; overflow-wrap: anywhere; }
.bill-rule { border-top: 1px dashed #111; margin: 6px 0; }
.bill-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.bill-row.bill-head, .bill-row.bill-head ~ .bill-row { grid-template-columns: minmax(0, 1fr) 34px 56px 64px; }
.bill-row span + span { text-align: right; }
.bill-head { font-weight: 700; }
.bill-total { display: flex; justify-content: flex-end; gap: 14px; }
.bill-total span:last-child { min-width: 64px; text-align: right; }
.bill-grand { font-weight: 700; font-size: 15px; }
.bill-note { font-family: inherit; margin: 12px 0 0; font-size: 12px; }

/* ---- smaller windows (1366 x 768 and below) ---- */
@media (max-width: 1500px) {
    .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .two-col { grid-template-columns: minmax(0, 1fr) 300px; }
    .review-list > div { grid-template-columns: 150px minmax(0, 1fr); }
}
@media (max-width: 1100px) {
    :root { --sidebar: 208px; }
    .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .two-col, .review { grid-template-columns: 1fr; }
    .field.compact input { width: 220px; }
    .step > a, .step > span:last-child { white-space: normal; }
}
@media (max-width: 760px) {
    .shell { flex-direction: column; }
    .sidebar { width: 100%; flex-basis: auto; height: auto; position: static; }
    .cards, .form-grid, .login, .summary, .steps { grid-template-columns: 1fr; }
    .span-2 { grid-column: auto; }
    .login-brand { display: none; }
}

/* Licenses (Phase 4.5) */
.key-box { display: grid; gap: 8px; }
.key-box #license-key { font-size: 20px; font-weight: 700; letter-spacing: 1px; padding: 10px 14px; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 8px; user-select: all; overflow-wrap: anywhere; }
.feature-set legend { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0; margin: 6px 0 2px; }
.feature-set { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.feature-set legend, .feature-set .field-error { grid-column: 1 / -1; }
.feature-set.has-error legend { color: var(--danger); }
.form-actions.start { justify-content: flex-start; flex-wrap: wrap; }
.status-forms { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 24px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--border); }
.status-forms h3 { margin-top: 0; }
.device-note { margin: 4px 0; }
#devices h3 { font-size: 15px; margin: 20px 0 6px; }
@media (max-width: 900px) { .status-forms, .feature-set { grid-template-columns: 1fr; } }

/* Installers (Phase 4.6) */
.table-title { margin: 0; padding: 16px 18px 12px; font-size: 16px; }
.hash { overflow-wrap: anywhere; word-break: break-all; font-size: 12px; }
.config-file { border: 1px solid var(--border); border-radius: 8px; margin: 8px 0; background: var(--surface); }
.config-file > summary { cursor: pointer; padding: 10px 14px; font-weight: 600; }
.config-file > p { margin: 0; padding: 0 14px 12px; }
.config-preview { margin: 0; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--sunken); font-size: 12.5px; line-height: 1.5; overflow-x: auto; white-space: pre; max-height: 360px; }
#preview h3, #package-result h3 { font-size: 15px; margin: 20px 0 6px; }
#checks td.detail { min-width: 280px; }
