/* static/css/main.css */

/* ========================================
   RESET & BASE STYLES
   ======================================== */
*,
*::before,
*::after {
    box-sizing: border-box;
}

:root {
    /* Colors — warm "directives" theme */
    --bg: #f5f3ef;            /* page background (warm cream) */
    --surface: #ffffff;       /* cards / panels */

    --primary: #292524;       /* charcoal accent (buttons, brand, active) */
    --primary-hover: #1c1917;
    --primary-light: #57534e;

    --indigo-50: #f3f1ed;
    --indigo-100: #ebe7e0;
    --indigo-600: #292524;

    --blue-50: #f1f0ec;

    --green-600: #15803d;     /* positive deltas */
    --green-bg: #e7f3ec;
    --amber-600: #b45309;     /* today / this week */
    --amber-bg: #fbf3df;
    --orange-600: #b45309;
    --red-600: #dc2626;       /* urgent */
    --red-700: #b91c1c;
    --red-bg: #fbeaea;

    /* Warm gray ramp (stone-like) */
    --gray-50: #f7f5f1;
    --gray-100: #efece6;
    --gray-200: #e7e3db;      /* borders */
    --gray-300: #d6d1c7;
    --gray-400: #b3aca0;
    --gray-500: #8a8579;
    --gray-600: #6b6659;
    --gray-700: #514c42;
    --gray-800: #322f29;
    --gray-900: #1a1a1a;

    /* Typography */
    --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Monaco, 'Cascadia Mono', Consolas, monospace;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;

    /* Border radius */
    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;

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

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
    background: var(--bg);
    color: var(--gray-900);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ========================================
   LAYOUT
   ======================================== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container {
        padding: 0 1.5rem;
    }
}

@media (min-width: 1024px) {
    .container {
        padding: 0 2rem;
    }
}

/* ========================================
   HEADER
   ======================================== */
header {
    background: var(--bg);
    border-bottom: 1px solid var(--gray-200);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 50;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: none;
    padding: 0 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

.logo:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-right > a {
    color: var(--gray-700);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-right > a:hover {
    color: var(--primary);
    text-decoration: none;
}

/* User Menu */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    background: white;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.user-menu-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
}

.user-icon {
    width: 1.25rem;
    height: 1.25rem;
    fill: currentColor;
}

.chevron {
    width: 1rem;
    height: 1rem;
    fill: currentColor;
    transition: transform 0.2s;
}

.user-menu-btn:hover .chevron {
    transform: translateY(1px);
}

#user-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    min-width: 200px;
    overflow: hidden;
    z-index: 100;
}

#user-dropdown.show {
    display: block;
    animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

#user-dropdown a,
#user-dropdown button {
    display: block;
    width: 100%;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    transition: background 0.15s;
    font-size: 0.875rem;
}

#user-dropdown button {
    text-align: left;
    background: none;
    border: none;
    font-family: inherit;
    cursor: pointer;
}

#user-dropdown a:hover,
#user-dropdown button:hover {
    background: var(--gray-50);
    text-decoration: none;
}

#user-dropdown hr {
    margin: 0;
    border: none;
    border-top: 1px solid var(--gray-200);
}

#user-dropdown .text-red {
    color: var(--red-600);
}

#user-dropdown .text-red:hover {
    background: #fef2f2;
}

/* ========================================
   MAIN CONTENT
   ======================================== */
main {
    padding: 0;
    min-height: calc(100vh - 200px);
}

.company-name {
    font-size: 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
}

.user-menu-wrap {
    position: relative;
}

/* ========================================
   CARDS
   ======================================== */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}

.card:hover {
    box-shadow: var(--shadow);
}

/* ========================================
   BUTTONS
   ======================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    text-decoration: none;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-outline {
    background: white;
    color: var(--gray-700);
    border-color: var(--gray-300);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    text-decoration: none;
}

.btn-outline.active,
.metric-toggle.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.metric-toggle.active:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
}

/* Period toggle (segmented control style) */
.period-toggle {
    color: var(--gray-600);
    border-radius: var(--radius-sm);
    transition: all 0.15s ease;
}

.period-toggle:hover {
    background: var(--gray-200);
}

