/* ==========================================================================
   Business ERP — Design System (Step 2)
   Navy #0E2844 + Steel #6C7079 on white. Enterprise, calm, high-trust.
   ========================================================================== */

/* ---- Tokens ------------------------------------------------------------- */
:root {
    /* Brand */
    --navy: #0E2844;
    --navy-700: #163351;
    --navy-900: #0A1D31;
    --steel: #6C7079;
    --steel-300: #A9ACB2;

    /* Surfaces */
    --bg: #FFFFFF;
    --surface: #F5F6F8;
    --surface-2: #EEF0F3;
    --border: #E3E5E9;

    /* Status */
    --success: #1E8E5A;
    --success-bg: #E5F3EC;
    --warning: #C9871F;
    --warning-bg: #FBF1DF;
    --danger: #C0392B;
    --danger-bg: #FAE8E6;
    --info: #2E6BB0;
    --info-bg: #E7EFF8;

    /* Type scale */
    --fs-xs: 11px;
    --fs-sm: 13px;
    --fs-md: 14px;
    --fs-lg: 16px;
    --fs-xl: 22px;
    --fs-2xl: 28px;

    /* Spacing + radius + shadow */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;
    --radius: 10px;
    --radius-sm: 8px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(14, 40, 68, .06);
    --shadow-md: 0 6px 20px rgba(14, 40, 68, .12);

    --sidebar-w: 244px;
    --sidebar-w-collapsed: 64px;
    --topbar-h: 58px;
    --font: system-ui, -apple-system, "Segoe UI", Roboto, Inter, Arial, sans-serif;
}

/* ---- Base resets -------------------------------------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    font-family: var(--font);
    font-size: var(--fs-md);
    line-height: 1.45;
    color: var(--navy);
    background: var(--surface);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 var(--sp-3); font-weight: 650; line-height: 1.25; }
h1 { font-size: var(--fs-xl); }
h2 { font-size: var(--fs-lg); }
h3 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }

.muted { color: var(--steel); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.icon { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.8; }
.row { display: flex; align-items: center; gap: var(--sp-3); }
.spacer { flex: 1; }

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

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--navy);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    transition: width .18s ease;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--navy-700); border-radius: 8px; }

.brand {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    padding: var(--sp-5) var(--sp-5) var(--sp-4);
    white-space: nowrap;
}
.brand-center { justify-content: center; }
.brand-mark {
    width: 36px; height: 36px;
    display: grid; place-items: center;
    background: #fff; color: var(--navy);
    border-radius: var(--radius-sm);
    font-weight: 800; font-size: 18px;
    flex-shrink: 0;
}
.brand-text { font-size: 18px; color: #fff; letter-spacing: .01em; }
.brand-text strong { color: var(--steel-300); font-weight: 700; }

.nav { display: flex; flex-direction: column; padding-bottom: var(--sp-6); }
.nav-group {
    color: var(--steel-300);
    text-transform: uppercase;
    font-size: var(--fs-xs);
    letter-spacing: .08em;
    padding: var(--sp-4) var(--sp-5) var(--sp-2);
    white-space: nowrap;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    color: #c8cfd8;
    text-decoration: none;
    padding: 10px var(--sp-5);
    font-size: var(--fs-md);
    border-left: 3px solid transparent;
    white-space: nowrap;
}
.nav-item:hover { background: var(--navy-700); color: #fff; text-decoration: none; }
.nav-item.active {
    background: var(--navy-900);
    color: #fff;
    border-left-color: var(--steel-300);
}
.nav-item .icon { width: 18px; height: 18px; }

/* Collapsed sidebar */
.app.sidebar-collapsed .sidebar { width: var(--sidebar-w-collapsed); }
.app.sidebar-collapsed .brand-text,
.app.sidebar-collapsed .nav-group,
.app.sidebar-collapsed .nav-item span { display: none; }
.app.sidebar-collapsed .brand { justify-content: center; padding-left: 0; padding-right: 0; }
.app.sidebar-collapsed .nav-item { justify-content: center; padding-left: 0; padding-right: 0; }

