/* ═══════════════════════════════════════════════════════════════════════════
   NPD Lifecycle Manager — Dual Theme (Light + Dark) · Accent #a5152d
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Dark Theme (default) ─────────────────────────────────────────────── */
:root {
    --bg-primary:    #0a0e17;
    --bg-secondary:  #111827;
    --bg-card:       #1a2234;
    --bg-card-hover: #1e2a3f;
    --bg-input:      #0f1724;
    --bg-sidebar:    #0d1321;

    --border-color:  #1e2d45;
    --border-light:  #2a3a55;

    --text-primary:  #e8ecf4;
    --text-secondary:#8899b4;
    --text-muted:    #7a8a9e;

    --accent:        #a5152d;
    --accent-hover:  #8c1126;
    --accent-light:  #c9354d;
    --accent-glow:   rgba(165, 21, 45, 0.15);

    --success:       #10b981;
    --success-bg:    rgba(16, 185, 129, 0.12);
    --warning:       #f59e0b;
    --warning-bg:    rgba(245, 158, 11, 0.12);
    --danger:        #ef4444;
    --danger-bg:     rgba(239, 68, 68, 0.12);
    --info:          #06b6d4;
    --info-bg:       rgba(6, 182, 212, 0.12);
    --purple:        #8b5cf6;
    --purple-bg:     rgba(139, 92, 246, 0.12);

    --accent-color:  var(--accent);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    --radius-sm:  6px;
    --radius-md:  10px;
    --radius-lg:  14px;

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.3);
    --shadow-md:  0 4px 14px rgba(0,0,0,0.4);
    --shadow-lg:  0 10px 30px rgba(0,0,0,0.5);
    --shadow-glow:0 0 20px var(--accent-glow);

    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);

    /* Theme-aware semi-transparent overlays */
    --overlay-subtle:  rgba(255,255,255,0.02);
    --overlay-light:   rgba(255,255,255,0.04);
    --overlay-medium:  rgba(255,255,255,0.06);
    --overlay-strong:  rgba(255,255,255,0.08);

    /* Modal/backdrop */
    --modal-backdrop:  rgba(0, 0, 0, 0.6);

    /* Body background gradient */
    --bg-gradient-1: rgba(165, 21, 45, 0.08);
    --bg-gradient-2: rgba(139, 92, 246, 0.05);

    /* Topbar background */
    --topbar-bg: rgba(10, 14, 23, 0.8);

    /* Scrollbar */
    --scrollbar-thumb: var(--border-color);
    --scrollbar-hover: var(--border-light);

    color-scheme: dark;
}

/* ── Light Theme ──────────────────────────────────────────────────────── */
[data-theme="light"] {
    --bg-primary:    #f4f5f9;
    --bg-secondary:  #ebedf2;
    --bg-card:       #ffffff;
    --bg-card-hover: #f8f9fb;
    --bg-input:      #f0f1f5;
    --bg-sidebar:    #ffffff;

    --border-color:  #dfe2e8;
    --border-light:  #c8ccd4;

    --text-primary:  #1a1d26;
    --text-secondary:#555b6a;
    --text-muted:    #8c919f;

    --accent:        #a5152d;
    --accent-hover:  #8c1126;
    --accent-light:  #c9354d;
    --accent-glow:   rgba(165, 21, 45, 0.10);

    --success:       #059669;
    --success-bg:    rgba(5, 150, 105, 0.10);
    --warning:       #d97706;
    --warning-bg:    rgba(217, 119, 6, 0.10);
    --danger:        #dc2626;
    --danger-bg:     rgba(220, 38, 38, 0.10);
    --info:          #0891b2;
    --info-bg:       rgba(8, 145, 178, 0.10);
    --purple:        #7c3aed;
    --purple-bg:     rgba(124, 58, 237, 0.10);

    --shadow-sm:  0 1px 3px rgba(0,0,0,0.06);
    --shadow-md:  0 4px 14px rgba(0,0,0,0.08);
    --shadow-lg:  0 10px 30px rgba(0,0,0,0.10);
    --shadow-glow:0 0 20px var(--accent-glow);

    --overlay-subtle:  rgba(0,0,0,0.015);
    --overlay-light:   rgba(0,0,0,0.03);
    --overlay-medium:  rgba(0,0,0,0.045);
    --overlay-strong:  rgba(0,0,0,0.06);

    --modal-backdrop:  rgba(0, 0, 0, 0.35);

    --bg-gradient-1: rgba(165, 21, 45, 0.03);
    --bg-gradient-2: rgba(124, 58, 237, 0.02);

    --topbar-bg: rgba(255, 255, 255, 0.85);

    --scrollbar-thumb: #ccc;
    --scrollbar-hover: #aaa;

    color-scheme: light;
}

