/* ============================================================
   CrewDesk v8 — Production Design System
   PWA-ready, mobile-first, iOS/Android safe area support
   ============================================================ */

:root {
  --bg: #edf3ee; --panel: #ffffff; --panel-2: #f3f8f4;
  --text: #0c1f11; --muted: #56736b; --line: #dce8de; --border: #dce8de;
  --brand: #16a34a; --brand-2: #15803d;
  --danger: #dc2626; --warning: #d97706; --success: #16a34a;
  --sidebar-bg: #0b1f12; --sidebar-text: #9dbfaa; --sidebar-text-bright: #e8f5ec;
  --shadow-sm: 0 1px 4px rgba(11,31,18,.06);
  --shadow: 0 4px 16px rgba(11,31,18,.09);
  --shadow-lg: 0 8px 32px rgba(11,31,18,.14);
  --radius: 14px; --radius-sm: 8px;
  /* Safe areas for notch/rounded corner phones */
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  font-family: 'Figtree', system-ui, sans-serif;
  background: var(--bg); color: var(--text);
  min-height: 100vh; min-height: 100dvh;
  font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-text-size-adjust: 100%;
  /* Prevent pull-to-refresh in standalone PWA */
  overscroll-behavior-y: contain;
}
button, input, select, textarea { font: inherit; }
a { color: inherit; text-decoration: none; }
.hidden { display: none !important; }

/* Prevent iOS zoom on input focus */
input, select, textarea { font-size: 16px; }
@media (min-width: 860px) {
  input, select, textarea { font-size: inherit; }
}