.period-toggle.active {
    background: white;
    color: var(--gray-900);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.period-toggle.active:hover {
    background: white;
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.btn-danger {
    background: var(--red-600);
    color: white;
    border-color: var(--red-600);
}

.btn-danger:hover {
    background: var(--red-700);
    border-color: var(--red-700);
}

.btn-success {
    background: var(--green-600);
    color: white;
    border-color: var(--green-600);
}

.btn-icon {
    padding: 0.5rem;
    min-width: 2.25rem;
}

button, input[type="submit"] {
    font-family: inherit;
}

/* ========================================
   TYPOGRAPHY
   ======================================== */
h1, h2, h3, h4, h5, h6 {
    margin: 0;
    font-weight: 600;
    line-height: 1.2;
    color: var(--gray-900);
}

h1 {
    font-size: 1.875rem;
    font-weight: 700;
}

h2 {
    font-size: 1.5rem;
}

h3 {
    font-size: 1.25rem;
}

p {
    margin: 0;
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--primary-hover);
    text-decoration: underline;
}

/* Text Utilities */
.text-xs {
    font-size: 0.75rem;
    line-height: 1rem;
}

.text-sm {
    font-size: 0.875rem;
    line-height: 1.25rem;
}

.text-lg {
    font-size: 1.125rem;
    line-height: 1.75rem;
}

.text-xl {
    font-size: 1.25rem;
    line-height: 1.75rem;
}

.text-2xl {
    font-size: 1.5rem;
    line-height: 2rem;
}

.text-3xl {
    font-size: 1.875rem;
    line-height: 2.25rem;
}

.text-4xl {
    font-size: 2.25rem;
    line-height: 2.5rem;
}

.font-medium {
    font-weight: 500;
}

.font-semibold {
    font-weight: 600;
}

.font-bold {
    font-weight: 700;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Color Utilities */
.text-gray-500 {
    color: var(--gray-500);
}

.text-gray-600 {
    color: var(--gray-600);
}

.text-gray-700 {
    color: var(--gray-700);
}

.text-gray-800 {
    color: var(--gray-800);
}

.text-gray-900 {
    color: var(--gray-900);
}

.text-indigo-600 {
    color: var(--indigo-600);
}

.text-green-600 {
    color: var(--green-600);
}

.text-orange-600 {
    color: var(--orange-600);
}

.text-red {
    color: var(--red-600);
}

.text-muted {
    color: var(--gray-500);
}

.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.whitespace-pre-line {
    white-space: pre-line;
}

/* ========================================
   SPACING UTILITIES
   ======================================== */
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }
.mb-10 { margin-bottom: var(--space-10); }

.mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-8 { margin-top: var(--space-8); }

.mx-auto { margin-left: auto; margin-right: auto; }

.py-3 { padding-top: var(--space-3); padding-bottom: var(--space-3); }
.py-8 { padding-top: var(--space-8); padding-bottom: var(--space-8); }
.py-10 { padding-top: var(--space-10); padding-bottom: var(--space-10); }

.px-8 { padding-left: var(--space-8); padding-right: var(--space-8); }

.p-10 { padding: var(--space-10); }

/* ========================================
   LAYOUT UTILITIES
   ======================================== */
.flex {
    display: flex;
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-1 {
    flex: 1;
}

.items-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-2 {
    gap: var(--space-2);
}

.gap-3 {
    gap: var(--space-3);
}

.gap-4 {
    gap: var(--space-4);
}

.gap-6 {
    gap: var(--space-6);
}

/* Grid */
.grid {
    display: grid;
}

.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

@media (min-width: 640px) {
    .sm\:grid-cols-2 {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (min-width: 1024px) {
    .lg\:grid-cols-4 {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

/* Width */
.max-w-2xl {
    max-width: 42rem;
}

/* ========================================
   BACKGROUND UTILITIES
   ======================================== */
.bg-gradient-to-r {
    background-image: linear-gradient(to right, var(--gradient-from), var(--gradient-to));
}

.from-indigo-50 {
    --gradient-from: var(--indigo-50);
}

.to-blue-50 {
    --gradient-to: var(--blue-50);
}

/* ========================================
   BORDER UTILITIES
   ======================================== */
.rounded-xl {
    border-radius: var(--radius-xl);
}

.border {
    border-width: 1px;
    border-style: solid;
}

.border-indigo-100 {
    border-color: var(--indigo-100);
}

/* ========================================
   MISC UTILITIES
   ======================================== */
.opacity-70 {
    opacity: 0.7;
}

.leading-relaxed {
    line-height: 1.625;
}

/* ========================================
   FOOTER
   ======================================== */
footer {
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 2rem 0;
    margin-top: 4rem;
    color: var(--gray-600);
    font-size: 0.875rem;
}

footer .container {
    text-align: center;
}

/* ========================================
   FORMS
   ======================================== */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="tel"],
input[type="date"],
input[type="file"],
select,
textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--gray-900);
    background: white;
    transition: all 0.2s;
}

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

label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-700);
    margin-bottom: 0.375rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

/* ========================================
   MAIN NAVIGATION
   ======================================== */

/* Main nav container - horizontal layout */
.main-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.25rem;
    margin-left: 2rem;
}

/* Nav link styling - pill tabs, shared by links and dropdown button */
.nav-link {
    display: inline-flex;
    align-items: center;
    padding: 0.4375rem 0.875rem;
    color: var(--gray-600);
    font-weight: 500;
    font-size: 0.9375rem;
    text-decoration: none;
    border-radius: 999px;
    transition: all 0.15s;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    font-family: inherit;
}

.nav-link:hover {
    color: var(--gray-900);
    background: var(--gray-100);
    text-decoration: none;
}

/* Active pill (current section) */
.nav-link.active,
.nav-dropdown.active .nav-dropdown-btn {
    color: var(--gray-900);
    background: var(--surface);
    border-color: var(--gray-200);
    box-shadow: var(--shadow-sm);
}

/* Nav dropdown container */
.nav-dropdown {
    position: relative;
    display: inline-flex;
}

/* Dropdown button inherits nav-link style, no extra styling needed */
.nav-dropdown-btn {
    /* Inherits from .nav-link */
}

.nav-dropdown.open .nav-dropdown-btn {
    color: var(--primary);
}

/* Nav dropdown menu */
.nav-dropdown .nav-dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    min-width: 160px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
}

