/* =========================================================================
   Admin theme — Spirit Freight Dashboard
   Same palette/components as the other Daemiy-built admin panels so the
   group's tools feel like one family.
   ========================================================================= */

:root {
    --bg: #0b0d10;
    --panel: #131820;
    --panel-2: #1a2029;
    --border: #1f2832;
    --fg: #e8edf3;
    --muted: #8a96a4;
    --accent: #00ff88;
    --accent-2: #00cc6e;
    --danger: #ff4d4d;
    --warning: #ffb53b;
    --sg: #4d9dff;
    --uk: #ff9d5c;
    --in: #c792ff;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; height: auto; display: block; }

.admin-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: 100vh; }
.admin-main { min-width: 0; }

.admin-sidebar {
    background: #07090c;
    border-right: 1px solid var(--border);
    padding: 1.25rem 0.75rem;
    display: flex;
    flex-direction: column;
}
.admin-sidebar .brand {
    padding: 0 0.75rem 1.1rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.admin-sidebar .brand .group-name {
    font-weight: 900;
    font-size: 1.35rem;
    letter-spacing: 0.02em;
    color: var(--fg);
    line-height: 1.15;
}
.admin-sidebar .brand .brand-logo { width: 100%; max-width: 190px; height: auto; margin-bottom: 0.45rem; }
.admin-sidebar .brand .group-sub {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--muted);
    margin-top: 0.15rem;
}

.company-switch { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 1.1rem; }
.company-switch a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.45rem 0.75rem;
    border-radius: 8px;
    color: var(--fg);
    font-size: 0.85rem;
    font-weight: 600;
}
.company-switch a:hover { background: var(--panel); text-decoration: none; }
/* The selected company is marked with its own colour (bar + tint), deliberately
   unlike the solid-green fill used for the current *page* in the nav below —
   two different selections shouldn't look like the same control. */
.company-switch a { border: 1px solid transparent; }
.company-switch a.c-all { --c: var(--accent); }
.company-switch a.c-sg  { --c: var(--sg); }
.company-switch a.c-uk  { --c: var(--uk); }
.company-switch a.c-in  { --c: var(--in); }
.company-switch a.active {
    background: color-mix(in srgb, var(--c, var(--accent)) 14%, var(--panel));
    border-color: color-mix(in srgb, var(--c, var(--accent)) 45%, transparent);
    box-shadow: inset 4px 0 0 var(--c, var(--accent));
    font-weight: 800;
}
.switch-label {
    padding: 0 0.75rem 0.4rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--muted);
}
.company-switch .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.company-switch .dot.all { background: var(--accent); }
.company-switch .dot.sg { background: var(--sg); }
.company-switch .dot.uk { background: var(--uk); }
.company-switch .dot.in { background: var(--in); }

.admin-sidebar nav { display: flex; flex-direction: column; gap: 0.1rem; }
.admin-sidebar nav a {
    display: flex; align-items: center; gap: 0.6rem;
    padding: 0.55rem 0.85rem; border-radius: 8px; color: var(--fg); font-weight: 500;
}
.admin-sidebar nav a:hover { background: var(--panel); text-decoration: none; }
.admin-sidebar nav a.active { background: var(--accent); color: #000; }
.admin-sidebar .who {
    margin-top: auto; padding: 1rem 0.85rem; border-top: 1px solid var(--border);
    font-size: 0.85rem; color: var(--muted);
}
.admin-sidebar .who a { color: var(--accent); }

.admin-main { padding: 1.5rem 2rem; }
.admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 1rem; margin-bottom: 1.5rem;
}
.admin-topbar h1 { margin: 0; font-size: 1.5rem; }
.admin-topbar .actions { display: flex; gap: 0.5rem; align-items: center; }

.flash { margin: 0 0 1rem; padding: 0.75rem 1rem; border-radius: 8px; font-weight: 500; }
.flash-success { background: rgba(0,255,136,0.12); color: var(--accent); border: 1px solid rgba(0,255,136,0.3); }
.flash-error   { background: rgba(255,77,77,0.12); color: var(--danger); border: 1px solid rgba(255,77,77,0.3); }
.flash-info    { background: rgba(255,255,255,0.06); color: #fff; border: 1px solid var(--border); }
.flash-warning { background: rgba(255,181,59,0.12); color: var(--warning); border: 1px solid rgba(255,181,59,0.3); }

.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.55rem 1rem; border-radius: 8px; border: 1px solid var(--border);
    background: var(--panel); color: var(--fg); font-weight: 600; font-size: 0.9rem;
    cursor: pointer; text-decoration: none; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--panel-2); text-decoration: none; }
.btn-primary { background: var(--accent); color: #000; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn-danger { background: rgba(255,77,77,0.12); color: var(--danger); border-color: rgba(255,77,77,0.3); }
.btn-danger:hover { background: rgba(255,77,77,0.18); }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }

.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.25rem; margin-bottom: 1.25rem; }
.panel h2 { margin: 0 0 0.85rem; font-size: 1.05rem; }