/* ── Toast ─────────────────────────────────────────── */
#toast-container {
  position: fixed; bottom: calc(28px + var(--sab)); right: 28px;
  z-index: 9999; display: flex; flex-direction: column; gap: 10px; pointer-events: none;
}
.toast {
  background: #0b1f12; color: #e8f5ec; padding: 13px 18px; border-radius: var(--radius);
  font-size: .92rem; font-weight: 600; min-width: 260px; max-width: 380px;
  box-shadow: var(--shadow-lg); border-left: 4px solid var(--brand);
  transform: translateY(16px); opacity: 0; transition: all .28s cubic-bezier(.34,1.36,.64,1);
  pointer-events: auto;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.toast-error   { border-left-color: #ef4444; background: #1e0a0a; }
.toast.toast-warning { border-left-color: #f59e0b; }

/* ── Modal ─────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(11,31,18,.62); backdrop-filter: blur(3px);
  z-index: 2000; display: flex; align-items: center; justify-content: center;
  padding: 20px; padding-top: calc(20px + var(--sat)); padding-bottom: calc(20px + var(--sab));
  opacity: 0; transition: opacity .2s ease;
}
.modal-overlay.show { opacity: 1; }
.modal-box {
  background: #fff; border-radius: 20px; width: min(620px, 100%); max-height: 90vh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-shadow: 0 28px 72px rgba(11,31,18,.32);
  transform: scale(.93) translateY(16px);
  transition: transform .24s cubic-bezier(.34,1.18,.64,1), opacity .24s ease;
  opacity: 0; display: flex; flex-direction: column;
}
.modal-overlay.show .modal-box { transform: scale(1) translateY(0); opacity: 1; }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 22px 14px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; background: #fff; z-index: 1; border-radius: 20px 20px 0 0;
}
.modal-header h2 { font-size: 1.08rem; font-weight: 800; }
.modal-close-btn {
  width: 36px; height: 36px; border-radius: 7px; border: none; background: var(--panel-2);
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--muted); transition: all .14s; flex-shrink: 0;
  /* Minimum 44px touch target */
  min-width: 44px; min-height: 44px;
}
.modal-close-btn:hover { background: #fee2e2; color: var(--danger); }
.modal-body   { padding: 18px 22px; flex: 1; }
.modal-footer {
  padding: 14px 22px calc(20px + var(--sab)); display: flex; gap: 9px; flex-wrap: wrap;
  border-top: 1px solid var(--line); background: var(--panel-2); border-radius: 0 0 20px 20px;
}
.modal-kv { display: flex; flex-direction: column; gap: 7px; margin-bottom: 14px; }
.modal-kv-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 9px 12px; background: var(--panel-2); border-radius: 8px; border: 1px solid var(--line); }
.modal-kv-row .lbl { font-size: .79rem; font-weight: 700; color: var(--muted); white-space: nowrap; margin-top: 2px; }
.modal-kv-row .val { font-weight: 600; text-align: right; font-size: .9rem; }
.modal-kv-row.highlight { background: #f0fdf4; border-color: #bbf7d0; }
.modal-kv-row.highlight .val { color: var(--brand); font-size: 1.05rem; font-weight: 900; }
.modal-kv-row.warn { background: #fffbeb; border-color: #fde68a; }
.modal-kv-row.warn .val { color: var(--warning); font-weight: 800; }
.pay-summary { background: var(--panel-2); border: 1px solid var(--line); border-radius: 11px; padding: 13px 15px; margin-bottom: 14px; }
.pay-summary-row { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; padding: 3px 0; }
.pay-summary-row.owing { border-top: 1px solid var(--line); margin-top: 6px; padding-top: 9px; }
.pay-summary-row.owing span   { font-weight: 700; }
.pay-summary-row.owing strong { color: var(--brand); font-size: 1.08rem; font-weight: 900; }
.modal-section { background: #fffbeb; border: 1px solid #fde68a; border-radius: 11px; padding: 13px 15px; margin-top: 12px; }
.modal-section-title { font-weight: 800; font-size: .86rem; color: #92400e; margin-bottom: 11px; }
.modal-section.blue  { background: #eff6ff; border-color: #bfdbfe; }
.modal-section-title.blue { color: #1d4ed8; }

/* ── Login ─────────────────────────────────────────── */
.login-shell { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px; background: linear-gradient(145deg,#e8f5ec 0%,#f3f8f4 40%,#dff0e5 100%); }
.login-card { width: min(960px,100%); display: grid; grid-template-columns: 1.15fr .85fr; background: var(--panel); border-radius: 24px; box-shadow: var(--shadow-lg); overflow: hidden; }
.login-hero { padding: 48px 42px; background: linear-gradient(150deg,#0b1f12 0%,#14392a 60%,#0f6630 100%); color: white; display: flex; flex-direction: column; justify-content: center; }
.hero-logo { font-size: 1rem; font-weight: 900; letter-spacing: .05em; text-transform: uppercase; color: #4ade80; margin-bottom: 26px; display: flex; align-items: center; gap: 10px; }
.login-hero h1 { font-size: 1.95rem; font-weight: 800; line-height: 1.2; margin-bottom: 12px; color: #f0fdf4; }
.login-hero p  { color: rgba(255,255,255,.73); line-height: 1.65; margin-bottom: 26px; font-size: .93rem; }
.hero-features { display: flex; flex-direction: column; gap: 8px; margin-bottom: 26px; }
.hero-features span { display: flex; align-items: center; gap: 9px; font-size: .87rem; color: rgba(255,255,255,.78); }
.hero-features span::before { content:''; width:6px; height:6px; border-radius:50%; background:#4ade80; flex-shrink:0; }
.demo-box { background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.13); border-radius: 12px; padding: 14px 16px; }
.demo-box h3 { font-size: .83rem; color: #86efac; font-weight: 700; margin-bottom: 9px; letter-spacing:.04em; text-transform:uppercase; }
.demo-box p  { margin: 5px 0; font-size: .87rem; color: rgba(255,255,255,.8); }
.demo-box code { background: rgba(255,255,255,.13); padding: 1px 6px; border-radius: 5px; font-size: .85em; }
.login-form-wrap { padding: 48px 38px; display: flex; align-items: center; }
.login-form { width: 100%; }
.login-form h2 { font-size: 1.6rem; font-weight: 800; margin-bottom: 5px; }
.login-form .sub { color: var(--muted); margin-bottom: 24px; font-size: .9rem; }

/* ── Forms ─────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(12,1fr); gap: 12px; }
.form-field { grid-column: span 12; display: flex; flex-direction: column; gap: 5px; }
.form-field.half       { grid-column: span 6; }
.form-field.third      { grid-column: span 4; }
.form-field.two-thirds { grid-column: span 8; }
label { font-weight: 700; font-size: .85rem; color: var(--text); }
input, select, textarea {
  border: 1.5px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; padding: 10px 12px; outline: none; color: var(--text);
  transition: border-color .14s, box-shadow .14s;
  /* iOS: prevent zoom + proper rendering */
  -webkit-appearance: none; appearance: none;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(22,163,74,.12); }
input[type="file"] { padding: 7px 9px; background: var(--panel-2); cursor: pointer; }
textarea { min-height: 72px; resize: vertical; }
select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M3 4.5L6 8 9 4.5' fill='none' stroke='%2356736b' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

/* ── Buttons ─────────────────────────────────────────── */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1.5px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; cursor: pointer; background: var(--panel-2);
  color: var(--text); font-weight: 700; font-size: .88rem;
  transition: all .14s; white-space: nowrap;
  /* Minimum touch target */
  min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn.ghost   { background: transparent; border-color: var(--line); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger  { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn.danger:hover  { background: #fee2e2; }
.btn.success { background: #f0fdf4; color: var(--success); border-color: #bbf7d0; }
.btn.success:hover { background: #dcfce7; }
.btn.warning { background: #fffbeb; color: var(--warning); border-color: #fde68a; }
.btn.warning:hover { background: #fef3c7; }
.btn.sm { padding: 6px 10px; font-size: .81rem; border-radius: 6px; min-height: 36px; }
.btn.xs { padding: 5px 10px; font-size: .77rem; border-radius: 5px; min-height: 32px; }
.btn.full { width: 100%; justify-content: center; }

/* ── Shell ───────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 258px 1fr; min-height: 100vh; min-height: 100dvh; }
.sidebar {
  background: var(--sidebar-bg); color: var(--sidebar-text);
  padding: 20px 13px; padding-top: calc(20px + var(--sat));
  position: sticky; top: 0; height: 100vh; height: 100dvh;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 18px; }
.brand-icon { width: 33px; height: 33px; border-radius: 9px; background: linear-gradient(135deg,#22c55e,#16a34a); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.brand-name { font-size: .98rem; font-weight: 900; color: var(--sidebar-text-bright); letter-spacing:-.01em; display:block; }
.brand-sub  { font-size: .7rem;  color: rgba(255,255,255,.32); font-weight: 500; display:block; }
.profile-card { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.07); border-radius: 10px; padding: 11px 12px; margin-bottom: 14px; display: flex; align-items: center; gap: 10px; }
.profile-avatar { width: 33px; height: 33px; border-radius: 8px; background: rgba(34,197,94,.14); border: 1px solid rgba(34,197,94,.24); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .86rem; color: #4ade80; flex-shrink: 0; }
.profile-info .name     { color: var(--sidebar-text-bright); font-weight: 700; font-size: .86rem; }
.profile-info .role     { color: #4ade80; font-size: .74rem; font-weight: 600; }
.profile-info .username { color: rgba(255,255,255,.32); font-size: .72rem; }
.nav { display: flex; flex-direction: column; gap: 1px; flex: 1; }
.nav button {
  width: 100%; text-align: left; border: none; background: transparent;
  color: var(--sidebar-text); padding: 10px 10px; border-radius: 8px;
  cursor: pointer; font-weight: 600; font-size: .86rem;
  display: flex; align-items: center; gap: 9px;
  transition: all .14s; border-left: 3px solid transparent;
  min-height: 44px; -webkit-tap-highlight-color: transparent;
}
.nav button:hover  { background: rgba(22,163,74,.17); color: var(--sidebar-text-bright); }
.nav button.active { background: rgba(22,163,74,.21); color: #4ade80; border-left-color: #22c55e; font-weight: 700; }
.nav-icon { width: 17px; height: 17px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; opacity: .72; }
.nav button.active .nav-icon, .nav button:hover .nav-icon { opacity: 1; }
.sidebar-footer { margin-top: 14px; padding-top: 12px; padding-bottom: var(--sab); border-top: 1px solid rgba(255,255,255,.07); }
.sidebar-footer .btn { width: 100%; justify-content: center; background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.1); color: var(--sidebar-text); font-size: .85rem; }
.sidebar-footer .btn:hover { background: rgba(220,38,38,.14); border-color: rgba(220,38,38,.28); color: #fca5a5; }

/* ── Mobile sidebar overlay (hidden by default) ─────── */
.sidebar-overlay { display: none; position: fixed; inset: 0; z-index: 999; background: rgba(0,0,0,.45); }

/* ── Main + Topbar (hamburger hidden on desktop) ─────── */
.main { padding: 26px; overflow-x: auto; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.topbar h1 { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; }
.hamburger {
  display: none; border: none; background: transparent; cursor: pointer;
  color: var(--text); padding: 8px; min-width: 44px; min-height: 44px;
  -webkit-tap-highlight-color: transparent;
}
.sidebar-toggle { display: none; margin-left: auto; border: none; background: rgba(255,255,255,.12); color: #fff; border-radius: 7px; padding: 8px 12px; cursor: pointer; font-size: 1rem; min-width: 44px; min-height: 44px; }

/* ── Grid ────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(12,1fr); gap: 15px; }
.card { grid-column: span 12; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 18px; transition: box-shadow .18s; }
.card:hover { box-shadow: var(--shadow); }
.card .card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.card .card-head h2 { font-size: .96rem; font-weight: 800; margin: 0; }
.span-3  { grid-column: span 3; }
.span-4  { grid-column: span 4; }
.span-5  { grid-column: span 5; }
.span-6  { grid-column: span 6; }
.span-7  { grid-column: span 7; }
.span-8  { grid-column: span 8; }
.span-9  { grid-column: span 9; }
.span-10 { grid-column: span 10; }
.span-11 { grid-column: span 11; }
.span-12 { grid-column: span 12; }

/* ── Stat cards ─────────────────────────────────────── */
.stat-card-wrap {
  grid-column: span 3; background: var(--panel);
  border: 1.5px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 15px 17px;
  cursor: pointer; transition: all .17s; display: block;
  position: relative; overflow: hidden; min-width: 0;
  -webkit-tap-highlight-color: transparent;
}
.stat-card-wrap::after { content: '→'; position: absolute; top: 12px; right: 12px; font-size: .76rem; color: var(--muted); opacity: 0; transition: opacity .17s, transform .17s; transform: translateX(-4px); }
.stat-card-wrap:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: var(--brand); }
.stat-card-wrap:hover::after { opacity: 1; transform: translateX(0); }
.stat-card { display: flex; align-items: flex-start; gap: 12px; }
.stat-icon { width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-icon.green  { background: #dcfce7; color: #15803d; }
.stat-icon.amber  { background: #fef3c7; color: #b45309; }
.stat-icon.red    { background: #fee2e2; color: #b91c1c; }
.stat-icon.blue   { background: #dbeafe; color: #1d4ed8; }
.stat-icon.purple { background: #f3e8ff; color: #7c3aed; }
.stat-icon.teal   { background: #ccfbf1; color: #0d9488; }
.stat-icon.orange { background: #ffedd5; color: #c2410c; }
.stat-body { flex: 1; min-width: 0; }
.stat-label { color: var(--muted); font-size: .79rem; font-weight: 600; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-value { font-size: 1.35rem; font-weight: 900; letter-spacing: -.02em; line-height: 1.15; overflow-wrap: break-word; word-break: break-all; }
.stat-note  { font-size: .75rem; color: var(--muted); margin-top: 2px; }

/* ── Dashboard TS action cards ──────────────────────── */
.ts-action-list { display: flex; flex-direction: column; gap: 8px; }
.ts-action-card { display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--panel-2); cursor: pointer; transition: all .13s; -webkit-tap-highlight-color: transparent; }
.ts-action-card:hover { border-color: var(--brand); background: #f0fdf4; }
.ts-action-avatar { width: 34px; height: 34px; border-radius: 8px; flex-shrink: 0; background: linear-gradient(135deg,#dcfce7,#bbf7d0); display: flex; align-items: center; justify-content: center; font-weight: 800; font-size: .84rem; color: #166534; }
.ts-action-info { flex: 1; min-width: 0; }
.ts-action-name   { font-weight: 700; font-size: .88rem; }
.ts-action-detail { font-size: .77rem; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ts-action-gross  { font-weight: 800; color: var(--brand); font-size: .9rem; white-space: nowrap; margin-right: 5px; }
.ts-action-btns   { display: flex; gap: 5px; flex-shrink: 0; }

/* ── Staff balance widget ────────────────────────────── */
.staff-bal-list { display: flex; flex-direction: column; gap: 8px; }
.staff-bal-item { padding: 11px 13px; border-radius: 10px; border: 1.5px solid var(--line); background: var(--panel-2); cursor: pointer; transition: all .13s; -webkit-tap-highlight-color: transparent; }
.staff-bal-item:hover { border-color: var(--brand); }
.staff-bal-top { display: flex; align-items: center; justify-content: space-between; gap: 9px; margin-bottom: 6px; }
.staff-bal-name   { font-weight: 700; font-size: .88rem; }
.staff-bal-amount { font-weight: 800; color: var(--brand); }
.staff-bal-bar-wrap { height: 5px; background: #e2e8f0; border-radius: 99px; overflow: hidden; }
.staff-bal-bar { height: 100%; background: linear-gradient(90deg,#22c55e,#16a34a); border-radius: 99px; transition: width .5s; }
.staff-bal-meta { display: flex; justify-content: space-between; font-size: .73rem; color: var(--muted); margin-top: 4px; }

/* ── Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; min-width: 540px; }
th { background: #f5faf6; font-size: .76rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: .87rem; }
tr:last-child td { border-bottom: none; }
tr.clickable-row { cursor: pointer; transition: background .11s; -webkit-tap-highlight-color: transparent; }
tr.clickable-row:hover td { background: #f0fdf4; }
tr.clickable-row:active td { background: #dcfce7; }
.small { font-size: .79rem; color: var(--muted); margin-top: 1px; }
.muted { color: var(--muted); }

/* ── Badges ──────────────────────────────────────────── */
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 999px; font-size: .75rem; font-weight: 800; }
.badge.approved,.badge.paid,.badge.completed { background: #dcfce7; color: #166534; }
.badge.pending,.badge.booked  { background: #fef3c7; color: #92400e; }
.badge.rejected               { background: #fee2e2; color: #991b1b; }
.badge.in-progress            { background: #dbeafe; color: #1e40af; }

/* ── Toolbar ─────────────────────────────────────────── */
.toolbar { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin-bottom: 13px; }
.toolbar input, .toolbar select { min-width: 145px; }

/* ── KV grid ─────────────────────────────────────────── */
.kv { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 8px; }
.kv div { padding: 9px 11px; background: var(--panel-2); border-radius: var(--radius-sm); border: 1px solid var(--line); }
.kv strong { display: block; font-size: .76rem; font-weight: 700; color: var(--muted); margin-bottom: 2px; }

/* ── File / doc list ─────────────────────────────────── */
.file-list { display: flex; flex-direction: column; gap: 7px; }
.file-item { display: flex; justify-content: space-between; align-items: center; gap: 11px; border: 1px solid var(--line); border-radius: 9px; padding: 10px 12px; background: var(--panel-2); transition: background .13s; }
.file-item:hover { background: #ebf5ee; }

/* ── Chart wrap ──────────────────────────────────────── */
.chart-wrap { position: relative; width: 100%; }

/* ── Misc ────────────────────────────────────────────── */
.empty { padding: 18px 15px; border-radius: 8px; background: var(--panel-2); color: var(--muted); border: 1.5px dashed var(--line); text-align: center; font-size: .87rem; font-weight: 500; }
.footer-note { margin-top: 11px; color: var(--muted); font-size: .83rem; }
hr.soft { border: none; border-top: 1px solid var(--line); margin: 13px 0; }

/* ── Nav badges ─────────────────────────────────────── */
.nav-badge { margin-left: auto; background: #f59e0b; color: #fff; font-size: .68rem; font-weight: 800; padding: 2px 6px; border-radius: 99px; min-width: 18px; text-align: center; }
.nav-badge.red { background: #dc2626; }

/* ── Training Portal ──────────────────────────────────── */
.training-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 4px; }
.training-card { border: 1.5px solid var(--border); border-radius: 12px; padding: 16px; background: var(--panel); transition: box-shadow .18s; }
.training-card:hover { box-shadow: 0 3px 16px rgba(0,0,0,.08); }
.training-card-done { border-color: #bbf7d0; background: #f0fdf4; }
.training-card-todo { border-color: #fecaca; background: #fff8f8; }
.training-doc-content { max-height: 340px; overflow-y: auto; -webkit-overflow-scrolling: touch; border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; background: var(--panel-2); font-size: .92rem; line-height: 1.75; margin-bottom: 16px; }
.training-doc-content h3 { font-size: 1.05rem; margin: 0 0 8px; }
.training-doc-content h4 { font-size: .9rem; margin: 14px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.training-doc-content ul { padding-left: 20px; }
.training-doc-content p  { margin: 0 0 8px; }
.training-sign-section { border: 1.5px solid var(--border); border-radius: 10px; padding: 16px; background: var(--panel-2); }

/* ── Job Confirmations ────────────────────────────────── */
.conf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.conf-card { border: 1.5px solid var(--border); border-radius: 12px; padding: 14px 16px; background: var(--panel); }
.conf-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.conf-card-job { font-size: .9rem; font-weight: 600; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.pending-conf { border-color: #fde68a; background: #fffbeb; }

/* ── Incident Log ─────────────────────────────────────── */
.badge.approved  { background: #dcfce7; color: #166534; }
.badge.rejected  { background: #fee2e2; color: #991b1b; }

/* ════════════════════════════════════════════════════════
   MEDIA QUERIES — mobile-first responsive breakpoints
   ════════════════════════════════════════════════════════ */

/* 1400px — stat cards 3-per-row */
@media (max-width: 1400px) {
  .stat-card-wrap { grid-column: span 4; }
}

/* 1100px — collapse sidebar, stack content */
@media (max-width: 1100px) {
  .login-card { grid-template-columns: 1fr; }
  .login-hero { display: none; }
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: relative; height: auto; flex-direction: row; flex-wrap: wrap; padding: 11px; padding-top: calc(11px + var(--sat)); }
  .brand { padding: 0; margin-right: auto; }
  .profile-card { display: none; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav button { padding: 6px 10px; font-size: .81rem; min-height: 40px; }
  .stat-card-wrap, .span-3,.span-4,.span-5,.span-6,.span-7,.span-8,.span-9,.span-10 { grid-column: span 12; }
}

/* 860px — mobile: overlay sidebar, show hamburger */
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: -280px; height: 100vh; height: 100dvh; width: 268px;
    z-index: 1000; transition: left .24s ease; box-shadow: none;
    flex-direction: column; flex-wrap: nowrap;
    padding: 20px 13px; padding-top: calc(20px + var(--sat));
  }
  .sidebar.open { left: 0; box-shadow: 4px 0 32px rgba(0,0,0,.35); }
  .sidebar-overlay.open { display: block; }
  .profile-card { display: flex; }
  .sidebar-toggle { display: block; }
  .hamburger { display: flex; align-items: center; justify-content: center; }
  .main { padding: 14px; padding-top: calc(14px + var(--sat)); padding-bottom: calc(14px + var(--sab)); }
  .stat-card-wrap, .span-3,.span-4,.span-5,.span-6,.span-7,.span-8,.span-9,.span-10 { grid-column: span 12; }
  .form-field.half,.form-field.third,.form-field.two-thirds { grid-column: span 12; }
  .training-grid { grid-template-columns: 1fr; }
  .conf-grid     { grid-template-columns: 1fr; }
  /* Stack stat cards 2-per-row on larger phones */
  .stat-card-wrap { grid-column: span 6; }
  .topbar h1 { font-size: 1.25rem; }
  .modal-box { border-radius: 16px; max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); }
  /* Bottom toast on mobile */
  #toast-container { left: 14px; right: 14px; bottom: calc(14px + var(--sab)); }
  .toast { min-width: unset; width: 100%; }
}

/* 480px — small phones */
@media (max-width: 480px) {
  .main { padding: 10px; padding-top: calc(10px + var(--sat)); padding-bottom: calc(10px + var(--sab)); }
  .grid { gap: 8px; }
  .stat-card-wrap { grid-column: span 12; padding: 12px 14px; }
  .stat-value { font-size: 1.1rem; }
  .card { padding: 14px; border-radius: 12px; }
  .modal-overlay { padding: 8px; }
  .modal-box { border-radius: 14px; }
  .modal-body { padding: 14px 16px; }
  .modal-footer { padding: 12px 16px calc(16px + var(--sab)); }
  .ts-action-card { flex-wrap: wrap; }
  .ts-action-gross { width: 100%; text-align: right; }
}