.nav-dropdown-menu a {
    display: block;
    padding: 0.625rem 1rem;
    color: var(--gray-700);
    font-size: 0.875rem;
    text-decoration: none;
    transition: background 0.15s;
}

.nav-dropdown-menu a:hover {
    background: var(--gray-50);
    color: var(--primary);
    text-decoration: none;
}

/* Responsive - hide nav on small screens */
@media (max-width: 768px) {
    .main-nav {
        display: none;
    }
}

/* ========================================
   APP SHELL + SIDEBAR
   ======================================== */
.app-shell {
    display: flex;
    align-items: flex-start;
    padding: 0;
    gap: 0;
}

.sidebar {
    width: 240px;
    flex-shrink: 0;
    align-self: stretch;
    padding: 1.75rem 1.25rem 2rem 2rem;
    position: sticky;
    top: 72px;
}

.app-content {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 1500px;
    background: var(--surface);
    padding: 1.75rem 2rem 2.5rem 2rem;
    border-left: 1px solid var(--gray-200);
}

/* When there's no sidebar (logged-out pages), content spans full width */
.app-content.full {
    padding-left: 0;
    border-left: none;
}

.sidebar-group {
    margin-bottom: 1.75rem;
}

.sidebar-group-label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--gray-500);
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    color: var(--gray-700);
    font-size: 0.9375rem;
    text-decoration: none;
    border: 1px solid transparent;
    transition: all 0.15s;
}

.sidebar-link:hover {
    background: var(--gray-100);
    color: var(--gray-900);
    text-decoration: none;
}

.sidebar-link.active {
    background: var(--surface);
    border-color: var(--gray-200);
    box-shadow: var(--shadow-sm);
    color: var(--gray-900);
    font-weight: 600;
}

.sidebar-count {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    font-weight: 700;
    color: #fff;
    background: var(--red-600);
    padding: 0.0625rem 0.4375rem;
    border-radius: 999px;
    min-width: 1.25rem;
    text-align: center;
    line-height: 1.4;
}

.sidebar-count.muted {
    background: var(--gray-300);
    color: var(--gray-700);
}

.sidebar-empty {
    padding: 0 0.75rem;
    font-size: 0.8125rem;
    color: var(--gray-500);
}

/* Mobile: sidebar collapses, toggled by .sidebar-toggle */
.sidebar-toggle {
    display: none;
}

@media (max-width: 900px) {
    .app-shell {
        flex-direction: column;
        padding: 0 1.5rem;
    }
    .sidebar {
        position: static;
        width: 100%;
        padding: 1rem 0;
        border-bottom: 1px solid var(--gray-200);
    }
    .sidebar:not(.open) .sidebar-body {
        display: none;
    }
    .app-content {
        width: 100%;
        padding: 1.5rem 0 2.5rem 0;
        border-left: none;
    }
    .sidebar-toggle {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        background: var(--surface);
        border: 1px solid var(--gray-200);
        border-radius: 8px;
        padding: 0.5rem 0.875rem;
        font-size: 0.875rem;
        font-weight: 600;
        color: var(--gray-800);
        cursor: pointer;
        font-family: inherit;
    }
}

/* ========================================
   KPI CARDS (dashboard)
   ======================================== */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: 14px;
    padding: 1.125rem 1.25rem;
    text-decoration: none;
    display: block;
    transition: box-shadow 0.15s, border-color 0.15s;
}

