/*
 * DistriGo ERP - Unified Design System & CSS Component Library
 *
 * TOKENS:
 *   --space-1..8: 4px, 8px, 12px, 16px, 20px, 24px, 32px, 40px
 *   --radius-sm/radius/radius-lg: 6px, 10px, 14px
 *   --shadow-sm/md/lg: elevation shadows
 *   --fs-xs..xl: 12px, 13px, 14px, 16px, 20px, 26px
 *   --content-max: 1440px | --sidebar-w: 260px | --topbar-h: 60px
 *
 * COMPONENTS:
 *   .page, .page-header, .page-title, .page-subtitle, .page-toolbar
 *   .grid-2, .grid-3, .grid-4, .split-2-1
 *   .card, .card-header, .card-body, .card-footer
 *   .stat-card, .stat-label, .stat-value, .stat-meta, .stat-icon
 *   .btn, .btn-sm, .btn-lg, .btn-primary, .btn-secondary, .btn-ghost, .btn-danger, .btn-success, .btn-icon
 *   .badge, .badge-success, .badge-warning, .badge-danger, .badge-info, .badge-neutral, .badge-violet
 *   .empty-state, .loading-state, .error-state, .skeleton
 */

:root {
    /* Brand & Surface Tokens */
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #f8fafc;
    --secondary-hover: #f1f5f9;
    --bg-color: #f8fafc;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --hover: #f1f5f9;
    --line: #e2e8f0;
    --line-strong: #cbd5e1;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --faint: #94a3b8;

    /* Status & Palette Tints */
    --c-sky: #0284c7;
    --c-green: #16a34a;
    --c-amber: #d97706;
    --c-red: #dc2626;
    --c-violet: #7c3aed;
    --c-indigo: #4f46e5;

    /* Soft Card Colour Theme (Prompt D2) */
    --card-sage-bg: #EAF3EA;
    --card-sage-border: #CFE3CF;
    --card-sage-text: #2F5D3A;
    --card-sage-icon-bg: #DCEBDC;

    --card-duck-bg: #E6F2F4;
    --card-duck-border: #C7E0E5;
    --card-duck-text: #2B5F6B;
    --card-duck-icon-bg: #D5E9ED;

    --card-butter-bg: #FBF3DC;
    --card-butter-border: #F0E1B0;
    --card-butter-text: #7A5C12;
    --card-butter-icon-bg: #F6E8C2;

    --card-blush-bg: #FBEAEA;
    --card-blush-border: #F2CFCF;
    --card-blush-text: #8A3B3B;
    --card-blush-icon-bg: #F6D8D8;

    --card-lav-bg: #EEEAF6;
    --card-lav-border: #D9D1EA;
    --card-lav-text: #4F3F7A;
    --card-lav-icon-bg: #E2DBEE;

    --card-stone-bg: #F2F0EB;
    --card-stone-border: #E0DCD2;
    --card-stone-text: #4A463E;
    --card-stone-icon-bg: #E6E2D8;

    --card-label-muted: #5B5B55;

    /* Spacing Scale */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-7: 32px;
    --space-8: 40px;

    /* Radii */
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;

    /* Elevation Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);

    /* Typography Scale */
    --fs-xs: 12px;
    --fs-sm: 13px;
    --fs-base: 14px;
    --fs-md: 16px;
    --fs-lg: 20px;
    --fs-xl: 26px;

    /* Layout Constraints */
    --content-max: 1440px;
    --sidebar-w: 260px;
    --topbar-h: 80px;
    --emb-bg:#e8edf5;
    --emb-bg-hi:#edf1f8;
    --emb-bg-lo:#e6ebf4;
    --emb-shadow-dark:#c5cbd8;
    --emb-shadow-dark-in:#c3c9d7;
    --emb-shadow-light:#ffffff;
    --logo-h:46px;
    --accent-bg: #eaf1ff;
    --accent-line: #dce8ff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--ink);
    font-size: var(--fs-base);
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    color: var(--ink);
    font-weight: 700;
    line-height: 1.3;
}

/* Page Layout Wrappers */
.page {
    max-width: var(--content-max);
    margin: 0 auto;
    width: 100%;
    min-width: 0;
    padding: var(--space-6);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-6);
    flex-wrap: wrap;
    gap: var(--space-4);
}

.page-title {
    font-size: var(--fs-xl);
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin: 0 0 var(--space-1) 0;
}

.page-subtitle {
    font-size: var(--fs-base);
    color: var(--muted);
    margin: 0;
}

.page-toolbar {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: var(--space-3) var(--space-4);
    margin-bottom: var(--space-5);
    box-shadow: var(--shadow-sm);
}

/* Responsive Grids */
.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-4);
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--space-4);
}

.grid-4 {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: var(--space-4);
}

.split-2-1 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--space-5);
}

@media (max-width: 1199px) {
    .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1100px) {
    .split-2-1 { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 639px) {
    .grid-4 { grid-template-columns: minmax(0, 1fr); }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
}

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--line);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-body {
    padding: var(--space-5);
}

.card-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Stat, KPI & Summary Cards (Prompt D2) */
.stat-card,
.kpi-card,
.summary-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.stat-label,
.kpi-label {
    font-size: var(--fs-sm);
    font-weight: 500;
    color: var(--card-label-muted);
    margin-bottom: var(--space-2);
}

.stat-value,
.kpi-value {
    font-size: var(--fs-xl);
    font-weight: 800;
    color: var(--ink);
    letter-spacing: -0.02em;
}

.stat-meta,
.kpi-meta {
    font-size: var(--fs-xs);
    color: var(--card-label-muted);
    margin-top: var(--space-2);
}

.stat-icon,
.kpi-icon {
    width: 40px;
    height: 40px;
    min-width: 40px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-md);
    background: var(--surface-2);
    color: var(--ink);
    flex-shrink: 0;
}

/* Soft Card Tone Modifiers */
.card-tone-sage {
    background-color: var(--card-sage-bg);
    border-color: var(--card-sage-border);
}
.card-tone-sage .stat-value,
.card-tone-sage .kpi-value,
.card-tone-sage [id^="kpi-"],
.card-tone-sage [id^="dash-"],
.card-tone-sage [id^="sum-"],
.card-tone-sage [id^="stat-"] {
    color: var(--card-sage-text);
}
.card-tone-sage .stat-icon,
.card-tone-sage .kpi-icon {
    background-color: var(--card-sage-icon-bg);
    color: var(--card-sage-text);
}

