/* ===== DESIGN TOKENS ===== */
:root {
    --blue-900: #1e3a8a;
    --blue-700: #1d4ed8;
    --blue-500: #3b82f6;
    --blue-100: #dbeafe;
    --blue-50:  #eff6ff;
    --slate-900: #0f172a;
    --slate-700: #334155;
    --slate-500: #64748b;
    --slate-300: #cbd5e1;
    --slate-100: #f1f5f9;
    --slate-50:  #f8fafc;
    --white: #ffffff;

    /* Status colours */
    --red-100: #fee2e2;   --red-600: #dc2626;
    --amber-100: #fef3c7; --amber-600: #d97706;
    --green-100: #dcfce7; --green-600: #16a34a;
    --green-200: #bbf7d0; --green-500: #22c55e;
    --purple-100: #f3e8ff; --purple-600: #9333ea;
    --teal-600: #0d9488;

    --sidebar-w: 220px;
    --topbar-h: 56px;
    --radius: 8px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,.10);
    --font-body: 'Inter', sans-serif;
    --font-display: 'Plus Jakarta Sans', sans-serif;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font-body); background: var(--slate-100); color: var(--slate-900); font-size: 14px; }
a { color: var(--blue-700); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ===== APP SHELL ===== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }

/* ===== SIDEBAR ===== */
.sidebar {
    width: var(--sidebar-w);
    background: var(--slate-900);
    display: flex; flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 10px;
    padding: 20px 18px 18px;
    font-family: var(--font-display);
    font-size: 18px; font-weight: 800;
    color: var(--white);
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.brand-icon { color: var(--blue-500); font-size: 22px; }
.sidebar-section-label {
    padding: 18px 18px 6px;
    font-size: 10px; font-weight: 600;
    letter-spacing: .1em;
    color: var(--slate-500);
}
.sidebar-nav { list-style: none; padding: 0 10px; }
.sidebar-nav li { margin-bottom: 2px; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px;
    border-radius: 6px;
    color: rgba(255,255,255,.65);
    font-size: 13.5px; font-weight: 500;
    transition: background .15s, color .15s;
}
.nav-link:hover { background: rgba(255,255,255,.07); color: var(--white); text-decoration: none; }
.nav-link.active { background: var(--blue-700); color: var(--white); }
.nav-link-disabled {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 10px; border-radius: 6px;
    color: rgba(255,255,255,.25);
    font-size: 13.5px; font-weight: 500;
    cursor: not-allowed; position: relative;
}
.nav-link-disabled:hover::after {
    content: attr(data-tip);
    position: absolute; left: 100%; top: 50%; transform: translateY(-50%);
    margin-left: 8px; background: var(--slate-900); color: white;
    padding: 5px 10px; border-radius: 5px; font-size: 11px; font-weight: 500;
    white-space: nowrap; z-index: 1000; box-shadow: var(--shadow-md);
    pointer-events: none;
}
.nav-icon { font-size: 15px; width: 20px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 16px 18px; }
.version-tag { font-size: 11px; color: var(--slate-500); }

/* ===== MAIN CONTENT ===== */
.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

.top-bar {
    height: var(--topbar-h);
    background: var(--white);
    border-bottom: 1px solid var(--slate-300);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 28px;
    flex-shrink: 0;
}
.page-title { font-family: var(--font-display); font-size: 16px; font-weight: 700; color: var(--slate-900); }
.date-display { font-size: 13px; color: var(--slate-500); }

.page-body { flex: 1; overflow-y: auto; padding: 24px 28px; }

/* ===== TOASTS ===== */
.toast-success, .toast-error {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; margin: 0 28px 0;
    border-radius: var(--radius);
    font-size: 13.5px; font-weight: 500;
    animation: slideDown .25s ease;
}
.toast-success { background: var(--green-100); color: var(--green-600); border: 1px solid var(--green-200); }
.toast-error   { background: var(--red-100); color: var(--red-600); }
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:none; } }

/* ===== CARDS & PANELS ===== */
.card {
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--slate-100);
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.card-body { padding: 20px; }

/* ===== STAT CARDS ===== */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat-card {
    background: var(--white);
    border: 1px solid var(--slate-300);
    border-radius: var(--radius);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}