a.kpi-card:hover {
    border-color: var(--gray-300);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
}

.kpi-label {
    font-family: var(--font-mono);
    font-size: 0.6875rem;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--gray-500);
    margin-bottom: 0.625rem;
}

.kpi-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--gray-900);
}

.kpi-sub {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.5rem;
}

.kpi-sub.pos { color: var(--green-600); }
.kpi-sub.neg { color: var(--red-600); }
.kpi-sub.warn { color: var(--amber-600); }

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

@media (max-width: 560px) {
    .kpi-grid { grid-template-columns: 1fr; }
}

/* ========================================
   DIRECTIVES (Today's Directives list)
   ======================================== */
.directives-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 1rem;
    margin-bottom: 1rem;
}

.directives-subtitle {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--gray-500);
    white-space: nowrap;
}

/* ========================================
   TABLES
   ======================================== */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table thead tr {
    border-bottom: 2px solid var(--gray-200);
    background: var(--gray-50);
}

.table th {
    text-align: left;
    padding: 0.75rem 1rem;
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.table th.text-right {
    text-align: right;
}

.table th.text-center {
    text-align: center;
}

.table tbody tr {
    border-bottom: 1px solid var(--gray-100);
    transition: background 0.15s;
}

.table tbody tr:hover {
    background: var(--gray-50);
}

.table td {
    padding: 0.75rem 1rem;
    color: var(--gray-700);
}

.table td.text-right {
    text-align: right;
}

.table td.text-center {
    text-align: center;
}

.table-container {
    overflow-x: auto;
}

/* ========================================
   STATUS BADGES
   ======================================== */
.badge {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-sm);
    text-transform: capitalize;
}