/* ---- Main column -------------------------------------------------------- */
.app-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

.topbar {
    height: var(--topbar-h);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    position: sticky;
    top: 0;
    z-index: 40;
}
.topbar-toggle {
    background: none; border: none; cursor: pointer;
    color: var(--steel); padding: 6px; border-radius: var(--radius-sm);
    display: grid; place-items: center;
}
.topbar-toggle:hover { background: var(--surface); color: var(--navy); }
.topbar-title { font-weight: 600; }
.topbar-sub { color: var(--steel); font-size: var(--fs-sm); }

.content { padding: var(--sp-6); }
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: var(--sp-5); gap: var(--sp-4); flex-wrap: wrap;
}
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--steel); font-size: var(--fs-sm); margin-top: 2px; }

/* ---- Search ------------------------------------------------------------- */
.search {
    display: flex; align-items: center; gap: var(--sp-2);
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-pill); padding: 6px 14px;
    color: var(--steel); min-width: 220px;
}
.search input {
    border: none; background: none; outline: none;
    font-size: var(--fs-sm); width: 100%; color: var(--navy);
}

/* ---- Dropdowns ---------------------------------------------------------- */
.dropdown { position: relative; }
.dropdown-toggle {
    display: flex; align-items: center; gap: var(--sp-2);
    background: none; border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 6px 10px; cursor: pointer; color: var(--navy); font-size: var(--fs-sm);
}
.dropdown-toggle:hover { background: var(--surface); }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px);
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-md);
    min-width: 220px; padding: var(--sp-2); z-index: 50;
    display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-item {
    display: flex; align-items: center; gap: var(--sp-2);
    padding: 9px 10px; border-radius: var(--radius-sm);
    color: var(--navy); font-size: var(--fs-sm); cursor: pointer; text-decoration: none;
}
.dropdown-item:hover { background: var(--surface); text-decoration: none; }
.dropdown-item.active { background: var(--info-bg); color: var(--info); }
.dropdown-header { padding: 8px 10px; font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--steel); }
.dropdown-divider { height: 1px; background: var(--border); margin: var(--sp-2) 0; }

/* Notification bell */
.bell { position: relative; }
.bell-dot {
    position: absolute; top: 2px; right: 2px;
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--danger); border: 2px solid var(--bg);
}

/* Avatar */
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--navy); color: #fff;
    display: grid; place-items: center; font-size: var(--fs-sm); font-weight: 600;
}

/* ---- Cards & grids ------------------------------------------------------ */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: var(--sp-5);
    box-shadow: var(--shadow-sm);
}
.card + .card { margin-top: var(--sp-5); }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--sp-4); }
.card-header h2 { margin: 0; }

.grid { display: grid; gap: var(--sp-5); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .grid-4 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 720px)  { .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; } }

/* Stat tile */
.stat {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius); padding: var(--sp-5); box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--steel); font-size: var(--fs-sm); margin-bottom: var(--sp-2); }
.stat-value { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -.01em; }
.stat-trend { font-size: var(--fs-sm); margin-top: var(--sp-2); }
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ---- Buttons ------------------------------------------------------------ */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
    border: 1px solid transparent; border-radius: var(--radius-sm);
    padding: 9px 16px; font-size: var(--fs-md); font-family: inherit;
    cursor: pointer; line-height: 1; transition: background .12s, border-color .12s;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--navy); color: #fff; }
.btn-primary:hover { background: var(--navy-700); }
.btn-secondary { background: var(--bg); color: var(--navy); border-color: var(--border); }
.btn-secondary:hover { background: var(--surface); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(.94); }
.btn-ghost { background: none; color: var(--steel); }
.btn-ghost:hover { background: var(--surface); color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: var(--fs-sm); }
.btn-block { width: 100%; }

