:root {
  --bg: #0f1117;
  --bg2: #1a1d27;
  --bg3: #252836;
  --border: #2e3247;
  --text: #e8eaf0;
  --text2: #8b90a8;
  --accent: #4f8ef7;
  --ok: #22c55e;
  --warn: #f59e0b;
  --alert: #ef4444;
  --done: #6b7280;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,.4);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────── */
header {
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0 16px;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 52px;
}
.logo {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
  letter-spacing: -.2px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}
.clock {
  font-size: 13px;
  color: var(--text2);
  font-variant-numeric: tabular-nums;
}

/* ── Main ────────────────────────────────────────── */
main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px 16px 60px;
}

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: opacity .15s;
}
.btn:hover { opacity: .85; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-ghost {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
}
.btn-danger { background: var(--alert); color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn-xs { padding: 3px 8px; font-size: 12px; }

/* ── Card ─────────────────────────────────────────── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}
.card h2 { font-size: 16px; margin-bottom: 16px; }

/* ── Page header ─────────────────────────────────── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 12px;
}
.page-header h1 { font-size: 22px; font-weight: 700; }
.subtitle { color: var(--text2); font-size: 13px; margin-top: 2px; }

/* ── Forms ────────────────────────────────────────── */
.form-row { margin-bottom: 14px; }
.form-row label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin-bottom: 6px;
}
.form-row label .hint { font-weight: 400; text-transform: none; margin-left: 6px; }
.form-row input, .form-row textarea {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 15px;
}
.form-row textarea { resize: vertical; }
.form-row-inline { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 16px; }

/* ── Job list ─────────────────────────────────────── */
.job-list { display: flex; flex-direction: column; gap: 8px; }
.job-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  text-decoration: none;
  color: var(--text);
  transition: border-color .15s;
}
.job-card:hover { border-color: var(--accent); }
.job-name { font-weight: 600; font-size: 16px; display: block; }
.job-date { font-size: 13px; color: var(--text2); }
.chevron { font-size: 22px; color: var(--text2); }

/* ── Legend ──────────────────────────────────────── */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
  font-size: 12px;
}
.badge { color: var(--text2); }
.badge.badge-ok { color: var(--ok); }
.badge.badge-warn { color: var(--warn); }
.badge.badge-alert { color: var(--alert); }

/* ── Table ───────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg2);
}
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--bg3);
  padding: 10px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody tr {
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background .1s;
}
tbody tr:hover { background: var(--bg3); }
tbody td { padding: 9px 10px; }
.name-col { font-weight: 600; white-space: nowrap; }
.notes-col { color: var(--text2); font-size: 12px; max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadline-col { font-weight: 700; }

/* Row status colors */
.row-alert { background: rgba(239,68,68,.08); }
.row-warn  { background: rgba(245,158,11,.08); }

/* ── Flag colors ─────────────────────────────────── */
.flag-ok   { color: var(--ok); }
.flag-warn { color: var(--warn); font-weight: 700; }
.flag-alert{ color: var(--alert); font-weight: 700; }
.flag-done { color: var(--done); }
.flag-none { color: var(--text2); }

/* ── Mobile crew cards ───────────────────────────── */
.crew-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.crew-card.overall-alert { border-left: 4px solid var(--alert); }
.crew-card.overall-warn  { border-left: 4px solid var(--warn); }
.crew-card.overall-ok    { border-left: 4px solid var(--ok); }
.crew-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  margin-bottom: 10px;
}
.crew-name { font-weight: 700; font-size: 16px; }
.crew-pos  { font-size: 12px; color: var(--text2); }
.status-dot { font-size: 20px; }
.overall-dot-ok    { color: var(--ok); }
.overall-dot-warn  { color: var(--warn); }
.overall-dot-alert { color: var(--alert); }
.overall-dot-none  { color: var(--text2); }

.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  display: flex;
  gap: 5px;
}
.pill-label { color: var(--text2); }
.pill-val   { font-weight: 600; }
.pill.flag-warn  { border-color: var(--warn); }
.pill.flag-alert { border-color: var(--alert); background: rgba(239,68,68,.1); }
.pill.flag-done  { opacity: .6; }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}
.modal {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 14px 14px 0 0;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 20px;
  box-shadow: var(--shadow);
}
@media (min-width: 600px) {
  .modal { border-radius: 14px; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}
.modal-header h2 { font-size: 18px; }
.modal-close {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text2);
  border-radius: 50%;
  width: 30px; height: 30px;
  cursor: pointer;
  font-size: 14px;
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 14px;
}
.modal-field { margin-bottom: 12px; }
.modal-field label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  color: var(--text2);
  margin-bottom: 5px;
}
.modal-field label small { text-transform: none; font-weight: 400; margin-left: 4px; }
.modal-field input, .time-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 9px 12px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.modal-calc { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.modal-calc h3 { font-size: 13px; color: var(--text2); text-transform: uppercase; letter-spacing: .4px; margin-bottom: 12px; }
.calc-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 20px;
  font-size: 13px;
}
.calc-label { color: var(--text2); }
.calc-val { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ── Responsive ──────────────────────────────────── */
.desktop-only { display: block; }
.mobile-only  { display: none; }
@media (max-width: 768px) {
  .desktop-only { display: none; }
  .mobile-only  { display: block; }
  .form-row-inline { grid-template-columns: 1fr; }
}

/* ── Modal scheduled display ──────────────────────── */
.modal-sched {
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 14px;
  color: var(--text2);
}
.modal-sched strong { color: var(--text); font-variant-numeric: tabular-nums; }

/* ── PDF preview ──────────────────────────────────── */
.pdf-preview { margin-top: 12px; overflow-x: auto; }
.pdf-preview-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.pdf-preview-table th {
  background: var(--bg3);
  padding: 8px 10px;
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text2);
  border-bottom: 1px solid var(--border);
}
.pdf-preview-table td { padding: 7px 10px; border-bottom: 1px solid var(--border); }

/* ── Phone link ───────────────────────────────────── */
.phone-link { color: var(--accent); text-decoration: none; font-weight: 600; }
.phone-link:hover { text-decoration: underline; }
.phone-display { padding: 6px 0; font-size: 15px; }

/* ── Alert banner ─────────────────────────────────── */
.alert-banner {
  position: fixed;
  top: 56px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  padding: 12px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 20px rgba(0,0,0,.5);
  white-space: nowrap;
  max-width: 90vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.banner-warn  { background: var(--warn);  color: #000; }
.banner-alert { background: var(--alert); color: #fff; }

/* ── Empty state ─────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text2);
}