/* Money values here run to 12+ characters ("$19,873,231.70", "INR 720,572,234.36").
   A fixed 1.75rem font in a 180px-minimum card spilled past the card edge on
   smaller windows / higher display scaling — so: wider minimum card, a font
   size that shrinks with the card (container query units), and a wrap
   fallback so nothing can ever be clipped. */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; container-type: inline-size; min-width: 0; }
.stat-card .label { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.04em; }
.stat-card .value {
    font-size: 1.75rem; font-weight: 800; margin-top: 0.2rem;
    font-variant-numeric: tabular-nums; line-height: 1.15;
    overflow-wrap: anywhere;
}
@supports (font-size: 1cqw) {
    .stat-card .value { font-size: clamp(1.1rem, 9.5cqw, 1.75rem); }
}

.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; }
table.data th, table.data td { padding: 0.65rem 0.85rem; text-align: left; vertical-align: middle; }
table.data thead { background: var(--panel-2); }
table.data th { font-size: 0.75rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; font-weight: 600; }
table.data tbody tr { border-top: 1px solid var(--border); }
table.data tbody tr:hover { background: rgba(255,255,255,0.02); }

.form-grid { display: grid; gap: 1rem; }
.form-grid .row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 700px) { .form-grid .row-2 { grid-template-columns: 1fr; } }
.form-grid label { display: block; font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; margin-bottom: 0.3rem; font-weight: 600; }
.form-grid input[type="text"], .form-grid input[type="number"], .form-grid input[type="email"],
.form-grid input[type="password"], .form-grid select, .form-grid textarea {
    width: 100%; background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.6rem 0.75rem; font-size: 0.95rem; font-family: inherit;
}
.form-grid input:focus, .form-grid select:focus, .form-grid textarea:focus { border-color: var(--accent); outline: none; }
.form-grid .help { font-size: 0.78rem; color: var(--muted); margin-top: 0.3rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.5rem; margin-top: 0.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }

.pill { display: inline-block; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.pill-on  { background: rgba(0,255,136,0.15); color: var(--accent); }
.pill-off { background: rgba(255,255,255,0.06); color: var(--muted); }
.pill-warn { background: rgba(255,181,59,0.15); color: var(--warning); }

.company-tag { display: inline-flex; align-items: center; gap: 0.35rem; font-size: 0.78rem; font-weight: 600; }
.company-tag .dot { width: 8px; height: 8px; border-radius: 50%; }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ── Filter bars (Sales report, HR lists) ────────────────────────── */
.filters { display: flex; flex-wrap: wrap; gap: 0.6rem; align-items: end; margin-bottom: 1rem; }
.filters .field { display: flex; flex-direction: column; min-width: 160px; }
.filters label { font-size: 0.7rem; color: var(--muted); text-transform: uppercase; margin-bottom: 0.2rem; font-weight: 600; letter-spacing: 0.04em; }
.filters input, .filters select {
    background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.45rem 0.6rem; font-size: 0.9rem; font-family: inherit;
}
.filters input:focus, .filters select:focus { border-color: var(--accent); outline: none; }

.form-grid .row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 700px) { .form-grid .row-3 { grid-template-columns: 1fr; } }
.form-grid input[type="date"], .form-grid input[type="datetime-local"], .form-grid input[type="tel"] {
    width: 100%; background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
    border-radius: 8px; padding: 0.6rem 0.75rem; font-size: 0.95rem; font-family: inherit;
}
.form-grid input[type="date"]:focus, .form-grid input[type="datetime-local"]:focus { border-color: var(--accent); outline: none; }
.row-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

/* One editable row = one <form>, laid out as a grid (a <form> can't sit inside <tbody>). */
.inline-row { display: grid; grid-template-columns: minmax(0, 1fr) 90px 110px auto; gap: 0.6rem; align-items: center;
              padding: 0.55rem 0; border-top: 1px solid var(--border); }
.inline-row:first-of-type { border-top: 0; }
.inline-row input[type="text"], .inline-row input[type="number"], .inline-row select {
    width: 100%; background: var(--panel-2); color: var(--fg); border: 1px solid var(--border);
    border-radius: 6px; padding: 0.35rem 0.55rem; font-family: inherit;
}
.inline-row input[type="color"] { width: 40px; height: 32px; padding: 0; border: 1px solid var(--border); border-radius: 6px; background: var(--panel-2); }

/* ── HR module ──────────────────────────────────────────────────── */
.hr-tabs {
    display: flex; flex-wrap: wrap; gap: 0.25rem; margin-bottom: 1.25rem; padding: 0.35rem;
    background: var(--panel); border: 1px solid var(--border); border-radius: 12px;
}
.hr-tabs a { display: inline-flex; align-items: center; gap: 0.35rem; padding: 0.45rem 0.75rem; border-radius: 8px;
             color: var(--fg); font-weight: 500; font-size: 0.85rem; white-space: nowrap; }