/* ---- Badges / pills ----------------------------------------------------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: var(--fs-xs); font-weight: 600;
    padding: 3px 10px; border-radius: var(--radius-pill);
    background: var(--surface-2); color: var(--steel);
}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-danger  { background: var(--danger-bg);  color: var(--danger); }
.badge-info    { background: var(--info-bg);    color: var(--info); }
.badge-navy    { background: var(--navy); color: #fff; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.dot-success { background: var(--success); }
.dot-warning { background: var(--warning); }
.dot-danger  { background: var(--danger); }
.dot-info    { background: var(--info); }

/* ---- Tables ------------------------------------------------------------- */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg); }
table.table { width: 100%; border-collapse: collapse; font-size: var(--fs-sm); }
.table thead th {
    position: sticky; top: 0; background: var(--surface);
    text-align: left; color: var(--steel); font-weight: 600;
    padding: 11px var(--sp-4); border-bottom: 1px solid var(--border);
    white-space: nowrap; z-index: 1;
}
.table tbody td { padding: 11px var(--sp-4); border-bottom: 1px solid var(--border); }
.table tbody tr:last-child td { border-bottom: none; }
.table tbody tr:hover { background: var(--surface); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.amt-pos { color: var(--success); }
.amt-neg { color: var(--danger); }

/* ---- Forms -------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--sp-4); }
.field label, .form-label { font-size: var(--fs-sm); color: var(--steel); }
.input, .select, .textarea {
    padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: var(--fs-md);
    font-family: inherit; color: var(--navy); background: var(--bg); width: 100%;
}
.input:focus, .select:focus, .textarea:focus {
    outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-bg);
}
.checkbox { display: inline-flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); }

/* ---- Tabs --------------------------------------------------------------- */
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--border); margin-bottom: var(--sp-5); }
.tab {
    background: none; border: none; cursor: pointer; font-family: inherit;
    padding: 10px var(--sp-4); font-size: var(--fs-md); color: var(--steel);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab:hover { color: var(--navy); }
.tab.active { color: var(--navy); border-bottom-color: var(--navy); font-weight: 600; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- Modals ------------------------------------------------------------- */
.modal-backdrop {
    position: fixed; inset: 0; background: rgba(10, 29, 49, .45);
    display: none; align-items: center; justify-content: center; z-index: 100; padding: var(--sp-4);
}
.modal-backdrop.open { display: flex; }
.modal {
    background: var(--bg); border-radius: var(--radius); box-shadow: var(--shadow-md);
    width: 100%; max-width: 480px; max-height: 90vh; overflow: auto;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-5); border-bottom: 1px solid var(--border); }
.modal-header h2 { margin: 0; }
.modal-body { padding: var(--sp-5); }
.modal-footer { display: flex; justify-content: flex-end; gap: var(--sp-3); padding: var(--sp-4) var(--sp-5); border-top: 1px solid var(--border); }
.modal-close { background: none; border: none; cursor: pointer; color: var(--steel); padding: 4px; border-radius: var(--radius-sm); }
.modal-close:hover { background: var(--surface); color: var(--navy); }

/* ---- Toasts ------------------------------------------------------------- */
.toast-stack { position: fixed; bottom: var(--sp-6); right: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-3); z-index: 200; }
.toast {
    display: flex; align-items: center; gap: var(--sp-3);
    background: var(--navy); color: #fff; padding: 12px 16px;
    border-radius: var(--radius-sm); box-shadow: var(--shadow-md); font-size: var(--fs-sm);
    animation: toast-in .18s ease;
}
.toast.success { background: var(--success); }
.toast.warning { background: var(--warning); }
.toast.danger  { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Auth --------------------------------------------------------------- */
.auth-body { display: grid; place-items: center; min-height: 100vh; background: var(--navy); }
.auth-card {
    background: var(--bg); border-radius: var(--radius);
    padding: var(--sp-8); width: 360px; box-shadow: var(--shadow-md);
}
.auth-card .brand { justify-content: center; padding: 0 0 var(--sp-5); }
.auth-card .brand-text { color: var(--navy); }
.auth-card .brand-text strong { color: var(--steel); }
.auth-form { display: flex; flex-direction: column; gap: var(--sp-4); }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); color: var(--steel); }
.auth-form input {
    padding: 10px 12px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); font-size: var(--fs-md);
}
.auth-note { text-align: center; margin: var(--sp-1) 0 0; font-size: var(--fs-xs); }
.auth-tagline { text-align: center; color: var(--navy); font-weight: 600; margin: 0 0 var(--sp-4); }
.auth-row { display: flex; align-items: center; justify-content: space-between; font-size: var(--fs-sm); }
.auth-row a { font-size: var(--fs-sm); }
.auth-policy { display: flex; align-items: center; justify-content: center; gap: var(--sp-2); margin-top: var(--sp-1); }