.badge-lg {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.badge-success {
    background: var(--green-bg);
    color: var(--green-600);
}

.badge-warning {
    background: var(--amber-bg);
    color: var(--amber-600);
}

.badge-danger {
    background: var(--red-bg);
    color: var(--red-600);
}

.badge-neutral {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-primary {
    background: var(--indigo-100);
    color: var(--indigo-600);
}

/* ========================================
   STAT CARDS
   ======================================== */
.stat-card {
    text-align: center;
    padding: 1.5rem;
}

.stat-value {
    font-size: 2.25rem;
    font-weight: 700;
    color: var(--indigo-600);
    line-height: 1.2;
}

.stat-label {
    color: var(--gray-600);
    margin-top: 0.5rem;
    font-size: 0.875rem;
}

/* Mini stat cards for dashboard */
.stat-card-mini {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    text-align: center;
}

.stat-value-mini {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-label-mini {
    color: var(--gray-500);
    margin-top: 0.25rem;
    font-size: 0.75rem;
    font-weight: 500;
}

.stat-card-clickable {
    cursor: pointer;
    transition: all 0.15s ease;
}

.stat-card-clickable:hover {
    background: white;
    border-color: var(--indigo-300);
    box-shadow: var(--shadow-sm);
}

.text-red-600 {
    color: var(--red-600);
}

.text-gray-400 {
    color: var(--gray-300);
}

/* ========================================
   INFO GRID (for detail pages)
   ======================================== */
.info-grid {
    display: grid;
    gap: 1rem;
}

.info-item label,
.info-label {
    display: block;
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.info-value {
    font-weight: 500;
    color: var(--gray-900);
}

/* ========================================
   PAGE HEADER
   ======================================== */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.page-header-actions {
    display: flex;
    gap: 0.75rem;
}

/* ========================================
   FILTERS BAR
   ======================================== */
.filters-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    padding: 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0;
}

.filter-group input,
.filter-group select {
    min-width: 150px;
    width: auto;
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
    margin-left: auto;
}

/* ========================================
   EMPTY STATE
   ======================================== */
.empty-state {
    text-align: center;
    padding: 3rem 2rem;
    background: linear-gradient(to right, var(--indigo-50), var(--blue-50));
    border-radius: var(--radius-xl);
    border: 1px solid var(--indigo-100);
}

.empty-state h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
}

.empty-state p {
    color: var(--gray-600);
    max-width: 32rem;
    margin: 0 auto 2rem;
    line-height: 1.625;
}

.empty-state-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}

/* ========================================
   TWO COLUMN LAYOUT
   ======================================== */
.two-col {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: 1fr;
}

@media (min-width: 768px) {
    .two-col {
        grid-template-columns: 1fr 1fr;
    }
}

/* ========================================
   SECTION HEADER (inside cards)
   ======================================== */
.section-header {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--gray-900);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

/* ========================================
   FORM SECTIONS
   ======================================== */
.form-section {
    margin-bottom: 2rem;
}

.form-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.form-row {
    display: grid;
    gap: 1rem;
    grid-template-columns: 1fr;
}

@media (min-width: 640px) {
    .form-row-2 {
        grid-template-columns: repeat(2, 1fr);
    }

    .form-row-3 {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========================================
   CHANGE LOG / ACTIVITY FEED
   ======================================== */
.activity-feed {
    display: grid;
    gap: 0.75rem;
}

.activity-item {
    display: flex;
    gap: 1rem;
    padding: 0.75rem;
    background: var(--gray-50);
    border-radius: var(--radius);
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--gray-900);
}

.activity-meta {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

/* ========================================
   FILE UPLOAD / DROP ZONE
   ======================================== */
.drop-zone {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 3rem 2rem;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
}

.drop-zone:hover,
.drop-zone.drag-over {
    border-color: var(--primary);
    background: var(--indigo-50);
}

.drop-zone-icon {
    width: 3rem;
    height: 3rem;
    color: var(--gray-400);
    margin: 0 auto 1rem;
}

.drop-zone-text {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.drop-zone-text strong {
    color: var(--primary);
}

/* ========================================
   PAGINATION
   ======================================== */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

.pagination a,
.pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2rem;
    height: 2rem;
    padding: 0 0.5rem;
    font-size: 0.875rem;
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.15s;
}

.pagination a {
    color: var(--gray-700);
    background: white;
    border: 1px solid var(--gray-300);
}

.pagination a:hover {
    background: var(--gray-50);
    border-color: var(--gray-400);
    text-decoration: none;
}

.pagination .current {
    background: var(--primary);
    color: white;
    border: 1px solid var(--primary);
    font-weight: 600;
}

.pagination .disabled {
    color: var(--gray-400);
    background: var(--gray-100);
    border: 1px solid var(--gray-200);
    cursor: not-allowed;
}

/* ========================================
   LINKS
   ======================================== */
.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.link:hover {
    text-decoration: underline;
}

/* ========================================
   UTILITY CLASSES
   ======================================== */
.hidden {
    display: none;
}

.block {
    display: block;
}

.inline-block {
    display: inline-block;
}

.relative {
    position: relative;
}

.absolute {
    position: absolute;
}

/* Accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */
@media (max-width: 640px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .card {
        padding: 1.25rem;
    }

    main {
        padding: 1.5rem 0;
    }

    .btn {
        width: 100%;
        justify-content: center;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .page-header-actions {
        width: 100%;
        flex-direction: column;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group input,
    .filter-group select {
        width: 100%;
    }

    .filter-actions {
        margin-left: 0;
        margin-top: 0.5rem;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.fade-in {
    animation: fadeIn 0.3s ease-in;
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    header,
    footer,
    .no-print {
        display: none;
    }

    body {
        background: white;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--gray-300);
    }
}

/* ========================================
   SKU FORECAST DETAIL PAGE STYLES
   Add these styles to the end of main.css
   ======================================== */

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.breadcrumb a {
    color: var(--gray-500);
    text-decoration: none;
}

.breadcrumb a:hover {
    color: var(--primary);
    text-decoration: underline;
}

.breadcrumb-sep {
    color: var(--gray-400);
}

/* SKU Info Grid - 6 cards */
.sku-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 768px) {
    .sku-info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (min-width: 1024px) {
    .sku-info-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

.info-card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
}

.info-card-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.25rem;
}

.info-card-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* Chart Sections */
.chart-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.chart-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.chart-container {
    position: relative;
    height: 280px;
}

.chart-container-lg {
    height: 350px;
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.75rem;
    color: var(--gray-600);
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.legend-color {
    width: 1rem;
    height: 0.5rem;
    border-radius: 2px;
}

.legend-bar {
    width: 1rem;
    height: 0.75rem;
    border-radius: 2px;
}

.legend-line {
    width: 1.25rem;
    height: 3px;
    border-radius: 1px;
}

.legend-line-dashed {
    width: 1.25rem;
    height: 3px;
    border-radius: 1px;
    background: repeating-linear-gradient(
        90deg,
        #f59e0b 0,
        #f59e0b 4px,
        transparent 4px,
        transparent 8px
    ) !important;
}

.inventory-legend {
    gap: 1.5rem;
}

/* Table Section */
.table-section {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    overflow: hidden;
    margin-bottom: 1.5rem;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--gray-200);
}

.table-header h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
}

.table-wrapper {
    overflow-x: auto;
}

/* Projection Table Specific */
.projection-table th {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    white-space: nowrap;
}

.projection-table td {
    font-variant-numeric: tabular-nums;
}

.projection-table .historical-row {
    background: var(--gray-50);
}

.projection-table .historical-row td {
    color: var(--gray-500);
}

/* Stockout row - red highlighting for projected stockout */
.projection-table .stockout-row {
    background: #fef2f2;
}

.projection-table .stockout-row td {
    color: var(--red-700);
}

/* Safety stock row - yellow highlighting when dipping into safety stock */
.projection-table .safety-stock-row {
    background: #fefce8;
}

.projection-table .safety-stock-row td {
    color: #92400e;
}

/* Table legend styles */
.table-legend {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    background: var(--gray-50);
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    flex-wrap: wrap;
}

.table-legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.table-legend-color {
    width: 1rem;
    height: 1rem;
    border-radius: 2px;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.table-legend-color.stockout {
    background: #fef2f2;
}

.table-legend-color.safety-stock {
    background: #fefce8;
}

.table-legend-color.historical {
    background: var(--gray-50);
}

.month-label {
    display: inline-block;
    font-weight: 500;
}

.month-label.historical {
    color: var(--gray-500);
}

/* Order quantity tooltip styles */
.projection-table td.has-order-tooltip {
    cursor: help;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
}

.order-tooltip {
    position: absolute;
    z-index: 1000;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    max-width: 360px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.15s ease, visibility 0.15s ease;
    pointer-events: none;
}

.order-tooltip.visible {
    opacity: 1;
    visibility: visible;
}

.order-tooltip-header {
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.order-tooltip-line {
    color: var(--gray-600);
    padding: 0.25rem 0;
    border-bottom: 1px solid var(--gray-100);
}

.order-tooltip-line:last-child {
    border-bottom: none;
}

/* Export Dropdown */
.export-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 0.5rem;
    min-width: 200px;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    z-index: 100;
}

.dropdown-menu.show {
    display: block;
    animation: slideDown 0.15s ease-out;
}

.dropdown-menu a {
    display: block;
    padding: 0.75rem 1rem;
    color: var(--gray-700);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.15s;
}

.dropdown-menu a:hover {
    background: var(--gray-50);
    text-decoration: none;
}

/* Badge colors for PO status */
.badge-gray {
    background: var(--gray-100);
    color: var(--gray-600);
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-indigo {
    background: var(--indigo-100);
    color: var(--indigo-600);
}

.badge-orange {
    background: #ffedd5;
    color: #c2410c;
}

.badge-green {
    background: #dcfce7;
    color: var(--green-600);
}

/* Text color utilities for projection table */
.text-orange-600 {
    color: #ea580c;
}

/* Responsive adjustments for SKU detail */
@media (max-width: 768px) {
    .chart-container {
        height: 220px;
    }

    .chart-container-lg {
        height: 280px;
    }

    .chart-legend {
        gap: 0.75rem;
    }

    .inventory-legend {
        flex-direction: column;
        align-items: flex-start;
    }
}


/* ========================================
   ACTION CARDS
   ======================================== */
.action-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.action-card {
    background: var(--surface);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-lg);
    padding: 1.125rem 1.25rem 1.125rem 1.375rem;
    position: relative;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.action-card:hover {
    box-shadow: var(--shadow-md);
}

/* Directive row layout (badge + title on the left, impact + action on the right) */
.directive-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.25rem;
}

.directive-main {
    flex: 1 1 auto;
    min-width: 0;
}

.directive-head {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    margin-bottom: 0.25rem;
}

.directive-aside {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.directive-impact {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    font-weight: 700;
    white-space: nowrap;
}

.directive-impact.pos { color: var(--green-600); }
.directive-impact.neg { color: var(--red-600); }
.directive-impact.muted { color: var(--gray-500); }

/* Action card badges read as uppercase mono pills in the directive list */
.action-card .badge {
    font-family: var(--font-mono);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    font-size: 0.6875rem;
}

.directive-card .action-card-title {
    margin: 0;
    font-size: 1rem;
    line-height: 1.35;
}

.directive-aside .action-card-actions {
    margin: 0;
}

.directive-aside .action-card-actions .btn {
    flex: 0 0 auto;
}

.icon-sm {
    width: 1rem;
    height: 1rem;
}

.dismissed-list {
    opacity: 0.7;
}

@media (max-width: 700px) {
    .directive-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    .directive-aside {
        width: 100%;
        justify-content: flex-start;
    }
}

.action-card.dismissed {
    opacity: 0.7;
    background: var(--gray-50);
}

.action-card.dismissed:hover {
    box-shadow: var(--shadow-sm);
}

/* Urgency indicator - left border */
.action-card[data-urgency="high"] {
    border-left: 4px solid var(--red-600);
}

.action-card[data-urgency="medium"] {
    border-left: 4px solid var(--orange-600);
}

.action-card[data-urgency="low"] {
    border-left: 4px solid var(--green-600);
}

.action-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    gap: 0.5rem;
}

.action-card .dismiss-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: 1px solid transparent;
    color: var(--gray-400);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.15s;
    flex-shrink: 0;
}

.action-card .dismiss-btn:hover {
    color: var(--gray-600);
    background: var(--gray-100);
    border-color: var(--gray-200);
}

.action-card-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--gray-900);
    margin: 0 0 0.75rem 0;
    line-height: 1.3;
}

/* Revenue at risk - prominent display */
.action-card-revenue-impact {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: #fef2f2;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--red-600);
}

.action-card-revenue-impact .revenue-label {
    font-size: 0.75rem;
    color: var(--gray-600);
    font-weight: 500;
}

.action-card-revenue-impact .revenue-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--red-600);
}

