/* =====================================================================
   SECTION 1 — FONT FACES
   Keep exactly ONE set of these rules. Paths are relative to this file.
   ===================================================================== */
@font-face{font-family:'Outfit';src:url('../fonts/outfit-regular.woff2') format('woff2');font-weight:400;font-style:normal;font-display:swap}
@font-face{font-family:'Outfit';src:url('../fonts/outfit-medium.woff2') format('woff2');font-weight:500;font-style:normal;font-display:swap}
@font-face{font-family:'Outfit';src:url('../fonts/outfit-semibold.woff2') format('woff2');font-weight:600;font-style:normal;font-display:swap}
@font-face{font-family:'Outfit';src:url('../fonts/outfit-bold.woff2') format('woff2');font-weight:700;font-style:normal;font-display:swap}


/* =====================================================================
   SECTION 2 — DESIGN TOKENS
   ===================================================================== */
:root {
    /* Layout */
    --sidebar-w: 264px;
    --sidebar-w-compact: 78px;
    --navbar-h: 64px;
    --radius-sm: 8px;
    --radius:    12px;
    --radius-lg: 16px;

    /* Sidebar (dark) */
    --sidebar-bg:        #15171c;
    --sidebar-bg-2:      #1a1d24;
    --sidebar-hover:     #22262f;
    --sidebar-active:    #2b3040;
    --sidebar-border:    #23262e;
    --sidebar-text:      #97a0b1;
    --sidebar-text-hi:   #eef1f6;
    --sidebar-text-dim:  #5f6878;
    --sidebar-accent:    #6f7cff;

    /* Navbar / Footer (medium semi-dark) */
    --bar-bg:            #2b2f38;
    --bar-bg-2:          #31363f;
    --bar-border:        #3a3f49;
    --bar-text:          #d7dce5;
    --bar-text-muted:    #98a1b0;
    --bar-input-bg:      #232732;
    --bar-input-border:  #3d424d;

    /* Main content (light) */
    --body-bg:           #f2f4f8;
    --card-bg:           #ffffff;
    --card-border:       #e5e8ef;
    --grid-line:         #eef0f5;

    /* Text */
    --text-primary:      #1c2233;
    --text-secondary:    #5a6478;
    --text-muted:        #8a92a6;

    /* Status */
    --primary:      #5b6cff;
    --primary-soft: #eef0ff;
    --primary-dark: #4553e0;

    --success:      #16a34a;
    --success-soft: #e8f6ee;

    --warning:      #d97706;
    --warning-soft: #fdf3e2;

    --danger:       #dc2626;
    --danger-soft:  #fdecec;

    --info:         #0891b2;
    --info-soft:    #e3f6fb;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(16,24,40,.04);
    --shadow-sm: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
    --shadow:    0 4px 14px rgba(16,24,40,.06), 0 2px 4px rgba(16,24,40,.04);
    --shadow-lg: 0 12px 30px rgba(16,24,40,.09);
}


/* =====================================================================
   SECTION 2B — DARK THEME
   Set on <html data-theme="dark"> by asset/js/theme.js; default is light.
   ===================================================================== */
