/* =========================================================================
   FODEALS Business Management — Laravel/Blade UI (no build step, no Node)
   ========================================================================= */
* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
    --bg: #f1f5f9;
    --panel: #ffffff;
    --border: #e2e8f0;
    --ink: #0f172a;
    --ink-soft: #475569;
    --ink-faint: #94a3b8;
    --brand: #4f46e5;
    --brand-dark: #4338ca;
    --emerald: #10b981;
    --amber: #f59e0b;
    --rose: #f43f5e;
    --cyan: #06b6d4;
    --purple: #9333ea;
    --sidebar-bg: #0f172a;
    --sidebar-ink: #cbd5e1;
    --radius: 14px;
    --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
}
html { font-family: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif; font-size: 14px; -webkit-text-size-adjust: 100%; }
body { background: var(--bg); color: var(--ink); }
a { color: var(--brand); text-decoration: none; }
a, button, input, select, textarea, summary, label { touch-action: manipulation; }
a, button { -webkit-tap-highlight-color: transparent; }
.icon { width: 16px; height: 16px; flex: none; }

/* ---------------- Layout ---------------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: 240px; background: var(--sidebar-bg); color: var(--sidebar-ink);
    position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
    border-right: 1px solid #1e293b; flex-shrink: 0; z-index: 50;
}
.sidebar-head { display: flex; align-items: center; gap: 10px; padding: 18px 16px; border-bottom: 1px solid #1e293b; }
.logo-badge { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: #fff; font-weight: 800; display: flex; align-items: center; justify-content: center; font-size: 13px; }
.logo-name { color: #fff; font-weight: 800; font-size: 14px; letter-spacing: .5px; }
.logo-sub { color: #64748b; font-size: 10px; }
.sidebar-close { display: none; margin-left: auto; background: none; border: 0; color: #94a3b8; font-size: 22px; cursor: pointer; }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px; }
.nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: #64748b; padding: 6px 10px 10px; }
.nav-item {
    display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
    color: var(--sidebar-ink); font-size: 12.5px; font-weight: 600; margin-bottom: 2px;
}
.nav-item:hover { background: #1e293b; color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item.highlight { color: #fbbf24; background: rgba(245, 158, 11, .08); border: 1px solid rgba(245, 158, 11, .2); }
.nav-badge { margin-left: auto; background: #1e293b; border: 1px solid #334155; color: #cbd5e1; font-size: 10px; font-weight: 700; padding: 1px 7px; border-radius: 999px; }
.nav-item.active .nav-badge { background: #fff; color: var(--brand); border-color: #fff; }
.sidebar-foot { padding: 14px; border-top: 1px solid #1e293b; display: flex; gap: 10px; align-items: center; background: rgba(2, 6, 23, .4); }
.user-chip { width: 32px; height: 32px; border-radius: 999px; background: rgba(99, 102, 241, .2); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, .4); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 800; }
.user-name { color: #fff; font-size: 12px; font-weight: 700; }
.logout-btn { background: none; border: 0; color: #64748b; font-size: 11px; cursor: pointer; padding: 0; }
.logout-btn:hover { color: #f87171; }
.sidebar-overlay { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: 56px; background: #fff; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 14px; padding: 0 20px;
    position: sticky; top: 0; z-index: 40;
}
.topbar-title { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.hamburger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; color: var(--ink-soft); padding: 8px; }
.topbar-ai-icon { display: none; }
.icon-btn { position: relative; color: var(--ink-soft); padding: 6px; border-radius: 8px; }
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn .dot { position: absolute; top: 4px; right: 4px; width: 8px; height: 8px; border-radius: 999px; background: var(--rose); }
.content { padding: 22px; max-width: 1400px; width: 100%; margin: 0 auto; }

/* ---------------- Flash / alerts ---------------- */
.flash { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; font-weight: 600; margin-bottom: 16px; }
.flash-success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.flash-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ---------------- Cards & panels ---------------- */
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; }
.card + .card, .grid + .card, .card + .grid { margin-top: 18px; }
.card-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink); padding-bottom: 12px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.card-sub { font-size: 11.5px; color: var(--ink-faint); margin-top: 2px; }

