/* ==========================================================================
   CRM + ERP — Design tokens
   White base / Primary Royal Blue / Secondary Light Blue
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Brand */
    --color-primary: #1E3A8A;         /* Royal Blue — sidebar, headers, primary actions */
    --color-primary-dark: #15296B;
    --color-primary-light: #3457C4;   /* hover / active states */
    --color-secondary: #5DA9E9;       /* Light Blue — accents, badges, secondary elements */
    --color-secondary-soft: #E8F2FD;  /* light blue tint for backgrounds/badges */

    /* Neutrals */
    --color-bg: #F4F7FC;
    --color-surface: #FFFFFF;
    --color-border: #E4E9F2;
    --color-text: #1F2937;
    --color-text-muted: #6B7280;
    --color-text-inverse: #FFFFFF;

    /* Status */
    --color-success: #16A34A;
    --color-success-soft: #E9F9EF;
    --color-warning: #D97706;
    --color-warning-soft: #FDF3E3;
    --color-danger: #DC2626;
    --color-danger-soft: #FCEAEA;

    /* Type */
    --font-display: 'Poppins', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 68px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-card: 0 1px 2px rgba(16, 30, 70, 0.04), 0 4px 16px rgba(16, 30, 70, 0.06);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: var(--font-body);
    background: var(--color-bg);
    color: var(--color-text);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, .font-display {
    font-family: var(--font-display);
    color: var(--color-primary-dark);
    margin: 0 0 4px;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { color: var(--color-primary-light); }

/* ==========================================================================
   Layout shell
   ========================================================================== */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(180deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: var(--color-text-inverse);
    flex-shrink: 0;
    position: fixed;
    top: 0; bottom: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 40;
    transition: transform 0.2s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.12);
}

.sidebar-brand .mark-img { width: 34px; height: 34px; object-fit: contain; flex-shrink: 0; }

.sidebar-brand .name {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 16px;
    line-height: 1.2;
    letter-spacing: 0.02em;
}

.sidebar-brand .tagline {
    font-size: 9.5px;
    letter-spacing: 0.06em;
    color: rgba(255,255,255,0.55);
    text-transform: uppercase;
    margin-top: 2px;
}

.sidebar-nav { padding: 12px 10px; overflow-y: auto; flex: 1; }

.sidebar-nav .nav-link,
.sidebar-nav .nav-group-toggle {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px 10px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.85);
    font-size: 13.5px;
    font-weight: 500;
    background: none;
    border: none;
    font-family: var(--font-body);
    cursor: pointer;
    text-align: left;
}

.sidebar-nav .nav-link:hover,
.sidebar-nav .nav-group-toggle:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav .nav-link.active { background: var(--color-secondary); color: var(--color-primary-dark); font-weight: 600; }
.sidebar-nav .nav-link.top-link { margin-bottom: 10px; }

.nav-group-toggle { justify-content: space-between; }
.nav-group-toggle svg:last-child { transition: transform 0.15s ease; opacity: 0.7; flex-shrink: 0; }
.nav-group.open .nav-group-toggle svg:last-child { transform: rotate(180deg); }

.nav-group-links {
    display: none;
    flex-direction: column;
    padding: 2px 0 6px 40px;
}
.nav-group.open .nav-group-links { display: flex; }

.nav-group-links a {
    padding: 7px 10px;
    font-size: 13px;
    color: rgba(255,255,255,0.65);
    border-radius: var(--radius-sm);
    margin-bottom: 1px;
}
.nav-group-links a:hover { color: #fff; background: rgba(255,255,255,0.06); }
.nav-group-links a.active { color: var(--color-secondary); font-weight: 600; background: rgba(255,255,255,0.06); }

.sidebar-footer {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.12);
    font-size: 12px;
    color: rgba(255,255,255,0.55);
}

.main-area {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
    position: sticky;
    top: 0;
    z-index: 30;
}

.topbar .page-title { font-family: var(--font-display); font-weight: 600; font-size: 18px; color: var(--color-primary-dark); }
.topbar .page-subtitle { font-size: 13px; color: var(--color-text-muted); }