/* MFA code boxes */
.mfa-inputs { display: flex; gap: var(--sp-2); justify-content: center; }
.mfa-digit {
    width: 44px; height: 52px; text-align: center;
    font-size: var(--fs-xl); font-weight: 600;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    color: var(--navy);
}
.mfa-digit:focus { outline: none; border-color: var(--info); box-shadow: 0 0 0 3px var(--info-bg); }

/* ---- POS ---------------------------------------------------------------- */
.pos-layout { display: grid; grid-template-columns: 1fr 380px; gap: var(--sp-5); align-items: start; }
@media (max-width: 980px) { .pos-layout { grid-template-columns: 1fr; } }

.pos-cats { display: flex; flex-wrap: wrap; gap: var(--sp-2); margin-bottom: var(--sp-4); }
.chip {
    border: 1px solid var(--border); background: var(--bg); color: var(--steel);
    border-radius: var(--radius-pill); padding: 6px 14px; font-size: var(--fs-sm);
    cursor: pointer; font-family: inherit;
}
.chip:hover { border-color: var(--navy); color: var(--navy); }
.chip.active { background: var(--navy); color: #fff; border-color: var(--navy); }

.pos-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: var(--sp-3); }
.pos-card {
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg);
    padding: var(--sp-4); cursor: pointer; text-align: left; font-family: inherit;
    display: flex; flex-direction: column; gap: var(--sp-2); min-height: 96px;
    transition: border-color .12s, box-shadow .12s;
}
.pos-card:hover { border-color: var(--navy); box-shadow: var(--shadow-sm); }
.pos-card .name { font-size: var(--fs-sm); font-weight: 600; line-height: 1.3; }
.pos-card .price { color: var(--info); font-weight: 700; }
.pos-card .unit { color: var(--steel-300); font-size: var(--fs-xs); }

/* Cart */
.cart { position: sticky; top: calc(var(--topbar-h) + var(--sp-5)); }
.cart-lines { max-height: 42vh; overflow: auto; }
.cart-line { display: flex; align-items: center; gap: var(--sp-2); padding: 8px 0; border-bottom: 1px solid var(--border); }
.cart-line .l-name { flex: 1; font-size: var(--fs-sm); }
.cart-line .qty { display: flex; align-items: center; gap: 6px; }
.qty button {
    width: 24px; height: 24px; border: 1px solid var(--border); background: var(--bg);
    border-radius: 6px; cursor: pointer; color: var(--navy); font-size: 14px; line-height: 1;
}
.cart-totals { border-top: 1px solid var(--border); margin-top: var(--sp-3); padding-top: var(--sp-3); }
.cart-totals .line { display: flex; justify-content: space-between; padding: 3px 0; font-size: var(--fs-sm); }
.cart-totals .grand { font-size: var(--fs-lg); font-weight: 700; }
.pay-split { display: flex; justify-content: space-between; padding: 6px 0; font-size: var(--fs-sm); border-bottom: 1px dashed var(--border); }

/* ---- Page actions ------------------------------------------------------- */
.page-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.toolbar { display: flex; gap: var(--sp-3); align-items: center; margin-bottom: var(--sp-4); flex-wrap: wrap; }