/* ── Reset & Base ──────────────────────────────────────────────────────── */

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    background-image:
        radial-gradient(ellipse 80% 50% at 50% -20%, var(--bg-gradient-1), transparent),
        radial-gradient(ellipse 60% 40% at 100% 100%, var(--bg-gradient-2), transparent);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ── Layout ────────────────────────────────────────────────────────────── */

.app-layout {
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */

.sidebar {
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 260px;
    z-index: 100;
    overflow-y: auto;
    backdrop-filter: blur(20px);
}

[data-theme="light"] .sidebar {
    box-shadow: 2px 0 8px rgba(0,0,0,0.04);
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-brand .logo-icon {
    width: 38px; height: 38px;
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 16px; color: #fff;
    box-shadow: 0 0 16px var(--accent-glow);
}

.sidebar-brand h1 {
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
}

.sidebar-brand h1 span {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.sidebar-nav { flex: 1; padding: 12px 10px; }

.nav-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition);
    cursor: pointer;
    position: relative;
}

.nav-item:hover {
    background: var(--accent-glow);
    color: var(--text-primary);
}

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

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0; top: 6px; bottom: 6px;
    width: 3px;
    background: var(--accent);
    border-radius: 0 3px 3px 0;
}

.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active svg { opacity: 1; }

.nav-badge {
    margin-left: auto;
    background: var(--accent);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 10px;
    min-width: 20px;
    text-align: center;
}

/* ── Theme Toggle ─────────────────────────────────────────────────────── */

.theme-toggle-wrap {
    padding: 8px 20px 0;
}

.theme-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.theme-toggle:hover {
    border-color: var(--border-light);
    color: var(--text-primary);
}

.theme-toggle svg { width: 16px; height: 16px; flex-shrink: 0; }

.theme-toggle .toggle-label { flex: 1; text-align: left; }

/* ── Main Content ──────────────────────────────────────────────────────── */

.main-content {
    margin-left: 260px;
    padding: 0;
    min-height: 100vh;
    min-width: 0;
    overflow-x: hidden;
}

/* ── Top Bar ───────────────────────────────────────────────────────────── */

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    border-bottom: 1px solid var(--border-color);
    background: var(--topbar-bg);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.topbar-actions { display: flex; gap: 10px; align-items: center; }

/* ── Page Container ────────────────────────────────────────────────────── */

.page-content { padding: 28px 32px; min-width: 0; }

/* ── Cards ─────────────────────────────────────────────────────────────── */

.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(8px);
}