:root {
    --surface-2:    #fafbfd;
    --control-bg:   #ffffff;
    --control-hover:#f4f6fa;
    --line-strong:  #cfd5e2;
}
:root[data-theme="dark"] {
    color-scheme: dark;
    --body-bg:        #0f1218;
    --card-bg:        #171b23;
    --card-border:    #262c38;
    --grid-line:      #1f2430;
    --surface-2:      #1b202a;
    --control-bg:     #1c212b;
    --control-hover:  #222836;
    --line-strong:    #3a4252;
    --text-primary:   #e6ebf5;
    --text-secondary: #a4aebf;
    --text-muted:     #7c869a;
    --primary-soft:   rgba(91,108,255,.16);
    --success-soft:   rgba(22,163,74,.16);
    --warning-soft:   rgba(217,119,6,.18);
    --danger-soft:    rgba(220,38,38,.16);
    --info-soft:      rgba(8,145,178,.18);
    --shadow-xs: 0 1px 2px rgba(0,0,0,.30);
    --shadow-sm: 0 1px 3px rgba(0,0,0,.36);
    --shadow:    0 4px 14px rgba(0,0,0,.38);
    --shadow-lg: 0 12px 30px rgba(0,0,0,.50);
}
:root[data-theme="dark"] ::-webkit-scrollbar-thumb { background: #3a4252; }
:root[data-theme="dark"] ::-webkit-scrollbar-thumb:hover { background: #4a5366; }
:root[data-theme="dark"] .stat-card:hover { border-color: #323a4a; }
:root[data-theme="dark"] .btn-ghost:hover,
:root[data-theme="dark"] .page-btn:hover:not(:disabled):not(.is-active) { border-color: var(--line-strong); }
:root[data-theme="dark"] .page-btn:hover:not(:disabled):not(.is-active) { background: var(--control-hover); }
:root[data-theme="dark"] .data-table thead th,
:root[data-theme="dark"] .data-table tbody tr:hover,
:root[data-theme="dark"] .table-foot,
:root[data-theme="dark"] .crm-modal-foot { background: var(--surface-2); }
:root[data-theme="dark"] .btn-ghost,
:root[data-theme="dark"] .page-btn,
:root[data-theme="dark"] .select-wrap select,
:root[data-theme="dark"] .toolbar-search input,
:root[data-theme="dark"] .form-field input,
:root[data-theme="dark"] .form-field select,
:root[data-theme="dark"] .form-field textarea,
:root[data-theme="dark"] .serial-input-row .act-btn,
:root[data-theme="dark"] .user-dropdown,
:root[data-theme="dark"] .alert-item { background: var(--control-bg); }
:root[data-theme="dark"] .page-btn.is-active { background: var(--primary); }
:root[data-theme="dark"] .alert-item.tone-danger  { border-color: rgba(220,38,38,.35);  background: rgba(220,38,38,.08); }
:root[data-theme="dark"] .alert-item.tone-warning { border-color: rgba(217,119,6,.35);  background: rgba(217,119,6,.08); }
:root[data-theme="dark"] .alert-item.tone-info    { border-color: rgba(8,145,178,.35);  background: rgba(8,145,178,.08); }
:root[data-theme="dark"] .alert-item.tone-success { border-color: rgba(22,163,74,.35);  background: rgba(22,163,74,.08); }
:root[data-theme="dark"] .table-alert,
:root[data-theme="dark"] .form-alert { border-color: rgba(220,38,38,.35); }
:root[data-theme="dark"] .pill.tone-primary,
:root[data-theme="dark"] .ref { color: #8f9bff; }
:root[data-theme="dark"] .pill.tone-success { color: #4ade80; }
:root[data-theme="dark"] .pill.tone-warning { color: #fbbf24; }
:root[data-theme="dark"] .pill.tone-danger  { color: #f87171; }
:root[data-theme="dark"] .pill.tone-info    { color: #38bdf8; }
:root[data-theme="dark"] .flash-success, :root[data-theme="dark"] .crm-toast.tone-success { border-color: rgba(22,163,74,.35);  background: rgba(22,163,74,.10);  color: #4ade80; }
:root[data-theme="dark"] .flash-danger,  :root[data-theme="dark"] .crm-toast.tone-danger  { border-color: rgba(220,38,38,.35);  background: rgba(220,38,38,.10);  color: #f87171; }
:root[data-theme="dark"] .flash-warning, :root[data-theme="dark"] .crm-toast.tone-warning { border-color: rgba(217,119,6,.35);  background: rgba(217,119,6,.10);  color: #fbbf24; }
:root[data-theme="dark"] .flash-info { border-color: rgba(8,145,178,.35); background: rgba(8,145,178,.10); color: #38bdf8; }
:root[data-theme="dark"] .crm-toast { background: var(--control-bg); }


/* =====================================================================
   SECTION 3 — RESET & BASE
   ===================================================================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
    background: var(--body-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

img, svg { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
ul { list-style: none; }
h1, h2, h3, h4, h5 { font-weight: 600; line-height: 1.25; letter-spacing: -.01em; }

::selection { background: rgba(91,108,255,.22); }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c7ccd8; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #a8afbd; }

.ico { flex-shrink: 0; }


/* =====================================================================
   SECTION 4 — CRM STATE HELPERS
   (scroll lock + visibility helpers used by customers.php / dashboard.php
    — replaces inline body.style.overflow and inline display toggles)
   ===================================================================== */
body.is-scroll-locked { overflow: hidden; }

.is-hidden { display: none !important; }
.is-shown  { display: block !important; }


/* =====================================================================
   SECTION 5 — APP SHELL
   ===================================================================== */
.crm-app {
    display: flex;
    min-height: 100vh;
}

.crm-main-wrap {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.crm-main {
    flex: 1 1 auto;
    padding: 26px 28px 34px;
    display: flex;
    flex-direction: column;
    gap: 22px;
}


/* =====================================================================
   SECTION 6 — SIDEBAR
   ===================================================================== */
.crm-sidebar {
    flex: 0 0 var(--sidebar-w);
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow: hidden;
    border-right: 1px solid var(--sidebar-border);
    transition: width .25s cubic-bezier(.4,0,.2,1), flex-basis .25s cubic-bezier(.4,0,.2,1);
    z-index: 100;
}

/* Brand */
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 20px 22px;
    border-bottom: 1px solid var(--sidebar-border);
    flex-shrink: 0;
}
.brand-mark {
    width: 50px; height: 50px;
    border-radius: 14px;
    display: grid; place-items: center;
    background: rgba(111,124,255,.12);
    border: 1px solid rgba(111,124,255,.28);
    flex-shrink: 0;
}
.brand-text {
    display: flex; flex-direction: column;
    line-height: 1.1;
    min-width: 0;
    overflow: hidden;
}
.brand-text strong {
    font-size: 18.75px;
    font-weight: 700;
    color: var(--sidebar-text-hi);
    letter-spacing: -.01em;
}
.brand-text em {
    font-style: normal;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--sidebar-accent);
    margin-top: 2px;
}

/* Nav */
.sidebar-nav {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 14px 12px 20px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.sidebar-nav::-webkit-scrollbar { width: 6px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: #2b2f38; border-radius: 6px; }

.nav-divider {
    border: 0;
    height: 1px;
    background: var(--sidebar-border);
    margin: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 13.5px;
    font-weight: 500;
    width: 100%;
    text-align: left;
    transition: background .18s ease, color .18s ease;
    position: relative;
}
.nav-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hi);
}
.nav-item.is-active {
    background: var(--sidebar-active);
    color: #ffffff;
}
.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: -12px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 22px;
    border-radius: 0 3px 3px 0;
    background: var(--sidebar-accent);
}
.nav-icon {
    display: grid; place-items: center;
    width: 20px; height: 20px;
    flex-shrink: 0;
    color: inherit;
    opacity: 1;
}
.nav-label {
    flex: 1 1 auto;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.nav-chevron {
    display: grid; place-items: center;
    flex-shrink: 0;
    color: inherit;
    opacity: .55;
    transition: transform .22s ease;
}
.nav-group.open .nav-chevron { transform: rotate(180deg); }

/* Icons always follow the item colour — never hard-coded black on the dark rail */
.sidebar-brand svg,
.nav-item svg,
.nav-sub-item svg,
.sidebar-foot svg { color: inherit; }

/* Parent of an open group stays readable */
.nav-group.open > .nav-item { color: var(--sidebar-text-hi); }
.nav-group.open > .nav-item.is-active { color: #ffffff; }

/* Submenu */
.nav-sub {
    display: none;
    flex-direction: column;
    gap: 1px;
    padding: 4px 0 6px 12px;
    margin-left: 18px;
    border-left: 1px solid var(--sidebar-border);
    margin-top: 2px;
}
.nav-group.open .nav-sub { display: flex; }

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 6px;
    font-size: 12.8px;
    color: var(--sidebar-text);
    transition: background .18s, color .18s;
}
.nav-sub-item:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-hi);
}
.nav-sub-item.is-active {
    color: #ffffff;
    background: rgba(111,124,255,.12);
}
.nav-sub-dot {
    width: 4px; height: 4px;
    border-radius: 50%;
    background: currentColor;
    opacity: .5;
    flex-shrink: 0;
}
.nav-sub-item.is-active .nav-sub-dot {
    opacity: 1;
    background: var(--sidebar-accent);
    box-shadow: 0 0 0 3px rgba(111,124,255,.18);
}

/* Sidebar foot */
.sidebar-foot {
    flex-shrink: 0;
    padding: 14px 22px;
    border-top: 1px solid var(--sidebar-border);
}
.sidebar-foot-text {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11.5px;
    color: var(--sidebar-text-dim);
    white-space: nowrap;
}
.foot-dot {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 3px rgba(22,163,74,.16);
    flex-shrink: 0;
}

/* Sidebar collapsed (desktop toggle) */
@media (min-width: 1101px) {
    .crm-sidebar.collapsed { width: var(--sidebar-w-compact); flex-basis: var(--sidebar-w-compact); }
    .crm-sidebar.collapsed .brand-text,
    .crm-sidebar.collapsed .nav-label,
    .crm-sidebar.collapsed .nav-chevron,
    .crm-sidebar.collapsed .sidebar-foot-text,
    .crm-sidebar.collapsed .nav-sub { display: none; }
    .crm-sidebar.collapsed .sidebar-brand { justify-content: center; padding: 20px 0; }
    .crm-sidebar.collapsed .nav-item { justify-content: center; padding: 11px 0; }
    .crm-sidebar.collapsed .nav-item.is-active::before { left: -6px; }
}


/* =====================================================================
   SECTION 7 — NAVBAR
   ===================================================================== */
.crm-navbar {
    position: sticky;
    top: 0;
    z-index: 60;
    height: var(--navbar-h);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    background: var(--bar-bg);
    border-bottom: 1px solid var(--bar-border);
    color: var(--bar-text);
    flex-shrink: 0;
}

.nav-toggle {
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 9px;
    color: var(--bar-text);
    transition: background .18s;
}
.nav-toggle:hover { background: rgba(255,255,255,.07); }

.navbar-title { flex-shrink: 0; min-width: 0; }
.navbar-title h1 {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    letter-spacing: -.01em;
    line-height: 1.2;
    white-space: nowrap;
}
.navbar-title p {
    font-size: 11.5px;
    color: var(--bar-text-muted);
    margin-top: 1px;
    white-space: nowrap;
}

.navbar-search {
    flex: 1 1 auto;
    max-width: 420px;
    position: relative;
    margin-left: auto;
}
.navbar-search .search-icon {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--bar-text-muted);
    pointer-events: none;
}
.navbar-search input {
    width: 100%;
    height: 38px;
    padding: 0 14px 0 38px;
    border-radius: 9px;
    background: var(--bar-input-bg);
    border: 1px solid var(--bar-input-border);
    color: var(--bar-text);
    font-size: 13px;
    outline: none;
    transition: border-color .18s, background .18s;
}
.navbar-search input::placeholder { color: var(--bar-text-muted); }
.navbar-search input:focus {
    border-color: var(--primary);
    background: #202430;
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.icon-btn {
    position: relative;
    display: grid; place-items: center;
    width: 38px; height: 38px;
    border-radius: 9px;
    color: var(--bar-text);
    transition: background .18s;
}
.icon-btn:hover { background: rgba(255,255,255,.07); }
.badge-dot {
    position: absolute;
    top: 8px; right: 8px;
    width: 7px; height: 7px;
    border-radius: 50%;
    background: var(--danger);
    box-shadow: 0 0 0 2px var(--bar-bg);
}

/* User menu */
.user-menu { position: relative; }
.user-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 10px 5px 5px;
    border-radius: 100px;
    transition: background .18s;
}
.user-btn:hover { background: rgba(255,255,255,.07); }

.user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #6f7cff, #22c1d6);
    color: #ffffff;
    display: grid; place-items: center;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: .02em;
    flex-shrink: 0;
}
.user-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    text-align: left;
}
.user-meta strong {
    font-size: 12.5px;
    font-weight: 600;
    color: #ffffff;
    white-space: nowrap;
}
.user-meta em {
    font-style: normal;
    font-size: 10.5px;
    color: var(--bar-text-muted);
    white-space: nowrap;
}
.user-chevron {
    color: var(--bar-text-muted);
    display: grid; place-items: center;
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    min-width: 210px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-6px);
    transition: opacity .18s, transform .18s, visibility .18s;
    z-index: 120;
}
.user-menu.open .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 11px;
    border-radius: 7px;
    font-size: 13px;
    color: var(--text-primary);
    transition: background .16s;
}
.user-dropdown a:hover { background: var(--body-bg); }
.user-dropdown a.danger { color: var(--danger); }
.user-dropdown a.danger:hover { background: var(--danger-soft); }
.user-dropdown hr {
    border: 0;
    height: 1px;
    background: var(--card-border);
    margin: 5px 8px;
}


/* =====================================================================
   SECTION 8 — FOOTER
   ===================================================================== */
.crm-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 26px;
    background: var(--bar-bg-2);
    border-top: 1px solid var(--bar-border);
    color: var(--bar-text-muted);
    font-size: 12.5px;
    flex-shrink: 0;
}
.footer-meta { color: var(--bar-text-muted); opacity: .75; }


/* =====================================================================
   SECTION 9 — QUICK ACTIONS
   ===================================================================== */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.qa-tile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: border-color .2s, transform .2s, box-shadow .2s;
    min-width: 0;
}
.qa-tile:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-sm);
}
.qa-icon {
    width: 38px; height: 38px;
    border-radius: 10px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.qa-text {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
}
.qa-text strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qa-text em {
    font-style: normal;
    font-size: 11.5px;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Tone helpers */
.tone-primary { background: var(--primary-soft); color: var(--primary); }
.tone-success { background: var(--success-soft); color: var(--success); }
.tone-warning { background: var(--warning-soft); color: var(--warning); }
.tone-danger  { background: var(--danger-soft);  color: var(--danger); }
.tone-info    { background: var(--info-soft);    color: var(--info); }


/* =====================================================================
   SECTION 10 — STAT GRID
   ===================================================================== */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
}

.stat-card {
    display: flex;
    gap: 14px;
    padding: 16px 18px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-xs);
    transition: transform .2s, box-shadow .2s, border-color .2s;
    min-width: 0;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
    border-color: #dfe3ec;
}
.stat-icon {
    width: 42px; height: 42px;
    border-radius: 11px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.stat-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}