/* ---- Pipeline (CRM) ----------------------------------------------------- */
.pipeline { display: grid; grid-template-columns: repeat(5, 1fr); gap: var(--sp-3); }
@media (max-width: 980px) { .pipeline { grid-template-columns: repeat(2, 1fr); } }
.pipe-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-3); }
.pipe-col h3 { font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .06em; color: var(--steel); }
.pipe-card { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; margin-top: 8px; }

/* ---- Misc helpers ------------------------------------------------------- */
.list-row { display: flex; align-items: center; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.list-row:last-child { border-bottom: none; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: var(--fs-sm); }
.kv dt { color: var(--steel); }
.kv dd { margin: 0; }
.label-preview {
    border: 1px dashed var(--steel); border-radius: var(--radius-sm); padding: 12px;
    text-align: center; width: 180px; background: var(--bg);
}
.barcode { height: 44px; background: repeating-linear-gradient(90deg, var(--navy) 0 2px, #fff 2px 4px); margin: 8px 0; }

/* ==========================================================================
   Industry presets (Step 8)
   ========================================================================== */
.nav-item { position: relative; }
.nav-focus-dot {
    width: 6px; height: 6px; border-radius: 50%; background: var(--warning);
    margin-left: auto; flex-shrink: 0;
}
.nav-item.is-focus > span:first-of-type { font-weight: 600; }
.preset-banner {
    display: flex; align-items: center; gap: var(--sp-3);
    background: var(--surface); border: 1px solid var(--border);
    border-left: 3px solid var(--navy);
    border-radius: var(--radius-sm); padding: 10px var(--sp-4);
    margin-bottom: var(--sp-4);
}
.preset-banner-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; border-radius: var(--radius-sm);
    background: var(--navy); color: #fff; flex-shrink: 0;
}
.preset-banner-text { display: flex; flex-direction: column; line-height: 1.35; }
.preset-banner .muted { margin-left: auto; }

/* ==========================================================================
   Role-specific full-screen views (Step 7)
   ========================================================================== */
.role-body { margin: 0; background: var(--surface); }
.role-screen { display: flex; flex-direction: column; min-height: 100vh; }
.role-bar {
    display: flex; align-items: center; gap: var(--sp-4);
    padding: 0 var(--sp-5); height: 60px;
    background: var(--navy); color: #fff; flex-shrink: 0;
}
.role-bar-id { display: flex; align-items: center; gap: var(--sp-3); }
.role-badge {
    background: rgba(255, 255, 255, .14); color: #fff;
    padding: 4px 12px; border-radius: var(--radius-pill);
    font-size: var(--fs-xs); text-transform: uppercase; letter-spacing: .08em; font-weight: 700;
}
.role-bar-title { font-weight: 700; font-size: var(--fs-lg); }
.role-bar-sub { font-size: var(--fs-sm); color: var(--steel-300); }
.role-bar-meta { margin-left: auto; }
.role-clock { font-size: var(--fs-xl); font-variant-numeric: tabular-nums; font-weight: 600; }
.role-bar-actions { display: flex; align-items: center; gap: var(--sp-3); }
.role-bar .dropdown-toggle { background: rgba(255, 255, 255, .1); color: #fff; border-color: transparent; }
.role-bar .dropdown-toggle:hover { background: rgba(255, 255, 255, .18); }
.role-main { flex: 1; padding: var(--sp-5); overflow: auto; }

/* Dark theme (kitchen) */
.theme-dark { background: #0A1422; color: #E8ECF1; }
.theme-dark .role-main { background: #0A1422; }

/* ---- Kitchen Display ---------------------------------------------------- */
.kds { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--sp-4); height: 100%; }
@media (max-width: 880px) { .kds { grid-template-columns: 1fr; } }
.kds-col { background: rgba(255, 255, 255, .04); border: 1px solid rgba(255, 255, 255, .08); border-radius: var(--radius); display: flex; flex-direction: column; min-height: 0; }
.kds-col-head { display: flex; align-items: center; justify-content: space-between; padding: var(--sp-3) var(--sp-4); border-bottom: 2px solid; }
.kds-col-head h2 { font-size: var(--fs-md); text-transform: uppercase; letter-spacing: .06em; margin: 0; }
.col-queued .kds-col-head { border-color: var(--steel); }
.col-preparing .kds-col-head { border-color: var(--warning); }
.col-ready .kds-col-head { border-color: var(--success); }
.kds-count { background: rgba(255, 255, 255, .12); border-radius: var(--radius-pill); padding: 2px 10px; font-weight: 700; font-size: var(--fs-sm); }
.kds-tickets { padding: var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); overflow: auto; }
.kds-ticket { background: #12203A; border: 1px solid rgba(255, 255, 255, .1); border-radius: var(--radius-sm); padding: var(--sp-3); transition: opacity .3s; }
.kds-ticket-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.kds-ref { font-weight: 700; font-size: var(--fs-lg); }
.kds-table { font-size: var(--fs-sm); color: var(--steel-300); }
.kds-items { list-style: none; margin: 0 0 var(--sp-3); padding: 0; font-size: var(--fs-md); }
.kds-items li { padding: 3px 0; border-bottom: 1px dashed rgba(255, 255, 255, .08); }
.kds-ticket-foot { display: flex; align-items: center; justify-content: space-between; }
.kds-time { display: inline-flex; align-items: center; gap: 6px; color: var(--steel-300); font-size: var(--fs-sm); }
.kds-empty { color: var(--steel); text-align: center; padding: var(--sp-5); font-size: var(--fs-sm); }

/* ---- Driver view -------------------------------------------------------- */
.driver { display: grid; grid-template-columns: 1.4fr 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 880px) { .driver { grid-template-columns: 1fr; } }
.driver-list { background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius); padding: var(--sp-4); display: flex; flex-direction: column; gap: var(--sp-3); }
.driver-job { display: flex; gap: var(--sp-3); justify-content: space-between; align-items: center; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--sp-3) var(--sp-4); }
.driver-job.is-done { opacity: .6; }
.driver-job-main { min-width: 0; }
.driver-cust { font-weight: 600; margin: 4px 0 2px; }
.driver-addr { font-size: var(--fs-sm); color: var(--steel); display: flex; align-items: center; gap: 6px; }
.driver-job-actions { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.driver-map { position: sticky; top: var(--sp-4); }
.map-placeholder {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
    min-height: 280px; color: var(--steel);
    background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius-sm);
    background-image: linear-gradient(var(--border) 1px, transparent 1px), linear-gradient(90deg, var(--border) 1px, transparent 1px);
    background-size: 28px 28px;
}

/* ---- Customer view ------------------------------------------------------ */
.cust { display: grid; grid-template-columns: 1.5fr 1fr; gap: var(--sp-4); align-items: start; }
@media (max-width: 880px) { .cust { grid-template-columns: 1fr; } }
.cust-side { display: flex; flex-direction: column; gap: var(--sp-4); }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--success); margin-left: 6px; animation: pulse 1.4s infinite; vertical-align: middle; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }
.cust-order td, .cust-order th { font-size: var(--fs-md); }
.cust-totals { padding: var(--sp-3) var(--sp-1); border-top: 1px solid var(--border); }
.cust-totals .row { display: flex; justify-content: space-between; padding: 4px 0; font-size: var(--fs-md); }
.cust-grand { font-size: var(--fs-lg); font-weight: 700; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 8px; }
.cust-loyalty { display: flex; align-items: center; gap: 8px; margin-top: var(--sp-3); padding: 10px var(--sp-3); background: var(--surface); border-radius: var(--radius-sm); font-size: var(--fs-sm); }
.track { display: flex; flex-direction: column; gap: 0; margin: var(--sp-2) 0; }
.track-step { display: flex; gap: var(--sp-3); padding-bottom: var(--sp-4); position: relative; }
.track-step:not(:last-child)::before { content: ""; position: absolute; left: 6px; top: 16px; bottom: 0; width: 2px; background: var(--border); }
.track-step.done:not(:last-child)::before { background: var(--success); }
.track-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--border); background: var(--bg); flex-shrink: 0; margin-top: 2px; z-index: 1; }
.track-step.done .track-dot { background: var(--success); border-color: var(--success); }
.track-label { font-weight: 600; font-size: var(--fs-sm); }

