@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=DM+Mono:wght@400;500&display=swap');

/* ═══════════════════════════════════════
   DESIGN TOKENS
   ═══════════════════════════════════════ */
:root {
    /* Typography */
    --font: 'Plus Jakarta Sans', -apple-system, sans-serif;
    --mono: 'DM Mono', 'Fira Code', monospace;

    /* Colors — Refined palette */
    --bg-primary: #fafbfc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f4f5f7;
    --bg-hover: #f0f1f3;
    --bg-active: #ebedf0;

    --border-light: #ebedf0;
    --border-default: #d8dbe0;
    --border-strong: #c1c5cc;

    --text-primary: #1a1d23;
    --text-secondary: #5c6370;
    --text-tertiary: #8b919a;
    --text-inverse: #ffffff;

    /* Accent */
    --accent: #5b5fc7;
    --accent-hover: #4b4fbd;
    --accent-light: #eff0fc;
    --accent-border: #c8caef;

    /* Semantic */
    --success: #2da44e;
    --success-light: #dafbe1;
    --warning: #d4a72c;
    --warning-light: #fdf4dc;
    --danger: #cf222e;
    --danger-light: #ffebe9;
    --info: #0969da;
    --info-light: #ddf4ff;

    /* Spacing — 4px base */
    --sp-1: 4px;  --sp-2: 8px;  --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px; --sp-10: 40px;
    --sp-12: 48px;

    /* Layout */
    --sidebar-w: 248px;
    --topbar-h: 56px;
    --radius-sm: 6px;
    --radius: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(27,31,36,.04);
    --shadow-sm: 0 1px 3px rgba(27,31,36,.06), 0 1px 2px rgba(27,31,36,.04);
    --shadow-md: 0 4px 12px rgba(27,31,36,.08);
    --shadow-lg: 0 8px 24px rgba(27,31,36,.12);
    --shadow-focus: 0 0 0 3px rgba(91,95,199,.15);
}

/* ═══════════════════════════════════════
   RESET + BASE
   ═══════════════════════════════════════ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 14px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body { font-family: var(--font); color: var(--text-primary); background: var(--bg-primary); line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent); color: var(--text-inverse); }
img { max-width: 100%; }

/* ═══════════════════════════════════════
   ICONS
   ═══════════════════════════════════════ */
.icon { display: inline-block; vertical-align: middle; flex-shrink: 0; }

/* ═══════════════════════════════════════
   AUTH LAYOUT
   ═══════════════════════════════════════ */
.auth-shell {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: var(--sp-6);
    background: linear-gradient(145deg, #1a1d23 0%, #2d3140 50%, #3d4260 100%);
}
.auth-card {
    background: var(--bg-secondary); border-radius: var(--radius-xl);
    padding: var(--sp-10); width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg), 0 40px 80px rgba(0,0,0,.2);
}
.auth-brand {
    text-align: center; margin-bottom: var(--sp-8);
}
.auth-brand h1 {
    font-size: 1.5rem; font-weight: 800; color: var(--accent); letter-spacing: -0.5px;
    display: flex; align-items: center; justify-content: center; gap: var(--sp-2);
}
.auth-brand p {
    color: var(--text-tertiary); font-size: 0.85rem; margin-top: var(--sp-1);
}

/* ═══════════════════════════════════════
   APP LAYOUT — Sidebar
   ═══════════════════════════════════════ */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-w); background: var(--text-primary);
    position: fixed; top: 0; left: 0; bottom: 0;
    overflow-y: auto; z-index: 100;
    display: flex; flex-direction: column;
    transition: transform 0.2s ease;
}
.sidebar-brand {
    padding: var(--sp-5) var(--sp-5);
    border-bottom: 1px solid rgba(255,255,255,.06);
    display: flex; align-items: center; gap: var(--sp-2);
    font-size: 1.05rem; font-weight: 800; color: #fff;
    letter-spacing: -0.3px;
}
.sidebar-brand .icon { color: var(--accent); }