.hr-tabs a:hover { background: var(--panel-2); text-decoration: none; }
.hr-tabs a.active { background: var(--accent); color: #000; }
.hr-tabs .tab-badge { background: var(--danger); color: #fff; border-radius: 999px; padding: 0.05rem 0.45rem; font-size: 0.7rem; font-weight: 700; }
.hr-tabs a.active .tab-badge { background: #000; color: var(--accent); }

.hr-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.85rem; margin-bottom: 1.5rem; }
.hr-stat { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem 1.1rem; }
.hr-stat .label { font-size: 0.72rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.hr-stat .value { font-size: 2rem; font-weight: 800; margin-top: 0.15rem; }
.hr-stat.tone-active .value     { color: var(--accent); }
.hr-stat.tone-probation .value  { color: #ffb53b; }
.hr-stat.tone-on_leave .value   { color: #4d9dff; }
.hr-stat.tone-notice .value     { color: #ff8a3d; }
.hr-stat.tone-suspended .value, .hr-stat.tone-terminated .value { color: var(--danger); }

.avatar-round { width: 44px; height: 44px; border-radius: 999px; background: linear-gradient(135deg, #1a2029, #131820);
                color: var(--fg); display: inline-flex; align-items: center; justify-content: center;
                font-weight: 700; font-size: 0.95rem; border: 1px solid var(--border); flex: none; }
.avatar-round.avatar-lg { width: 72px; height: 72px; font-size: 1.4rem; }

.hr-cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.hr-cal-head { background: var(--panel); text-align: center; font-size: 0.72rem; color: var(--muted); padding: 0.4rem 0; text-transform: uppercase; letter-spacing: 0.05em; }
.hr-cal-cell { background: var(--panel); min-height: 96px; padding: 0.3rem; font-size: 0.75rem; min-width: 0; }
.hr-cal-cell.empty { background: var(--bg, #0b0e13); opacity: 0.5; }
.hr-cal-cell.weekend { background: #10151c; }
.hr-cal-cell.today { outline: 2px solid var(--accent); outline-offset: -2px; }
.hr-cal-day { color: var(--muted); font-weight: 700; margin-bottom: 0.15rem; }
.hr-cal-ev { display: block; margin-top: 0.15rem; padding: 0.1rem 0.35rem; border-radius: 4px; color: #000; font-weight: 600;
             font-size: 0.7rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 720px) { .hr-cal-cell { min-height: 64px; padding: 0.15rem; } .hr-cal-ev { font-size: 0.62rem; padding: 0.05rem 0.2rem; } }

.kv { display: grid; grid-template-columns: 160px 1fr; gap: 0.35rem 1rem; margin: 0; }
.kv dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.04em; padding-top: 0.1rem; }
.kv dd { margin: 0; }

/* ── Revenue (dashboard / sales report) ─────────────────────────── */
.stat-card .sub { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }
.delta-up   { color: var(--accent); font-weight: 700; }
.delta-down { color: var(--danger); font-weight: 700; }
.split-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.25rem; }
.split-1-1 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
@media (max-width: 1000px) { .split-2-1, .split-1-1 { grid-template-columns: 1fr; } }
.bar-row { padding: 0.4rem 0; }
.bar-row .bar-head { display: flex; justify-content: space-between; gap: 0.75rem; font-size: 0.85rem; margin-bottom: 0.2rem; }
.bar-row .bar-head span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 6px; background: var(--panel-2); border-radius: 3px; overflow: hidden; }
.bar-fill { height: 100%; background: var(--accent); border-radius: 3px; }
.legend { display: flex; gap: 0.85rem; font-size: 0.8rem; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.notes-pre { white-space: pre-wrap; font-family: inherit; font-size: 0.82rem; margin: 0.5rem 0 0; color: var(--warning); }
.form-grid input[type="file"] { width: 100%; background: var(--panel-2); color: var(--fg); border: 1px dashed var(--border); border-radius: 8px; padding: 0.9rem; }
.filters input[type="month"] { min-width: 150px; }

/* Grid children default to min-width:auto, so one long customer name or
   un-wrappable figure would widen the whole page on a phone. */
.split-2-1 > *, .split-1-1 > *, .stat-grid > * { min-width: 0; }

/* ── Phones / narrow windows: sidebar becomes a compact top bar ─── */
@media (max-width: 900px) {
    .admin-shell { grid-template-columns: minmax(0, 1fr); }
    .admin-sidebar { padding: 0.75rem; border-right: 0; border-bottom: 1px solid var(--border); }
    .admin-sidebar .brand { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; padding: 0 0.25rem 0.6rem; margin-bottom: 0.6rem; }
    .admin-sidebar .brand .brand-logo { max-width: 140px; margin: 0; }
    .admin-sidebar nav { flex-direction: row; flex-wrap: wrap; gap: 0.3rem; }
    .admin-sidebar nav a { padding: 0.4rem 0.7rem; font-size: 0.85rem; background: var(--panel); }
    .admin-sidebar .who { margin-top: 0.6rem; padding: 0.6rem 0.25rem 0; font-size: 0.8rem; }
    .admin-sidebar .who br { display: none; }
    .admin-sidebar .who a { margin-left: 0.5rem; }
    .admin-main { padding: 1rem; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
    .admin-topbar h1 { font-size: 1.25rem; }
    .kv { grid-template-columns: 1fr; }
}