.action-card-meta {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.5rem;
    display: block;
}

.action-card-meta strong {
    color: var(--gray-800);
}

.action-card-meta.link {
    color: var(--indigo-600);
}

.action-card-meta.link:hover {
    text-decoration: underline;
}

.action-card-description {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin: 0 0 0.75rem 0;
    line-height: 1.5;
}

.action-card-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.action-card-actions .btn {
    flex: 1;
}

/* Expandable details section */
.action-card-expand {
    border-top: 1px solid var(--gray-100);
    padding-top: 0.75rem;
}

.action-card-expand-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.8125rem;
    color: var(--gray-500);
    cursor: pointer;
    padding: 0.25rem 0;
    font-weight: 500;
    list-style: none;
}

.action-card-expand-toggle::-webkit-details-marker {
    display: none;
}

.action-card-expand-toggle:hover {
    color: var(--indigo-600);
}

.action-card-expand-toggle .expand-icon {
    transition: transform 0.2s;
}

.action-card-expand[open] .action-card-expand-toggle .expand-icon {
    transform: rotate(180deg);
}

.action-card-details-content {
    padding-top: 0.75rem;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.375rem 0;
    font-size: 0.8125rem;
    border-bottom: 1px solid var(--gray-100);
}

.detail-row:last-of-type {
    border-bottom: none;
}