.sidebar-nav { padding: var(--sp-3) 0; flex: 1; }
.nav-group-label {
    padding: var(--sp-5) var(--sp-5) var(--sp-2);
    font-size: 0.65rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 1.2px; color: rgba(255,255,255,.2);
}
.nav-link {
    display: flex; align-items: center; gap: var(--sp-3);
    padding: var(--sp-2) var(--sp-5); margin: 1px var(--sp-2);
    border-radius: var(--radius-sm); color: rgba(255,255,255,.5);
    font-size: 0.85rem; font-weight: 500;
    transition: all 0.12s ease; cursor: pointer;
    text-decoration: none !important;
}
.nav-link:hover {
    background: rgba(255,255,255,.06); color: rgba(255,255,255,.85);
}
.nav-link.active {
    background: rgba(91,95,199,.2); color: #fff; font-weight: 600;
}
.nav-link .icon { opacity: 0.6; }
.nav-link.active .icon { opacity: 1; color: #a5a8f3; }

/* ═══════════════════════════════════════
   APP LAYOUT — Main area
   ═══════════════════════════════════════ */
.main-area { margin-left: var(--sidebar-w); flex: 1; min-width: 0; }

.topbar {
    height: var(--topbar-h); background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-light);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 var(--sp-6); position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 0.95rem; font-weight: 700; color: var(--text-primary); }
.topbar-actions {
    display: flex; align-items: center; gap: var(--sp-4);
    font-size: 0.82rem; color: var(--text-secondary);
}
.topbar-actions a { color: var(--text-tertiary); font-weight: 500; }
.topbar-actions a:hover { color: var(--danger); text-decoration: none; }
.hamburger {
    display: none; background: none; border: none;
    color: var(--text-primary); cursor: pointer; padding: var(--sp-2);
    border-radius: var(--radius-sm);
}
.hamburger:hover { background: var(--bg-hover); }

.content { padding: var(--sp-6); }

/* ═══════════════════════════════════════
   CARDS
   ═══════════════════════════════════════ */
.card {
    background: var(--bg-secondary); border-radius: var(--radius-lg);
    border: 1px solid var(--border-light); box-shadow: var(--shadow-xs);
    overflow: hidden;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: var(--sp-4) var(--sp-5); border-bottom: 1px solid var(--border-light);
}
.card-title {
    font-size: 0.88rem; font-weight: 700; color: var(--text-primary);
    display: flex; align-items: center; gap: var(--sp-2);
}
.card-body { padding: var(--sp-5); }

/* ═══════════════════════════════════════
   KPI CARDS
   ═══════════════════════════════════════ */
.kpi-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-4); margin-bottom: var(--sp-6);
}
.kpi {
    background: var(--bg-secondary); border-radius: var(--radius-lg);
    padding: var(--sp-5); border: 1px solid var(--border-light);
    box-shadow: var(--shadow-xs); display: flex; gap: var(--sp-4);
    transition: all 0.15s ease;
}
.kpi:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.kpi-icon {
    width: 40px; height: 40px; border-radius: var(--radius);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.kpi-icon.blue    { background: var(--info-light); color: var(--info); }
.kpi-icon.green   { background: var(--success-light); color: var(--success); }
.kpi-icon.amber   { background: var(--warning-light); color: var(--warning); }
.kpi-icon.red     { background: var(--danger-light); color: var(--danger); }
.kpi-icon.violet  { background: var(--accent-light); color: var(--accent); }
.kpi-label { font-size: 0.75rem; color: var(--text-tertiary); font-weight: 500; }
.kpi-value {
    font-size: 1.35rem; font-weight: 800; color: var(--text-primary);
    letter-spacing: -0.5px; margin: 2px 0;
}
.kpi-sub { font-size: 0.7rem; color: var(--text-tertiary); }

/* ═══════════════════════════════════════
   TABLES
   ═══════════════════════════════════════ */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    background: var(--bg-tertiary); padding: var(--sp-3) var(--sp-4);
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.5px; color: var(--text-tertiary);
    text-align: left; border-bottom: 1px solid var(--border-light);
    white-space: nowrap;
}
tbody td {
    padding: var(--sp-3) var(--sp-4); border-bottom: 1px solid var(--border-light);
    font-size: 0.85rem; vertical-align: middle;
}
tbody tr { transition: background 0.1s ease; }
tbody tr:hover { background: var(--bg-tertiary); }
.table-empty {
    text-align: center; color: var(--text-tertiary);
    padding: var(--sp-12) var(--sp-4) !important;
}
.td-mono { font-family: var(--mono); font-size: 0.78rem; color: var(--accent); }