.user-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 8px 6px 6px;
    border-radius: 999px;
    background: var(--color-secondary-soft);
}

.user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    font-family: var(--font-display);
}

.user-chip .role { font-size: 11px; color: var(--color-text-muted); }
.user-chip .fname { font-size: 13px; font-weight: 600; color: var(--color-text); }

.content { padding: 26px; flex: 1; }

/* ==========================================================================
   Topbar: search + icon buttons
   ========================================================================== */

.topbar-search {
    display: flex;
    align-items: center;
    gap: 9px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    padding: 9px 16px;
    width: 320px;
    color: var(--color-text-muted);
}
.topbar-search input {
    border: none; background: none; outline: none; font-size: 13.5px;
    font-family: var(--font-body); width: 100%; color: var(--color-text);
}

.icon-btn {
    position: relative;
    width: 38px; height: 38px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text-muted);
    cursor: pointer;
}
.icon-btn:hover { background: var(--color-secondary-soft); color: var(--color-primary); }
.icon-btn .badge-dot {
    position: absolute; top: -4px; right: -4px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 999px;
    background: var(--color-danger);
    color: #fff;
    font-size: 10px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    border: 2px solid #fff;
}
.icon-btn .badge-dot[hidden] { display: none; }

/* ==========================================================================
   Topbar: global search dropdown
   ========================================================================== */

.topbar-search { position: relative; }

.search-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 380px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 8px 0;
    z-index: 60;
}

.search-group-label {
    padding: 8px 16px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--color-text-muted);
}

.search-result-item {
    display: block;
    padding: 8px 16px;
    text-decoration: none;
    color: var(--color-text);
}
.search-result-item:hover { background: var(--color-secondary-soft); }
.sri-title { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.sri-subtitle { font-size: 12px; color: var(--color-text-muted); margin-top: 1px; }

.dropdown-empty {
    padding: 18px 16px;
    font-size: 13px;
    color: var(--color-text-muted);
    text-align: center;
}
.dropdown-empty a { color: var(--color-primary); font-weight: 600; }

/* ==========================================================================
   Topbar: notifications & messages popovers
   ========================================================================== */

.topbar-popover { position: relative; }

.topbar-panel {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    width: 360px;
    max-height: 460px;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    z-index: 60;
    overflow: hidden;
}
.topbar-panel[hidden] { display: none; }

.topbar-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 14px;
    color: var(--color-primary-dark);
}

.link-btn {
    background: none;
    border: none;
    color: var(--color-primary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    padding: 0;
}
.link-btn:hover { text-decoration: underline; }

.topbar-panel-body { overflow-y: auto; }

/* Notifications */
.notif-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    border-left: 3px solid transparent;
}
.notif-item.notif-danger { border-left-color: var(--color-danger); }
.notif-item.notif-warning { border-left-color: var(--color-warning); }
.notif-item.notif-info { border-left-color: var(--color-secondary); }
.notif-body { flex: 1; min-width: 0; text-decoration: none; color: var(--color-text); }
.notif-title { font-size: 12.5px; font-weight: 700; color: var(--color-text); }
.notif-message { font-size: 12.5px; color: var(--color-text-muted); margin-top: 2px; line-height: 1.4; }
.notif-time { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }
.notif-dismiss {
    background: none; border: none; cursor: pointer;
    color: var(--color-text-muted); font-size: 16px; line-height: 1;
    padding: 2px 4px; border-radius: 4px; flex-shrink: 0;
}
.notif-dismiss:hover { background: var(--color-danger-soft); color: var(--color-danger); }

/* Messages */
.msg-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    text-decoration: none;
    color: var(--color-text);
    position: relative;
}
.msg-item:hover { background: var(--color-secondary-soft); }
.msg-item.unread .msg-name { font-weight: 700; }
.msg-item.unread .msg-preview { color: var(--color-text); font-weight: 500; }
.msg-avatar {
    width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 600;
    font-family: var(--font-display);
}
.msg-body { flex: 1; min-width: 0; }
.msg-name { font-size: 13px; font-weight: 600; }
.msg-preview { font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--color-primary); flex-shrink: 0; }

