/* NINA — Ministry of Motion dashboard
   Dark glass aesthetic. All class names preserved from v1. */

:root {
  --bg: #07090f;
  --bg-grad-a: #0b0e1a;
  --bg-grad-b: #07090f;
  --bg-card: rgba(255, 255, 255, 0.025);
  --bg-card-hover: rgba(255, 255, 255, 0.055);
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #e9ebf2;
  --text-dim: #8b91a5;
  --accent: #7aa2ff;
  --accent-2: #9b7bff;
  --accent-grad: linear-gradient(135deg, #5b8cff 0%, #9b7bff 60%, #c86bff 100%);
  --green: #54d98c;
  --amber: #f5b85e;
  --red: #ef6b6b;
  --blue: #6db4ef;
  --white: #cfd2dc;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background:
    radial-gradient(1200px 700px at 85% -10%, rgba(91, 80, 255, 0.13), transparent 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(64, 130, 255, 0.09), transparent 55%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b) 40%);
  background-attachment: fixed;
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "Inter", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky; top: 0;
  display: flex; align-items: center; gap: 18px;
  padding: 14px 28px;
  background: rgba(7, 9, 15, 0.72);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 17px; letter-spacing: 2.5px;
}
.me-chip {
  margin-left: auto;
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-dim); white-space: nowrap;
}

/* ---------- Schedule week grid ---------- */

.sched-scroll { overflow-x: auto; }
.sched-grid { width: 100%; border-collapse: collapse; table-layout: fixed; }
.sched-grid th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); padding: 6px 8px; border-bottom: 1px solid var(--border);
}
.sched-grid th.sched-name, .sched-grid td.sched-name { width: 110px; font-weight: 600; font-size: 13px; }
.sched-cell {
  vertical-align: top; padding: 4px; min-height: 54px; height: 54px;
  border: 1px solid var(--border); position: relative;
}
.sched-cell:hover { background: rgba(124, 199, 255, 0.04); cursor: pointer; }
.sched-cell.over { box-shadow: inset 0 0 0 1px var(--red); }
.sched-cell.sched-today, th.sched-today { background: rgba(124, 199, 255, 0.05); }
.sched-block {
  border-radius: 6px; padding: 4px 6px; margin-bottom: 3px; font-size: 11px;
  line-height: 1.25; cursor: pointer; overflow: hidden;
  display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: baseline;
}
.sched-block-title { font-weight: 700; }
.sched-block-sub { opacity: 0.85; }
.sched-block-hours { margin-left: auto; opacity: 0.7; font-size: 10px; }
.sched-block.timeoff {
  background: repeating-linear-gradient(45deg, rgba(255,255,255,0.06), rgba(255,255,255,0.06) 6px, rgba(255,255,255,0.12) 6px, rgba(255,255,255,0.12) 12px);
  color: var(--text-dim); border: 1px dashed var(--border-strong);
}
.sched-total { font-size: 10px; color: var(--text-dim); text-align: right; padding-right: 2px; }
.sched-total.over { color: var(--red); font-weight: 700; }

/* ---------- Timesheets ---------- */