.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.15;
    margin-top: 2px;
    letter-spacing: -.02em;
}
.stat-foot {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--text-muted);
    min-width: 0;
}
.stat-foot span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.trend {
    font-style: normal;
    font-weight: 600;
    font-size: 11px;
    padding: 1px 6px;
    border-radius: 4px;
    white-space: nowrap;
}
.trend-up   { background: var(--success-soft); color: var(--success); }
.trend-down { background: var(--danger-soft);  color: var(--danger); }
.trend-warn { background: var(--warning-soft); color: var(--warning); }


/* =====================================================================
   SECTION 11 — LAYOUT GRID
   ===================================================================== */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: 1.4fr 1fr; }


/* =====================================================================
   SECTION 12 — CARDS
   ===================================================================== */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xs);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px 12px;
    flex-wrap: wrap;
}
.card-head h2 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -.01em;
}
.card-head p {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}
.link-more {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--primary);
    transition: opacity .18s;
}
.link-more:hover { opacity: .75; }

.card-body { padding: 8px 20px 20px; flex: 1 1 auto; min-width: 0; }
.card-body.no-pad { padding: 0; }

/* Legend */
.legend { display: flex; gap: 14px; align-items: center; }
.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
}
.legend-item i {
    width: 9px; height: 9px;
    border-radius: 2px;
    display: inline-block;
}
/* Chart legend colors (were inline styles in dashboard.php) */
.legend-item .legend-dot-inward  { background: var(--primary); }
.legend-item .legend-dot-outward { background: var(--info); }