.hero {
    background: linear-gradient(110deg, #0f172a, #1e1b4b 55%, #0f172a);
    color: #fff; border-radius: 16px; padding: 24px; margin-bottom: 20px;
    border: 1px solid #1e293b; display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px;
}
.hero h1 { font-size: 21px; font-weight: 900; letter-spacing: -.01em; }
.hero p { font-size: 12px; color: #cbd5e1; margin-top: 6px; max-width: 640px; }
.pill { display: inline-flex; align-items: center; gap: 5px; font-size: 10px; font-weight: 800; padding: 3px 9px; border-radius: 999px; text-transform: uppercase; letter-spacing: .04em; }
.pill-green { background: rgba(16, 185, 129, .15); color: #34d399; border: 1px solid rgba(16, 185, 129, .3); }
.pill-purple { background: rgba(147, 51, 234, .15); color: #c084fc; border: 1px solid rgba(147, 51, 234, .3); }
.pill-muted { background: #f1f5f9; color: var(--ink-soft); border: 1px solid var(--border); }

/* ---------------- KPI grid ---------------- */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-5 { grid-template-columns: repeat(5, 1fr); }
@media (max-width: 1100px) { .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 700px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } .grid-4, .grid-5 { grid-template-columns: repeat(2, 1fr); gap: 10px; } .kpi { padding: 12px; } .kpi .kpi-value { font-size: 19px; } }

.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.kpi .kpi-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-faint); display: flex; align-items: center; gap: 6px; }
.kpi .kpi-value { font-size: 22px; font-weight: 900; margin-top: 6px; letter-spacing: -.02em; }
.kpi .kpi-hint { font-size: 11px; color: var(--ink-faint); margin-top: 4px; }
.k-emerald .kpi-value { color: var(--emerald); } .k-amber .kpi-value { color: var(--amber); }
.k-rose .kpi-value { color: var(--rose); } .k-brand .kpi-value { color: var(--brand); }
.k-cyan .kpi-value { color: var(--cyan); } .k-purple .kpi-value { color: var(--purple); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 12.5px; }
table.data th { text-align: left; font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); background: #f8fafc; padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
table.data td { padding: 11px 12px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
table.data tr:hover td { background: #f8fafc; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-weight: 700; }
.right { text-align: right; } .center { text-align: center; }
.num { font-variant-numeric: tabular-nums; font-weight: 700; }
.muted { color: var(--ink-faint); } .soft { color: var(--ink-soft); }
.text-emerald { color: var(--emerald); } .text-amber { color: var(--amber); }
.text-rose { color: var(--rose); } .text-brand { color: var(--brand); }

/* ---------------- Badges ---------------- */
.badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 3px 8px; border-radius: 999px; border: 1px solid transparent; white-space: nowrap; }
.b-new { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.b-contacted { background: #f0f9ff; color: #0284c7; border-color: #bae6fd; }
.b-interested { background: #ecfeff; color: #0891b2; border-color: #a5f3fc; }
.b-negotiating { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.b-converted, .b-completed, .b-paid, .b-delivered, .b-cleared, .b-signed, .b-created { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.b-lost, .b-cancelled, .b-overdue { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.b-enquiry, .b-booking { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.b-deposit, .b-partially, .b-processing, .b-loading, .b-sent { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.b-transit, .b-shipped, .b-transshipment, .b-transit2 { background: #ecfeff; color: #0e7490; border-color: #a5f3fc; }
.b-arrived, .b-purchased, .b-contract { background: #f5f3ff; color: #7c3aed; border-color: #ddd6fe; }
.b-pending, .b-unpaid, .b-notcreated, .b-clearance { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.b-critical { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.b-high { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.b-medium { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.b-low { background: #f1f5f9; color: #64748b; border-color: #e2e8f0; }

/* ---------------- Buttons & forms ---------------- */
.btn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; padding: 9px 14px; border-radius: 10px; border: 1px solid transparent; cursor: pointer; transition: .12s; white-space: nowrap; }
.btn-sm { padding: 6px 11px; font-size: 11px; border-radius: 8px; }
.btn-primary { background: var(--brand); color: #fff; } .btn-primary:hover { background: var(--brand-dark); }
.btn-emerald { background: var(--emerald); color: #fff; } .btn-emerald:hover { background: #059669; }
.btn-amber { background: var(--amber); color: #1c1917; } .btn-amber:hover { background: #d97706; color: #fff; }
.btn-danger { background: var(--rose); color: #fff; } .btn-danger:hover { background: #e11d48; }
.btn-ghost { background: #f1f5f9; color: var(--ink-soft); border-color: var(--border); } .btn-ghost:hover { background: #e2e8f0; color: var(--ink); }
.btn-outline { background: transparent; color: var(--brand); border-color: #c7d2fe; } .btn-outline:hover { background: #eef2ff; }
.btn-icon { padding: 6px; border-radius: 8px; background: none; border: 0; color: var(--ink-faint); cursor: pointer; display: inline-flex; }
.btn-icon:hover { background: #eef2ff; color: var(--brand); }
.btn-icon.danger:hover { background: #fef2f2; color: var(--rose); }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

.field { margin-bottom: 13px; }
.field label { display: block; font-size: 11px; font-weight: 700; color: var(--ink-soft); margin-bottom: 5px; }
.input, .select, .textarea {
    width: 100%; background: #f8fafc; border: 1px solid var(--border); border-radius: 10px;
    padding: 9px 12px; font-size: 13px; color: var(--ink); font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus { outline: 2px solid rgba(79, 70, 229, .35); border-color: var(--brand); }
.textarea { min-height: 76px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.form-grid .full { grid-column: 1 / -1; }
@media (max-width: 700px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------------- Tabs ---------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; overflow-x: auto; }
.tabs a { padding: 10px 14px; font-size: 12px; font-weight: 700; color: var(--ink-faint); border-bottom: 2px solid transparent; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px; }
.tabs a:hover { color: var(--ink); }
.tabs a.active { color: var(--purple); border-bottom-color: var(--purple); }

/* ---------------- Progress ---------------- */
.progress { height: 10px; background: #e2e8f0; border-radius: 999px; overflow: hidden; }
.progress > div { height: 100%; background: var(--emerald); border-radius: 999px; }

/* ---------------- Detail rows / timeline ---------------- */
.dl { display: grid; grid-template-columns: 140px 1fr; row-gap: 9px; font-size: 12.5px; }
.dl dt { color: var(--ink-faint); font-weight: 600; }
.dl dd { color: var(--ink); font-weight: 600; }
.timeline { position: relative; padding-left: 22px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: #e2e8f0; }
.timeline li { position: relative; list-style: none; padding-bottom: 14px; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: -19px; top: 3px; width: 10px; height: 10px; border-radius: 999px; background: #cbd5e1; border: 2px solid #fff; }
.timeline li.done::before { background: var(--emerald); }
.timeline li.current::before { background: var(--brand); box-shadow: 0 0 0 4px rgba(79, 70, 229, .18); }

/* ---------------- Alert items ---------------- */
.alert-item { display: flex; gap: 12px; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); margin-bottom: 10px; }
.alert-item.unread { border-left: 3px solid var(--brand); }
.alert-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none; }
.ai-critical { background: #fef2f2; color: var(--rose); }
.ai-high { background: #fff7ed; color: var(--amber); }
.ai-medium { background: #fffbeb; color: #d97706; }
.ai-low { background: #f1f5f9; color: var(--ink-soft); }
.alert-title { font-size: 13px; font-weight: 800; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.alert-msg { font-size: 12px; color: var(--ink-soft); margin-top: 3px; }
.alert-meta { font-size: 11px; color: var(--ink-faint); margin-top: 5px; display: flex; gap: 12px; flex-wrap: wrap; }

/* ---------------- Misc ---------------- */
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 18px; }
.section-head h2 { font-size: 19px; font-weight: 900; letter-spacing: -.01em; display: flex; align-items: center; gap: 8px; }
.section-head p { font-size: 12px; color: var(--ink-faint); margin-top: 3px; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 16px; }
.filters .input, .filters .select { width: auto; min-width: 140px; }
.empty { text-align: center; padding: 40px 20px; color: var(--ink-faint); font-size: 13px; }
.split { display: grid; grid-template-columns: 1fr 380px; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .split { grid-template-columns: 1fr; } }
.inline-form { display: inline; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 6px; }
.checkbox-grid label { display: flex; gap: 8px; align-items: center; font-size: 12px; font-weight: 600; padding: 7px 9px; border: 1px solid var(--border); border-radius: 8px; background: #f8fafc; cursor: pointer; }
.checkbox-grid label:hover { border-color: var(--brand); }
.checkbox-grid input { accent-color: var(--brand); }
details.expander { border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); margin-bottom: 12px; }
details.expander > summary { cursor: pointer; padding: 13px 16px; font-size: 13px; font-weight: 700; list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
details.expander > summary::-webkit-details-marker { display: none; }
details.expander > summary::after { content: "+"; font-size: 16px; color: var(--ink-faint); }
details.expander[open] > summary::after { content: "–"; }
details.expander .expander-body { padding: 4px 16px 16px; border-top: 1px solid var(--border); }

/* ---------------- Contract (printable) ---------------- */
.contract-sheet { max-width: 820px; margin: 0 auto; background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 44px 48px; box-shadow: var(--shadow); }
.contract-sheet h1 { font-size: 20px; text-align: center; letter-spacing: .02em; }
.contract-sheet .contract-sub { text-align: center; color: var(--ink-faint); font-size: 12px; margin: 4px 0 26px; }
.contract-sheet table.terms { width: 100%; border-collapse: collapse; font-size: 13px; margin: 18px 0; }
.contract-sheet table.terms td { border: 1px solid var(--border); padding: 9px 12px; }
.contract-sheet table.terms td:first-child { background: #f8fafc; font-weight: 700; width: 38%; }
.sig-row { display: flex; justify-content: space-between; gap: 40px; margin-top: 56px; }
.sig-box { flex: 1; }
.sig-line { border-top: 1.5px solid var(--ink); margin-top: 44px; padding-top: 8px; font-size: 12px; color: var(--ink-soft); }
@media print {
    .sidebar, .topbar, .sidebar-overlay, .no-print, .flash { display: none !important; }
    body { background: #fff; } .content { padding: 0; max-width: none; }
    .contract-sheet { border: 0; box-shadow: none; border-radius: 0; padding: 0; }
}

/* ---------------- Login ---------------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(140deg, #0f172a, #1e1b4b); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 18px; padding: 34px; box-shadow: 0 20px 60px rgba(0, 0, 0, .35); }
.login-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-card h1 { font-size: 19px; font-weight: 900; }
.login-card .sub { font-size: 12px; color: var(--ink-faint); margin: 4px 0 20px; }

/* ---------------- Voice console ---------------- */
.voice-box { background: linear-gradient(135deg, #0f172a, #312e81); color: #fff; border-radius: 16px; padding: 28px; }
.voice-box textarea { width: 100%; min-height: 90px; border-radius: 12px; border: 1px solid #4338ca; background: rgba(15, 23, 42, .6); color: #fff; padding: 14px; font-size: 14px; font-family: inherit; }
.voice-box textarea::placeholder { color: #818cf8; }
.voice-result { margin-top: 16px; background: rgba(255, 255, 255, .06); border: 1px solid #4338ca; border-radius: 12px; padding: 16px; }
.voice-result h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: #a5b4fc; margin-bottom: 8px; }
.voice-result pre { white-space: pre-wrap; font-size: 12px; color: #c7d2fe; font-family: ui-monospace, monospace; }

/* ---------------- Mobile bottom tab bar & app polish ---------------- */
.mobile-nav { display: none; }

/* Top navigation progress bar (shown while a new page loads) */
.page-loader {
    position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 200;
    background: transparent; pointer-events: none; opacity: 0; transition: opacity .2s;
}
.page-loader.show { opacity: 1; }
.page-loader > div { height: 100%; width: 0; background: var(--brand); border-radius: 0 3px 3px 0; transition: width .35s ease; box-shadow: 0 0 8px rgba(79, 70, 229, .8); }

/* Gentle page-in motion */
@keyframes pageIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.content { animation: pageIn .22s ease-out; }

/* App-like press feedback */
.btn:active, .nav-item:active, .mob-item:active, .btn-icon:active, .icon-btn:active {
    transform: scale(.96); transition: transform .08s;
}
.mobile-nav, .tabs, .topbar { -webkit-user-select: none; user-select: none; }

@media (max-width: 960px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; height: 100dvh; transform: translateX(-102%); transition: transform .25s cubic-bezier(.2, .8, .3, 1); border-radius: 0 18px 18px 0; box-shadow: 0 0 60px rgba(2, 6, 23, .5); }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-overlay { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 45; }
    .sidebar-close { display: block; padding: 8px; }
    .sidebar-nav { overscroll-behavior: contain; }
    .nav-item { padding: 13px 12px; font-size: 13.5px; margin-bottom: 3px; }
    .hamburger { display: block; }
    .content { padding: 16px; }

    /* Bottom tab bar — fixed app-style navigation */
    .mobile-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
        background: rgba(15, 23, 42, .97); border-top: 1px solid #1e293b;
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
        padding: 6px 4px calc(8px + env(safe-area-inset-bottom, 0px));
    }
    .mob-item {
        flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-height: 52px; background: none; border: 0; border-radius: 10px;
        color: var(--sidebar-ink); font-size: 10px; font-weight: 700; font-family: inherit; cursor: pointer;
        position: relative; padding-top: 8px;
    }
    .mob-item::before {
        content: ""; position: absolute; top: 0; width: 22px; height: 3px; border-radius: 999px;
        background: transparent; transition: background .18s;
    }
    .mob-item .icon { width: 21px; height: 21px; }
    .mob-item.active { color: #fff; }
    .mob-item.active .icon { color: #a5b4fc; }
    .mob-item.active::before { background: #818cf8; }
    .mob-item:active { background: #1e293b; }
    .content { padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px)); }

    /* Translucent topbar that lets content slide beneath it */
    .topbar {
        padding: 0 10px; gap: 6px; height: auto; min-height: 54px;
        padding-top: env(safe-area-inset-top, 0px);
        background: rgba(255, 255, 255, .86);
        backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
    }
    .topbar-ai { display: none; }
    .topbar-ai-icon { display: inline-flex; color: var(--brand); padding: 8px; }
    .icon-btn { padding: 8px; }

    /* Thumb-friendly inputs — 16px prevents iOS auto-zoom on focus */
    .input, .select, .textarea { font-size: 16px; padding: 12px 14px; }
    .voice-box textarea { font-size: 16px; }
    .btn { min-height: 44px; padding: 11px 16px; font-size: 13px; }
    .btn-sm { min-height: 38px; padding: 8px 13px; }
    .btn-icon { min-width: 40px; min-height: 40px; align-items: center; justify-content: center; }
    .btn-icon .icon { width: 18px; height: 18px; }
    .tabs { scrollbar-width: none; }
    .tabs::-webkit-scrollbar { display: none; }
    .tabs a { min-height: 44px; padding: 10px 14px; }
    .filters .input, .filters .select, .filters .btn { flex: 1 1 100%; width: 100%; }
    .hero { padding: 18px; }
    .card { padding: 16px; }
    .section-head h2 { font-size: 17px; }
    details.expander > summary { padding: 15px 16px; font-size: 14px; min-height: 52px; }

    /* Flash messages float as app toasts above the tab bar */
    .flash {
        position: fixed; left: 12px; right: 12px; z-index: 60;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        box-shadow: 0 10px 30px rgba(15, 23, 42, .22);
        transition: opacity .3s, transform .3s;
    }
    .flash.hide { opacity: 0; transform: translateY(10px); }
}

/* ---------------- Phones: tables become stacked record cards ---------------- */
@media (max-width: 640px) {
    .contract-sheet { padding: 22px 16px; }
    .sig-row { flex-direction: column; gap: 18px; }

    table.data { display: block; border: 0; font-size: 13px; }
    table.data thead { display: none; }
    table.data tbody, table.data tr { display: block; }
    table.data tbody tr {
        margin-bottom: 12px; border: 1px solid var(--border); border-radius: 12px;
        background: var(--panel); padding: 4px 12px; box-shadow: var(--shadow); overflow: hidden;
    }
    table.data td {
        display: flex; justify-content: space-between; align-items: center; gap: 14px;
        padding: 9px 0; border-bottom: 1px solid #f1f5f9; text-align: right;
    }
    table.data td:last-child { border-bottom: 0; }
    table.data td::before {
        content: attr(data-label); font-size: 10px; font-weight: 800; text-transform: uppercase;
        letter-spacing: .05em; color: var(--ink-faint); text-align: left; flex-shrink: 0; max-width: 45%;
    }
    table.data td[colspan] { display: block; text-align: center; }
    table.data td[colspan]::before { content: none; }
    .table-wrap { overflow-x: visible; }
}