.ts-day { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; margin-bottom: 10px; }
.ts-day-head { display: flex; align-items: center; gap: 12px; margin-bottom: 6px; }
.ts-ghosts { margin-bottom: 6px; display: flex; flex-wrap: wrap; gap: 4px; }
.sched-block.ghost { opacity: 0.45; display: inline-flex; cursor: default; }
.ts-entry { display: flex; align-items: center; gap: 10px; padding: 4px 0; font-size: 13px; }
.ts-entry .sched-block { margin: 0; cursor: default; }
.ts-quick-add { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.ts-quick-add select, .ts-quick-add input { padding: 5px 8px; font-size: 12px; }
.ts-sum-cell { text-align: center; padding: 8px; border: 1px solid var(--border); font-size: 12px; }
.ts-sum-cell.ts-ok { color: var(--green); font-weight: 600; }
.ts-sum-cell.ts-partial { color: var(--amber); }
.ts-sum-cell.ts-missing { color: var(--red); font-weight: 600; }

/* Deterministic project colours — projColor() hashes project_id to pj-0..9 */
.pj-0 { background: rgba(124, 199, 255, 0.22); color: #cfe9ff; }
.pj-1 { background: rgba(155, 123, 255, 0.24); color: #e2d8ff; }
.pj-2 { background: rgba(84, 217, 140, 0.20); color: #c8f5da; }
.pj-3 { background: rgba(255, 184, 108, 0.22); color: #ffe3c2; }
.pj-4 { background: rgba(239, 107, 107, 0.20); color: #ffd4d4; }
.pj-5 { background: rgba(94, 234, 212, 0.20); color: #cdfaf0; }
.pj-6 { background: rgba(250, 204, 21, 0.18); color: #fcedad; }
.pj-7 { background: rgba(244, 114, 182, 0.20); color: #fdd3ea; }
.pj-8 { background: rgba(129, 140, 248, 0.22); color: #dde0fe; }
.pj-9 { background: rgba(163, 230, 53, 0.18); color: #e5f7c3; }
.brand-sub {
  font-weight: 400; font-size: 11px; letter-spacing: 0.6px;
  color: var(--text-dim); text-transform: uppercase;
  border-left: 1px solid var(--border-strong);
  padding-left: 10px; margin-left: 2px;
}
.brand-orb {
  width: 14px; height: 14px; border-radius: 50%;
  background: var(--accent-grad);
  box-shadow: 0 0 14px rgba(124, 199, 255, 0.8), 0 0 34px rgba(155, 123, 255, 0.4);
  animation: orb-breathe 4s ease-in-out infinite;
}
@keyframes orb-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.85); opacity: 0.75; }
}

.status { color: var(--text-dim); font-size: 12px; flex: 1; }

/* ---------- Tabs ---------- */

.tabs {
  position: sticky; top: 53px;
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 28px;
  background: rgba(7, 9, 15, 0.72);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  z-index: 9;
}
.tab {
  background: transparent;
  color: var(--text-dim);
  border: 1px solid transparent;
  padding: 7px 14px; font-size: 12.5px;
  border-radius: 999px;
  cursor: pointer; font-family: inherit;
  transition: all 0.18s ease;
}
.tab:hover { color: var(--text); background: var(--bg-card-hover); }
.tab.active {
  color: #fff;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.22), rgba(155, 123, 255, 0.22));
  border-color: rgba(122, 162, 255, 0.45);
  box-shadow: 0 0 18px rgba(91, 140, 255, 0.18);
}
.tab-count {
  display: inline-block; min-width: 17px;
  padding: 1px 5px; margin-left: 4px;
  border-radius: 9px; font-size: 10px; font-weight: 600;
  background: rgba(255, 255, 255, 0.1); color: var(--text-dim);
}
.tab-count.action { background: var(--amber); color: #0a0d14; }
.tab-count:empty { display: none; }

.sub-tabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px; }
.sub-tab {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--border);
  padding: 4px 11px; font-size: 11.5px; border-radius: 999px;
  cursor: pointer; font-family: inherit;
  transition: all 0.15s ease;
}
.sub-tab:hover { color: var(--text); border-color: var(--border-strong); }
.sub-tab.active { color: #fff; border-color: var(--accent); background: rgba(122, 162, 255, 0.14); }

/* ---------- Layout / cards ---------- */

main { max-width: 1140px; margin: 0 auto; padding: 28px; }

.panel { display: none; }
.panel.active { display: block; animation: panel-in 0.25s ease; }
@keyframes panel-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 26px;
  overflow: hidden;
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.card > header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.025), transparent);
}
.card h2 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.2px; }
.card h2 small { color: var(--text-dim); font-weight: 400; margin-left: 6px; }
.panel-body { padding: 18px 22px; }

/* ---------- Buttons ---------- */

.btn {
  background: var(--bg-card-hover);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12.5px;
  font-family: inherit;
  transition: all 0.16s ease;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 14px rgba(122, 162, 255, 0.15); }
.btn.small { padding: 4px 10px; font-size: 11px; border-radius: 6px; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { box-shadow: none; color: var(--accent); }
.btn.primary {
  background: var(--accent-grad);
  color: #fff; border: none; font-weight: 600;
  box-shadow: 0 2px 14px rgba(122, 130, 255, 0.35);
}
.btn.primary:hover { filter: brightness(1.12); box-shadow: 0 2px 20px rgba(122, 130, 255, 0.5); }
.btn.success { background: var(--green); color: #07210f; border: none; font-weight: 600; }
.btn.danger { background: var(--red); color: #2a0808; border: none; font-weight: 600; }
button:disabled { opacity: 0.55; cursor: wait; }

/* ---------- Rows / lists ---------- */

.empty { color: var(--text-dim); font-style: italic; padding: 14px 0; }

.row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.row:last-child { border-bottom: none; }
.row .left { flex: 1; min-width: 0; }
.row .right { flex-shrink: 0; }
.row .title { font-weight: 550; }
.row .meta { color: var(--text-dim); font-size: 12px; margin-top: 3px; }

.badge {
  display: inline-block; padding: 2px 9px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.06); color: var(--text-dim);
  font-size: 10.5px; font-weight: 550;
  border: 1px solid var(--border);
}
.badge.amber { color: var(--amber); border-color: rgba(245, 184, 94, 0.5); background: rgba(245, 184, 94, 0.08); }
.badge.green { color: var(--green); border-color: rgba(84, 217, 140, 0.5); background: rgba(84, 217, 140, 0.08); }
.badge.red { color: var(--red); border-color: rgba(239, 107, 107, 0.5); background: rgba(239, 107, 107, 0.08); }
.badge.blue { color: var(--blue); border-color: rgba(109, 180, 239, 0.5); background: rgba(109, 180, 239, 0.08); }

/* ---------- Triage ---------- */

.triage-row { align-items: flex-start; }
.triage-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }

.lvl-pill {
  display: inline-block; padding: 2px 8px; border-radius: 6px;
  font-size: 10px; font-weight: 700; margin-right: 8px;
  background: var(--bg); border: 1px solid var(--border);
  letter-spacing: 0.4px;
}
.lvl-pill.l5 { background: var(--red); color: #fff; border-color: var(--red); box-shadow: 0 0 12px rgba(239, 107, 107, 0.4); }
.lvl-pill.l4 { background: var(--amber); color: #0a0d14; border-color: var(--amber); }
.lvl-pill.l3 { background: var(--blue); color: #fff; border-color: var(--blue); }

.lvl-5 { border-left: 3px solid var(--red); padding-left: 12px; }
.lvl-4 { border-left: 3px solid var(--amber); padding-left: 12px; }
.lvl-3 { border-left: 3px solid var(--blue); padding-left: 12px; }
.lvl-2, .lvl-1, .lvl-0 { border-left: 3px solid transparent; padding-left: 12px; }

/* ---------- Forms ---------- */

.add-form { display: flex; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: rgba(255, 255, 255, 0.015); }
.add-form input {
  flex: 1; padding: 9px 12px; background: rgba(0, 0, 0, 0.3); border: 1px solid var(--border);
  color: var(--text); border-radius: 8px; font-family: inherit; font-size: 13px;
}
.add-form input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.12); }

select {
  background: rgba(0, 0, 0, 0.35); color: var(--text); border: 1px solid var(--border);
  padding: 5px 9px; border-radius: 7px; font-family: inherit; font-size: 12px;
}

textarea {
  width: 100%; min-height: 84px;
  background: rgba(0, 0, 0, 0.3); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 11px; font-family: inherit; font-size: 13px;
  resize: vertical;
}
textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.12); }

.form-field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 13px; }
.form-field label { color: var(--text-dim); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px; }
.form-field input, .form-field select, .form-field textarea {
  background: rgba(0, 0, 0, 0.3); color: var(--text); border: 1px solid var(--border);
  border-radius: 8px; padding: 9px 11px; font-family: inherit; font-size: 13px;
}
.form-field input:focus, .form-field select:focus, .form-field textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(122, 162, 255, 0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }
.find-results { background: rgba(0, 0, 0, 0.3); padding: 12px; border-radius: 8px; border: 1px solid var(--border); margin-top: 8px; font-size: 12px; }

/* ---------- Modal ---------- */

.modal { position: fixed; inset: 0; background: rgba(2, 3, 8, 0.78); backdrop-filter: blur(6px); z-index: 100; display: flex; align-items: flex-start; justify-content: center; padding: 56px 20px; overflow-y: auto; }
.modal.hidden { display: none; }
.modal-content {
  background: #0d1019;
  border: 1px solid var(--border-strong); border-radius: 16px;
  padding: 28px; width: 100%; max-width: 760px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6);
  position: relative;
}
.modal .close-modal { position: absolute; top: 14px; right: 14px; font-size: 18px; padding: 4px 10px; }

.kv { display: grid; grid-template-columns: 170px 1fr; gap: 7px 16px; font-size: 13px; margin-top: 12px; }
.kv dt { color: var(--text-dim); }
.kv dd { margin: 0; word-break: break-word; }

.notes { white-space: pre-wrap; background: rgba(0, 0, 0, 0.3); padding: 13px; border-radius: 8px; border: 1px solid var(--border); font-family: ui-monospace, SFMono-Regular, monospace; font-size: 12px; color: var(--text-dim); }

a.linklike { color: var(--accent); text-decoration: none; cursor: pointer; }
a.linklike:hover { text-decoration: underline; }

/* ---------- Status summary card ---------- */

.status-card {
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.08), rgba(155, 123, 255, 0.05));
  border: 1px solid rgba(122, 162, 255, 0.4);
  border-radius: 12px;
  padding: 18px 20px;
  margin: 8px 0 16px;
}
.status-card.empty-status { border-color: var(--border); color: var(--text-dim); background: rgba(255, 255, 255, 0.015); }
.status-card p { color: var(--text); line-height: 1.55; }
.status-card dl.kv { grid-template-columns: 140px 1fr; gap: 5px 12px; }

