/* =============================================
   All Hands Ops — fleet & mission management app
   ============================================= */

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

:root {
  color-scheme: dark;
  --navy:    #050d1a;
  --navy-2:  #071326;
  --navy-3:  #0d1f3c;
  --accent:    #4da3ff;
  --accent-dim: rgba(77,163,255,0.12);
  --accent-mid: rgba(77,163,255,0.35);
  --white:   #ffffff;
  --muted:   #7a8fa8;
  --text:    #c8d8ec;
  --border:  rgba(77,163,255,0.18);
  --line:    rgba(200,216,236,0.09);

  --ok:      #3ecf7a;
  --info:    #b497ff;
  --warn:    #f0b545;
  --bad:     #ff6b6b;

  --font-head: 'Bebas Neue', sans-serif;
  --font-body: 'Inter', sans-serif;

  --side-w: 232px;
  --top-h: 64px;
  --radius: 6px;
  --transition: 0.2s ease;
}

body {
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
}

a { color: inherit; text-decoration: none; }
button { font-family: inherit; }
[hidden] { display: none !important; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

.side {
  width: var(--side-w);
  flex-shrink: 0;
  background: var(--navy-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}

.side-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  height: var(--top-h);
  padding: 0 1.1rem;
  border-bottom: 1px solid var(--border);
}
.side-mark { width: 26px; height: 26px; color: var(--accent); flex-shrink: 0; }
.side-by { margin-top: 0.4rem; opacity: 0.7; }
.side-wordmark {
  font-family: var(--font-head);
  font-size: 1.45rem;
  letter-spacing: 0.08em;
  color: var(--white);
}
.side-wordmark em { font-style: normal; color: var(--accent); }

.side-nav { flex: 1; padding: 1rem 0.7rem; overflow-y: auto; }
.side-group {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 1rem 0.7rem 0.4rem;
}
.side-link {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.7rem;
  border-radius: var(--radius);
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text);
  transition: background var(--transition), color var(--transition);
}
.side-link svg { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.75; }
.side-link:hover { background: rgba(200,216,236,0.05); color: var(--white); }
.side-link.active { background: var(--accent-dim); color: var(--accent); }
.side-link.active svg { opacity: 1; }
.side-count {
  margin-left: auto;
  font-size: 0.72rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.side-foot {
  padding: 1rem 1.1rem 1.2rem;
  border-top: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--muted);
}
.demo-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  border: 1px solid var(--accent-mid);
  border-radius: 20px;
  padding: 0.2rem 0.7rem;
  margin-bottom: 0.5rem;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.top {
  height: var(--top-h);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0 1.8rem;
  border-bottom: 1px solid var(--border);
  background: rgba(5,13,26,0.92);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 20;
}
.top-title {
  font-family: var(--font-head);
  font-size: 1.7rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--white);
}
.top-org { margin-left: auto; font-size: 0.8rem; color: var(--muted); }

.menu-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
}
.menu-btn span { display: block; width: 22px; height: 2px; background: var(--white); border-radius: 2px; }

#view { padding: 1.8rem; width: min(1320px, 100%); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0.6rem 1.1rem;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--navy); }
.btn-primary:hover { background: #7dbcff; border-color: #7dbcff; color: var(--navy); }
.btn-danger:hover { border-color: var(--bad); color: var(--bad); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Cards / panels ── */
.panel {
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.panel-title {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}
.panel-link { font-size: 0.76rem; color: var(--muted); }
.panel-link:hover { color: var(--accent); }
.panel-body { padding: 1.1rem 1.2rem; }

.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1rem; }
.kpi {
  background: var(--navy-3);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.2rem;
}
.kpi-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.kpi-value {
  font-family: var(--font-head);
  font-size: 2.6rem;
  line-height: 1.1;
  letter-spacing: 0.03em;
  color: var(--white);
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 1.2rem; color: var(--muted); }
.kpi-note { font-size: 0.76rem; color: var(--muted); }

.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.grid-even { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }

/* ── Toolbar ── */
.toolbar { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 1rem; flex-wrap: wrap; }
.toolbar .spacer { flex: 1; }

input, select, textarea {
  background: var(--navy);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  color: var(--white);
  font-family: var(--font-body);
  font-size: 0.88rem;
  padding: 0.55rem 0.8rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
input::placeholder, textarea::placeholder { color: rgba(122,143,168,0.55); }
input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(77,163,255,0.12);
}
select option { background: var(--navy-2); }
input[type="date"] { color-scheme: dark; }
.search { width: min(280px, 100%); }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0.75rem 1.2rem;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td {
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
  font-size: 0.86rem;
}
tr:last-child td { border-bottom: none; }
tbody tr.clickable { cursor: pointer; transition: background var(--transition); }
tbody tr.clickable:hover { background: rgba(77,163,255,0.05); }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }
.cell-main { color: var(--white); font-weight: 500; }
.cell-sub { font-size: 0.76rem; color: var(--muted); }
.clip { max-width: 320px; color: var(--muted); }
.flag-bad { color: var(--bad); font-weight: 600; }
.flag-warn { color: var(--warn); font-weight: 600; }

.empty { padding: 2.5rem 1.2rem; text-align: center; color: var(--muted); }

/* ── Status pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
  padding: 0.18rem 0.6rem;
  border-radius: 20px;
  border: 1px solid currentColor;
  color: var(--muted);
}
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok   { color: var(--ok); }
.pill.info { color: var(--info); }
.pill.warn { color: var(--warn); }
.pill.bad  { color: var(--bad); }

/* ── Lists (dashboard) ── */
.list { list-style: none; }
.list li {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.8rem 1.2rem;
  border-bottom: 1px solid var(--line);
}
.list li:last-child { border-bottom: none; }
.list li.clickable { cursor: pointer; transition: background var(--transition); }
.list li.clickable:hover { background: rgba(77,163,255,0.05); }
.alert-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 0.4rem; flex-shrink: 0; }
.alert-dot.bad { background: var(--bad); }
.alert-dot.warn { background: var(--warn); }
.list .grow { flex: 1; min-width: 0; }