.card:hover {
    border-color: var(--border-light);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.card-title {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

/* ── Stat Cards (Dashboard) ────────────────────────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px 22px;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
}

.stat-card.blue::before   { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.stat-card.green::before  { background: linear-gradient(90deg, var(--success), #34d399); }
.stat-card.amber::before  { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.stat-card.red::before    { background: linear-gradient(90deg, var(--danger), #f87171); }
.stat-card.purple::before { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.stat-card.cyan::before   { background: linear-gradient(90deg, var(--info), #22d3ee); }

.stat-card:hover {
    border-color: var(--border-light);
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.stat-card.blue:hover   { box-shadow: 0 4px 20px rgba(165,21,45,0.15); }
.stat-card.green:hover  { box-shadow: 0 4px 20px rgba(16,185,129,0.15); }
.stat-card.amber:hover  { box-shadow: 0 4px 20px rgba(245,158,11,0.15); }
.stat-card.red:hover    { box-shadow: 0 4px 20px rgba(239,68,68,0.15); }
.stat-card.purple:hover { box-shadow: 0 4px 20px rgba(139,92,246,0.15); }
.stat-card.cyan:hover   { box-shadow: 0 4px 20px rgba(6,182,212,0.15); }

.stat-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.stat-value {
    font-size: 26px;
    font-weight: 800;
    letter-spacing: -0.03em;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card.blue .stat-value   { color: var(--accent); }
.stat-card.green .stat-value  { color: var(--success); }
.stat-card.amber .stat-value  { color: var(--warning); }
.stat-card.red .stat-value    { color: var(--danger); }
.stat-card.purple .stat-value { color: var(--purple); }
.stat-card.cyan .stat-value   { color: var(--info); }

/* ── Buttons ───────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}

.btn svg { width: 16px; height: 16px; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-light));
    color: #fff;
    box-shadow: 0 0 12px var(--accent-glow);
}
.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover), var(--accent));
    box-shadow: 0 0 24px var(--accent-glow), 0 0 8px rgba(165,21,45,0.2);
    transform: translateY(-1px);
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border-light);
}

.btn-success {
    background: var(--success);
    color: #fff;
}
.btn-success:hover { filter: brightness(1.1); }

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger-bg);
}

.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-xs { padding: 3px 8px; font-size: 11px; }
.btn-icon { padding: 6px; }
.btn:disabled, .btn[disabled] {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* ── Tables ────────────────────────────────────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    -webkit-overflow-scrolling: touch;
}

td.text-right, th.text-right { text-align: right; }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: var(--overlay-subtle);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
}

thead th:hover { color: var(--text-secondary); }

tbody td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: middle;
}

tbody tr { transition: background var(--transition); }
tbody tr:hover { background: var(--overlay-subtle); }
tbody tr:last-child td { border-bottom: none; }

/* ── Status Badges ─────────────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
}

.badge-draft       { background: var(--overlay-medium); color: var(--text-muted); }
.badge-draft::before { background: var(--text-muted); }

.badge-in_review, .badge-in-review   { background: var(--info-bg); color: var(--info); }
.badge-in_review::before, .badge-in-review::before { background: var(--info); }

.badge-approved    { background: var(--success-bg); color: var(--success); }
.badge-approved::before { background: var(--success); }

.badge-rejected    { background: var(--danger-bg); color: var(--danger); }
.badge-rejected::before { background: var(--danger); }

.badge-on_hold, .badge-on-hold     { background: var(--warning-bg); color: var(--warning); }
.badge-on_hold::before, .badge-on-hold::before { background: var(--warning); }

.badge-production  { background: var(--purple-bg); color: var(--purple); }
.badge-production::before { background: var(--purple); }

.badge-cancelled   { background: var(--overlay-light); color: var(--text-muted); }
.badge-cancelled::before { background: var(--text-muted); }

/* Priority badges */
.priority-low      { color: var(--text-muted); }
.priority-medium   { color: var(--info); }
.priority-high     { color: var(--warning); }
.priority-critical { color: var(--danger); font-weight: 700; }

/* Generic colour badges used in help/FAQ */
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-warning::before { background: var(--warning); }
.badge-info { background: var(--info-bg); color: var(--info); }
.badge-info::before { background: var(--info); }
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-success::before { background: var(--success); }
.badge-danger { background: var(--danger-bg); color: var(--danger); }
.badge-danger::before { background: var(--danger); }

/* ── Forms ─────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 18px; }

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 9px 14px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    transition: all var(--transition);
    outline: none;
}

.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow), 0 0 12px rgba(165,21,45,0.08);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%235a6a84' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

textarea.form-control { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.form-hint {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Filters Bar ───────────────────────────────────────────────────────── */

.filters-bar {
    display: flex;
    gap: 12px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.filters-bar .form-control {
    width: auto;
    min-width: 140px;
    max-width: 200px;
    flex: 0 1 auto;
    padding: 7px 12px;
    font-size: 12px;
}

.filters-bar .search-input {
    flex: 1 1 180px;
    min-width: 140px;
    max-width: none;
}

.filter-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ── Modals ────────────────────────────────────────────────────────────── */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

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

.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 20px;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 24px; }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ── Tabs ──────────────────────────────────────────────────────────────── */

.tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.tab-item {
    padding: 10px 20px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}

.tab-item:hover { color: var(--text-secondary); }

.tab-item.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* ── Activity / Timeline ───────────────────────────────────────────────── */

.timeline { padding: 0; list-style: none; }

.timeline-item {
    display: flex;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-color);
}

.timeline-item:last-child { border-bottom: none; }

.timeline-dot {
    width: 28px; height: 28px;
    border-radius: 50%;
    margin-top: 2px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}
.timeline-dot svg { opacity: 0.85; }

.timeline-dot.system       { background: var(--overlay-medium); color: var(--text-muted); }
.timeline-dot.comment      { background: var(--accent-glow); color: var(--accent); }
.timeline-dot.approval     { background: var(--success-bg); color: var(--success); }
.timeline-dot.status_change{ background: var(--warning-bg); color: var(--warning); }
.timeline-dot.formulation  { background: var(--info-bg); color: var(--info); }
.timeline-dot.field_change { background: var(--purple-bg); color: var(--purple); }
.timeline-dot.image        { background: var(--success-bg); color: var(--success); }
.timeline-dot.phase        { background: var(--warning-bg); color: var(--warning); }

.timeline-content { flex: 1; }
.timeline-content p { font-size: 13px; color: var(--text-secondary); }
.timeline-meta {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── Cost Breakdown Bars ───────────────────────────────────────────────── */

.cost-bar-group { margin-bottom: 14px; }

.cost-bar-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    margin-bottom: 4px;
}

.cost-bar-label span:first-child { color: var(--text-secondary); font-weight: 500; }
.cost-bar-label span:last-child  { color: var(--text-primary); font-weight: 700; font-variant-numeric: tabular-nums; }

.cost-bar-track {
    height: 8px;
    background: var(--overlay-medium);
    border-radius: 4px;
    overflow: hidden;
}

.cost-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.cost-bar-fill.ingredients { background: linear-gradient(90deg, var(--accent), var(--accent-light)); }
.cost-bar-fill.labour      { background: linear-gradient(90deg, var(--purple), #a78bfa); }
.cost-bar-fill.overhead    { background: linear-gradient(90deg, var(--warning), #fbbf24); }
.cost-bar-fill.packaging   { background: linear-gradient(90deg, var(--success), #34d399); }

/* ── Workflow Steps ────────────────────────────────────────────────────── */

.workflow-steps {
    display: flex;
    align-items: center;
    gap: 0;
    padding: 20px 0;
    overflow-x: auto;
}

.workflow-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 120px;
    position: relative;
}

.workflow-step-dot {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    border: 2px solid var(--border-color);
    background: var(--bg-card);
    color: var(--text-muted);
    transition: all var(--transition);
    z-index: 2;
}

.workflow-step.completed .workflow-step-dot {
    border-color: var(--success);
    background: var(--success);
    color: #fff;
}

.workflow-step.current .workflow-step-dot {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
    box-shadow: 0 0 14px var(--accent-glow);
}

.workflow-step.rejected .workflow-step-dot {
    border-color: var(--danger);
    background: var(--danger);
    color: #fff;
}

.workflow-step-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-top: 8px;
    text-align: center;
    max-width: 100px;
}

.workflow-step.completed .workflow-step-label { color: var(--success); }
.workflow-step.current .workflow-step-label   { color: var(--accent); }

.workflow-connector {
    flex: 1;
    height: 2px;
    background: var(--border-color);
    min-width: 40px;
    margin-top: -16px;
}

.workflow-connector.done { background: var(--success); }

/* ── Toasts ────────────────────────────────────────────────────────────── */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 20px;
    font-size: 13px;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease-out;
    max-width: 380px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--accent); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ── Empty State ───────────────────────────────────────────────────────── */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text-secondary); margin-bottom: 8px; }
.empty-state p { font-size: 13px; max-width: 360px; margin: 0 auto 20px; }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-hover); }