@media (max-width: 720px) {
    .search-dropdown { width: 90vw; left: -8px; }
    .topbar-panel { width: 90vw; right: -60px; }
}

/* ==========================================================================
   Dashboard greeting hero
   ========================================================================== */

.page-hero {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 14px;
}
.page-hero h1 { font-size: 22px; margin-bottom: 2px; }
.page-hero .sub { color: var(--color-text-muted); font-size: 13.5px; }

.date-pill {
    display: flex; align-items: center; gap: 10px;
    background: #fff; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    padding: 9px 16px;
    font-size: 13.5px; font-weight: 500; color: var(--color-text);
}

/* ==========================================================================
   Stat cards — 6-up row, with icon + sparkline
   ========================================================================== */

.stat-grid-6 {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 14px;
    margin-bottom: 22px;
}

.stat-card-v2 {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 16px 16px 12px;
    box-shadow: var(--shadow-card);
}
.stat-card-v2 .top-row { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.stat-card-v2 .stat-icon {
    width: 32px; height: 32px; border-radius: 9px;
    background: var(--color-secondary-soft);
    color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.stat-card-v2.accent-warning .stat-icon { background: var(--color-warning-soft); color: var(--color-warning); }
.stat-card-v2 .stat-label { font-size: 11px; font-weight: 600; letter-spacing: 0.02em; color: var(--color-text-muted); text-transform: uppercase; }
.stat-card-v2 .stat-value { font-family: var(--font-display); font-size: 21px; font-weight: 700; color: var(--color-primary-dark); }
.stat-card-v2 .stat-delta { font-size: 11.5px; color: var(--color-success); margin-top: 3px; }
.stat-card-v2 .stat-delta.down { color: var(--color-danger); }
.stat-card-v2 .stat-link { font-size: 11.5px; color: var(--color-primary); margin-top: 3px; display: inline-block; }
.stat-card-v2 .sparkline { margin-top: 10px; height: 30px; }

/* ==========================================================================
   Sales Performance card
   ========================================================================== */

.chart-toolbar { display: flex; gap: 6px; }
.chart-toolbar button {
    border: 1px solid var(--color-border);
    background: #fff;
    color: var(--color-text-muted);
    font-size: 12px; font-weight: 600;
    padding: 6px 13px; border-radius: 999px;
    cursor: pointer;
}
.chart-toolbar button.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.chart-summary-row {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 10px;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}
.chart-summary-row .item .label { font-size: 11px; color: var(--color-text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.chart-summary-row .item .value { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--color-primary-dark); margin-top: 2px; }

/* ==========================================================================
   Order Pipeline (Print-on-Demand)
   ========================================================================== */

.pipeline-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.pipeline-step { display: flex; flex-direction: column; align-items: center; gap: 8px; min-width: 68px; }
.pipeline-step .circle {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--color-secondary-soft);
    color: var(--color-primary);
    display: flex; align-items: center; justify-content: center;
}
.pipeline-step.done .circle { background: var(--color-success); color: #fff; }
.pipeline-step .count { font-family: var(--font-display); font-weight: 700; font-size: 15px; color: var(--color-primary-dark); }
.pipeline-step .step-label { font-size: 10.5px; color: var(--color-text-muted); text-align: center; max-width: 76px; }
.pipeline-arrow { color: var(--color-border); flex-shrink: 0; margin: 0 2px 22px; }

/* ==========================================================================
   Priority / status badges (production queue)
   ========================================================================== */

.badge-priority-high { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-priority-medium { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-priority-low { background: var(--color-success-soft); color: var(--color-success); }

/* ==========================================================================
   Top selling products list
   ========================================================================== */

.rank-list-item {
    display: flex; align-items: center; gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--color-border);
}
.rank-list-item:last-child { border-bottom: none; }
.rank-badge {
    width: 26px; height: 26px; border-radius: 7px;
    background: var(--color-secondary-soft);
    color: var(--color-primary);
    font-size: 12px; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.rank-list-item .info { flex: 1; min-width: 0; }
.rank-list-item .name { font-size: 13.5px; font-weight: 600; }
.rank-list-item .meta { font-size: 11.5px; color: var(--color-text-muted); }
.rank-list-item .amount { font-size: 13.5px; font-weight: 700; color: var(--color-primary-dark); font-family: var(--font-display); }

/* ==========================================================================
   Inventory Summary donut + legend
   ========================================================================== */

.donut-wrap { display: flex; align-items: center; gap: 20px; }
.donut-canvas-holder { position: relative; width: 140px; height: 140px; flex-shrink: 0; }
.donut-center-label { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-center-label .val { font-family: var(--font-display); font-weight: 700; font-size: 16px; color: var(--color-primary-dark); }
.donut-center-label .lbl { font-size: 10px; color: var(--color-text-muted); }

.donut-legend { flex: 1; display: flex; flex-direction: column; gap: 10px; }
.legend-row { display: flex; align-items: center; justify-content: space-between; font-size: 12.5px; }
.legend-row .dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; margin-right: 8px; }
.legend-row .amt { font-weight: 600; color: var(--color-text); }

/* ==========================================================================
   Financial summary list
   ========================================================================== */

.finance-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 11px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 13.5px;
}
.finance-row:last-child { border-bottom: none; }
.finance-row .amt { font-weight: 700; font-family: var(--font-display); }
.finance-row.total .amt { color: var(--color-primary-dark); font-size: 16px; }
.finance-row .amt.positive { color: var(--color-success); }
.finance-row .amt.negative { color: var(--color-danger); }

/* ==========================================================================
   CRM pipeline funnel
   ========================================================================== */

.funnel-row { margin-bottom: 12px; }
.funnel-row .top { display: flex; justify-content: space-between; font-size: 12.5px; margin-bottom: 5px; }
.funnel-row .top .label { font-weight: 600; color: var(--color-text); }
.funnel-row .top .count { font-weight: 700; color: var(--color-primary-dark); font-family: var(--font-display); }
.funnel-bar-track { height: 7px; border-radius: 999px; background: var(--color-bg); overflow: hidden; }
.funnel-bar-fill { height: 100%; border-radius: 999px; background: var(--color-secondary); }

/* ==========================================================================
   Reminders & Alerts / Recent Activities
   ========================================================================== */

.alert-item, .activity-item {
    display: flex; gap: 12px;
    padding: 11px 0;
    border-bottom: 1px solid var(--color-border);
}
.alert-item:last-child, .activity-item:last-child { border-bottom: none; }
.alert-item .ai-icon, .activity-item .ai-icon {
    width: 30px; height: 30px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    background: var(--color-secondary-soft); color: var(--color-primary);
}
.alert-item.warn .ai-icon { background: var(--color-warning-soft); color: var(--color-warning); }
.alert-item.danger .ai-icon { background: var(--color-danger-soft); color: var(--color-danger); }
.alert-item.success .ai-icon, .activity-item.success .ai-icon { background: var(--color-success-soft); color: var(--color-success); }
.alert-item .title, .activity-item .title { font-size: 13px; font-weight: 600; }
.alert-item .desc { font-size: 12px; color: var(--color-text-muted); margin-top: 1px; }
.activity-item .time { font-size: 11px; color: var(--color-text-muted); margin-top: 1px; }

/* ==========================================================================
   CRUD pages — toolbar, table actions, simple form layout
   ========================================================================== */

.toolbar-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 18px; flex-wrap: wrap;
}
.toolbar-search {
    display: flex; align-items: center; gap: 9px;
    background: #fff; border: 1px solid var(--color-border);
    border-radius: var(--radius-sm); padding: 9px 14px; min-width: 260px;
}
.toolbar-search input, .toolbar-search select { border: none; outline: none; font-size: 13.5px; font-family: var(--font-body); width: 100%; background: none; }
.filter-select { padding: 9px 12px; border: 1px solid var(--color-border); border-radius: var(--radius-sm); font-size: 13.5px; background: #fff; font-family: var(--font-body); }

.table-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.icon-action {
    width: 30px; height: 30px; border-radius: var(--radius-sm);
    border: 1px solid var(--color-border); background: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    color: var(--color-text-muted); cursor: pointer;
}
.icon-action:hover { background: var(--color-secondary-soft); color: var(--color-primary); }
.icon-action.danger:hover { background: var(--color-danger-soft); color: var(--color-danger); }

.form-card { max-width: 640px; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-check { display: flex; align-items: center; gap: 9px; }
.form-check input { width: 16px; height: 16px; }
.form-check label { margin: 0; font-weight: 500; font-size: 13.5px; }
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.stock-pill { font-weight: 700; }
.stock-pill.low { color: var(--color-danger); }
.stock-pill.ok { color: var(--color-text); }

@media (max-width: 720px) {
    .form-row-2 { grid-template-columns: 1fr; }
}

@media (max-width: 1200px) {
    .stat-grid-6 { grid-template-columns: repeat(3, 1fr); }
    .chart-summary-row { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 720px) {
    .stat-grid-6 { grid-template-columns: repeat(2, 1fr); }
    .topbar-search { display: none; }
}

/* ==========================================================================
   Cards / Stat cards
   ========================================================================== */

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    padding: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-left: 4px solid var(--color-secondary);
    border-radius: var(--radius-md);
    padding: 18px 20px;
    box-shadow: var(--shadow-card);
}

.stat-card .label { font-size: 12.5px; color: var(--color-text-muted); font-weight: 500; }
.stat-card .value { font-family: var(--font-display); font-size: 26px; font-weight: 700; color: var(--color-primary-dark); margin-top: 4px; }
.stat-card .delta { font-size: 12px; margin-top: 6px; color: var(--color-success); }
.stat-card.accent-warning { border-left-color: var(--color-warning); }
.stat-card.accent-primary { border-left-color: var(--color-primary); }

.panel-grid { display: grid; grid-template-columns: 1.4fr 1fr; gap: 18px; }
.dashboard-grid { display: grid; grid-template-columns: 1.7fr 1fr; gap: 18px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
@media (max-width: 1100px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
}

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px;
}
.panel-header h3 { font-size: 15px; }

.empty-state {
    text-align: center;
    padding: 34px 18px;
    color: var(--color-text-muted);
    font-size: 13.5px;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--color-text-muted); padding: 10px 12px; border-bottom: 1px solid var(--color-border); }
td { padding: 12px; border-bottom: 1px solid var(--color-border); }
tr:last-child td { border-bottom: none; }

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
}
.badge-success { background: var(--color-success-soft); color: var(--color-success); }
.badge-warning { background: var(--color-warning-soft); color: var(--color-warning); }
.badge-danger { background: var(--color-danger-soft); color: var(--color-danger); }
.badge-info { background: var(--color-secondary-soft); color: var(--color-primary); }

/* ==========================================================================
   Forms / Buttons
   ========================================================================== */

.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--color-text); }

.form-control {
    width: 100%;
    padding: 10px 13px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-family: var(--font-body);
    background: #fff;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(30, 58, 138, 0.12);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-body);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-light); color: #fff; }
.btn-secondary { background: var(--color-secondary-soft); color: var(--color-primary); }
.btn-secondary:hover { background: var(--color-secondary); color: #fff; }
.btn-outline { background: transparent; border-color: var(--color-border); color: var(--color-text); }
.btn-block { width: 100%; justify-content: center; }

/* ==========================================================================
   Login page
   ========================================================================== */

.auth-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        radial-gradient(circle at 15% 20%, rgba(93,169,233,0.25), transparent 40%),
        radial-gradient(circle at 85% 80%, rgba(30,58,138,0.18), transparent 45%),
        var(--color-bg);
    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    padding: 34px 30px;
}

.auth-card .mark {
    width: 46px; height: 46px;
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display);
    font-weight: 700;
    margin-bottom: 16px;
}

.auth-card h1 { font-size: 19px; }
.auth-card .sub { color: var(--color-text-muted); font-size: 13.5px; margin-bottom: 22px; }

.alert {
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    margin-bottom: 16px;
    border: 1px solid transparent;
}
.alert-error { background: var(--color-danger-soft); color: var(--color-danger); border-color: rgba(220,38,38,0.2); }
.alert-success { background: var(--color-success-soft); color: var(--color-success); border-color: rgba(22,163,74,0.2); }

/* ==========================================================================
   Utility / Responsive
   ========================================================================== */

.text-muted { color: var(--color-text-muted); }
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.mt-0 { margin-top: 0; }

.sidebar-toggle { display: none; }

/* ==========================================================================
   Print (used by Reports & Analytics "Print" button and window.print())
   ========================================================================== */

@media print {
    .sidebar, .topbar, .no-print { display: none !important; }
    .app-shell { display: block !important; }
    .main-area { margin-left: 0 !important; }
    .content { padding: 0 !important; }
    body { background: #fff !important; }
    .card { box-shadow: none !important; border: 1px solid #ddd !important; break-inside: avoid; page-break-inside: avoid; }
    .dashboard-grid { display: block !important; }
    .stack { display: block !important; }
    .page-hero { margin-bottom: 14px; }
}

@media (max-width: 960px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .panel-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Printable documents (Invoice / Quotation / Purchase Order) — standalone
   layout, not wrapped in the app shell. Meant to look like something you'd
   actually hand to a customer or supplier.
   ========================================================================== */

.print-toolbar {
    max-width: 780px;
    margin: 0 auto 16px;
    padding: 14px 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.print-page {
    max-width: 780px;
    margin: 0 auto 60px;
    background: #fff;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 48px 52px;
    box-shadow: var(--shadow-card);
}

.print-letterhead {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding-bottom: 22px;
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: 26px;
}

.print-letterhead .company-block { display: flex; gap: 12px; align-items: center; }
.print-letterhead .company-block img { width: 44px; height: 44px; object-fit: contain; }
.print-letterhead .company-name { font-family: var(--font-display); font-weight: 700; font-size: 18px; color: var(--color-primary-dark); }
.print-letterhead .company-meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; line-height: 1.6; }

.print-letterhead .doc-block { text-align: right; }
.print-letterhead .doc-title { font-family: var(--font-display); font-weight: 700; font-size: 22px; color: var(--color-primary); letter-spacing: 0.04em; text-transform: uppercase; }
.print-letterhead .doc-number { font-size: 13px; color: var(--color-text-muted); margin-top: 2px; }

.print-meta-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 26px;
}
.print-meta-grid .label { font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--color-text-muted); margin-bottom: 4px; }
.print-meta-grid .value { font-size: 13.5px; font-weight: 600; color: var(--color-text); }
.print-meta-grid .value.small { font-weight: 400; font-size: 12.5px; color: var(--color-text-muted); }

.print-table { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
.print-table th {
    text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em;
    color: #fff; background: var(--color-primary); padding: 9px 12px;
}
.print-table th:last-child, .print-table td:last-child { text-align: right; }
.print-table th:nth-child(3), .print-table td:nth-child(3),
.print-table th:nth-child(4), .print-table td:nth-child(4) { text-align: right; }
.print-table td { padding: 10px 12px; border-bottom: 1px solid var(--color-border); font-size: 13px; }

.print-totals { display: flex; justify-content: flex-end; margin-bottom: 30px; }
.print-totals table { width: 260px; border-collapse: collapse; }
.print-totals td { padding: 6px 4px; font-size: 13px; }
.print-totals td:last-child { text-align: right; font-weight: 600; }
.print-totals tr.grand-total td { border-top: 2px solid var(--color-primary); padding-top: 10px; font-size: 15.5px; font-weight: 700; color: var(--color-primary-dark); }

.print-status-stamp {
    display: inline-block; padding: 5px 16px; border-radius: 6px; font-weight: 700;
    font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; border: 2px solid;
}
.print-status-stamp.paid, .print-status-stamp.received, .print-status-stamp.accepted { color: var(--color-success); border-color: var(--color-success); }
.print-status-stamp.unpaid, .print-status-stamp.overdue, .print-status-stamp.rejected { color: var(--color-danger); border-color: var(--color-danger); }
.print-status-stamp.partial, .print-status-stamp.sent, .print-status-stamp.ordered, .print-status-stamp.partially_received { color: var(--color-warning); border-color: var(--color-warning); }

.print-footer-note { font-size: 11.5px; color: var(--color-text-muted); border-top: 1px solid var(--color-border); padding-top: 16px; margin-top: 10px; }

.print-signature-row { display: flex; justify-content: space-between; margin-top: 60px; }
.print-signature-row .sig { width: 220px; text-align: center; }
.print-signature-row .sig .line { border-top: 1px solid var(--color-text); margin-bottom: 6px; padding-top: 34px; }
.print-signature-row .sig .label { font-size: 11.5px; color: var(--color-text-muted); }

@media print {
    body { background: #fff !important; }
    .print-toolbar { display: none !important; }
    .print-page { border: none !important; box-shadow: none !important; margin: 0 !important; padding: 0 !important; max-width: 100%; }
    @page { margin: 16mm; }
}

@media (max-width: 720px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .sidebar-toggle {
        display: inline-flex; align-items: center; justify-content: center;
        width: 36px; height: 36px; border-radius: var(--radius-sm);
        border: 1px solid var(--color-border); background: #fff; cursor: pointer;
    }
    .stat-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Employee E-ID card — CR80 badge proportions (85.6mm x 54mm), not the A4
   print-document layout used by invoices/POs/payslips.
   ========================================================================== */

.eid-card {
    width: 340px;
    aspect-ratio: 85.6 / 54;
    border-radius: 14px;
    background: linear-gradient(150deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: #fff;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-card);
    display: flex;
    flex-direction: column;
    font-family: var(--font-body);
}

.eid-card::before {
    content: '';
    position: absolute;
    top: -40px; right: -40px;
    width: 140px; height: 140px;
    border-radius: 50%;
    background: rgba(255,255,255,0.07);
}

.eid-card .eid-header { display: flex; align-items: center; gap: 8px; margin-bottom: 10px; }
.eid-card .eid-header img { width: 22px; height: 22px; object-fit: contain; }
.eid-card .eid-header .eid-brand { font-family: var(--font-display); font-weight: 700; font-size: 11px; letter-spacing: 0.04em; }

.eid-card .eid-body { display: flex; align-items: center; gap: 14px; flex: 1; }
.eid-card .eid-avatar {
    width: 64px; height: 64px; border-radius: 12px;
    background: rgba(255,255,255,0.15);
    display: flex; align-items: center; justify-content: center;
    font-family: var(--font-display); font-weight: 700; font-size: 22px;
    flex-shrink: 0;
    border: 1px solid rgba(255,255,255,0.25);
}
.eid-card .eid-name { font-family: var(--font-display); font-weight: 700; font-size: 15px; line-height: 1.25; }
.eid-card .eid-position { font-size: 11px; opacity: 0.85; margin-top: 2px; }
.eid-card .eid-code { font-size: 10.5px; opacity: 0.7; margin-top: 6px; letter-spacing: 0.03em; }

.eid-card .eid-qr {
    background: #fff; border-radius: 8px; padding: 4px;
    width: 56px; height: 56px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.eid-card .eid-qr canvas { width: 100% !important; height: 100% !important; }

.eid-card .eid-footer { font-size: 8.5px; opacity: 0.6; text-align: center; margin-top: 10px; letter-spacing: 0.05em; }

.eid-verify-badge {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 18px; border-radius: 999px;
    font-weight: 600; font-size: 14px;
}
.eid-verify-badge.valid { background: var(--color-success-soft); color: var(--color-success); }
.eid-verify-badge.invalid { background: var(--color-danger-soft); color: var(--color-danger); }

@media print {
    .eid-print-page {
        display: flex; justify-content: center; align-items: center; min-height: 100vh;
        page: eid-badge;
    }
    @page eid-badge { size: 90mm 57mm; margin: 0; }
}