.detail-label {
    color: var(--gray-500);
}

.detail-value {
    font-weight: 500;
    color: var(--gray-800);
}

.sku-lines-section {
    margin-top: 0.75rem;
}

.sku-lines-header {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
}

.sku-lines-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.8125rem;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius-sm);
    background: var(--gray-50);
}

.sku-lines-list li {
    padding: 0.625rem 0.75rem;
    border-bottom: 1px solid var(--gray-200);
}

.sku-lines-list li:last-child {
    border-bottom: none;
}

.sku-line-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.sku-lines-list .sku-number {
    font-weight: 600;
    color: var(--gray-800);
}

.sku-lines-list .sku-qty {
    color: var(--gray-600);
    white-space: nowrap;
}

.sku-line-detail {
    font-size: 0.75rem;
    color: var(--gray-500);
    margin-top: 0.25rem;
}

.action-card-dismissed-info {
    font-size: 0.75rem;
    color: var(--gray-400);
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-100);
}

/* Animation for card removal */
.action-card.removing {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .action-cards-grid {
        grid-template-columns: 1fr;
    }

    .action-card-actions {
        flex-direction: column;
    }
}

/* ========================================
   COMPANY IMPERSONATION
   ======================================== */
.impersonation-banner {
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    padding: 0.375rem 1rem;
    text-align: center;
    font-size: 0.8125rem;
    color: #92400e;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
}

.impersonation-stop-btn {
    all: unset;
    cursor: pointer;
    font-size: 0.75rem;
    font-weight: 600;
    color: #92400e;
    background: rgba(146, 64, 14, 0.1);
    padding: 0.125rem 0.5rem;
    border-radius: var(--radius-sm);
    border: 1px solid #d97706;
}

.impersonation-stop-btn:hover {
    background: rgba(146, 64, 14, 0.2);
}

.company-switcher select {
    font-size: 0.8125rem;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    background: white;
    color: var(--gray-700);
    cursor: pointer;
    max-width: 200px;
}

.company-switcher select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

/* ============================================
   Forecast Override Editor
   ============================================ */

.chart-header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.forecast-override-toggle {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    background: transparent;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 4px 10px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
}

.forecast-override-toggle:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.forecast-override-toggle .chevron-icon {
    display: inline-block;
    transition: transform 0.15s ease;
    font-size: 10px;
}

.forecast-override-toggle[aria-expanded="true"] .chevron-icon {
    transform: rotate(90deg);
}

