/* ==========================================================================
   Design Kettle · AR Cards — Admin theme
   Brand: Kettle Blue #0096DA  ·  Chai Orange #F7A11A  ·  Deep Ink #0B1B2E
   ========================================================================== */

:root {
    --brand: #0096DA;
    --brand-600: #0083C2;
    --brand-700: #006A9E;
    --brand-300: #5CC2F0;
    --brand-100: #D7F0FC;
    --brand-50: #EEF8FE;
    --accent: #F7A11A;
    --accent-600: #E38B00;
    --accent-100: #FEEBCB;
    --accent-50: #FFF7EA;

    --ink: #0B1B2E;
    --ink-2: #23364D;
    --muted: #64768C;
    --faint: #97A6B8;
    --line: #E4EBF2;
    --line-2: #EEF2F7;
    --bg: #F3F6FA;
    --surface: #FFFFFF;

    --success: #12A150;
    --success-50: #E7F7EE;
    --danger: #E5374F;
    --danger-50: #FDECEF;
    --warning: #D98200;
    --warning-50: #FFF4E0;

    --sidebar: #0A1A2D;
    --sidebar-2: #0E2440;

    --radius-sm: 10px;
    --radius: 16px;
    --radius-lg: 22px;
    --shadow-xs: 0 1px 2px rgba(11, 27, 46, .06);
    --shadow-sm: 0 1px 2px rgba(11, 27, 46, .04), 0 4px 14px -6px rgba(11, 27, 46, .10);
    --shadow: 0 2px 6px rgba(11, 27, 46, .04), 0 16px 36px -18px rgba(11, 27, 46, .22);
    --shadow-brand: 0 10px 24px -10px rgba(0, 150, 218, .65);
    --shadow-accent: 0 10px 24px -10px rgba(247, 161, 26, .7);

    --font: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --sidebar-w: 272px;
    --ease: cubic-bezier(.2, .8, .2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 14.5px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--brand-700); text-decoration: none; }
img, video { max-width: 100%; display: block; }
h1, h2, h3, h4 { margin: 0; letter-spacing: -.02em; line-height: 1.2; }
p { margin: 0; }
button { font: inherit; }
.icon { flex-shrink: 0; }
[hidden] { display: none !important; }
::selection { background: var(--brand-100); }

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

.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    padding: 22px 16px 16px;
    color: #C6D3E2;
    background: var(--sidebar);
    transition: transform .35s var(--ease);
}
.brand {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 12px;
    padding: 10px 10px 22px;
}
.brand-logo {
    width: 54px; height: 54px; border-radius: 16px;
    background: #fff; display: grid; place-items: center;
    box-shadow: 0 10px 24px -10px rgba(0,0,0,.6), inset 0 0 0 1px rgba(255,255,255,.4);
    padding: 6px;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand-text strong { display: block; color: #fff; font-size: 16px; font-weight: 800; letter-spacing: -.01em; }
.brand-text span {
    display: inline-flex; align-items: center; gap: 6px; margin-top: 2px;
    font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent);
}
.brand-text span::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 3px rgba(247,161,26,.2); }

.nav { position: relative; z-index: 1; display: flex; flex-direction: column; gap: 4px; flex: 1; overflow-y: auto; }
.nav-label { margin: 18px 12px 8px; font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #6F86A3; }
.nav a {
    position: relative; display: flex; align-items: center; gap: 12px;
    padding: 11px 14px; border-radius: 12px;
    color: #B7C6D8; font-weight: 600;
    transition: background .2s, color .2s, transform .2s var(--ease);
}
.nav a:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav a.active {
    color: #fff;
    background: var(--brand);
}
.nav a.active::after {
    content: ""; position: absolute; right: 12px; width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent); box-shadow: 0 0 0 3px rgba(247,161,26,.25);
}
.nav a .badge-count {
    margin-left: auto; min-width: 24px; padding: 1px 8px; border-radius: 999px; text-align: center;
    font-size: 11.5px; font-weight: 700; color: #fff; background: rgba(255,255,255,.1);
}
.nav a.active .badge-count { margin-right: 14px; background: rgba(255,255,255,.2); }

.sidebar-promo {
    position: relative; z-index: 1; overflow: hidden;
    margin: 16px 4px 14px; padding: 18px; border-radius: 18px;
    color: #fff;
    background: var(--accent);
}
.sidebar-promo strong { position: relative; display: block; font-size: 15px; margin-bottom: 4px; }
.sidebar-promo p { position: relative; font-size: 12.5px; opacity: .92; margin-bottom: 12px; }
.sidebar-promo a {
    position: relative; display: inline-flex; align-items: center; gap: 8px;
    padding: 8px 14px; border-radius: 10px; font-weight: 700; font-size: 12.5px;
    color: var(--accent-600); background: #fff;
}