/* ==========================================================================
   Polish & microinteractions (Step 9)
   ========================================================================== */

/* ---- 9.1 Empty states --------------------------------------------------- */
.empty-state {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: var(--sp-2); text-align: center; padding: var(--sp-8) var(--sp-5);
    color: var(--steel);
}
.empty-state .empty-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 56px; height: 56px; border-radius: 50%;
    background: var(--surface); color: var(--steel-300); margin-bottom: var(--sp-1);
}
.empty-state .empty-icon .icon { width: 26px; height: 26px; }
.empty-state h3 { margin: 0; font-size: var(--fs-md); color: var(--navy); }
.empty-state p { margin: 0; font-size: var(--fs-sm); max-width: 320px; }

/* ---- 9.1 Loading skeletons ---------------------------------------------- */
.skeleton {
    position: relative; overflow: hidden;
    background: var(--surface-2); border-radius: var(--radius-sm);
}
.skeleton::after {
    content: ""; position: absolute; inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, .6), transparent);
    animation: shimmer 1.3s infinite;
}
.skeleton-text { height: 12px; margin: 8px 0; }
.skeleton-text.sk-sm { width: 40%; }
.skeleton-text.sk-md { width: 65%; }
.skeleton-line { height: 14px; margin: 10px 0; }
.skeleton-block { height: 120px; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
@media (prefers-reduced-motion: reduce) {
    .skeleton::after { animation: none; }
    .toast { animation: none; }
    .live-dot { animation: none; }
}

/* ---- 9.4 Accessibility -------------------------------------------------- */
/* Visible keyboard focus everywhere (kept subtle for mouse via :focus-visible). */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--info);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}
.nav-item:focus-visible, .chip:focus-visible, .tab:focus-visible {
    outline: 2px solid #fff; outline-offset: -2px;
}
/* Skip link — first focusable element, hidden until focused. */
.skip-link {
    position: absolute; left: var(--sp-3); top: -48px; z-index: 300;
    background: var(--navy); color: #fff; padding: 10px var(--sp-4);
    border-radius: var(--radius-sm); transition: top .15s ease;
}
.skip-link:focus { top: var(--sp-3); }
/* Screen-reader-only utility. */
.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;
}