.forecast-override-panel {
    margin-top: var(--space-4);
    padding: var(--space-4);
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
    border-radius: var(--radius);
}

.forecast-override-panel[hidden] {
    display: none;
}

.forecast-override-panel p {
    margin: 0 0 var(--space-3) 0;
}

.override-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--space-3);
    margin-bottom: var(--space-4);
}

.override-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 8px 10px;
    background: white;
    border: 1px solid var(--gray-200);
    border-left: 3px solid transparent;
    border-radius: var(--radius-sm);
}

.override-cell.is-overridden {
    border-left-color: #f59e0b;
    background: #fffbeb;
}

.override-cell.is-dirty {
    border-left-color: var(--primary);
}

.override-cell-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-700);
}

.override-cell-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--gray-900);
}

.override-cell-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(79, 70, 229, 0.15);
}

.override-cell-hint {
    font-size: 11px;
    color: var(--gray-500);
}

.override-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.override-status {
    font-size: 13px;
    color: var(--gray-600);
    margin-right: auto;
}

.override-status.is-success { color: #047857; }
.override-status.is-error   { color: #b91c1c; }
.override-status.is-info    { color: var(--gray-700); }

/* Forecast chart legend swatch for the override indicator */
.legend-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
    margin-right: 4px;
}

.legend-swatch--override {
    background: #f59e0b;
    border: 2px solid #b45309;
    box-sizing: content-box;
    width: 8px;
    height: 8px;
}

/* Projection table override indicator */
.override-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 1px 6px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 4px;
    vertical-align: middle;
}

.projection-table tr.override-row td.cell--override {
    background: #fffbeb;
    font-weight: 600;
}

/* ============================================
   Channel selector + cascade badge (SKU detail)
   ============================================ */
.channel-selector {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0 0 var(--space-4) 0;
    padding: 4px;
    background: var(--gray-100, #f3f4f6);
    border-radius: 8px;
    width: fit-content;
    max-width: 100%;
}

.channel-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-700, #374151);
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.channel-chip:hover {
    background: #ffffff;
    color: var(--gray-900, #111827);
}

.channel-chip.is-active {
    background: #ffffff;
    color: var(--gray-900, #111827);
    border-color: var(--gray-300, #d1d5db);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.channel-chip-share {
    font-size: 11px;
    color: var(--gray-500, #6b7280);
    font-weight: 400;
}

/* SKU channel-demand inline formset (SKU edit page) */
.channel-demand-formset {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.channel-demand-formset th,
.channel-demand-formset td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--gray-200, #e5e7eb);
    vertical-align: top;
}

.channel-demand-formset th {
    font-weight: 600;
    color: var(--gray-700, #374151);
    background: var(--gray-50, #f9fafb);
}

.channel-demand-formset input,
.channel-demand-formset select {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--gray-300, #d1d5db);
    border-radius: 4px;
    font-size: 13px;
}

.formset-row-errors {
    color: #b91c1c;
    font-size: 12px;
    padding: 4px 8px;
}

/* Channel breakdown rows under SKU rows in the forecast dashboard */
.channel-row .row-label {
    padding-left: 56px;
    color: var(--gray-600, #4b5563);
    font-size: 13px;
    font-style: italic;
}

.channel-row td {
    background: var(--gray-50, #f9fafb);
    color: var(--gray-700, #374151);
    font-size: 13px;
}

.channel-row.hidden { display: none; }

.channel-expand-icon {
    margin-right: 6px;
    cursor: pointer;
    color: var(--gray-500, #6b7280);
    transition: transform 0.15s ease;
}

.channel-expand-icon.expanded {
    transform: rotate(90deg);
}

/* Cascade-from-aggregate inline indicator (sits next to override badge) */
.cascade-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-left: 4px;
    font-size: 11px;
    line-height: 1;
    color: #b45309;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 50%;
    cursor: help;
    vertical-align: middle;
}

/* Historical sales overlay toggle (forecast charts) */
.historical-overlay {
    display: inline-flex;
    align-items: center;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.historical-overlay-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray-700);
    cursor: pointer;
    user-select: none;
}

.historical-overlay-toggle input {
    cursor: pointer;
    margin: 0;
}

.historical-overlay-years {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
}

.historical-overlay-years[hidden] {
    display: none;
}

.historical-overlay-year {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: 12px;
    color: var(--gray-700);
    cursor: pointer;
    background: white;
    user-select: none;
}

.historical-overlay-year input {
    margin: 0;
    cursor: pointer;
}

.historical-overlay-year .year-swatch {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.historical-overlay-year:has(input:checked) {
    border-color: var(--gray-500);
    background: var(--gray-50);
}