/* ── Responsive ────────────────────────────────────────────────────────── */

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

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

/* ── Mobile hamburger button ─────────────────────────────────────────── */

.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px 8px;
    margin-right: 8px;
    transition: all var(--transition);
}
.hamburger-btn:hover { background: var(--bg-card-hover); }
.hamburger-btn svg { width: 20px; height: 20px; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--modal-backdrop);
    z-index: 99;
}
.sidebar-backdrop.active { display: block; }

@media (max-width: 768px) {
    .hamburger-btn { display: inline-flex; }
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }
    .sidebar.mobile-open {
        transform: translateX(0);
    }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .form-row { grid-template-columns: 1fr; }
    .page-content { padding: 20px 16px; }
    .topbar { padding: 12px 16px; flex-wrap: wrap; gap: 8px; }
    .topbar h2 { font-size: 16px; }
    .topbar-actions { flex-wrap: wrap; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .filters-bar { flex-direction: column; align-items: stretch; }
    .filters-bar .form-control { width: 100%; min-width: unset; }
}

/* ── Form Utility Components ───────────────────────────────────────────── */

.password-field-wrapper {
    position: relative;
}
.password-field-wrapper .password-toggle-btn {
    position: absolute;
    right: 4px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    cursor: pointer;
    transition: all var(--transition);
}
.password-toggle-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-light);
}

.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
}

/* ── Utility ───────────────────────────────────────────────────────────── */

.text-right { text-align: right; }
.text-center { text-align: center; }
.text-mono { font-family: var(--font-mono); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; min-width: 0; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; min-width: 0; }

.clickable-row { cursor: pointer; }