/* ---------- Stats ---------- */

.stats { display: flex; gap: 14px; flex-wrap: wrap; }
.stat {
  background: rgba(0, 0, 0, 0.25); padding: 14px 18px; border-radius: 10px;
  border: 1px solid var(--border); min-width: 90px;
}
.stat .num { font-size: 22px; font-weight: 700; background: var(--accent-grad); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.stat .label { color: var(--text-dim); font-size: 11px; margin-top: 3px; }

/* ---------- Schedule lines ---------- */

.schedule-list { list-style: none; padding: 0; margin: 4px 0 16px; }
.schedule-list li { padding: 0; margin: 0; }
.schedule-line {
  display: flex; align-items: baseline; gap: 14px;
  padding: 7px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.schedule-line:last-child { border-bottom: none; }
.schedule-date {
  color: var(--accent); font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 12px; min-width: 84px; flex-shrink: 0;
}
.schedule-desc { flex: 1; }
.schedule-actions { display: none; gap: 10px; margin-left: auto; font-size: 11px; }
.schedule-line:hover .schedule-actions { display: inline-flex; }

details { margin: 8px 0; border-top: 1px solid var(--border); padding-top: 12px; }
details summary { cursor: pointer; color: var(--text-dim); font-size: 13px; padding: 8px 0; }
details summary:hover { color: var(--text); }
details[open] summary { color: var(--text); }

/* ---------- Spinner ---------- */

.spinner {
  display: inline-block;
  width: 10px; height: 10px;
  border: 2px solid var(--text-dim);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: -1px;
  margin-right: 4px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Voice: orb + panel ---------- */

.voice-orb {
  position: fixed; right: 28px; bottom: 28px;
  width: 64px; height: 64px; border-radius: 50%;
  border: none; cursor: pointer;
  background: var(--accent-grad);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 28px rgba(122, 130, 255, 0.45), 0 0 0 0 rgba(122, 162, 255, 0.4);
  z-index: 90;
  transition: transform 0.18s ease;
}
.voice-orb:hover { transform: scale(1.07); }
.voice-orb.listening {
  background: linear-gradient(135deg, #ff5b5b, #ff8e53);
  animation: orb-pulse 1.2s ease-in-out infinite;
}
.voice-orb.thinking {
  background: linear-gradient(135deg, #5b8cff, #9b7bff);
  animation: orb-spin-glow 1.6s linear infinite;
}
.voice-orb.speaking {
  background: linear-gradient(135deg, #54d98c, #5bd0ff);
  animation: orb-pulse 0.9s ease-in-out infinite;
}
@keyframes orb-pulse {
  0%, 100% { box-shadow: 0 6px 28px rgba(255, 110, 110, 0.5), 0 0 0 0 rgba(255, 110, 110, 0.35); }
  50% { box-shadow: 0 6px 28px rgba(255, 110, 110, 0.5), 0 0 0 16px rgba(255, 110, 110, 0); }
}
@keyframes orb-spin-glow {
  0% { filter: hue-rotate(0deg) brightness(1); }
  50% { filter: hue-rotate(25deg) brightness(1.25); }
  100% { filter: hue-rotate(0deg) brightness(1); }
}

.voice-panel {
  position: fixed; right: 28px; bottom: 106px;
  width: 380px; max-height: 60vh;
  display: flex; flex-direction: column;
  background: rgba(10, 13, 22, 0.92);
  backdrop-filter: blur(22px) saturate(1.4);
  -webkit-backdrop-filter: blur(22px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: 18px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
  z-index: 89;
  overflow: hidden;
  animation: panel-in 0.22s ease;
}
.voice-panel.hidden { display: none; }
.voice-panel-header {
  display: flex; align-items: center; gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: 13px;
}
.voice-panel-header span:first-child { flex: 1; }
.voice-tts-status { font-size: 10.5px; color: var(--text-dim); font-weight: 400; }

.voice-transcript {
  flex: 1; overflow-y: auto;
  padding: 14px 16px;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 120px;
}
.voice-hint { color: var(--text-dim); font-size: 12px; font-style: italic; }
.voice-msg { max-width: 88%; padding: 9px 13px; border-radius: 14px; font-size: 13px; line-height: 1.5; }
.voice-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(91, 140, 255, 0.3), rgba(155, 123, 255, 0.3));
  border: 1px solid rgba(122, 162, 255, 0.35);
  border-bottom-right-radius: 4px;
}
.voice-msg.nina {
  align-self: flex-start;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.voice-msg.interim { opacity: 0.55; font-style: italic; }

.voice-input-row {
  display: flex; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--border);
}
.voice-input-row input {
  flex: 1; padding: 9px 12px;
  background: rgba(0, 0, 0, 0.35); border: 1px solid var(--border);
  color: var(--text); border-radius: 999px; font-family: inherit; font-size: 13px;
}
.voice-input-row input:focus { outline: none; border-color: var(--accent); }

/* ---------- Scrollbars ---------- */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.12); border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.2); }