/* ═══════════════════════════════════════
   BADGES
   ═══════════════════════════════════════ */
.badge {
    display: inline-flex; align-items: center;
    padding: 2px 10px; border-radius: 99px;
    font-size: 0.7rem; font-weight: 600; white-space: nowrap;
    line-height: 1.6;
}
.bg-emerald { background: var(--success-light); color: #1a7f37; }
.bg-amber   { background: var(--warning-light); color: #9a6700; }
.bg-red     { background: var(--danger-light);  color: #cf222e; }
.bg-blue    { background: var(--info-light);    color: #0550ae; }
.bg-indigo  { background: #e8e8fd; color: #4338ca; }
.bg-violet  { background: #f3e8ff; color: #7c3aed; }
.bg-sky     { background: #e0f2fe; color: #0284c7; }
.bg-rose    { background: #ffe4e6; color: #be123c; }
.bg-slate   { background: var(--bg-tertiary); color: var(--text-secondary); }

/* ═══════════════════════════════════════
   BUTTONS
   ═══════════════════════════════════════ */
.btn {
    display: inline-flex; align-items: center; gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4); border-radius: var(--radius-sm);
    font-size: 0.82rem; font-weight: 600; font-family: var(--font);
    cursor: pointer; border: none; transition: all 0.12s ease;
    text-decoration: none !important; white-space: nowrap;
    line-height: 1.5;
}
.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: var(--text-inverse); }
.btn-primary:hover { background: var(--accent-hover); box-shadow: var(--shadow-sm); }

.btn-success { background: var(--success); color: var(--text-inverse); }
.btn-success:hover { background: #2c974b; }

.btn-danger  { background: var(--danger); color: var(--text-inverse); }
.btn-danger:hover { background: #a40e26; }

.btn-warning { background: var(--warning); color: var(--text-inverse); }
.btn-info    { background: var(--info); color: var(--text-inverse); }

.btn-outline {
    background: var(--bg-secondary); border: 1px solid var(--border-default);
    color: var(--text-secondary);
}
.btn-outline:hover { background: var(--bg-tertiary); border-color: var(--border-strong); color: var(--text-primary); }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-sm { padding: 4px var(--sp-3); font-size: 0.75rem; border-radius: var(--radius-sm); }
.btn-lg { padding: var(--sp-3) var(--sp-6); font-size: 0.92rem; }
.btn-block { width: 100%; justify-content: center; }

/* ═══════════════════════════════════════
   FORMS
   ═══════════════════════════════════════ */
.form-group { margin-bottom: var(--sp-4); }
.form-label {
    display: block; font-size: 0.78rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: var(--sp-1);
}
.form-control {
    width: 100%; padding: var(--sp-2) var(--sp-3);
    border: 1px solid var(--border-default); border-radius: var(--radius-sm);
    font-size: 0.85rem; font-family: var(--font);
    color: var(--text-primary); background: var(--bg-secondary);
    transition: all 0.12s ease; line-height: 1.5;
}
.form-control:focus {
    outline: none; border-color: var(--accent);
    box-shadow: var(--shadow-focus);
}
.form-control::placeholder { color: var(--text-tertiary); }
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 72px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-4); }
.form-hint { font-size: 0.72rem; color: var(--text-tertiary); margin-top: 2px; }

/* ═══════════════════════════════════════
   FLASH MESSAGES
   ═══════════════════════════════════════ */
.flash-wrap { margin-bottom: var(--sp-5); }
.flash {
    padding: var(--sp-3) var(--sp-4); border-radius: var(--radius);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.85rem; font-weight: 500; margin-bottom: var(--sp-2);
    animation: slideDown 0.25s ease;
}
.flash-success { background: var(--success-light); color: #1a7f37; border: 1px solid #aceebb; }
.flash-error   { background: var(--danger-light);  color: #cf222e; border: 1px solid #ffcecb; }
.flash-info    { background: var(--info-light);    color: #0550ae; border: 1px solid #b6d7ff; }
.flash-close {
    background: none; border: none; font-size: 1.1rem;
    cursor: pointer; opacity: 0.5; padding: 0 4px;
}
.flash-close:hover { opacity: 1; }
@keyframes slideDown { from { transform: translateY(-8px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ═══════════════════════════════════════
   PAGINATION
   ═══════════════════════════════════════ */
.pagination {
    display: flex; align-items: center; justify-content: center;
    gap: 2px; padding: var(--sp-4);
}
.pagination a, .pagination span {
    padding: var(--sp-1) var(--sp-3); border-radius: var(--radius-sm);
    font-size: 0.8rem; font-weight: 500;
}
.pagination a {
    color: var(--text-secondary); border: 1px solid var(--border-light);
}
.pagination a:hover { background: var(--bg-hover); text-decoration: none; }
.pagination .active { background: var(--accent); color: var(--text-inverse); }

/* ═══════════════════════════════════════
   ADMIN / DELIVERY LAYOUTS
   ═══════════════════════════════════════ */
.admin-bar {
    background: var(--text-primary); padding: var(--sp-4) var(--sp-8);
    display: flex; align-items: center; justify-content: space-between; color: #fff;
}
.admin-bar h1 { font-size: 0.95rem; font-weight: 700; display: flex; align-items: center; gap: var(--sp-2); }
.admin-bar a { color: rgba(255,255,255,.5); font-size: 0.82rem; }
.admin-bar a:hover { color: #fff; }
.admin-body { max-width: 1200px; margin: 0 auto; padding: var(--sp-6); }

.tab-bar { display: flex; gap: 0; border-bottom: 2px solid var(--border-light); margin-bottom: var(--sp-6); }
.tab {
    padding: var(--sp-3) var(--sp-6); font-size: 0.85rem; font-weight: 600;
    color: var(--text-tertiary); border-bottom: 2px solid transparent;
    margin-bottom: -2px; text-decoration: none !important; transition: all 0.12s;
}
.tab:hover { color: var(--text-primary); }
.tab.active { color: var(--accent); border-bottom-color: var(--accent); }

.del-bar {
    background: linear-gradient(135deg, #065f46, #047857);
    padding: var(--sp-4) var(--sp-6); display: flex; align-items: center;
    justify-content: space-between; color: #fff;
}
.del-bar h1 { font-size: 0.95rem; font-weight: 700; }
.del-bar a { color: rgba(255,255,255,.6); font-size: 0.82rem; }
.del-bar a:hover { color: #fff; }
.del-nav {
    background: var(--bg-secondary); border-bottom: 1px solid var(--border-light);
    padding: 0 var(--sp-6); display: flex;
}
.del-nav a {
    padding: var(--sp-3) var(--sp-5); font-size: 0.82rem; font-weight: 600;
    color: var(--text-tertiary); border-bottom: 2px solid transparent;
    text-decoration: none !important;
}
.del-nav a:hover { color: var(--text-primary); }
.del-nav a.active { color: #047857; border-bottom-color: #047857; }
.del-body { max-width: 900px; margin: 0 auto; padding: var(--sp-6); }

.mission-card {
    background: var(--bg-secondary); border: 1px solid var(--border-light);
    border-radius: var(--radius-lg); padding: var(--sp-5);
    margin-bottom: var(--sp-3); box-shadow: var(--shadow-xs);
    transition: all 0.15s ease;
}
.mission-card:hover { box-shadow: var(--shadow-md); border-color: var(--accent-border); }

/* ═══════════════════════════════════════
   PRINT STYLES
   ═══════════════════════════════════════ */
.print-doc { max-width: 800px; margin: 0 auto; padding: var(--sp-8); background: #fff; }
.print-header {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: var(--sp-8); padding-bottom: var(--sp-5);
    border-bottom: 3px solid var(--accent);
}
.print-title { font-size: 1.5rem; font-weight: 800; color: var(--accent); }
.print-doc table { width: 100%; border-collapse: collapse; margin: var(--sp-4) 0; }
.print-doc th {
    background: var(--bg-tertiary); padding: var(--sp-2) var(--sp-3);
    font-size: 0.75rem; font-weight: 600; text-align: left;
    border: 1px solid var(--border-default);
}
.print-doc td { padding: var(--sp-2) var(--sp-3); border: 1px solid var(--border-light); }
.barcode-area {
    text-align: center; margin: var(--sp-5) 0;
    padding: var(--sp-5); border: 1px dashed var(--border-default);
    border-radius: var(--radius);
}

/* ═══════════════════════════════════════
   TRIAL BANNER
   ═══════════════════════════════════════ */
.trial-banner {
    background: linear-gradient(135deg, var(--accent), #4338ca);
    color: #fff; padding: var(--sp-3) var(--sp-5);
    border-radius: var(--radius-lg); margin-bottom: var(--sp-5);
    display: flex; align-items: center; justify-content: space-between;
    font-size: 0.85rem; gap: var(--sp-4);
}
.trial-banner strong { font-weight: 700; }
.trial-banner .btn { background: rgba(255,255,255,.2); color: #fff; border: none; }
.trial-banner .btn:hover { background: rgba(255,255,255,.3); }

/* ═══════════════════════════════════════
   UTILITIES
   ═══════════════════════════════════════ */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }
.wrap { flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-5); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-4 { margin-top: var(--sp-6); }
.mt-2 { margin-top: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-6); }
.mb-3 { margin-bottom: var(--sp-4); }
.text-sm { font-size: 0.78rem; }
.text-xs { font-size: 0.7rem; }
.text-muted { color: var(--text-tertiary); }
.text-accent { color: var(--accent); }
.font-mono { font-family: var(--mono); }
.font-bold { font-weight: 700; }
code {
    font-family: var(--mono); background: var(--bg-tertiary);
    padding: 1px 6px; border-radius: 4px; font-size: 0.8rem;
    color: var(--accent);
}

/* ═══════════════════════════════════════
   PRINT OVERRIDES
   ═══════════════════════════════════════ */
@media print {
    body { background: #fff !important; }
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    .sidebar, .topbar, .hamburger, .flash-wrap { display: none !important; }
    .main-area { margin: 0 !important; }
    .content { padding: 0 !important; }
}
.print-only { display: none; }

/* ═══════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════ */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .hamburger { display: block; }
    .form-row, .grid-2 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .content, .admin-body, .del-body { padding: var(--sp-4); }
    .topbar { padding: 0 var(--sp-4); }
}
@media (max-width: 480px) {
    .kpi-grid { grid-template-columns: 1fr; }
}
.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.confirm-modal.show {
    display: flex;
}

.confirm-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(4px);
}

.confirm-modal-box {
    position: relative;
    width: min(100%, 420px);
    background: #fff;
    border: 1px solid rgba(0,0,0,.08);
    border-radius: 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.20);
    padding: 20px;
    z-index: 1;
    animation: confirmPop .18s ease;
}

.confirm-modal-title {
    font-size: 1.05rem;
    font-weight: 700;
    margin-bottom: 8px;
    color: #0f172a;
}

.confirm-modal-text {
    font-size: .95rem;
    color: #475569;
    line-height: 1.5;
    margin-bottom: 18px;
}

.confirm-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes confirmPop {
    from { opacity: 0; transform: translateY(8px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