/* ---- 9.3 Print stylesheet (receipts & barcode labels) ------------------- */
@media print {
    @page { margin: 12mm; }
    body { background: #fff; color: #000; }

    /* Hide app chrome and non-essential UI. */
    .sidebar, .topbar, .toast-stack, .skip-link,
    .role-bar, .page-actions, .modal-footer, .modal-close,
    .no-print { display: none !important; }

    /* Neutralise layout so printed content flows from the top. */
    .app, .app-main, .content, .role-screen, .role-main { display: block; margin: 0; padding: 0; }

    /* Print only the marked region, full width at the top of the page. */
    body.printing * { visibility: hidden; }
    body.printing .print-section, body.printing .print-section * { visibility: visible; }
    body.printing .print-section {
        position: absolute; left: 0; top: 0; width: 100%;
        box-shadow: none; border: none; background: #fff;
    }

    /* Receipt: monospace, narrow, no chrome. */
    .modal-backdrop { position: static; background: none; display: block; padding: 0; }
    #receiptModal .modal { box-shadow: none; max-width: 80mm; margin: 0 auto; }
    #receiptModal .modal-header { border: none; }

    /* Barcode labels grid prints cleanly across the page. */
    .label-preview { border: 1px solid #000 !important; break-inside: avoid; }
}