/* =====================================================================
   SECTION 13 — CHARTS
   ===================================================================== */
.chart-wrap {
    padding: 4px 10px 6px 4px;
}
.chart-svg {
    width: 100%;
    height: auto;
    display: block;
    overflow: visible;
}
.chart-svg .bar {
    transform-origin: center bottom;
    animation: barGrow .7s cubic-bezier(.2,.8,.2,1) both;
}
.chart-svg .bar-b { animation-delay: .08s; }
@keyframes barGrow {
    from { transform: scaleY(.05); opacity: .25; }
    to   { transform: scaleY(1);   opacity: 1; }
}

.donut-wrap {
    display: flex;
    align-items: center;
    gap: 22px;
    flex-wrap: wrap;
    padding: 4px 20px 18px;
}
.donut-chart { flex: 0 0 200px; max-width: 200px; }
.donut-svg { width: 100%; height: auto; animation: donutIn .8s ease both; }
@keyframes donutIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }

.donut-legend {
    flex: 1 1 160px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
.donut-legend li {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-secondary);
}
.donut-legend .dot {
    width: 10px; height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}
.donut-legend .label { flex: 1 1 auto; }
.donut-legend strong {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 13.5px;
}
/* Donut legend dot colors (were inline styles in dashboard.php) */
.donut-legend .dot.dot-warning { background: var(--warning); }
.donut-legend .dot.dot-info    { background: var(--info); }
.donut-legend .dot.dot-primary { background: var(--primary); }
.donut-legend .dot.dot-success { background: var(--success); }


