/* ─── Design Tokens (Kroll Style) ─── */
:root {
    --brand-primary: #14487F;
    --brand-dark: #001424;
    --brand-accent: #C4D600;
    --brand-accent-hover: #b0c200;

    --bg-primary: #EEF9FC;
    --bg-card: #FFFFFF;
    --bg-dark: #001424;

    --text-primary: #001424;
    --text-secondary: #4a6a8a;
    --text-on-dark: #FFFFFF;
    --text-muted: #8ba3b9;

    --border-light: rgba(20,72,127,0.10);
    --border-medium: rgba(20,72,127,0.22);

    --color-success: #4caf50;
    --color-warning: #f59e0b;
    --color-error: #e53935;

    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 100vw;
}

/* ─── Reset & Base ─── */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}
html {
    height: -webkit-fill-available;
}
body {
    font-family: 'Nunito Sans', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
button { cursor: pointer; font-family: inherit; }
input { font-family: inherit; }

/* ─── Theme classes (kept for template compat) ─── */
.theme-dark, .theme-light {
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    min-height: 100dvh;
    min-height: -webkit-fill-available;
}

/* ─── Status Badges ─── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px 12px; border-radius: var(--radius-full);
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-sm { padding: 2px 8px; font-size: 11px; }
.badge-instock { background: #e8f5e9; color: #2e7d32; }
.badge-transit { background: #e3f2fd; color: #1565c0; }
.badge-outstock { background: #fff8e1; color: #f57f17; }
.badge-unregistered { background: #f5f5f5; color: #757575; }

/* ─── Area Badge ─── */
.area-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 26px; border-radius: 7px; padding: 0 6px;
    color: #fff; font-size: 11px; font-weight: 800; white-space: nowrap;
}
.area-A { background: #14487F; }
.area-B { background: #1976d2; }
.area-C { background: #7b1fa2; }
.area-室内仓库 { background: #f57f17; }
.area-室外斜坡 { background: #2e7d32; }
.area-室外车道 { background: #1565c0; }

/* ─── Cards ─── */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 14px; border: 1px solid var(--border-light);
}
.card-dark {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 14px; border: 1px solid var(--border-light);
}

/* ─── Buttons ─── */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    padding: 13px 24px; border-radius: var(--radius-md); border: none;
    font-size: 15px; font-weight: 700; letter-spacing: 0.5px;
    transition: background 0.2s, opacity 0.2s;
}
.btn:active { opacity: 0.85; }
.btn-primary {
    background: var(--brand-accent); color: var(--brand-dark);
    box-shadow: none;
}
.btn-primary:active { background: var(--brand-accent-hover); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-warning { background: var(--color-warning); color: #fff; }
.btn-dark { background: var(--brand-dark); color: var(--text-on-dark); }
.btn-disabled {
    background: #d6e4ed; color: var(--text-muted);
    cursor: default; box-shadow: none;
}
.btn-block { width: 100%; }

/* ─── Forms ─── */
.input-dark {
    width: 100%; padding: 12px 14px; border-radius: var(--radius-md);
    border: 1px solid var(--border-medium); background: var(--bg-card);
    color: var(--text-primary); font-size: 15px; outline: none;
    box-sizing: border-box;
}
.input-dark:focus { border-color: var(--brand-primary); }
.input-pin {
    font-size: 20px; font-weight: 700; letter-spacing: 10px;
    text-align: center; padding-right: 44px;
}
.label-dark {
    display: block; text-align: left; color: var(--text-secondary);
    font-size: 11px; font-weight: 700; margin-bottom: 8px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

/* ─── Top Bar ─── */
.topbar {
    background: var(--brand-dark); padding: 12px 14px;
    display: flex; align-items: center; gap: 10px;
}
.topbar-title { color: var(--text-on-dark); font-size: 14px; font-weight: 700; }
.topbar-sub { color: var(--text-muted); font-size: 10px; }
.topbar-back {
    background: none; border: none; color: var(--brand-accent);
    font-size: 20px; padding: 4px; text-decoration: none;
}

/* ─── Tab Switcher ─── */
.tab-bar {
    display: flex; gap: 3px; background: var(--bg-card);
    border-radius: var(--radius-md); padding: 3px;
    border: 1px solid var(--border-light);
}
.tab-btn {
    flex: 1; padding: 8px 0; border-radius: 6px; border: none;
    font-size: 12px; font-weight: 700; background: transparent;
    color: var(--text-muted);
}
.tab-btn.active {
    background: var(--brand-dark); color: var(--text-on-dark);
}

/* ─── Stat Cards Grid ─── */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stat-card {
    background: var(--bg-card); border-radius: var(--radius-md);
    padding: 12px 6px; text-align: center;
    border: 1px solid var(--border-light);
}
.stat-value {
    font-size: 22px; font-weight: 800;
    font-family: 'Roboto Mono', 'SF Mono', monospace;
    color: var(--brand-primary);
}
.stat-label { font-size: 10px; color: var(--text-secondary); margin-top: 1px; }

/* ─── Flash Messages ─── */
.flash-error {
    color: var(--color-error); font-size: 12px; font-weight: 600;
    margin-bottom: 10px; text-align: left;
}

/* ─── Monospace ─── */
.mono { font-family: 'Roboto Mono', 'SF Mono', 'Menlo', monospace; }

/* ─── Warning Banner ─── */
.warning-bar {
    background: #fff8e1; border: 1px solid #ffe082;
    border-radius: var(--radius-md); padding: 10px;
    display: flex; gap: 6px; align-items: flex-start;
    font-size: 11px; color: #e65100; line-height: 1.4;
}

/* ─── Bottom Navigation ─── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    display: flex; justify-content: space-around;
    background: var(--brand-dark);
    border-top: 1px solid rgba(196,214,0,0.15);
    padding: 6px 0 env(safe-area-inset-bottom, 8px);
    z-index: 100;
}
/* Both nav themes now use the same dark style */
.nav-dark, .nav-light {
    background: var(--brand-dark);
    border-top: 1px solid rgba(196,214,0,0.15);
}
.bottom-nav-item {
    display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 16px; border-radius: var(--radius-md);
    text-decoration: none; font-size: 10px; font-weight: 700;
    color: var(--text-muted); transition: color 0.15s;
}
.nav-dark .bottom-nav-item,
.nav-light .bottom-nav-item { color: var(--text-muted); }
.nav-dark .bottom-nav-item.active,
.nav-light .bottom-nav-item.active { color: var(--brand-accent); }
.has-bottom-nav::after {
    content: '';
    display: block;
    height: 80px;
    height: calc(80px + env(safe-area-inset-bottom, 0px));
}

/* ─── Plate Buttons ─── */
.plate-btn {
    padding: 8px 14px; border-radius: var(--radius-md);
    border: 1px solid var(--border-medium); background: var(--bg-card);
    font-size: 13px; font-weight: 700; color: var(--text-primary);
    cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.plate-btn.selected {
    border-color: var(--brand-primary); background: #e3f2fd;
    color: var(--brand-primary);
}
.plate-badge {
    display: inline-block; padding: 2px 8px; border-radius: var(--radius-sm);
    background: var(--brand-dark); color: var(--brand-accent);
    font-size: 11px; font-weight: 800; font-family: 'Roboto Mono', monospace;
    letter-spacing: 1px;
}

/* ─── Responsive ─── */
@media (max-width: 375px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