.card-tone-duck {
    background-color: var(--card-duck-bg);
    border-color: var(--card-duck-border);
}
.card-tone-duck .stat-value,
.card-tone-duck .kpi-value,
.card-tone-duck [id^="kpi-"],
.card-tone-duck [id^="dash-"],
.card-tone-duck [id^="sum-"],
.card-tone-duck [id^="stat-"] {
    color: var(--card-duck-text);
}
.card-tone-duck .stat-icon,
.card-tone-duck .kpi-icon {
    background-color: var(--card-duck-icon-bg);
    color: var(--card-duck-text);
}

.card-tone-butter {
    background-color: var(--card-butter-bg);
    border-color: var(--card-butter-border);
}
.card-tone-butter .stat-value,
.card-tone-butter .kpi-value,
.card-tone-butter [id^="kpi-"],
.card-tone-butter [id^="dash-"],
.card-tone-butter [id^="sum-"],
.card-tone-butter [id^="stat-"] {
    color: var(--card-butter-text);
}
.card-tone-butter .stat-icon,
.card-tone-butter .kpi-icon {
    background-color: var(--card-butter-icon-bg);
    color: var(--card-butter-text);
}

.card-tone-blush {
    background-color: var(--card-blush-bg);
    border-color: var(--card-blush-border);
}
.card-tone-blush .stat-value,
.card-tone-blush .kpi-value,
.card-tone-blush [id^="kpi-"],
.card-tone-blush [id^="dash-"],
.card-tone-blush [id^="sum-"],
.card-tone-blush [id^="stat-"] {
    color: var(--card-blush-text);
}
.card-tone-blush .stat-icon,
.card-tone-blush .kpi-icon {
    background-color: var(--card-blush-icon-bg);
    color: var(--card-blush-text);
}

.card-tone-lav {
    background-color: var(--card-lav-bg);
    border-color: var(--card-lav-border);
}
.card-tone-lav .stat-value,
.card-tone-lav .kpi-value,
.card-tone-lav [id^="kpi-"],
.card-tone-lav [id^="dash-"],
.card-tone-lav [id^="sum-"],
.card-tone-lav [id^="stat-"] {
    color: var(--card-lav-text);
}
.card-tone-lav .stat-icon,
.card-tone-lav .kpi-icon {
    background-color: var(--card-lav-icon-bg);
    color: var(--card-lav-text);
}

.card-tone-stone {
    background-color: var(--card-stone-bg);
    border-color: var(--card-stone-border);
}
.card-tone-stone .stat-value,
.card-tone-stone .kpi-value,
.card-tone-stone [id^="kpi-"],
.card-tone-stone [id^="dash-"],
.card-tone-stone [id^="sum-"],
.card-tone-stone [id^="stat-"] {
    color: var(--card-stone-text);
}
.card-tone-stone .stat-icon,
.card-tone-stone .kpi-icon {
    background-color: var(--card-stone-icon-bg);
    color: var(--card-stone-text);
}

/* Backward compatibility for legacy is-* classes */
.stat-card.is-success:not([class*="card-tone-"]) { background-color: var(--card-sage-bg); border-color: var(--card-sage-border); }
.stat-card.is-success:not([class*="card-tone-"]) .stat-value { color: var(--card-sage-text); }
.stat-card.is-info:not([class*="card-tone-"]) { background-color: var(--card-duck-bg); border-color: var(--card-duck-border); }
.stat-card.is-info:not([class*="card-tone-"]) .stat-value { color: var(--card-duck-text); }
.stat-card.is-warning:not([class*="card-tone-"]) { background-color: var(--card-butter-bg); border-color: var(--card-butter-border); }
.stat-card.is-warning:not([class*="card-tone-"]) .stat-value { color: var(--card-butter-text); }
.stat-card.is-danger:not([class*="card-tone-"]) { background-color: var(--card-blush-bg); border-color: var(--card-blush-border); }
.stat-card.is-danger:not([class*="card-tone-"]) .stat-value { color: var(--card-blush-text); }
.stat-card.is-primary:not([class*="card-tone-"]) { background-color: var(--card-lav-bg); border-color: var(--card-lav-border); }
.stat-card.is-primary:not([class*="card-tone-"]) .stat-value { color: var(--card-lav-text); }

/* Clickable KPI / Stat / Summary Cards (Prompt D1 / D2) */
.stat-card.is-clickable,
.kpi-card.is-clickable,
.summary-card.is-clickable,
[role="link"].stat-card,
[role="link"].kpi-card,
[role="link"].summary-card {
    cursor: pointer;
    position: relative;
    user-select: none;
}