/* ── Bar charts ── */
.bar-row { display: grid; grid-template-columns: minmax(90px, 180px) 1fr 56px; align-items: center; gap: 0.8rem; padding: 0.35rem 0; }
.bar-label { font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 10px; background: rgba(200,216,236,0.07); border-radius: 5px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 5px; }
.bar-val { text-align: right; font-size: 0.82rem; color: var(--white); font-variant-numeric: tabular-nums; }

/* ── Modal ── */
.modal {
  margin: auto;
  width: min(640px, 94vw);
  max-height: 92vh;
  background: var(--navy-2);
  color: var(--text);
  border: 1px solid var(--accent-mid);
  border-radius: 12px;
  padding: 0;
}
.modal::backdrop { background: rgba(2,6,14,0.75); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.4rem;
  border-bottom: 1px solid var(--line);
}
.modal-title { font-family: var(--font-head); font-size: 1.5rem; font-weight: 400; letter-spacing: 0.05em; color: var(--white); }
.modal-close { background: none; border: none; color: var(--muted); font-size: 1.4rem; line-height: 1; cursor: pointer; padding: 4px 8px; }
.modal-close:hover { color: var(--white); }
.modal-body { padding: 1.3rem 1.4rem; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.modal-foot { display: flex; gap: 0.7rem; padding: 1rem 1.4rem; border-top: 1px solid var(--line); }
.modal-foot .spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 0.4rem; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .field > .field-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}
.field label span { color: var(--accent); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { resize: vertical; min-height: 84px; }
.checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.3rem 1rem;
  max-height: 140px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.8rem;
  background: var(--navy);
}
.checks label { display: flex; align-items: center; gap: 0.5rem; font-size: 0.84rem; cursor: pointer; }
.checks input { width: auto; accent-color: var(--accent); }

/* ── Account ── */
.plan-price { font-family: var(--font-head); font-size: 3rem; line-height: 1; color: var(--white); letter-spacing: 0.03em; }
.plan-price small { font-family: var(--font-body); font-size: 0.85rem; color: var(--muted); letter-spacing: 0; }
.plan-list { list-style: none; margin: 1rem 0; display: flex; flex-direction: column; gap: 0.45rem; }
.plan-list li { padding-left: 1.2rem; position: relative; font-size: 0.86rem; }
.plan-list li::before { content: ''; position: absolute; left: 0; top: 0.5em; width: 5px; height: 5px; border-radius: 50%; background: var(--accent); }
.note { font-size: 0.8rem; color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 0.9rem; align-items: flex-start; }

.tiers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; margin-bottom: 1rem; }
.tier {
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.3rem 1.2rem;
  display: flex;
  flex-direction: column;
}
.tier.current { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent) inset; }
.tier-name {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.7rem;
}
.tier .plan-price { font-size: 2.6rem; }
.tier .plan-list { flex: 1; }