.sidebar-user {
    position: relative; z-index: 1;
    display: flex; align-items: center; gap: 12px;
    padding: 12px; border-radius: 14px;
    background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.07);
}
.avatar {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: grid; place-items: center;
    font-weight: 800; font-size: 14px; color: #fff;
    background: var(--brand);
}
.sidebar-user .meta { min-width: 0; flex: 1; }
.sidebar-user strong { display: block; color: #fff; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user span { display: block; font-size: 12px; color: #7F95B0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user button {
    width: 36px; height: 36px; border-radius: 10px; border: 0; cursor: pointer;
    display: grid; place-items: center; color: #B7C6D8; background: rgba(255,255,255,.06);
    transition: background .2s, color .2s;
}
.sidebar-user button:hover { background: var(--danger); color: #fff; }

.main { flex: 1; min-width: 0; margin-left: var(--sidebar-w); display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 16px;
    padding: 16px 32px;
    background: rgba(243, 246, 250, .82);
    backdrop-filter: saturate(180%) blur(14px);
    -webkit-backdrop-filter: saturate(180%) blur(14px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s, box-shadow .2s;
}
.topbar.scrolled { border-bottom-color: var(--line); box-shadow: 0 6px 20px -16px rgba(11,27,46,.4); }
.topbar .menu-toggle { display: none; }
.crumbs { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--brand); }
.page-title { font-size: 22px; font-weight: 800; color: var(--ink); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 10px; }

.content { padding: 8px 32px 40px; flex: 1; }
.footer { padding: 18px 32px 26px; color: var(--faint); font-size: 12.5px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer strong { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
    --b-bg: var(--surface); --b-fg: var(--ink-2); --b-bd: var(--line);
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    height: 42px; padding: 0 18px; border-radius: 12px;
    font-weight: 700; font-size: 13.5px; white-space: nowrap;
    color: var(--b-fg); background: var(--b-bg); border: 1px solid var(--b-bd);
    cursor: pointer; user-select: none;
    transition: transform .15s var(--ease), box-shadow .2s, background .2s, border-color .2s, color .2s;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); border-color: #D2DCE7; }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 3px solid var(--brand-100); outline-offset: 2px; }
.btn[disabled], .btn.disabled { opacity: .55; pointer-events: none; }
.btn-primary {
    --b-fg: #fff; --b-bd: transparent;
    background: linear-gradient(135deg, #12A8EC, var(--brand) 45%, var(--brand-700));
    box-shadow: var(--shadow-brand), inset 0 1px 0 rgba(255,255,255,.25);
}
.btn-primary:hover { box-shadow: 0 14px 28px -12px rgba(0,150,218,.8), inset 0 1px 0 rgba(255,255,255,.25); border-color: transparent; }
.btn-accent {
    --b-fg: #fff; --b-bd: transparent;
    background: linear-gradient(135deg, #FFB43D, var(--accent) 45%, var(--accent-600));
    box-shadow: var(--shadow-accent), inset 0 1px 0 rgba(255,255,255,.3);
}
.btn-accent:hover { border-color: transparent; }
.btn-soft { --b-bg: var(--brand-50); --b-fg: var(--brand-700); --b-bd: transparent; }
.btn-soft:hover { --b-bg: var(--brand-100); border-color: transparent; }
.btn-ghost { --b-bg: transparent; --b-bd: transparent; }
.btn-ghost:hover { --b-bg: var(--surface); }
.btn-danger { --b-bg: var(--danger-50); --b-fg: var(--danger); --b-bd: transparent; }
.btn-danger:hover { --b-bg: var(--danger); --b-fg: #fff; border-color: transparent; }
.btn-dark { --b-bg: var(--ink); --b-fg: #fff; --b-bd: transparent; }
.btn-sm { height: 34px; padding: 0 12px; border-radius: 10px; font-size: 12.5px; }
.btn-lg { height: 50px; padding: 0 24px; border-radius: 14px; font-size: 15px; }
.btn-icon { width: 38px; padding: 0; }
.btn-icon.btn-sm { width: 34px; }
.btn-block { width: 100%; }

/* ---------- Surfaces ---------- */
.panel {
    background: var(--surface); border-radius: var(--radius-lg);
    border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
}
.panel-head { display: flex; align-items: center; gap: 12px; padding: 20px 22px 0; }
.panel-head h3 { font-size: 16px; font-weight: 800; }
.panel-head p { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.panel-head .actions { margin-left: auto; display: flex; gap: 8px; }
.panel-body { padding: 20px 22px 22px; }

.grid { display: grid; gap: 20px; }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
.stack { display: flex; flex-direction: column; gap: 20px; }
.row { display: flex; align-items: center; gap: 12px; }
.mt-0 { margin-top: 0 !important; }
.mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }

/* ---------- Hero ---------- */
.hero {
    position: relative; overflow: hidden; isolation: isolate;
    display: flex; align-items: center; gap: 28px;
    padding: 30px 34px; border-radius: 26px; color: #fff;
    background:
        radial-gradient(60% 120% at 100% 0%, rgba(247,161,26,.55), transparent 60%),
        radial-gradient(70% 140% at 0% 100%, rgba(0,60,110,.55), transparent 70%),
        linear-gradient(120deg, #0AA3EA, var(--brand) 40%, #0073AE);
    box-shadow: 0 24px 50px -28px rgba(0,110,170,.9);
}
.hero::before {
    content: ""; position: absolute; inset: 0; z-index: -1; opacity: .35;
    background-image: linear-gradient(rgba(255,255,255,.12) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.12) 1px, transparent 1px);
    background-size: 34px 34px;
    mask-image: radial-gradient(80% 100% at 70% 50%, #000, transparent);
}
.hero-text { flex: 1; min-width: 0; }
.hero-eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 6px 12px; border-radius: 999px;
    background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.25);
    font-size: 12px; font-weight: 700; letter-spacing: .04em;
}
.hero h2 { font-size: 30px; font-weight: 800; margin: 14px 0 8px; }
.hero h2 em { font-style: normal; color: #FFE2AD; }
.hero p { max-width: 520px; opacity: .9; font-size: 14.5px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.hero .btn-white { --b-bg: #fff; --b-fg: var(--brand-700); --b-bd: transparent; }
.hero .btn-glass { --b-bg: rgba(255,255,255,.14); --b-fg: #fff; --b-bd: rgba(255,255,255,.3); }
.hero .btn-glass:hover { --b-bg: rgba(255,255,255,.22); border-color: rgba(255,255,255,.4); }

/* AR card illustration (pure CSS) */
.ar-illus { position: relative; width: 300px; height: 190px; perspective: 900px; flex-shrink: 0; }
.ar-illus .phone {
    position: absolute; right: 18px; top: -6px; width: 128px; height: 210px; border-radius: 26px;
    background: #0B1B2E; border: 5px solid #13283F; box-shadow: 0 30px 50px -20px rgba(0,0,0,.6);
    transform: rotate(8deg); overflow: hidden;
}
.ar-illus .phone::before {
    content: ""; position: absolute; inset: 0;
    background: linear-gradient(160deg, #1d3a58, #0B1B2E);
}
.ar-illus .phone .scanline {
    position: absolute; left: 10px; right: 10px; height: 2px; top: 30%;
    background: var(--accent); box-shadow: 0 0 12px 2px var(--accent);
    animation: scan 2.4s ease-in-out infinite;
}
.ar-illus .vcard {
    position: absolute; left: 0; top: 52px; width: 196px; height: 112px; border-radius: 12px;
    background: #fff; box-shadow: 0 26px 40px -18px rgba(0,0,0,.55);
    transform: rotateX(48deg) rotateZ(-14deg); transform-origin: center;
    padding: 14px; color: var(--ink);
}
.ar-illus .vcard i { display: block; height: 7px; border-radius: 4px; background: var(--line); margin-bottom: 7px; }
.ar-illus .vcard i:first-child { width: 60%; height: 10px; background: var(--brand); }
.ar-illus .vcard i:nth-child(2) { width: 40%; background: var(--accent); }
.ar-illus .vcard i:nth-child(3) { width: 75%; }
.ar-illus .vcard i:nth-child(4) { width: 55%; }
.ar-illus .vplay {
    position: absolute; left: 34px; top: -6px; width: 150px; height: 88px; border-radius: 12px;
    background: linear-gradient(135deg, rgba(255,255,255,.95), rgba(255,255,255,.75));
    display: grid; place-items: center; color: var(--brand);
    box-shadow: 0 18px 34px -12px rgba(0,0,0,.45);
    animation: float 4s ease-in-out infinite;
}
.ar-illus .vplay span {
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--accent), var(--accent-600)); box-shadow: var(--shadow-accent);
}
.ar-illus .beam {
    position: absolute; left: 70px; top: 80px; width: 80px; height: 60px;
    background: linear-gradient(180deg, rgba(255,255,255,.35), transparent);
    clip-path: polygon(20% 0, 80% 0, 100% 100%, 0 100%);
    filter: blur(2px); animation: pulse 2.4s ease-in-out infinite;
}
@keyframes float { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(1deg); } }
@keyframes scan { 0%,100% { top: 22%; } 50% { top: 72%; } }
@keyframes pulse { 0%,100% { opacity: .35; } 50% { opacity: .8; } }

/* ---------- Stat tiles ---------- */
.stat {
    position: relative; overflow: hidden;
    padding: 20px; border-radius: var(--radius-lg);
    background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-sm);
    transition: transform .25s var(--ease), box-shadow .25s;
}
.stat:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.stat-top { display: flex; align-items: center; justify-content: space-between; }
.stat-icon {
    width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
    color: var(--brand-700); background: var(--brand-50);
}
.stat-icon.orange { color: var(--accent-600); background: var(--accent-50); }
.stat-icon.green { color: var(--success); background: var(--success-50); }
.stat-icon.ink { color: #fff; background: linear-gradient(135deg, var(--ink-2), var(--ink)); }
.stat-label { margin-top: 16px; font-size: 13px; font-weight: 600; color: var(--muted); }
.stat-value { margin-top: 2px; font-size: 30px; font-weight: 800; letter-spacing: -.03em; }
.stat-foot { margin-top: 6px; font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.trend { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-weight: 700; font-size: 11.5px; }
.trend.up { color: var(--success); background: var(--success-50); }
.trend.down { color: var(--danger); background: var(--danger-50); }
.trend.flat { color: var(--muted); background: var(--line-2); }
.stat::after {
    content: ""; position: absolute; right: -40px; bottom: -40px; width: 120px; height: 120px; border-radius: 50%;
    background: radial-gradient(circle, rgba(0,150,218,.08), transparent 70%);
}

/* ---------- Bar chart ---------- */
.chart { display: flex; align-items: flex-end; gap: 8px; height: 220px; padding-top: 18px; }
.chart .bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; min-width: 0; }
.chart .bar-track { position: relative; flex: 1; width: 100%; display: flex; align-items: flex-end; justify-content: center; }
.chart .bar {
    position: relative; width: 100%; max-width: 30px; min-height: 4px; border-radius: 8px 8px 4px 4px;
    background: linear-gradient(180deg, var(--brand-300), var(--brand));
    transform-origin: bottom; animation: grow .8s var(--ease) both;
    transition: filter .2s;
}
.chart .bar.zero { background: var(--line); }
.chart .bar.today { background: linear-gradient(180deg, #FFC56B, var(--accent)); }
.chart .bar-col:hover .bar { filter: brightness(1.08) saturate(1.1); }
.chart .bar .tip {
    position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translate(-50%, 4px);
    padding: 4px 9px; border-radius: 8px; white-space: nowrap; pointer-events: none;
    font-size: 11.5px; font-weight: 700; color: #fff; background: var(--ink);
    opacity: 0; transition: opacity .15s, transform .15s;
}
.chart .bar-col:hover .tip { opacity: 1; transform: translate(-50%, 0); }
.chart .bar-label { font-size: 11px; font-weight: 600; color: var(--faint); }
.chart.dense { gap: 4px; }
.chart.dense .bar-label { font-size: 10px; }
@keyframes grow { from { transform: scaleY(0); } to { transform: scaleY(1); } }

/* ---------- Lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px dashed var(--line); }
.list-item:last-child { border-bottom: 0; }
.list-item .thumb { width: 52px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--line-2); box-shadow: var(--shadow-xs); }
.list-item .grow { flex: 1; min-width: 0; }
.list-item strong { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item span.sub { display: block; font-size: 12px; color: var(--muted); }
.rank {
    width: 26px; height: 26px; border-radius: 8px; display: grid; place-items: center; flex-shrink: 0;
    font-size: 12px; font-weight: 800; color: var(--brand-700); background: var(--brand-50);
}
.rank.r1 { color: #fff; background: linear-gradient(135deg, #FFC25A, var(--accent-600)); }
.progress { height: 6px; border-radius: 99px; background: var(--line-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--brand), var(--brand-300)); }
.progress.orange > span { background: linear-gradient(90deg, var(--accent-600), var(--accent)); }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px;
    font-size: 11.5px; font-weight: 700; white-space: nowrap;
    color: var(--brand-700); background: var(--brand-50);
}
.badge .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.live { color: var(--success); background: var(--success-50); }
.badge.live .dot { animation: blink 1.6s infinite; box-shadow: 0 0 0 0 currentColor; }
.badge.paused { color: var(--muted); background: var(--line-2); }
.badge.warn { color: var(--warning); background: var(--warning-50); }
.badge.orange { color: var(--accent-600); background: var(--accent-50); }
@keyframes blink { 0% { box-shadow: 0 0 0 0 rgba(18,161,80,.5); } 70% { box-shadow: 0 0 0 6px rgba(18,161,80,0); } 100% { box-shadow: 0 0 0 0 rgba(18,161,80,0); } }

/* ---------- Alerts / Toasts ---------- */
.alert {
    display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px; border-radius: 14px;
    font-weight: 600; font-size: 13.5px; margin-bottom: 20px;
    color: var(--brand-700); background: var(--brand-50); border: 1px solid var(--brand-100);
}
.alert.success { color: #0C7A3C; background: var(--success-50); border-color: #C9EDD8; }
.alert.danger { color: #B4233A; background: var(--danger-50); border-color: #F8CCD4; }
.alert.warn { color: #9A5B00; background: var(--warning-50); border-color: #FBE0B0; }
.alert .grow { flex: 1; }
.alert .btn { margin-left: auto; }

.toasts { position: fixed; right: 22px; bottom: 22px; z-index: 100; display: flex; flex-direction: column; gap: 10px; }
.toast {
    display: flex; align-items: center; gap: 12px; min-width: 280px; max-width: 380px;
    padding: 14px 16px; border-radius: 14px; color: #fff; background: var(--ink);
    box-shadow: 0 20px 40px -16px rgba(11,27,46,.6);
    animation: toastIn .35s var(--ease);
    font-weight: 600; font-size: 13.5px;
}
.toast .ti { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.12); flex-shrink: 0; }
.toast.success .ti { background: var(--success); }
.toast.error .ti { background: var(--danger); }
.toast.info .ti { background: var(--brand); }
.toast .grow { flex: 1; }
.toast small { display: block; font-weight: 500; opacity: .7; font-size: 12px; }
.toast .progress { margin-top: 8px; background: rgba(255,255,255,.15); }
.toast.out { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px); } }

/* ---------- Toolbar / filters ---------- */
.toolbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.segmented { display: inline-flex; padding: 4px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.segmented a {
    display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; border-radius: 9px;
    color: var(--muted); font-weight: 700; font-size: 13px;
}
.segmented a span { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line-2); color: var(--muted); }
.segmented a.on { color: #fff; background: var(--ink); }
.segmented a.on span { background: rgba(255,255,255,.18); color: #fff; }
.search {
    position: relative; flex: 1; max-width: 360px; margin-left: auto;
}
.search .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { padding-left: 42px; }

/* ---------- Card grid ---------- */
.card-grid { display: grid; gap: 22px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.ar-card {
    position: relative; display: flex; flex-direction: column; overflow: hidden;
    background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line-2);
    box-shadow: var(--shadow-sm); transition: transform .3s var(--ease), box-shadow .3s;
}
.ar-card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }
.ar-card .media {
    position: relative; aspect-ratio: 16 / 10; overflow: hidden; display: block;
    background: linear-gradient(135deg, #DDEFF9, #F7F1E6);
}
.ar-card .media img, .ar-card .media video {
    position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
    transition: opacity .4s, transform .6s var(--ease);
}
.ar-card .media .card-img {
    inset: 14% 12%; width: 76%; height: 72%; object-fit: cover; border-radius: 10px;
    box-shadow: 0 18px 30px -14px rgba(11,27,46,.55);
    transform: perspective(700px) rotateX(14deg);
}
.ar-card .media video { opacity: 0; }
.ar-card:hover .media video { opacity: 1; }
.ar-card:hover .media .card-img { transform: perspective(700px) rotateX(0) scale(1.03); }
.ar-card .media .chips { position: absolute; left: 12px; top: 12px; right: 12px; display: flex; justify-content: space-between; z-index: 2; }
.ar-card .media .chips .badge { background: rgba(255,255,255,.92); backdrop-filter: blur(6px); }
.ar-card .media .playhint {
    position: absolute; right: 12px; bottom: 12px; z-index: 2;
    display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 99px;
    font-size: 11.5px; font-weight: 700; color: #fff; background: rgba(11,27,46,.65); backdrop-filter: blur(6px);
}
.ar-card .body { padding: 16px 18px 6px; flex: 1; }
.ar-card .body h3 { font-size: 16px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-card .body h3 a { color: var(--ink); }
.ar-card .body h3 a:hover { color: var(--brand); }
.ar-card .body .sub { font-size: 12.5px; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ar-card .meta { display: flex; gap: 14px; margin-top: 12px; font-size: 12px; color: var(--muted); font-weight: 600; }
.ar-card .meta span { display: inline-flex; align-items: center; gap: 5px; }
.ar-card .foot { display: flex; align-items: center; gap: 6px; padding: 12px 14px 14px; border-top: 1px solid var(--line-2); margin-top: 12px; }
.ar-card .foot .spacer { flex: 1; }

/* Empty state */
.empty {
    text-align: center; padding: 60px 24px; border-radius: var(--radius-lg);
    background: var(--surface); border: 2px dashed var(--line);
}
.empty .art {
    width: 96px; height: 96px; border-radius: 28px; margin: 0 auto 18px; display: grid; place-items: center;
    color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-700)); box-shadow: var(--shadow-brand);
    transform: rotate(-6deg);
}
.empty h3 { font-size: 20px; font-weight: 800; }
.empty p { color: var(--muted); max-width: 420px; margin: 8px auto 20px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 7px; }
.field label { font-size: 13px; font-weight: 700; color: var(--ink-2); }
.field label .opt { font-weight: 500; color: var(--faint); }
.field .hint { font-size: 12px; color: var(--muted); }
.field .error { font-size: 12px; font-weight: 600; color: var(--danger); }
.input, select.input, textarea.input {
    width: 100%; height: 46px; padding: 0 14px; border-radius: 12px;
    font: inherit; font-size: 14px; color: var(--ink);
    background: #FBFCFE; border: 1.5px solid var(--line);
    transition: border-color .2s, box-shadow .2s, background .2s;
}
textarea.input { height: auto; min-height: 96px; padding: 12px 14px; resize: vertical; }
.input::placeholder { color: #A9B6C6; }
.input:hover { border-color: #D3DDE8; }
.input:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 4px rgba(0,150,218,.12); }
.input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 4px rgba(229,55,79,.1); }
.input-icon { position: relative; }
.input-icon > .icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon > .input { padding-left: 44px; }
.form-grid { display: grid; gap: 18px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }

.switch { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--line); background: #FBFCFE; cursor: pointer; }
.switch strong { display: block; font-size: 13.5px; }
.switch span { font-size: 12px; color: var(--muted); }
.switch input { appearance: none; -webkit-appearance: none; position: relative; width: 46px; height: 26px; border-radius: 99px; background: #D5DEE8; cursor: pointer; transition: background .25s; flex-shrink: 0; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 2px 4px rgba(0,0,0,.2); transition: transform .25s var(--ease); }
.switch input:checked { background: var(--brand); }
.switch input:checked::after { transform: translateX(20px); }

.choice-group { display: grid; gap: 10px; grid-template-columns: repeat(2, 1fr); }
.choice { position: relative; cursor: pointer; }
.choice input { position: absolute; opacity: 0; }
.choice .box {
    display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px;
    border: 1.5px solid var(--line); background: #FBFCFE; transition: all .2s;
}
.choice .box .ico { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; color: var(--muted); background: var(--line-2); transition: all .2s; }
.choice .box strong { display: block; font-size: 13.5px; }
.choice .box small { color: var(--muted); font-size: 12px; }
.choice input:checked + .box { border-color: var(--brand); background: var(--brand-50); box-shadow: 0 0 0 4px rgba(0,150,218,.1); }
.choice input:checked + .box .ico { color: #fff; background: var(--brand); }

/* ---------- Wizard ---------- */
.wizard { display: grid; gap: 24px; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); align-items: start; }
.steps { display: flex; gap: 10px; margin-bottom: 20px; }
.step {
    flex: 1; display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-radius: 16px;
    background: var(--surface); border: 1.5px solid var(--line-2); cursor: pointer;
    transition: all .25s var(--ease); text-align: left;
}
.step .num {
    width: 36px; height: 36px; border-radius: 11px; display: grid; place-items: center; flex-shrink: 0;
    font-weight: 800; color: var(--muted); background: var(--line-2); transition: all .25s;
}
.step strong { display: block; font-size: 13.5px; color: var(--ink); }
.step small { display: block; font-size: 11.5px; color: var(--muted); }
.step.active { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(0,150,218,.1); }
.step.active .num { color: #fff; background: linear-gradient(135deg, var(--brand), var(--brand-700)); box-shadow: var(--shadow-brand); }
.step.done .num { color: #fff; background: var(--success); }
.step-pane { display: none; animation: fadeUp .35s var(--ease); }
.step-pane.active { display: block; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(10px); } }

.tabs { display: inline-flex; gap: 4px; padding: 4px; border-radius: 13px; background: var(--line-2); margin-bottom: 18px; }
.tabs button {
    display: inline-flex; align-items: center; gap: 8px; height: 38px; padding: 0 16px; border-radius: 10px; border: 0; cursor: pointer;
    font-weight: 700; font-size: 13px; color: var(--muted); background: transparent; transition: all .2s;
}
.tabs button.on { color: var(--ink); background: #fff; box-shadow: var(--shadow-xs); }

.dropzone {
    position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    min-height: 280px; padding: 30px; border-radius: 18px; text-align: center; cursor: pointer;
    border: 2px dashed #C9D6E3; background:
        radial-gradient(60% 80% at 50% 0%, rgba(0,150,218,.06), transparent),
        #FBFCFE;
    transition: border-color .2s, background .2s, transform .2s;
}
.dropzone:hover, .dropzone.drag { border-color: var(--brand); background-color: var(--brand-50); }
.dropzone.drag { transform: scale(1.01); }
.dropzone .dz-icon {
    width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-700)); box-shadow: var(--shadow-brand);
}
.dropzone.orange .dz-icon { background: linear-gradient(135deg, var(--accent), var(--accent-600)); box-shadow: var(--shadow-accent); }
.dropzone strong { font-size: 15.5px; }
.dropzone span { font-size: 12.5px; color: var(--muted); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.camera-stage {
    position: relative; overflow: hidden; border-radius: 18px; background: #050B14;
    aspect-ratio: 16 / 10; display: grid; place-items: center;
}
.camera-stage video { width: 100%; height: 100%; object-fit: cover; }
.camera-stage .guide {
    position: absolute; left: 50%; top: 50%; width: 76%; aspect-ratio: 1.75; transform: translate(-50%, -50%);
    border-radius: 14px; box-shadow: 0 0 0 2000px rgba(5,11,20,.55);
    pointer-events: none;
}
.camera-stage .guide::before, .camera-stage .guide::after {
    content: ""; position: absolute; inset: -3px; border-radius: 16px; border: 3px solid transparent;
}
.camera-stage .guide i { position: absolute; width: 30px; height: 30px; border: 4px solid var(--accent); }
.camera-stage .guide i:nth-child(1) { left: -4px; top: -4px; border-right: 0; border-bottom: 0; border-radius: 14px 0 0 0; }
.camera-stage .guide i:nth-child(2) { right: -4px; top: -4px; border-left: 0; border-bottom: 0; border-radius: 0 14px 0 0; }
.camera-stage .guide i:nth-child(3) { left: -4px; bottom: -4px; border-right: 0; border-top: 0; border-radius: 0 0 0 14px; }
.camera-stage .guide i:nth-child(4) { right: -4px; bottom: -4px; border-left: 0; border-top: 0; border-radius: 0 0 14px 0; }
.camera-stage .guide .line { position: absolute; left: 6%; right: 6%; height: 2px; background: var(--brand-300); box-shadow: 0 0 14px 2px var(--brand); animation: scan 2.6s ease-in-out infinite; }
.camera-stage .cam-msg { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); padding: 6px 14px; border-radius: 99px; font-size: 12.5px; font-weight: 700; color: #fff; background: rgba(0,0,0,.45); backdrop-filter: blur(6px); white-space: nowrap; }
.camera-stage .cam-controls { position: absolute; left: 0; right: 0; bottom: 16px; display: flex; justify-content: center; align-items: center; gap: 18px; }
.shutter {
    width: 68px; height: 68px; border-radius: 50%; border: 4px solid #fff; cursor: pointer;
    background: rgba(255,255,255,.25); display: grid; place-items: center; transition: transform .15s;
}
.shutter::after { content: ""; width: 50px; height: 50px; border-radius: 50%; background: #fff; transition: all .2s; }
.shutter:active { transform: scale(.92); }
.shutter.rec::after { background: var(--danger); }
.shutter.recording::after { width: 26px; height: 26px; border-radius: 6px; background: var(--danger); }
.cam-btn { width: 44px; height: 44px; border-radius: 50%; border: 0; cursor: pointer; color: #fff; background: rgba(255,255,255,.18); backdrop-filter: blur(6px); display: grid; place-items: center; }
.rec-timer { position: absolute; top: 14px; right: 14px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-weight: 800; font-size: 13px; color: #fff; background: var(--danger); font-variant-numeric: tabular-nums; }
.rec-timer::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #fff; animation: blinkdot 1s infinite; }
@keyframes blinkdot { 50% { opacity: .2; } }

.result-box { position: relative; border-radius: 18px; overflow: hidden; background: #0B1B2E; }
.result-box img, .result-box video { width: 100%; max-height: 420px; object-fit: contain; background: #0B1B2E; }
.result-box .rb-bar {
    display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: #fff; border: 1px solid var(--line-2); border-top: 0; border-radius: 0 0 18px 18px;
}
.result-box .rb-bar .grow { flex: 1; min-width: 0; }
.result-box .rb-bar strong { display: block; font-size: 13px; }
.result-box .rb-bar small { color: var(--muted); font-size: 12px; }

.quality { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 12px; font-size: 12.5px; font-weight: 600; margin-top: 12px; }
.quality.good { color: #0C7A3C; background: var(--success-50); }
.quality.ok { color: #9A5B00; background: var(--warning-50); }
.quality.bad { color: #B4233A; background: var(--danger-50); }

.wizard-nav { display: flex; align-items: center; gap: 10px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-2); }
.wizard-nav .spacer { flex: 1; }

/* Live preview (sticky) */
.preview-sticky { position: sticky; top: 96px; }
.preview-stage {
    position: relative; overflow: hidden; border-radius: 22px; aspect-ratio: 4 / 5;
    background:
        radial-gradient(70% 50% at 50% 30%, rgba(0,150,218,.35), transparent 70%),
        radial-gradient(60% 40% at 80% 100%, rgba(247,161,26,.3), transparent 70%),
        linear-gradient(180deg, #102A45, #07131F);
    perspective: 900px; display: grid; place-items: center;
}
.preview-stage .pv-card {
    position: relative; width: 78%; aspect-ratio: 1.75; border-radius: 12px; overflow: hidden;
    transform: rotateX(42deg) rotateZ(-8deg) translateY(30px);
    box-shadow: 0 40px 50px -20px rgba(0,0,0,.7);
    background: linear-gradient(135deg, #fff, #E9F1F8); transition: transform .8s var(--ease);
    transform-style: preserve-3d;
}
.preview-stage:hover .pv-card { transform: rotateX(30deg) rotateZ(-4deg) translateY(30px); }
.preview-stage .pv-card > img { width: 100%; height: 100%; object-fit: cover; }
.preview-stage .pv-card .pv-video {
    position: absolute; inset: 0; overflow: hidden; background: #000;
    transform: translateZ(18px); opacity: .97;
    box-shadow: 0 0 0 2px rgba(255,255,255,.6), 0 0 30px rgba(0,150,218,.6);
}
.preview-stage .pv-card .pv-video video { width: 100%; height: 100%; object-fit: cover; }
.preview-stage .pv-card .pv-video.contain video { object-fit: contain; }
.preview-stage .pv-ph { display: grid; place-items: center; height: 100%; color: var(--faint); font-weight: 700; font-size: 13px; text-align: center; padding: 10px; }
.preview-stage .pv-label { position: absolute; top: 16px; left: 16px; display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 99px; font-size: 12px; font-weight: 700; color: #fff; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); backdrop-filter: blur(8px); }
.preview-stage .pv-label .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.preview-stage .pv-corners { position: absolute; inset: 22% 14%; pointer-events: none; }
.preview-stage .pv-corners i { position: absolute; width: 26px; height: 26px; border: 3px solid rgba(255,255,255,.7); }
.preview-stage .pv-corners i:nth-child(1) { left: 0; top: 0; border-right: 0; border-bottom: 0; border-radius: 10px 0 0 0; }
.preview-stage .pv-corners i:nth-child(2) { right: 0; top: 0; border-left: 0; border-bottom: 0; border-radius: 0 10px 0 0; }
.preview-stage .pv-corners i:nth-child(3) { left: 0; bottom: 0; border-right: 0; border-top: 0; border-radius: 0 0 0 10px; }
.preview-stage .pv-corners i:nth-child(4) { right: 0; bottom: 0; border-left: 0; border-top: 0; border-radius: 0 0 10px 0; }
.checklist { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.checklist div { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--muted); }
.checklist div .ck { width: 22px; height: 22px; border-radius: 7px; display: grid; place-items: center; background: var(--line-2); color: transparent; transition: all .25s; }
.checklist div.ok { color: var(--ink); }
.checklist div.ok .ck { background: var(--success); color: #fff; }

/* Save overlay */
.overlay {
    position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; padding: 20px;
    background: rgba(7,19,31,.6); backdrop-filter: blur(8px); animation: fadeIn .25s;
}
@keyframes fadeIn { from { opacity: 0; } }
.overlay-card { width: 100%; max-width: 440px; padding: 30px; border-radius: 24px; background: #fff; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); text-align: center; animation: fadeUp .35s var(--ease); }
.overlay-card h3 { font-size: 19px; font-weight: 800; margin-top: 18px; }
.overlay-card p { color: var(--muted); margin-top: 6px; font-size: 13.5px; }
.overlay-card .progress { height: 10px; margin-top: 22px; }
.overlay-card .pct { margin-top: 10px; font-weight: 800; font-size: 13px; color: var(--brand-700); }
.spinner-kettle {
    width: 74px; height: 74px; margin: 0 auto; border-radius: 22px; display: grid; place-items: center; position: relative;
    background: var(--brand-50);
}
.spinner-kettle img { width: 50px; }
.spinner-kettle::after {
    content: ""; position: absolute; inset: -6px; border-radius: 26px; border: 3px solid transparent;
    border-top-color: var(--brand); border-right-color: var(--accent); animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: 20px; background: rgba(7,19,31,.55); backdrop-filter: blur(6px); animation: fadeIn .2s; }
.modal-card { width: 100%; max-width: 420px; border-radius: 24px; background: #fff; padding: 26px; box-shadow: 0 40px 80px -30px rgba(0,0,0,.6); animation: fadeUp .3s var(--ease); }
.modal-card h3 { font-size: 18px; font-weight: 800; }
.modal-card p { color: var(--muted); margin-top: 6px; }
.modal-card .actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 22px; }
.modal-ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; margin-bottom: 16px; color: var(--danger); background: var(--danger-50); }
.qr-box { display: grid; place-items: center; padding: 18px; border-radius: 18px; background: #fff; border: 1px solid var(--line); }
.qr-box canvas, .qr-box img { width: 100%; max-width: 240px; height: auto; image-rendering: pixelated; }

/* Detail page */
.detail-hero { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 0; overflow: hidden; }
.detail-media { position: relative; background: #07131F; min-height: 320px; }
.detail-media video { width: 100%; height: 100%; object-fit: contain; position: absolute; inset: 0; }
.detail-info { padding: 26px; display: flex; flex-direction: column; gap: 16px; }
.detail-info h2 { font-size: 24px; font-weight: 800; }
.kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kv div { padding: 12px 14px; border-radius: 12px; background: var(--bg); min-width: 0; }
.kv small { display: block; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); }
.kv strong { display: block; font-size: 13.5px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.linkbox { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 12px; border: 1.5px solid var(--line); background: #FBFCFE; }
.linkbox input { flex: 1; min-width: 0; border: 0; background: transparent; font: inherit; font-size: 13px; color: var(--ink-2); outline: none; }
.card-thumb-lg { border-radius: 14px; overflow: hidden; box-shadow: var(--shadow); }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--faint); padding: 0 0 10px; }
.table td { padding: 11px 0; border-top: 1px dashed var(--line); }

/* Pagination */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 28px; }
.pagination a, .pagination span {
    min-width: 40px; height: 40px; padding: 0 12px; border-radius: 11px; display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; color: var(--ink-2); background: #fff; border: 1px solid var(--line);
}
.pagination .on { color: #fff; background: var(--brand); border-color: var(--brand); }
.pagination .off { opacity: .45; }

/* Scanner status */
.status-ring { width: 88px; height: 88px; border-radius: 50%; display: grid; place-items: center; flex-shrink: 0; color: #fff; }
.status-ring.ok { background: linear-gradient(135deg, #2BD07A, var(--success)); box-shadow: 0 12px 28px -12px rgba(18,161,80,.8); }
.status-ring.stale { background: linear-gradient(135deg, #FFC25A, var(--accent-600)); box-shadow: var(--shadow-accent); }
.status-ring.none { background: linear-gradient(135deg, #9AAABB, #6B7C93); }

/* ---------- Responsive ---------- */
.backdrop { display: none; }
@media (max-width: 1200px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .wizard { grid-template-columns: 1fr; }
    .preview-sticky { position: static; }
    .ar-illus { display: none; }
}
@media (max-width: 992px) {
    .sidebar { transform: translateX(-100%); box-shadow: 30px 0 60px -30px rgba(0,0,0,.5); }
    body.nav-open .sidebar { transform: none; }
    body.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(7,19,31,.45); backdrop-filter: blur(2px); }
    .main { margin-left: 0; }
    .topbar .menu-toggle { display: inline-flex; }
    .grid-main, .grid-3, .grid-2, .detail-hero { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .topbar { padding: 12px 16px; }
    .content { padding: 4px 16px 30px; }
    .footer { padding: 16px; }
    .grid-4 { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat { padding: 16px; }
    .stat-value { font-size: 24px; }
    .hero { padding: 24px; border-radius: 22px; }
    .hero h2 { font-size: 23px; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: auto; }
    .steps { flex-direction: column; }
    .page-title { font-size: 18px; }
    .topbar-actions .hide-sm { display: none; }
    .search { max-width: none; margin-left: 0; flex-basis: 100%; }
    .kv { grid-template-columns: 1fr; }
    .chart { gap: 4px; }
    .chart .bar-label { font-size: 9.5px; }
}

/* Let grid/flex children shrink below their content width (prevents sideways overflow on phones) */
.grid > *, .stack > *, .wizard > *, .detail-hero > * { min-width: 0; }
@media (max-width: 640px) {
    .chart.dense .bar-col:nth-child(even) .bar-label { visibility: hidden; }
    .chart.dense { gap: 2px; }
}
/* Keep edge tooltips inside the chart */
.chart .bar-col:nth-last-child(-n+2) .tip { left: auto; right: 0; transform: translateY(4px); }
.chart .bar-col:nth-child(-n+2) .tip { left: 0; transform: translateY(4px); }
.chart .bar-col:nth-last-child(-n+2):hover .tip, .chart .bar-col:nth-child(-n+2):hover .tip { transform: none; }

/* ==========================================================================
   Mobile app experience (phones & small tablets)
   ========================================================================== */
@view-transition { navigation: auto; }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .22s; }
.tabbar { view-transition-name: tabbar; }
.topbar { view-transition-name: topbar; }

.tabbar, .sheet, .back-btn, .show-mobile { display: none; }
.avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 13px; }
.btn.show-mobile.btn-icon { width: 42px; height: 42px; padding: 0; border-radius: 13px; }

@media (max-width: 992px) {
    html { -webkit-tap-highlight-color: transparent; }
    body { padding-bottom: calc(84px + env(safe-area-inset-bottom)); overscroll-behavior-y: none; }
    body.no-tabbar { padding-bottom: env(safe-area-inset-bottom); }
    .sidebar, .backdrop, .topbar .menu-toggle, .footer, .crumbs, .hide-mobile { display: none !important; }
    .show-mobile { display: inline-flex; }

    /* App bar */
    .topbar {
        padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
        min-height: calc(60px + env(safe-area-inset-top));
        background: rgba(243, 246, 250, .9);
    }
    .topbar-titles { min-width: 0; flex: 1; }
    .page-title { font-size: 24px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
    .topbar.scrolled .page-title { font-size: 18px; }
    .page-title { transition: font-size .2s var(--ease); }
    .back-btn {
        display: grid; place-items: center; width: 40px; height: 40px; margin-left: -6px; border-radius: 12px; flex-shrink: 0;
        color: var(--ink); background: var(--surface); box-shadow: var(--shadow-xs); border: 1px solid var(--line-2);
    }
    .back-btn:active { transform: scale(.92); background: var(--line-2); }
    .topbar-actions { gap: 8px; }
    .topbar-actions .btn { height: 40px; border-radius: 12px; }

    .content { padding: 6px 16px 24px; }

    /* Bottom tab bar */
    .tabbar {
        position: fixed; left: 0; right: 0; bottom: 0; z-index: 60;
        display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
        padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
        background: rgba(255, 255, 255, .92);
        backdrop-filter: saturate(180%) blur(18px); -webkit-backdrop-filter: saturate(180%) blur(18px);
        border-top: 1px solid var(--line);
        box-shadow: 0 -10px 30px -18px rgba(11, 27, 46, .35);
        user-select: none; -webkit-user-select: none;
    }
    body.no-tabbar .tabbar { display: none; }
    .tabbar > a, .tabbar > button {
        display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 4px 0 2px;
        border: 0; background: none; cursor: pointer;
        font-size: 10.5px; font-weight: 700; color: var(--faint); letter-spacing: .01em;
        transition: color .2s, transform .15s;
    }
    .tabbar > a:active, .tabbar > button:active { transform: scale(.9); }
    .tabbar .tab-ico { width: 52px; height: 30px; border-radius: 99px; display: grid; place-items: center; transition: background .25s var(--ease), color .25s; }
    .tabbar > a.on { color: var(--brand-700); }
    .tabbar > a.on .tab-ico { color: var(--brand); background: var(--brand-50); }
    .tabbar .tab-fab { align-self: center; padding: 0; }
    .tabbar .tab-fab .tab-ico {
        width: 56px; height: 56px; margin-top: -26px; border-radius: 19px; color: #fff;
        background: var(--brand); box-shadow: 0 12px 24px -8px rgba(0,150,218,.75), 0 0 0 5px #fff;
    }
    .tabbar .tab-fab:active .tab-ico { background: var(--brand-700); }

    /* Bottom sheets (More menu) */
    .sheet { position: fixed; inset: 0; z-index: 96; display: block; }
    .sheet[hidden] { display: none; }
    .sheet-backdrop { position: absolute; inset: 0; background: rgba(7,19,31,.45); animation: fadeIn .25s; }
    .sheet-panel {
        position: absolute; left: 0; right: 0; bottom: 0; max-height: 88vh; overflow-y: auto;
        padding: 10px 18px calc(20px + env(safe-area-inset-bottom));
        border-radius: 26px 26px 0 0; background: #fff;
        box-shadow: 0 -20px 50px -20px rgba(0,0,0,.4);
        animation: sheetUp .35s var(--ease);
        touch-action: pan-y;
    }
    .sheet.closing .sheet-panel { animation: sheetDown .25s var(--ease) forwards; }
    .sheet.closing .sheet-backdrop { animation: fadeOut .25s forwards; }
    .sheet-grabber { display: block; width: 40px; height: 5px; border-radius: 99px; margin: 0 auto 16px; background: #D5DEE8; }
    .sheet-profile { display: flex; align-items: center; gap: 12px; padding: 4px 4px 16px; border-bottom: 1px solid var(--line-2); }
    .sheet-profile .avatar { width: 50px; height: 50px; border-radius: 16px; font-size: 18px; }
    .sheet-profile strong { display: block; font-size: 16px; }
    .sheet-profile span { font-size: 13px; color: var(--muted); }
    .sheet-list { display: flex; flex-direction: column; padding: 10px 0 18px; }
    .sheet-list > a, .sheet-list > button {
        display: flex; align-items: center; gap: 14px; padding: 12px 4px; border: 0; background: none; text-align: left;
        font-weight: 700; font-size: 15px; color: var(--ink); border-radius: 14px; cursor: pointer;
    }
    .sheet-list > a:active, .sheet-list > button:active { background: var(--bg); }
    .sheet-list .si { width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; color: var(--brand-700); background: var(--brand-50); flex-shrink: 0; }
    .sheet-list .si.orange { color: var(--accent-600); background: var(--accent-50); }
    .sheet-list .go { margin-left: auto; color: var(--faint); }
    .sheet-tip .icon { margin-top: 1px; color: var(--brand); }
    .sheet-tip span { flex: 1; min-width: 0; }
    .sheet-tip { display: flex; align-items: flex-start; gap: 10px; line-height: 1.5; padding: 12px 14px; margin-top: 6px; border-radius: 12px; font-size: 13px; color: var(--ink-2); background: var(--bg); }

    /* Dialogs become bottom sheets */
    .modal { align-items: end; padding: 0; }
    .modal-card {
        max-width: none; border-radius: 26px 26px 0 0;
        padding: 26px 20px calc(22px + env(safe-area-inset-bottom));
        animation: sheetUp .35s var(--ease);
    }
    .modal-card .actions { flex-direction: column-reverse; }
    .modal-card .actions .btn { width: 100%; height: 50px; border-radius: 14px; font-size: 15px; }

    /* Toasts sit above the tab bar, full width */
    .toasts { left: 12px; right: 12px; bottom: calc(92px + env(safe-area-inset-bottom)); }
    body.no-tabbar .toasts { bottom: calc(16px + env(safe-area-inset-bottom)); }
    .toast { min-width: 0; max-width: none; }

    /* Touch feedback instead of hover lifts */
    .btn:active { transform: scale(.96); }
    .ar-card:active, .stat:active, .list-item:active { transform: scale(.98); }
}

@media (hover: none) {
    .stat:hover, .ar-card:hover, .btn:hover { transform: none; }
    .ar-card .media .playhint { display: none; }
}

@media (max-width: 640px) {
    /* Avoid iOS zoom on focus */
    .input, select.input, textarea.input { font-size: 16px; height: 50px; border-radius: 14px; }

    .hero { padding: 22px 20px; border-radius: 24px; gap: 0; }
    .hero h2 { font-size: 22px; margin: 12px 0 6px; }
    .hero p { font-size: 13.5px; }
    .hero-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
    .hero-actions .btn { height: 46px; padding: 0 10px; font-size: 13.5px; }

    .grid.mt-3, section.mt-3 { margin-top: 16px; }
    .grid, .stack { gap: 14px; }
    .stat { border-radius: 20px; }
    .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
    .stat-label { margin-top: 12px; font-size: 12px; }
    .stat-foot { font-size: 11px; }
    .panel { border-radius: 22px; }
    .panel-head { padding: 18px 18px 0; }
    .panel-body { padding: 16px 18px 18px; }
    .chart { height: 170px; }

    /* Cards list: full-width app tiles */
    .toolbar { gap: 10px; margin-bottom: 14px; }
    .segmented { width: 100%; }
    .segmented a { flex: 1; justify-content: center; padding: 9px 8px; }
    .card-grid { grid-template-columns: 1fr; gap: 14px; }
    .ar-card .foot .btn-icon { width: 40px; height: 40px; }

    /* Wizard: compact progress stepper + sticky action bar */
    .steps { flex-direction: row; gap: 6px; margin-bottom: 14px; }
    .step { flex-direction: column; justify-content: center; gap: 6px; padding: 10px 4px; border-radius: 14px; text-align: center; }
    .step small { display: none; }
    .step strong { font-size: 11.5px; }
    .step .num { width: 30px; height: 30px; border-radius: 10px; font-size: 13px; }
    .wizard { gap: 14px; }
    .wizard-nav {
        position: sticky; bottom: 0; z-index: 5; margin: 18px -18px -18px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
        background: rgba(255,255,255,.95); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid var(--line-2); border-radius: 0 0 22px 22px;
    }
    .wizard-nav .btn { height: 48px; }
    .wizard-nav .btn-primary, .wizard-nav .btn-accent { flex: 1; }
    .wizard-nav .spacer { display: none; }
    .tabs { display: flex; width: 100%; }
    .tabs button { flex: 1; justify-content: center; padding: 0 8px; }
    .camera-stage { aspect-ratio: 4 / 5; border-radius: 20px; }
    .camera-stage .guide { width: 86%; }
    .dropzone { min-height: 220px; }
    .preview-stage { aspect-ratio: 16 / 12; }
    .choice-group { grid-template-columns: 1fr; }

    .detail-media { min-height: 230px; }
    .detail-info { padding: 20px; }
    .detail-info h2 { font-size: 21px; }
    .empty { padding: 40px 20px; }
}

@keyframes sheetUp { from { transform: translateY(100%); } }
@keyframes sheetDown { to { transform: translateY(100%); } }
@keyframes fadeOut { to { opacity: 0; } }

/* Installed app (standalone) */
@media (display-mode: standalone) {
    body { -webkit-user-select: none; user-select: none; }
    input, textarea { -webkit-user-select: text; user-select: text; }
}

/* ---------- Inquiries ---------- */
.inq-list { display: flex; flex-direction: column; gap: 12px; }
.inq { border-radius: 20px; background: var(--surface); border: 1px solid var(--line-2); box-shadow: var(--shadow-xs); transition: box-shadow .2s, border-color .2s; }
.inq[open] { box-shadow: var(--shadow); border-color: transparent; }
.inq.is-new { border-left: 4px solid var(--accent); }
.inq summary { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; cursor: pointer; list-style: none; }
.inq summary::-webkit-details-marker { display: none; }
.inq-av { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; flex-shrink: 0; font-weight: 800; color: #fff; background: var(--brand); }
.inq.is-new .inq-av { background: var(--accent); }
.inq-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.inq-main strong { display: flex; align-items: center; gap: 8px; font-size: 15px; }
.inq-sub { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.inq-preview { font-size: 13px; color: var(--ink-2); margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.inq[open] .inq-preview { display: none; }
.inq-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.inq-meta small { font-size: 12px; color: var(--faint); font-weight: 600; }
.inq-body { padding: 0 18px 18px 76px; }
.inq-message { white-space: pre-line; padding: 14px 16px; border-radius: 14px; background: var(--bg); color: var(--ink-2); line-height: 1.6; margin-bottom: 14px; }
.inq-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
@media (max-width: 640px) {
    .inq summary { flex-wrap: wrap; padding: 14px; }
    .inq-meta { flex-direction: row; align-items: center; width: 100%; padding-left: 58px; justify-content: space-between; }
    .inq-body { padding: 0 14px 14px; }
    .inq-actions .btn-sm { height: 40px; }
}

.tabbar .tab-ico { position: relative; }
.tab-dot { position: absolute; top: 2px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 0 2px #fff; }