/* =====================================================================
   SECTION 14 — STOCK OVERVIEW
   ===================================================================== */
.stock-wrap { padding: 4px 20px 20px; display: flex; flex-direction: column; gap: 16px; }
.stock-row { display: flex; flex-direction: column; gap: 7px; }
.stock-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12.5px;
}
.stock-label { color: var(--text-secondary); }
.stock-value { font-weight: 600; color: var(--text-primary); }
.stock-bar {
    height: 8px;
    border-radius: 100px;
    background: var(--grid-line);
    overflow: hidden;
}
.stock-fill {
    display: block;
    height: 100%;
    border-radius: 100px;
    transition: width .9s cubic-bezier(.2,.8,.2,1);
}
.stock-fill.tone-success { background: var(--success); }
.stock-fill.tone-warning { background: var(--warning); }
.stock-fill.tone-danger  { background: var(--danger); }

/* Stock bar width helpers — 0..100% (were inline styles in dashboard.php) */
.stock-bar .stock-fill.pct-0{width:0%}
.stock-bar .stock-fill.pct-1{width:1%}
.stock-bar .stock-fill.pct-2{width:2%}
.stock-bar .stock-fill.pct-3{width:3%}
.stock-bar .stock-fill.pct-4{width:4%}
.stock-bar .stock-fill.pct-5{width:5%}
.stock-bar .stock-fill.pct-6{width:6%}
.stock-bar .stock-fill.pct-7{width:7%}
.stock-bar .stock-fill.pct-8{width:8%}
.stock-bar .stock-fill.pct-9{width:9%}
.stock-bar .stock-fill.pct-10{width:10%}
.stock-bar .stock-fill.pct-11{width:11%}
.stock-bar .stock-fill.pct-12{width:12%}
.stock-bar .stock-fill.pct-13{width:13%}
.stock-bar .stock-fill.pct-14{width:14%}
.stock-bar .stock-fill.pct-15{width:15%}
.stock-bar .stock-fill.pct-16{width:16%}
.stock-bar .stock-fill.pct-17{width:17%}
.stock-bar .stock-fill.pct-18{width:18%}
.stock-bar .stock-fill.pct-19{width:19%}
.stock-bar .stock-fill.pct-20{width:20%}
.stock-bar .stock-fill.pct-21{width:21%}
.stock-bar .stock-fill.pct-22{width:22%}
.stock-bar .stock-fill.pct-23{width:23%}
.stock-bar .stock-fill.pct-24{width:24%}
.stock-bar .stock-fill.pct-25{width:25%}
.stock-bar .stock-fill.pct-26{width:26%}
.stock-bar .stock-fill.pct-27{width:27%}
.stock-bar .stock-fill.pct-28{width:28%}
.stock-bar .stock-fill.pct-29{width:29%}
.stock-bar .stock-fill.pct-30{width:30%}
.stock-bar .stock-fill.pct-31{width:31%}
.stock-bar .stock-fill.pct-32{width:32%}
.stock-bar .stock-fill.pct-33{width:33%}
.stock-bar .stock-fill.pct-34{width:34%}
.stock-bar .stock-fill.pct-35{width:35%}
.stock-bar .stock-fill.pct-36{width:36%}
.stock-bar .stock-fill.pct-37{width:37%}
.stock-bar .stock-fill.pct-38{width:38%}
.stock-bar .stock-fill.pct-39{width:39%}
.stock-bar .stock-fill.pct-40{width:40%}
.stock-bar .stock-fill.pct-41{width:41%}
.stock-bar .stock-fill.pct-42{width:42%}
.stock-bar .stock-fill.pct-43{width:43%}
.stock-bar .stock-fill.pct-44{width:44%}
.stock-bar .stock-fill.pct-45{width:45%}
.stock-bar .stock-fill.pct-46{width:46%}
.stock-bar .stock-fill.pct-47{width:47%}
.stock-bar .stock-fill.pct-48{width:48%}
.stock-bar .stock-fill.pct-49{width:49%}
.stock-bar .stock-fill.pct-50{width:50%}
.stock-bar .stock-fill.pct-51{width:51%}
.stock-bar .stock-fill.pct-52{width:52%}
.stock-bar .stock-fill.pct-53{width:53%}
.stock-bar .stock-fill.pct-54{width:54%}
.stock-bar .stock-fill.pct-55{width:55%}
.stock-bar .stock-fill.pct-56{width:56%}
.stock-bar .stock-fill.pct-57{width:57%}
.stock-bar .stock-fill.pct-58{width:58%}
.stock-bar .stock-fill.pct-59{width:59%}
.stock-bar .stock-fill.pct-60{width:60%}
.stock-bar .stock-fill.pct-61{width:61%}
.stock-bar .stock-fill.pct-62{width:62%}
.stock-bar .stock-fill.pct-63{width:63%}
.stock-bar .stock-fill.pct-64{width:64%}
.stock-bar .stock-fill.pct-65{width:65%}
.stock-bar .stock-fill.pct-66{width:66%}
.stock-bar .stock-fill.pct-67{width:67%}
.stock-bar .stock-fill.pct-68{width:68%}
.stock-bar .stock-fill.pct-69{width:69%}
.stock-bar .stock-fill.pct-70{width:70%}
.stock-bar .stock-fill.pct-71{width:71%}
.stock-bar .stock-fill.pct-72{width:72%}
.stock-bar .stock-fill.pct-73{width:73%}
.stock-bar .stock-fill.pct-74{width:74%}
.stock-bar .stock-fill.pct-75{width:75%}
.stock-bar .stock-fill.pct-76{width:76%}
.stock-bar .stock-fill.pct-77{width:77%}
.stock-bar .stock-fill.pct-78{width:78%}
.stock-bar .stock-fill.pct-79{width:79%}
.stock-bar .stock-fill.pct-80{width:80%}
.stock-bar .stock-fill.pct-81{width:81%}
.stock-bar .stock-fill.pct-82{width:82%}
.stock-bar .stock-fill.pct-83{width:83%}
.stock-bar .stock-fill.pct-84{width:84%}
.stock-bar .stock-fill.pct-85{width:85%}
.stock-bar .stock-fill.pct-86{width:86%}
.stock-bar .stock-fill.pct-87{width:87%}
.stock-bar .stock-fill.pct-88{width:88%}
.stock-bar .stock-fill.pct-89{width:89%}
.stock-bar .stock-fill.pct-90{width:90%}
.stock-bar .stock-fill.pct-91{width:91%}
.stock-bar .stock-fill.pct-92{width:92%}
.stock-bar .stock-fill.pct-93{width:93%}
.stock-bar .stock-fill.pct-94{width:94%}
.stock-bar .stock-fill.pct-95{width:95%}
.stock-bar .stock-fill.pct-96{width:96%}
.stock-bar .stock-fill.pct-97{width:97%}
.stock-bar .stock-fill.pct-98{width:98%}
.stock-bar .stock-fill.pct-99{width:99%}
.stock-bar .stock-fill.pct-100{width:100%}