/* ── Daily log page ── */
.crumb { display: inline-block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.9rem; }
.crumb:hover { color: var(--accent); }
.log-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.log-title { font-family: var(--font-head); font-weight: 400; font-size: 2.1rem; letter-spacing: 0.04em; color: var(--white); line-height: 1.1; }
.log-sub { display: flex; align-items: center; gap: 0.7rem; flex-wrap: wrap; margin-top: 0.4rem; color: var(--text); }
.facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.facts > div { background: var(--navy-2); padding: 0.8rem 1.1rem; min-width: 0; }
.facts dt { font-size: 0.66rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); }
.facts dd { color: var(--white); font-size: 0.92rem; margin-top: 0.15rem; overflow-wrap: anywhere; }
.add-entry { display: grid; grid-template-columns: 146px 1fr auto; gap: 0.6rem; margin-bottom: 1rem; }
.add-entry input { width: 100%; min-width: 0; font-size: 0.95rem; padding: 0.7rem 0.9rem; }
.log-panel { margin-bottom: 1rem; }
.eod-hours { display: grid; grid-template-columns: 180px 180px; gap: 1rem; max-width: 100%; }
.entry-table td:first-child, .entry-table th:first-child { width: 110px; }
.entry-table td { white-space: pre-wrap; overflow-wrap: anywhere; }
.lock-note {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  padding: 0.7rem 1.1rem;
  margin-bottom: 1rem;
  border: 1px solid rgba(62,207,122,0.4);
  border-radius: 8px;
  background: rgba(62,207,122,0.08);
  color: var(--text);
  font-size: 0.86rem;
}
textarea[readonly], input[readonly] { opacity: 0.75; }
.icon-btn {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
}
.icon-btn:hover { color: var(--bad); }
.btn-small { padding: 0.4rem 0.8rem; font-size: 0.68rem; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ── Banner, toast, sidebar account ── */
.banner {
  padding: 0.6rem 1.8rem;
  font-size: 0.82rem;
  color: var(--text);
  background: var(--accent-dim);
  border-bottom: 1px solid var(--border);
}
.banner.warn { background: rgba(240,181,69,0.12); border-bottom-color: rgba(240,181,69,0.35); }
.banner a { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translate(-50%, 20px);
  max-width: min(520px, 92vw);
  background: var(--navy-3);
  color: var(--white);
  border: 1px solid var(--accent-mid);
  border-radius: 8px;
  padding: 0.7rem 1.1rem;
  font-size: 0.86rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 200;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: var(--bad); }

.side-user { color: var(--text); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-foot a, .side-foot button.link {
  background: none; border: none; padding: 0; font: inherit; cursor: pointer;
  color: var(--accent);
}
.side-foot p { overflow: hidden; text-overflow: ellipsis; }

/* ── Sign-in gate ── */
.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: var(--navy);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 8vh 16px 40px;
}
.gate-card {
  width: min(400px, 100%);
  background: var(--navy-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.8rem 1.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}
.gate-brand .side-wordmark { font-size: 1.7rem; }
.gate-title { font-family: var(--font-head); font-weight: 400; font-size: 2rem; letter-spacing: 0.04em; color: var(--white); line-height: 1.1; }
.gate-form { display: flex; flex-direction: column; gap: 0.9rem; }
.gate-or { display: flex; align-items: center; gap: 0.8rem; font-size: 0.74rem; color: var(--muted); }
.gate-or::before, .gate-or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.gate-msg { font-size: 0.84rem; color: var(--warn); }
.gate-note { font-size: 0.76rem; color: var(--warn); }
.gate-links { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; font-size: 0.8rem; }
.gate-links a { color: var(--accent); }

/* ── Responsive ── */
@media (max-width: 1080px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .grid-2, .grid-even { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .side {
    position: fixed;
    z-index: 40;
    left: 0; top: 0;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }
  .side.open { transform: none; box-shadow: 0 0 60px rgba(0,0,0,0.6); }
  .menu-btn { display: flex; }
  .top { padding: 0 1rem; }
  #view { padding: 1rem; }
  .modal-body { grid-template-columns: 1fr; }
  .top-org { display: none; }
  .tiers { grid-template-columns: 1fr; }
  .eod-hours { grid-template-columns: 1fr 1fr; width: 100%; }
  .add-entry { grid-template-columns: 146px 1fr; }
  .add-entry button { grid-column: 1 / -1; justify-content: center; }
  .banner { padding: 0.6rem 1rem; }
}

@media (max-width: 520px) {
  .kpis { grid-template-columns: 1fr; }
}

@media print {
  body { background: #fff; color: #111; }
  .side, .top, .toolbar, .banner, .gate, .toast, .no-print { display: none !important; }
  #view { padding: 0; }
  .panel, .kpi { background: #fff; border-color: #bbb; break-inside: avoid; }
  .kpi-value, .cell-main, .bar-val { color: #111; }
  .panel-title { color: #111; }
  td, th { border-color: #ddd; color: #111; }
  .log-title, .facts dd { color: #111; }
  .facts, .facts > div { background: #fff; border-color: #bbb; }
  textarea { border: none; padding: 0; color: #111; background: #fff; resize: none; }
  .bar-fill { background: #333; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