.stat-label { font-size: 10px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--slate-400); margin-bottom: 6px; }
.stat-value { font-family: var(--font-display); font-size: 22px; font-weight: 800; color: var(--slate-900); line-height: 1.2; }
.stat-sub { font-size: 12px; color: var(--slate-500); margin-top: 4px; }
.stat-card.accent-blue  { border-top: 3px solid var(--blue-500); }
.stat-card.accent-green { border-top: 3px solid var(--green-500); }
.stat-card.accent-red   { border-top: 3px solid var(--red-600); }
.stat-card.accent-purple{ border-top: 3px solid var(--purple-600); }
.stat-card.accent-teal  { border-top: 3px solid var(--teal-600); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px; border-radius: 6px;
    font-size: 13px; font-weight: 600; cursor: pointer;
    border: 1px solid transparent; transition: all .15s;
    line-height: 1.4;
}
.btn-primary { background: var(--blue-700); color: var(--white); border-color: var(--blue-700); }
.btn-primary:hover { background: var(--blue-900); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--slate-700); border-color: var(--slate-300); }
.btn-secondary:hover { background: var(--slate-50); text-decoration: none; }
.btn-success { background: var(--green-600); color: var(--white); }
.btn-success:hover { opacity:.9; text-decoration: none; }
.btn-danger { background: var(--red-600); color: var(--white); }
.btn-danger:hover { opacity:.9; text-decoration: none; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-excel { background: #1a6b3c; color: var(--white); border-color: #1a6b3c; }
.btn-excel:hover { background: #145230; text-decoration: none; }

/* ===== TABLES ===== */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
    background: var(--slate-900);
    color: var(--white);
    padding: 10px 14px;
    text-align: left; font-weight: 600;
    font-size: 12px; letter-spacing: .04em;
    white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--slate-100); }
tbody tr:hover { background: var(--blue-50); }
tbody td { padding: 10px 14px; vertical-align: middle; }
.text-center { text-align: center; }
.text-right { text-align: right; }

/* ===== ALLOCATION GRID CELLS ===== */
.alloc-cell {
    border-radius: 5px;
    padding: 5px 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    min-width: 72px;
    display: block;
    cursor: pointer;
    position: relative;
}
.status-unallocated { background: var(--red-100); color: var(--red-600); }
.status-low         { background: var(--amber-100); color: var(--amber-600); }
.status-partial     { background: #d1fae5; color: #065f46; }
.status-full        { background: var(--green-500); color: var(--white); }
.status-over        { background: var(--purple-100); color: var(--purple-600); }

/* Tooltip for cell hover */
.alloc-cell .tooltip-content {
    display: none;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%; transform: translateX(-50%);
    background: var(--slate-900); color: var(--white);
    padding: 8px 12px; border-radius: 6px;
    font-size: 11.5px; font-weight: 400;
    white-space: nowrap; z-index: 100;
    box-shadow: var(--shadow-md);
    min-width: 160px;
}
.alloc-cell:hover .tooltip-content { display: block; }

/* ===== FORMS ===== */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.full-width { grid-column: 1 / -1; }
label { font-size: 12px; font-weight: 600; color: var(--slate-700); text-transform: uppercase; letter-spacing: .04em; }
input[type=text], input[type=date], input[type=number], select, textarea {
    padding: 9px 12px;
    border: 1px solid var(--slate-300);
    border-radius: 6px;
    font-size: 13.5px;
    font-family: var(--font-body);
    color: var(--slate-900);
    background: var(--white);
    transition: border-color .15s;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(59,130,246,.15);
}
.field-error { font-size: 12px; color: var(--red-600); }
.form-actions { display: flex; gap: 10px; padding-top: 8px; }
.input-hint { font-size: 11px; color: var(--slate-500); }

/* ===== BADGES ===== */
.badge {
    display: inline-block;
    padding: 2px 9px; border-radius: 100px;
    font-size: 11px; font-weight: 600;
}
.badge-green  { background: var(--green-100); color: var(--green-600); }
.badge-blue   { background: var(--blue-100); color: var(--blue-700); }
.badge-red    { background: var(--red-100); color: var(--red-600); }
.badge-amber  { background: var(--amber-100); color: var(--amber-600); }
.badge-purple { background: var(--purple-100); color: var(--purple-600); }
.badge-slate  { background: var(--slate-100); color: var(--slate-700); }

/* ===== FILTER BAR ===== */
.filter-bar {
    display: flex; gap: 10px; align-items: center; flex-wrap: wrap;
    margin-bottom: 16px;
}
.filter-bar input, .filter-bar select { width: auto; min-width: 160px; }

/* ===== MISC ===== */
.page-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.section-title { font-family: var(--font-display); font-size: 15px; font-weight: 700; }
.empty-state { text-align: center; padding: 48px 20px; color: var(--slate-500); }
.empty-state .empty-icon { font-size: 36px; margin-bottom: 12px; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; }
.legend-item { display: flex; align-items: center; gap: 5px; }
.legend-dot { width: 12px; height: 12px; border-radius: 3px; }

/* ===== PROGRESS BAR ===== */
.progress-bar { height: 6px; background: var(--slate-100); border-radius: 3px; overflow: hidden; width: 80px; }
.progress-fill { height: 100%; border-radius: 3px; background: var(--blue-500); }

@media (max-width: 768px) {
    .form-grid { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== ICON BUTTONS ===== */
.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 6px;
    border: 1px solid var(--slate-200); background: var(--slate-50);
    cursor: pointer; font-size: 13px; transition: all .15s;
    position: relative; flex-shrink: 0; color: var(--slate-600);
    text-decoration: none;
}
.icon-btn:hover { border-color: var(--blue-400); background: var(--blue-50);
    color: var(--blue-700); text-decoration: none; transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(59,130,246,.2); }
.icon-btn.icon-btn-danger { border-color: var(--red-200); color: var(--red-500); }
.icon-btn.icon-btn-danger:hover { border-color: var(--red-500); background: var(--red-50);
    color: var(--red-600); box-shadow: 0 2px 6px rgba(220,38,38,.15); }
.icon-btn.icon-btn-primary { background: var(--blue-700); border-color: var(--blue-700); color: white; }
.icon-btn.icon-btn-primary:hover { background: var(--blue-900); transform: translateY(-1px); }

/* Tooltip on icon buttons */
.icon-btn::after {
    content: attr(data-tip);
    position: absolute; bottom: calc(100% + 6px); left: 50%;
    transform: translateX(-50%);
    background: var(--slate-900); color: white;
    font-size: 11px; font-weight: 500; white-space: nowrap;
    padding: 4px 8px; border-radius: 4px;
    pointer-events: none; opacity: 0; transition: opacity .15s;
    font-family: var(--font-body);
}
.icon-btn:hover::after { opacity: 1; }

/* ===== EXTENDED DESIGN TOKENS (added) ===== */
:root {
    --amber-600: #d97706; --amber-400: #fbbf24; --amber-100: #fef3c7;
    --blue-400:  #60a5fa; --blue-600:  #2563eb; --blue-200: #bfdbfe;
    --blue-300:  #93c5fd;
    --green-400: #4ade80; --green-700: #15803d; --green-300: #86efac;
    --red-200:   #fecaca; --red-400:   #f87171; --red-500: #ef4444;
    --red-300:   #fca5a5;
    --slate-200: #e2e8f0; --slate-400: #94a3b8;
    --slate-600: #475569; --slate-800: #1e293b;
    --purple-500:#a855f7;
}

/* ===== PROFITABILITY TABS ===== */
.prof-tabs {
    display: flex; gap: 0;
    border-bottom: 2px solid var(--slate-200);
    margin-bottom: 20px;
}
.prof-tab {
    padding: 9px 20px; font-size: 13px; font-weight: 600;
    text-decoration: none; color: var(--slate-500);
    border-bottom: 2px solid transparent; margin-bottom: -2px;
    transition: color .15s, border-color .15s;
}
.prof-tab:hover  { color: var(--blue-700); text-decoration: none; }
.prof-tab.active { color: var(--blue-700); border-bottom-color: var(--blue-700); }

/* ===== PAGE HEADER STYLE ===== */
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 12px; margin-bottom: 20px;
}
.page-header-title {
    font-family: var(--font-display); font-size: 18px; font-weight: 800; color: var(--slate-900);
}
.page-header-sub { font-size: 12px; color: var(--slate-400); margin-top: 2px; }

/* ===== BETTER BADGES ===== */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 20px;
    font-size: 11px; font-weight: 600; line-height: 1.5;
}
.badge-green  { background: #dcfce7; color: #166534; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-red    { background: #fee2e2; color: #b91c1c; }
.badge-amber  { background: #fef3c7; color: #92400e; }
.badge-purple { background: #f3e8ff; color: #7e22ce; }
.badge-slate  { background: #f1f5f9; color: #475569; }

/* ===== CARD IMPROVEMENTS ===== */
.card-header {
    padding: 12px 16px;
}
.card-title { font-size: 14px; font-weight: 700; }

/* ===== TABLE IMPROVEMENTS ===== */
thead th {
    padding: 8px 12px;
    font-size: 11px;
    background: var(--slate-800);
}
tbody td { padding: 8px 12px; font-size: 13px; }

/* ===== SHOW HISTORY BUTTON ===== */
.show-history-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 11px 16px;
    background: white; border: 1px solid var(--slate-200);
    border-radius: 8px; cursor: pointer;
    font-size: 13px; font-weight: 600; color: var(--slate-600);
    transition: all .15s; width: 100%; text-align: left;
    margin-top: 16px;
}
.show-history-btn:hover {
    background: var(--blue-50); border-color: var(--blue-300);
    color: var(--blue-700); box-shadow: 0 2px 8px rgba(59,130,246,.1);
}

/* ===== ICON BUTTON TEXT SYMBOLS ===== */
.icon-btn {
    font-size: 14px; font-weight: 700;
    font-family: var(--font-body);
    color: var(--slate-500);
    letter-spacing: 0;
}
.icon-btn:hover { color: var(--blue-700); }
.icon-btn.icon-btn-danger { color: var(--red-500); }
.icon-btn.icon-btn-primary { color: white; }