.stock-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    padding-top: 16px;
    border-top: 1px solid var(--grid-line);
    margin-top: 6px;
}
.stock-summary div {
    display: flex;
    flex-direction: column;
    align-items: center;
}
.stock-summary strong {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -.02em;
}
.stock-summary span {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 2px;
}


/* =====================================================================
   SECTION 15 — ALERTS
   ===================================================================== */
.alerts-card .card-body { padding: 4px 20px 20px; }
.alerts-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}
.alert-item {
    display: flex;
    gap: 12px;
    padding: 14px 16px;
    border-radius: var(--radius);
    border: 1px solid;
    background: #ffffff;
    align-items: flex-start;
}
.alert-item .alert-icon {
    width: 32px; height: 32px;
    border-radius: 8px;
    display: grid; place-items: center;
    flex-shrink: 0;
}
.alert-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}
.alert-text strong {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}
.alert-text span {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.4;
}

.alert-item.tone-danger  { border-color: #f5d0d0; background: #fffafa; }
.alert-item.tone-warning { border-color: #f3dfb8; background: #fffcf5; }
.alert-item.tone-info    { border-color: #c6e8f0; background: #f7fdff; }
.alert-item.tone-success { border-color: #c8e6d0; background: #f9fffb; }

.alert-item.tone-danger  .alert-icon { background: var(--danger-soft);  color: var(--danger); }
.alert-item.tone-warning .alert-icon { background: var(--warning-soft); color: var(--warning); }
.alert-item.tone-info    .alert-icon { background: var(--info-soft);    color: var(--info); }
.alert-item.tone-success .alert-icon { background: var(--success-soft); color: var(--success); }