.stat-card.is-clickable:hover,
.kpi-card.is-clickable:hover,
.summary-card.is-clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.card-tone-sage.is-clickable:hover { border-color: #9EC79E; }
.card-tone-duck.is-clickable:hover { border-color: #8EBFC9; }
.card-tone-butter.is-clickable:hover { border-color: #E2C779; }
.card-tone-blush.is-clickable:hover { border-color: #DE9E9E; }
.card-tone-lav.is-clickable:hover { border-color: #B5A4D3; }
.card-tone-stone.is-clickable:hover { border-color: #C2BAA8; }

.stat-card.is-clickable:focus-visible,
.kpi-card.is-clickable:focus-visible,
.summary-card.is-clickable:focus-visible {
    outline: 2px solid var(--primary, #2563eb);
    outline-offset: 2px;
}

.kpi-drilldown-arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 6px;
    font-size: 13px;
    color: var(--muted);
    transition: transform 0.15s ease, color 0.15s ease;
}

.stat-card.is-clickable:hover .kpi-drilldown-arrow,
.kpi-card.is-clickable:hover .kpi-drilldown-arrow {
    color: var(--c-sky, #0284c7);
    transform: translateX(3px);
}

/* Filter Chip (Prompt D1) */
.filter-active-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(2, 132, 199, 0.12);
    color: var(--c-sky, #0284c7);
    border: 1px solid rgba(2, 132, 199, 0.3);
    padding: 4px 10px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
}

.filter-active-chip .chip-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    padding: 0 2px;
}

.filter-active-chip .chip-close:hover {
    color: var(--c-red, #dc2626);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: inherit;
    font-size: var(--fs-base);
    font-weight: 600;
    height: 38px;
    padding: 0 var(--space-4);
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    white-space: nowrap;
}

.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.25);
}

.btn:disabled, .btn.is-loading {
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-sm { height: 32px; padding: 0 var(--space-3); font-size: var(--fs-sm); }
.btn-lg { height: 44px; padding: 0 var(--space-6); font-size: var(--fs-md); }

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: var(--surface);
    color: var(--ink-2);
    border-color: var(--line-strong);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--muted);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink); }

.btn-danger {
    background: var(--c-red);
    color: #ffffff;
}
.btn-danger:hover { background: #b91c1c; }

.btn-success {
    background: var(--c-green);
    color: #ffffff;
}
.btn-success:hover { background: #15803d; }

.btn-icon {
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    background: transparent;
    border: 1px solid transparent;
    color: var(--muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.btn-icon:hover { background: var(--surface-2); color: var(--ink); }

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-neutral { background: #e2e8f0; color: #475569; }
.badge-success { background: #dcfce7; color: #15803d; }
.badge-warning { background: #fef3c7; color: #b45309; }
.badge-danger { background: #fee2e2; color: #b91c1c; }
.badge-info { background: #e0f2fe; color: #0369a1; }
.badge-violet { background: #f3e8ff; color: #6b21a8; }

/* States */
.empty-state {
    text-align: center;
    padding: var(--space-8) var(--space-5);
    color: var(--muted);
}
.empty-icon { font-size: 48px; color: var(--faint); margin-bottom: var(--space-3); }
.empty-title { font-size: var(--fs-md); color: var(--ink); margin-bottom: var(--space-1); }
.empty-hint { font-size: var(--fs-sm); max-width: 400px; margin: 0 auto var(--space-4) auto; }

.loading-state {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-3);
    padding: var(--space-8);
    color: var(--muted);
    font-size: var(--fs-sm);
}

.error-state {
    text-align: center;
    padding: var(--space-8);
    color: var(--c-red);
}
.error-icon { font-size: 36px; margin-bottom: var(--space-2); }
.error-title { font-size: var(--fs-md); margin-bottom: var(--space-1); }
.error-hint { font-size: var(--fs-sm); color: var(--muted); margin-bottom: var(--space-4); }

.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-sm);
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* App Shell Layout */
.app-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background-color: var(--bg-color);
}

/* Sticky Top Header */
.top-bar {
    position: sticky;
    top: 0;
    z-index: 200;
    background: var(--surface);
    display: flex;
    flex-direction: column;
}

.top-bar.hidden {
    display: none !important;
}

.top-bar-header {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
}

.top-bar-left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
    min-width: 0;
}

.header-logo {
    height: 38px;
    width: auto;
    object-fit: contain;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: var(--fs-lg);
    color: var(--ink);
    cursor: pointer;
}

/* Tile Bar (Desktop) */
.sidebar {
    display: flex;
    justify-content: center;
    flex: 1;
}

.sidebar-header {
    display: none;
}

.sidebar-nav {
    display: flex;
    gap: 4px;
    align-items: center;
}

.nav-group {
    position: relative;
}

.tile-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 58px;
    padding: 5px 8px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    transition: 0.15s;
    text-decoration: none;
    font-family: inherit;
}

.tile-btn:hover {
    background: var(--surface-2);
    border-color: var(--line);
}

.nav-group.active-tile .tile-btn,
.tile-btn.active {
    background: var(--accent-bg);
    border-color: var(--accent-line);
}

.nav-group.active-tile .tile-label,
.tile-btn.active .tile-label {
    color: var(--primary);
    font-weight: 700;
}

.tile-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 13px;
    box-shadow: 0 2px 5px rgba(16, 24, 43, 0.12);
    transition: transform 0.15s;
}

.tile-btn:hover .tile-icon {
    transform: translateY(-1px);
}

.tile-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--ink-2);
    margin-top: 3px;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 3px;
}

.tile-chevron {
    font-size: 7px;
    color: var(--faint);
    transition: transform 0.2s;
}

.nav-group.flyout-open .tile-chevron {
    transform: rotate(180deg);
}

/* Flyout Panels */
.flyout-panel {
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(-6px);
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 12px;
    min-width: 230px;
    z-index: 500;
    box-shadow: 0 14px 36px rgba(16, 24, 43, 0.14), 0 2px 8px rgba(16, 24, 43, 0.06);
    opacity: 0;
    pointer-events: none;
    transition: opacity 150ms, transform 150ms;
}

.nav-group.flyout-open .flyout-panel {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(-50%) translateY(0);
}

.flyout-admin {
    min-width: 440px;
}

.flyout-admin-cols {
    display: grid;
    grid-template-columns: 210px 210px;
    gap: 12px;
}

.flyout-section-title {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
    padding: 4px 8px 6px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 6px;
}

/* Flyout Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    border-radius: 8px;
    text-decoration: none;
    font-size: 12px;
    font-weight: 500;
    color: var(--ink-2);
    white-space: nowrap;
    transition: 0.15s;
    border: none;
}

.nav-item i {
    width: 15px;
    text-align: center;
    font-size: 11px;
    color: var(--muted);
}

.nav-item:hover {
    background: var(--surface-2);
    color: var(--primary);
}

.nav-item:hover i {
    color: var(--primary);
}

.nav-item.active {
    background: var(--accent-bg);
    color: var(--primary);
    font-weight: 600;
}

.nav-item.active i {
    color: var(--primary);
}

.nav-item-badge {
    margin-left: auto;
    background: var(--c-red);
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 9999px;
}

/* Hybrid Tile specific logic */
@media (min-width: 900px) {
    .reports-hybrid-tile.nav-item {
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-width: 58px;
        padding: 5px 8px;
        border-radius: 10px;
        border: 1px solid transparent;
        background: transparent;
        gap: 0;
    }
    .reports-hybrid-tile.nav-item:hover {
        background: var(--surface-2);
        border-color: var(--line);
    }
    .nav-group.active-tile .reports-hybrid-tile.nav-item,
    .reports-hybrid-tile.nav-item.active {
        background: var(--accent-bg);
        border-color: var(--accent-line);
    }
    .nav-group.active-tile .reports-hybrid-tile.nav-item .tile-label,
    .reports-hybrid-tile.nav-item.active .tile-label {
        color: var(--primary);
        font-weight: 700;
    }
    .reports-hybrid-tile.nav-item:hover .tile-icon {
        transform: translateY(-1px);
    }
    .reports-hybrid-tile .mobile-only-flex {
        display: none !important;
    }
    .reports-hybrid-tile .desktop-only-flex {
        display: flex !important;
    }
}

@media (max-width: 899px) {
    .reports-hybrid-tile .desktop-only-flex {
        display: none !important;
    }
    .reports-hybrid-tile .mobile-only-flex {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
    }
}

/* Top Bar Right */
.top-bar-right {
    display: flex;
    align-items: center;
    gap: var(--space-5);
    flex-shrink: 0;
}

.top-bar-date {
    font-size: var(--fs-xs);
    color: var(--muted);
    font-weight: 500;
}

.user-chip {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-1) var(--space-3);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 9999px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-size: var(--fs-xs);
    font-weight: 600;
    color: var(--ink);
}

.user-role {
    font-size: 11px;
    color: var(--muted);
}

.btn-logout-pill {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--c-red);
    color: var(--c-red);
    border-radius: 9999px;
    font-size: var(--fs-xs);
    font-weight: 600;
    cursor: pointer;
    transition: 0.15s;
}

.btn-logout-pill:hover {
    background: rgba(220, 38, 38, 0.1);
}

/* Sub-bar Breadcrumb */
.top-bar-sub {
    height: 36px;
    background: var(--surface-2);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    padding: 0 20px;
}

.breadcrumb {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 12.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bc-section { color: var(--muted); font-weight: 500; }
.bc-sep { color: var(--faint); }
.bc-title { color: var(--ink); font-weight: 600; }

/* Main Content Area */
.main-content {
    flex: 1;
    min-width: 0;
    background-color: var(--bg-color);
    display: flex;
    flex-direction: column;
}

.view-container {
    flex: 1;
    animation: fadeIn 150ms ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Toast Container */
#toast-container {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    z-index: 20000;
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 4px solid var(--primary);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    padding: var(--space-3) var(--space-5);
    color: var(--ink);
    font-size: var(--fs-sm);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    min-width: 280px;
    animation: slideIn 0.2s ease-out;
}

.toast.success { border-left-color: var(--c-green); }
.toast.error { border-left-color: var(--c-red); }
.toast.warning { border-left-color: var(--c-amber); }
.toast.info { border-left-color: var(--c-sky, #0284c7); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Mobile & Tablet Overrides */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1000;
    backdrop-filter: blur(2px);
}

@media (max-width: 1023px) {
    .top-bar-date, .user-name, .user-role {
        display: none;
    }
}

@media (max-width: 899px) {
    .menu-toggle {
        display: block;
    }

    .top-bar-header {
        padding: 0 16px;
    }

    .top-bar-sub {
        padding: 0 16px;
    }

    /* Transform Sidebar into left drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        background: #0f172a;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        justify-content: flex-start;
    }

    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar.open ~ .sidebar-backdrop,
    body:has(.sidebar.open) .sidebar-backdrop {
        display: block;
    }

    .sidebar-header.mobile-only {
        display: flex;
        padding: 20px;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        align-items: center;
        justify-content: center;
    }

    .sidebar-logo {
        height: 40px;
        width: auto;
    }

    .sidebar-nav {
        flex-direction: column;
        align-items: stretch;
        padding: 16px 0;
        gap: 0;
        overflow-y: auto;
    }

    .tile-btn {
        display: none;
    }

    .flyout-panel, .flyout-panel.flyout-admin {
        position: static;
        transform: none;
        box-shadow: none;
        opacity: 1;
        pointer-events: auto;
        background: transparent;
        border: none;
        padding: 0;
        min-width: 0;
        display: flex;
        flex-direction: column;
    }
    
    .nav-section {
        display: block !important;
        padding: 12px 20px;
        font-size: 11px;
        font-weight: 700;
        color: #64748b;
        text-transform: uppercase;
        letter-spacing: 0.05em;
    }

    .flyout-admin-cols {
        display: flex;
        flex-direction: column;
        gap: 0;
    }
    
    .flyout-section-title {
        display: none;
    }

    .nav-item {
        padding: 10px 20px;
        color: #94a3b8;
        border-radius: 0;
        border-left: 3px solid transparent;
        font-size: 14px;
        gap: 12px;
    }

    .nav-item i {
        font-size: 14px;
        color: #64748b;
    }

    .nav-item:hover {
        background: rgba(255, 255, 255, 0.05);
        color: #f8fafc;
    }
    
    .nav-item:hover i {
        color: #f8fafc;
    }

    .nav-item.active {
        background: rgba(79, 70, 229, 0.15);
        color: #818cf8;
        border-left-color: var(--primary);
    }
    
    .nav-item.active i {
        color: #818cf8;
    }
}

/* Form Grid Layout */
.form-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: var(--space-4);
}

.col-12 { grid-column: span 12; }
.col-6  { grid-column: span 6; }
.col-4  { grid-column: span 4; }
.col-3  { grid-column: span 3; }

@media (max-width: 640px) {
    .col-6, .col-4, .col-3 { grid-column: span 12; }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    margin-bottom: var(--space-3);
}

.form-label {
    font-size: var(--fs-sm);
    font-weight: 600;
    color: var(--ink-2);
    display: flex;
    align-items: center;
    gap: 4px;
}

.form-label.is-required::after {
    content: '*';
    color: var(--c-red);
}

.form-control, select.form-control, textarea.form-control,
input[type="text"], input[type="number"], input[type="password"], input[type="email"], input[type="date"], select, textarea {
    width: 100%;
    height: 38px;
    padding: 0 var(--space-3);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-family: inherit;
    font-size: var(--fs-base);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

textarea, textarea.form-control {
    height: auto;
    min-height: 80px;
    padding: var(--space-2) var(--space-3);
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.15);
}

.form-control.is-invalid {
    border-color: var(--c-red);
}

.form-hint {
    font-size: var(--fs-xs);
    color: var(--muted);
}

.form-error {
    font-size: var(--fs-xs);
    color: var(--c-red);
}

/* Modals & Backdrop */
.modal-overlay, .modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.modal-overlay:not(.hidden), .modal-backdrop:not(.hidden), .modal-overlay.is-open {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.modal-overlay.is-open .modal-card, .modal-backdrop:not(.hidden) .modal-card {
    transform: scale(1);
}

.modal-sm { max-width: 420px; }
.modal-md { max-width: 640px; }
.modal-lg { max-width: 900px; }

.modal-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.modal-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Right-side Drawers */
.drawer {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: 560px;
    max-width: 100%;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    border-left: 1px solid var(--line);
    z-index: 950;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.drawer:not(.hidden), .drawer.is-open {
    transform: translateX(0);
}

.drawer-header {
    padding: var(--space-4) var(--space-5);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.drawer-title {
    font-size: var(--fs-lg);
    font-weight: 700;
    color: var(--ink);
    margin: 0;
}

.drawer-body {
    padding: var(--space-5);
    overflow-y: auto;
    flex: 1;
}

.drawer-footer {
    padding: var(--space-4) var(--space-5);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* Data Tables Component */
.table-wrap {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    width: 100%;
}

.table-scroll {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: var(--fs-base);
}

.data-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
    white-space: nowrap;
}

.data-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    height: 48px;
    vertical-align: middle;
}

.data-table tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background-color: var(--hover);
}

.data-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.data-table .mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: var(--fs-sm);
}

.row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-wrap: nowrap;
    white-space: nowrap;
}

.row-btn {
    height: 30px;
    padding: 0 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    cursor: pointer;
    box-sizing: border-box;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    text-decoration: none;
    line-height: 1;
}

.row-btn i {
    font-size: 14px;
}

/* Row button color variants */
.row-btn-neutral-outline {
    background: var(--surface, #ffffff);
    border: 1px solid var(--line-strong, #cbd5e1);
    color: var(--ink-2, #334155);
}
.row-btn-neutral-outline:hover {
    background: var(--surface-2, #f8fafc);
    color: var(--ink, #0f172a);
}

.row-btn-blue-outline {
    background: transparent;
    border: 1px solid var(--c-sky, #0284c7);
    color: var(--c-sky, #0284c7);
}
.row-btn-blue-outline:hover {
    background: rgba(2, 132, 199, 0.08);
}

.row-btn-green-solid {
    background: var(--c-green, #16a34a);
    border: 1px solid var(--c-green, #16a34a);
    color: #ffffff;
}
.row-btn-green-solid:hover {
    background: #15803d;
    border-color: #15803d;
}

.row-btn-blue-solid {
    background: #2563eb;
    border: 1px solid #2563eb;
    color: #ffffff;
}
.row-btn-blue-solid:hover {
    background: #1d4ed8;
    border-color: #1d4ed8;
}

.row-btn-red-outline {
    background: transparent;
    border: 1px solid var(--c-red, #dc2626);
    color: var(--c-red, #dc2626);
}
.row-btn-red-outline:hover {
    background: rgba(220, 38, 38, 0.08);
}

.row-actions .btn-icon.is-danger {
    color: var(--c-red, #dc2626);
}

.row-actions .btn-icon.is-danger:hover {
    background: rgba(220, 38, 38, 0.1);
}

.table-footer {
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: var(--fs-sm);
    color: var(--muted);
}

/* Utilities */
.hidden { display: none !important; }

/* ============================================================
   LOGIN PAGE — Light Neumorphic Design
   ============================================================ */

/* Full-screen wrapper */
.login-view-wrapper {
    min-height: 100vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
    background: #e8ecf1;
}

/* Subtle decorative background blobs (very light) */
.fmcg-bg-animation {
    position: absolute;
    inset: 0;
    overflow: hidden;
    z-index: 0;
    pointer-events: none;
}

.ambient-glow {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.18;
    animation: glow-pulse 10s ease-in-out infinite alternate;
}
.ambient-glow.g1 {
    width: 600px; height: 600px;
    background: radial-gradient(circle, #c7d2fe, transparent);
    top: -160px; left: -120px;
    animation-delay: 0s;
}
.ambient-glow.g2 {
    width: 480px; height: 480px;
    background: radial-gradient(circle, #a5f3fc, transparent);
    bottom: -100px; right: -100px;
    animation-delay: 4s;
}

@keyframes glow-pulse {
    0%   { transform: scale(1); }
    100% { transform: scale(1.12) translate(16px, 8px); }
}

/* Floating FMCG icon particles (very subtle on light bg) */
.fmcg-particle {
    position: absolute;
    font-size: 22px;
    color: #94a3b8;
    opacity: 0.15;
    animation: particle-float linear infinite;
}
.p1  { top: 10%; left: 6%;   animation-duration: 20s; animation-delay: 0s; }
.p2  { top: 70%; left: 10%;  animation-duration: 24s; animation-delay: 2s; }
.p3  { top: 25%; right: 8%;  animation-duration: 18s; animation-delay: 5s; }
.p4  { top: 80%; right: 14%; animation-duration: 22s; animation-delay: 1s; }
.p5  { top: 4%;  right: 28%; animation-duration: 28s; animation-delay: 7s; }
.p6  { top: 50%; left: 38%;  animation-duration: 21s; animation-delay: 3s; }
.p7  { top: 90%; left: 52%;  animation-duration: 19s; animation-delay: 6s; }
.p8  { top: 18%; left: 52%;  animation-duration: 17s; animation-delay: 4s; }

@keyframes particle-float {
    0%   { transform: translateY(0px) rotate(0deg); opacity: 0.12; }
    50%  { opacity: 0.2; }
    100% { transform: translateY(-30px) rotate(360deg); opacity: 0.12; }
}

/* Login card — neumorphic raised panel */
.login-view {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 20px 16px;
}

.neo-card {
    background: #e8ecf1;
    border-radius: 24px;
    padding: 44px 40px 40px;
    /* Neumorphic dual shadow — light top-left, dark bottom-right */
    box-shadow:
        12px 12px 24px #c8cdd6,
        -12px -12px 24px #ffffff;
}

/* Logo / emblem */
.neo-emblem {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

/* Neumorphic logo circle container */
.neo-emblem-inner {
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: #e8ecf1;
    box-shadow:
        6px 6px 14px #c4c9d4,
        -6px -6px 14px #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
}

.distrigo-logo-img {
    height: 110px;
    width: auto;
    object-fit: contain;
}

/* Card typography */
.neo-title {
    font-family: 'Inter', sans-serif;
    font-size: 22px;
    font-weight: 800;
    color: #1e293b;
    text-align: center;
    margin: 0 0 6px;
    letter-spacing: -0.3px;
}

.neo-sub {
    font-size: 15px;
    font-weight: 500;
    color: #334155;
    text-align: center;
    margin-bottom: 32px;
    line-height: 1.55;
}

/* Form fields */
.neo-card .form-group {
    margin-bottom: 20px;
}

.neo-card label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.neo-input-wrap {
    position: relative;
}

.neo-input-wrap .input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
    font-size: 13px;
    pointer-events: none;
    z-index: 1;
}

/* Neumorphic inset input fields */
.neo-card input[type="text"],
.neo-card input[type="password"] {
    width: 100%;
    height: 48px;
    padding: 0 16px 0 42px;
    background: #e8ecf1;
    border: none;
    border-radius: 12px;
    color: #1e293b;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 500;
    /* Inset neumorphic shadow */
    box-shadow:
        inset 4px 4px 8px #c4c9d4,
        inset -4px -4px 8px #ffffff;
    transition: box-shadow 0.2s ease;
    outline: none;
    -webkit-appearance: none;
}

.neo-card input::placeholder {
    color: #a0aec0;
    font-weight: 400;
}

.neo-card input:focus {
    box-shadow:
        inset 4px 4px 8px #c4c9d4,
        inset -4px -4px 8px #ffffff,
        0 0 0 2px rgba(99, 102, 241, 0.35);
}

/* Divider */
.neo-divider {
    height: 1px;
    background: linear-gradient(to right, transparent, #cbd5e1, transparent);
    margin: 8px 0 20px;
}

/* Neumorphic CTA button — raised, indigo */
.neo-btn {
    width: 100%;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 4px;
    background: linear-gradient(145deg, #5b52f0, #4338ca);
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    font-weight: 700;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    letter-spacing: 0.04em;
    box-shadow:
        6px 6px 14px #b8bcc8,
        -4px -4px 10px #ffffff,
        inset 0 1px 0 rgba(255,255,255,0.2);
    transition: all 0.18s ease;
    position: relative;
    overflow: hidden;
}

.neo-btn::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 50%;
    background: linear-gradient(to bottom, rgba(255,255,255,0.15), transparent);
    border-radius: 14px 14px 0 0;
    pointer-events: none;
}

.neo-btn:hover {
    box-shadow:
        8px 8px 18px #b0b5c2,
        -5px -5px 12px #ffffff,
        inset 0 1px 0 rgba(255,255,255,0.2);
    transform: translateY(-1px);
}

.neo-btn:active {
    transform: translateY(1px);
    box-shadow:
        inset 3px 3px 7px rgba(0,0,0,0.2),
        inset -2px -2px 5px rgba(255,255,255,0.1);
}

.neo-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

/* Footer hint under button */
.neo-footer-hint {
    text-align: center;
    margin-top: 20px;
    font-size: 12px;
    color: #94a3b8;
}

/* Loading spinner */
.loading-spinner {
    animation: spin 0.75s linear infinite;
}

@keyframes spin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@media (max-width: 480px) {
    .neo-card { padding: 32px 24px 28px; border-radius: 20px; }
    .login-view { padding: 16px 12px; }
}

/* animate-fade-in utility */
.animate-fade-in {
    animation: fadeIn 200ms ease-in-out;
}



/* Reusable Tab Navigation Component */
.tabs, .inventory-tabs {
    display: flex;
    gap: var(--space-2);
    border-bottom: 2px solid var(--line);
    margin-bottom: var(--space-6);
    overflow-x: auto;
    padding-bottom: 2px;
    align-items: center;
}

.tab-btn {
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    padding: var(--space-3) var(--space-4);
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.tab-btn:hover {
    color: var(--ink);
    background: rgba(241, 245, 249, 0.6);
}

.tab-btn.active {
    color: var(--c-sky);
    border-bottom-color: var(--c-sky);
    background: transparent;
}

.tab-pane, .tab-content {
    display: none;
    width: 100%;
}

.tab-pane.active {
    display: block;
    width: 100%;
}

.btn-logout-pill {
    margin-left: 12px;
    background: #e53935;
    color: #ffffff;
    border: none;
    border-radius: 50px;
    padding: 10px 20px;
    font-weight: 700;
    font-size: var(--fs-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 10px rgba(229, 57, 53, 0.3);
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-logout-pill:hover {
    background: #d32f2f;
    box-shadow: 0 6px 14px rgba(229, 57, 53, 0.4);
    transform: translateY(-1px);
}


/* Beat Planning Grid Custom Styles */

.rc-0 { background: #fee2e2; color: #b91c1c; }
.rc-1 { background: #dcfce7; color: #15803d; }
.rc-2 { background: #e0f2fe; color: #0369a1; }
.rc-3 { background: #fef3c7; color: #b45309; }
.rc-4 { background: #f3e8ff; color: #6b21a8; }
.rc-5 { background: #ffedd5; color: #c2410c; }
.rc-6 { background: #e0e7ff; color: #4338ca; }
.rc-7 { background: #fce7f3; color: #be185d; }

.route-chip {
    padding: var(--space-1) var(--space-2);
    border-radius: 8px;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.2;
    text-align: center;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 40px;
    max-height: 52px;
}

.route-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    display: block;
}

.route-chip-count {
    font-size: 10px;
    opacity: 0.8;
    margin-top: 2px;
}

.route-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border: 1px dashed var(--line-strong);
    border-radius: 8px;
    color: transparent;
    transition: all 0.2s ease;
}

.route-empty:hover {
    color: var(--muted);
    background: var(--surface-2);
}
.route-empty:hover::before {
    content: '+';
}

td:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: -2px;
}

.salesman-info {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.salesman-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface-2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--fs-xs);
    font-weight: 700;
    color: var(--primary);
    border: 1px solid var(--line);
}

.salesman-details {
    display: flex;
    flex-direction: column;
}

.salesman-name {
    font-weight: 600;
    font-size: var(--fs-sm);
    color: var(--ink);
}

.salesman-phone {
    font-size: var(--fs-xs);
    color: var(--muted);
}
.salesman-coverage {
    font-size: 10px;
    color: var(--muted);
    margin-top: 2px;
}

/* Beat Planning Adjustments */
#beats-grid-table {
    table-layout: fixed;
    width: 100%;
}
.density-comfortable #beats-grid-table th, .density-comfortable #beats-grid-table td {
    height: 64px;
}
.density-comfortable .route-chip {
    flex-direction: column;
    align-items: flex-start !important;
    white-space: normal;
}
.density-comfortable .route-chip-name {
    white-space: normal;
}
.route-empty {
    border: 1px dashed var(--line-strong);
    height: 28px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    transition: color 0.2s;
    cursor: pointer;
}
.route-empty:hover {
    color: var(--muted);
}
.route-empty::after {
    content: '+';
    font-size: 16px;
}
@media (max-width: 768px) {
    .assign-modal-form-pane {
        flex: 1 1 100% !important;
        border-right: none !important;
        border-bottom: 1px solid var(--line);
    }
    .assign-modal-shops-pane {
        max-height: 260px !important;
    }
}

/* Route Drawer Table (stacked at 390px) */
@media (max-width: 500px) {
    .route-drawer-table thead {
        display: none;
    }
    .route-drawer-table, .route-drawer-table tbody, .route-drawer-table tr, .route-drawer-table td {
        display: block;
        width: 100%;
    }
    .route-drawer-table tr {
        margin-bottom: 12px;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        position: relative;
        padding-left: 0;
        padding-right: 0;
        height: auto !important;
    }
    .route-drawer-table td {
        border: none;
        padding: 8px 16px !important;
        text-align: left !important;
    }
    .route-drawer-table td:first-child {
        position: absolute;
        top: 8px;
        right: 8px;
        width: auto !important;
        padding: 0 !important;
    }
    .route-drawer-table td:last-child {
        border-top: 1px solid var(--line);
        margin-top: 8px;
        padding-top: 12px !important;
    }
    .route-drawer-table td:last-child .row-actions {
        justify-content: flex-end !important;
    }
}

/* Tooltips */
.erp-tooltip {
    position: fixed;
    background: #1e293b;
    color: #f8fafc;
    font-size: 12px;
    padding: 6px 10px;
    border-radius: 4px;
    z-index: 9999;
    pointer-events: none;
    max-width: 220px;
    text-align: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    opacity: 0;
    transition: opacity 150ms ease-in-out;
}
.erp-tooltip.show {
    opacity: 1;
}

/* Modal Form Layout */
.modal-card > form { display:flex; flex-direction:column; flex:1 1 auto; min-height:0; }
.modal-card .modal-body { flex:1 1 auto; min-height:0; overflow-y:auto; }
.modal-card .modal-header, .modal-card .modal-footer { flex:0 0 auto; }
.modal-footer { position:sticky; bottom:0; background:var(--surface); border-top:1px solid var(--line); }
.modal-xl { max-width: 760px; width: 100%; }

/* Toggle Switch */
.switch input:checked + .slider {
    background-color: var(--primary);
}
.switch input:focus + .slider {
    box-shadow: 0 0 1px var(--primary);
}
.switch input:checked + .slider:before {
    transform: translateX(16px);
}
.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 2px;
    bottom: 2px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

/* Table Action Buttons */
.return-action-btn {
    height: 32px;
    padding: 0 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.return-action-btn:focus-visible {
    outline: 2px solid var(--c-sky);
    outline-offset: 2px;
}

.return-action-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.return-action-btn.approve {
    background: rgba(34,197,94,0.15);
    color: var(--c-green);
    border: 1px solid var(--c-green);
}

.return-action-btn.approve:hover:not(:disabled) {
    background: var(--c-green);
    color: #fff;
}

.return-action-btn.reject {
    background: rgba(239,68,68,0.15);
    color: var(--c-red);
    border: 1px solid var(--c-red);
}

.return-action-btn.reject:hover:not(:disabled) {
    background: var(--c-red);
    color: #fff;
}

/* Force highest z-index for confirm modals */
.z-top {
    z-index: 99999 !important;
}

/* Audit Log page */
.audit-card { padding: 0; overflow: hidden; }
.audit-table-scroll { width: 100%; overflow-x: auto; }
.audit-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    text-align: left;
    font-size: var(--fs-sm, 13px);
}
.audit-table th {
    background: var(--surface-2);
    color: var(--muted);
    font-size: var(--fs-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.audit-table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
    vertical-align: middle;
    overflow: hidden;
    text-overflow: ellipsis;
}
.audit-table tbody tr:hover { background-color: var(--hover); }
.audit-table tr:last-child td { border-bottom: none; }
.audit-strong { font-weight: 500; }
.audit-muted { color: var(--muted); font-size: 11px; }
.audit-ref { font-size: 11px; color: var(--c-sky); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; overflow: hidden; text-overflow: ellipsis; }
.audit-summary { white-space: nowrap; }
.audit-badge {
    display: inline-block;
    max-width: 100%;
    background: var(--surface-2);
    padding: 3px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.audit-empty { text-align: center; padding: 30px !important; color: var(--muted); }
.audit-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: var(--space-3) var(--space-4);
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}
.audit-meta { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px 16px; margin-bottom: 15px; }
.audit-meta-wide { grid-column: 1 / -1; }
.audit-diff { display: flex; gap: 16px; margin-top: 15px; }
.audit-diff-pane {
    flex: 1; min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 10px;
}
.audit-diff-pane h4 { margin: 0 0 8px 0; font-size: 13px; }
.audit-diff-pane pre {
    margin: 0; white-space: pre-wrap; word-break: break-word;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px; color: var(--ink);
    max-height: 380px; overflow-y: auto;
}
.audit-changed { background: rgba(245, 158, 11, 0.22); display: inline-block; width: 100%; }
@media (max-width: 900px) {
    .audit-table { min-width: 860px; }
    .audit-meta { grid-template-columns: 1fr 1fr; }
    .audit-diff { flex-direction: column; }
}

/* ========================================================================= */
/* STAGE 2: HYBRID SOFT EMBOSS + 3D KEYCAP                                   */
/* ========================================================================= */
:root {
    --emb-bg:#e8edf5;
    --emb-bg-hi:#edf1f8;
    --emb-bg-lo:#e6ebf4;
    --emb-shadow-dark:#c5cbd8;
    --emb-shadow-dark-in:#c3c9d7;
    --emb-shadow-light:#ffffff;
    --logo-h:54px;
    --topbar-h:84px;
}

/* Header bar (embossed surface) */
#top-bar {
    background: linear-gradient(var(--emb-bg-hi), var(--emb-bg-lo));
    box-shadow: 0 8px 20px rgba(163,177,198,.5), inset 0 1px 0 #fff;
    border-bottom: none;
}
#top-bar .top-bar-header {
    display: flex;
    justify-content: space-between;
}
/* Logo */
#top-bar .header-logo {
    height: var(--logo-h);
    width: auto;
    object-fit: contain;
    display: block;
    margin: -6px 0 -6px -4px; /* Compensate for PNG padding */
}

/* Center tile bar */
#top-bar .nav-section {
    display: none !important;
}

#top-bar .sidebar-nav {
    flex: 1;
    display: flex;
    justify-content: center;
    gap: 10px;
}
#top-bar .top-bar-left {
    flex-shrink: 0;
}
#top-bar .top-bar-right {
    flex-shrink: 0;
}

/* Tiles (pad) */
#top-bar .tile-btn,
#top-bar .reports-hybrid-tile.nav-item {
    min-width: 70px;
    padding: 8px 8px 7px;
    border-radius: 15px;
    gap: 7px;
    background: var(--emb-bg);
    box-shadow: 5px 5px 11px var(--emb-shadow-dark), -5px -5px 11px var(--emb-shadow-light), inset 0 1px 0 rgba(255,255,255,.8);
    transition: 0.15s ease;
    border: none;
}
#top-bar .tile-btn:hover,
#top-bar .reports-hybrid-tile.nav-item:hover {
    box-shadow: 6px 6px 14px var(--emb-shadow-dark), -6px -6px 14px var(--emb-shadow-light), inset 0 1px 0 rgba(255,255,255,.8);
    transform: translateY(-1px);
}
/* Tile (keycap) */
#top-bar .tile-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    color: #fff;
    background: var(--c);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 3px 0 rgba(0,0,0,.25), 0 7px 10px rgba(16,24,43,.2);
    transform: translateY(-1px);
}
@supports (color: color-mix(in srgb, red, blue)) {
    #top-bar .tile-icon {
        background: linear-gradient(165deg, color-mix(in srgb, var(--c) 60%, #fff), var(--c));
        box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 3px 0 color-mix(in srgb, var(--c) 68%, #000), 0 7px 10px rgba(16,24,43,.2);
    }
}
#top-bar .tile-icon i {
    font-size: 15px;
    text-shadow: 0 1px 0 rgba(0,0,0,.25);
}
#top-bar .tile-label {
    font-size: 10.5px;
    font-weight: 600;
    color: #33405b;
    text-shadow: 0 1px 0 rgba(255,255,255,.9);
}

/* Active Tile States */
#top-bar .nav-group.active-tile .tile-btn,
#top-bar .nav-group.active-tile .reports-hybrid-tile.nav-item,
#top-bar .tile-btn[aria-expanded="true"],
#top-bar .reports-hybrid-tile.nav-item.active {
    box-shadow: inset 4px 4px 9px var(--emb-shadow-dark-in), inset -4px -4px 9px var(--emb-shadow-light);
    transform: none;
    background: var(--emb-bg);
    border-color: transparent;
}
#top-bar .nav-group.active-tile .tile-icon,
#top-bar .tile-btn[aria-expanded="true"] .tile-icon,
#top-bar .reports-hybrid-tile.nav-item.active .tile-icon {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 1px 0 rgba(0,0,0,.25), 0 2px 4px rgba(16,24,43,.25);
}
@supports (color: color-mix(in srgb, red, blue)) {
    #top-bar .nav-group.active-tile .tile-icon,
    #top-bar .tile-btn[aria-expanded="true"] .tile-icon,
    #top-bar .reports-hybrid-tile.nav-item.active .tile-icon {
        box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 1px 0 color-mix(in srgb, var(--c) 68%, #000), 0 2px 4px rgba(16,24,43,.25);
    }
}
#top-bar .nav-group.active-tile .tile-label,
#top-bar .tile-btn[aria-expanded="true"] .tile-label,
#top-bar .reports-hybrid-tile.nav-item.active .tile-label {
    color: #2563eb;
    font-weight: 700;
}

/* Flyout panel */
#top-bar .flyout-panel {
    background: var(--emb-bg);
    border: none;
    border-radius: 20px;
    padding: 14px;
    min-width: 268px;
    box-shadow: 12px 12px 26px var(--emb-shadow-dark), -10px -10px 22px var(--emb-shadow-light);
    top: calc(100% + 12px);
}
#top-bar .flyout-section-title {
    font-size: 9.5px;
    font-weight: 800;
    text-transform: uppercase;
    color: #6b7690;
    border-bottom: 1px solid rgba(163,177,198,.4);
    box-shadow: 0 1px 0 #fff;
    margin-bottom: 8px;
    padding-bottom: 4px;
}
#top-bar .flyout-panel .nav-item {
    padding: 8px 12px;
    border-radius: 13px;
    gap: 11px;
    font-size: 12px;
    font-weight: 500;
    color: #33405b;
    margin-bottom: 5px;
    background: transparent;
    border: none;
}
#top-bar .flyout-panel .nav-item i {
    width: 22px;
    height: 22px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    color: #fff;
    background: linear-gradient(165deg,#b8c2d4,#8d99b0);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.6), 0 2px 0 #6f7a92;
}
#top-bar .flyout-panel .nav-item:hover {
    box-shadow: 3px 3px 7px var(--emb-shadow-dark), -3px -3px 7px var(--emb-shadow-light);
}
#top-bar .flyout-panel .nav-item.active {
    box-shadow: inset 3px 3px 7px var(--emb-shadow-dark-in), inset -3px -3px 7px var(--emb-shadow-light);
    color: #2563eb;
    font-weight: 700;
}
#top-bar .flyout-panel .nav-item.active i {
    background: linear-gradient(165deg,#60a5fa,#2563eb);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.5), 0 1px 0 #1d4ed8;
    transform: translateY(1px);
}

/* Right Controls */
#top-bar #user-chip {
    padding: 4px 14px 4px 4px;
    border-radius: 99px;
    background: transparent;
    border: none;
    box-shadow: inset 3px 3px 6px var(--emb-shadow-dark), -3px -3px 6px var(--emb-shadow-light);
}
#top-bar #user-chip .user-avatar-initials {
    background: linear-gradient(165deg,#60a5fa,#2563eb);
    box-shadow: 0 2px 0 #1d4ed8, 0 4px 6px rgba(37,99,235,.3);
}
#top-bar #btn-logout {
    padding: 8px 15px;
    border-radius: 12px;
    color: #fff;
    font-weight: 700;
    background: linear-gradient(165deg,#f87171,#dc2626);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 3px 0 #a31515, 0 7px 12px rgba(220,38,38,.3);
    border: none;
}
#top-bar #btn-logout:hover {
    transform: translateY(2px);
    box-shadow: inset 0 1px 0 rgba(255,255,255,.3), 0 1px 0 #a31515;
}

/* Breadcrumb Sub-bar */
#breadcrumb {
    background: var(--emb-bg);
    box-shadow: inset 0 6px 8px -8px rgba(163,177,198,.6);
    padding: 8px 22px; /* min 8px vertical padding */
}

/* Mobile Drawer (under 900px) */
@media (max-width: 899px) {
    #app-sidebar.sidebar {
        background: var(--emb-bg);
    }
    .header-logo {
        height: 36px !important;
    }
    #menu-toggle {
        border-radius: 50%;
        background: var(--emb-bg);
        box-shadow: 3px 3px 7px var(--emb-shadow-dark), -3px -3px 7px var(--emb-shadow-light);
    }
    /* Mobile Drawer Items */
    .sidebar-nav .nav-item {
        padding: 8px 12px;
        border-radius: 13px;
        background: transparent;
        border: none;
    }
}

/* Breakpoints */
@media (min-width: 1280px) {
    #top-bar .header-logo { height: 54px; }
}
@media (min-width: 1024px) and (max-width: 1279px) {
    #top-bar .header-logo { height: 46px; }
}
@media (min-width: 900px) and (max-width: 1100px) {
    #top-bar .header-logo { height: 40px; }
    #top-bar .tile-btn,
    #top-bar .reports-hybrid-tile.nav-item {
        min-width: 62px;
    }
    #top-bar .sidebar-nav {
        gap: 6px;
    }
}

/* Accessibility */
.header-logo:focus-visible,
.tile-btn:focus-visible,
.nav-item:focus-visible,
#btn-logout:focus-visible,
#menu-toggle:focus-visible {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}
@media (prefers-reduced-motion: reduce) {
    .tile-btn, .tile-icon, #btn-logout {
        transition: none;
        transform: none !important;
    }
}