/* ── Accessibility ─────────────────────────────────────────────────── */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--accent);
    color: #fff;
    padding: 8px 16px;
    z-index: 200;
    font-size: 13px;
    font-weight: 600;
    border-radius: 0 0 var(--radius-sm) 0;
    transition: top 0.2s;
}
.skip-link:focus { top: 0; }

/* Visible keyboard focus ring for interactive controls. Uses :focus-visible
   so it only appears for keyboard/AT users, never on mouse click. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
.nav-item:focus-visible,
.modal-close:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent-light);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

.clickable-row:hover td { color: var(--text-primary); }

.loading-spinner {
    width: 20px; height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ── Range Sliders ────────────────────────────────────────────────────── */

input[type="range"].form-range {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    outline: none;
    cursor: pointer;
}

input[type="range"].form-range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 6px rgba(165,21,45,0.4);
    cursor: pointer;
}

input[type="range"].form-range::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent);
    border: 2px solid var(--bg-card);
    box-shadow: 0 0 6px rgba(165,21,45,0.4);
    cursor: pointer;
}

/* ── File Input ───────────────────────────────────────────────────────── */

input[type="file"].form-control {
    padding: 8px;
    line-height: 1.4;
}

input[type="file"].form-control::file-selector-button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-right: 10px;
}

/* ── Animations ──────────────────────────────────────────────────────── */

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

.page-content .card,
.page-content .stats-grid,
.page-content .table-wrapper,
.page-content .filters-bar {
    animation: fadeInUp 0.35s ease-out both;
}

.page-content .stats-grid { animation-delay: 0.05s; }
.page-content .card:nth-child(2) { animation-delay: 0.1s; }
.page-content .card:nth-child(3) { animation-delay: 0.15s; }

.nav-item.active {
    box-shadow: inset 0 0 20px var(--accent-glow);
}

.sidebar-brand .logo-icon {
    animation: pulseGlow 3s ease-in-out infinite;
}

@keyframes pulseGlow {
    0%, 100% { box-shadow: 0 0 16px var(--accent-glow); }
    50% { box-shadow: 0 0 24px rgba(165,21,45,0.3), 0 0 8px rgba(165,21,45,0.15); }
}

.workflow-step.current .workflow-step-dot {
    animation: pulseGlow 2s ease-in-out infinite;
}

/* ── Help & FAQ Page Styles ───────────────────────────────────────────── */

.help-section { margin-bottom: 32px; }
.help-section h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.help-section h3 .section-icon {
    width: 28px; height: 28px;
    border-radius: var(--radius-sm);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}
.help-section p, .help-section li {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.8;
}
.help-section ul { padding-left: 20px; }
.help-section ol { padding-left: 20px; }
.help-section li { margin-bottom: 4px; }

.faq-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
    transition: border-color var(--transition);
}
.faq-item:hover { border-color: var(--border-light); }

.faq-question {
    padding: 16px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--overlay-subtle);
    transition: background var(--transition);
    list-style: none;
}
.faq-question::-webkit-details-marker { display: none; }
.faq-question::after {
    content: '+';
    font-size: 18px;
    color: var(--text-muted);
    transition: transform var(--transition);
    flex-shrink: 0;
}
details.faq-item[open] > .faq-question::after { transform: rotate(45deg); }
.faq-question:hover { background: var(--overlay-light); }

.faq-answer {
    padding: 0 20px 20px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.shortcut-key {
    display: inline-block;
    padding: 2px 8px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-secondary);
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.feature-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: all var(--transition);
}
.feature-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.feature-card h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-primary);
}
.feature-card p {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* ── User Session Indicator (Topbar) ──────────────────────────────────── */

.user-session-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 8px 6px 6px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    margin-left: 12px;
    transition: all var(--transition);
}

.user-session-indicator:hover {
    border-color: var(--border-light);
}

.session-avatar {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    text-transform: uppercase;
}

.session-avatar.sa-admin   { background: linear-gradient(135deg, #ef4444, #dc2626); }
.session-avatar.sa-manager { background: linear-gradient(135deg, #f59e0b, #d97706); }
.session-avatar.sa-user    { background: linear-gradient(135deg, var(--accent), var(--accent-light)); }
.session-avatar.sa-viewer  { background: linear-gradient(135deg, #6b7280, #4b5563); }

.session-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.session-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.session-role {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: capitalize;
}

.session-logout {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
    margin-left: 2px;
}

.session-logout:hover {
    background: var(--danger-bg);
    color: var(--danger);
}
