/* pwa-v2/app/styles.css — mobile-first dark theme. No framework. */

:root {
  --bg:        #0b0d10;
  --bg-1:      #14171b;
  --bg-2:      #1b1f25;
  --bg-3:      #232830;
  --line:      #2a2f36;
  --text:      #e7eaee;
  --text-d:    #9aa3ad;
  --accent:    #2563eb;
  --accent-d:  #1d4ed8;
  --gold:      #c8a84b;
  --green:     #22c55e;
  --red:       #ef4444;
  --orange:    #f59e0b;
  --safe-top:    env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --row-h:      64px;
  --tap-min:    44px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body {
  margin: 0; padding: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.4 -apple-system, system-ui, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none; touch-action: pan-y;
}

/* Phase 9c a11y: visible focus ring (offset so dark-theme buttons still show focus). */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
button:focus-visible, .btn:focus-visible { outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: var(--tap-min); }

#app-root { min-height: 100vh; padding-top: var(--safe-top); padding-bottom: calc(56px + var(--safe-bottom)); }

/* ── Header ───────────────────────────────────────────────────────────────── */
.app-hdr {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--bg-1); border-bottom: 1px solid var(--line);
  padding-top: calc(10px + var(--safe-top));
}
.app-hdr h1 { margin: 0; font-size: 16px; font-weight: 700; flex: 1; }
.app-hdr .badge { background: var(--bg-2); border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--text-d); }
.btn-icon {
  background: var(--bg-2); border: 1px solid var(--line); width: 36px; height: 36px;
  border-radius: 8px; display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.sync-pill { font-size: 11px; padding: 2px 8px; border-radius: 999px; }
.sync-pill.online  { background: rgba(34,197,94,.15);  color: var(--green); border: 1px solid rgba(34,197,94,.3); }
.sync-pill.offline { background: rgba(239,68,68,.15);  color: var(--red);   border: 1px solid rgba(239,68,68,.3); }
.sync-pill.syncing { background: rgba(37,99,235,.15);  color: #93c5fd;       border: 1px solid rgba(37,99,235,.3); }

/* ── Bottom nav ───────────────────────────────────────────────────────────── */
.app-bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; background: var(--bg-1); border-top: 1px solid var(--line); padding-bottom: var(--safe-bottom); }
.app-bottom button { flex: 1; background: none; border: 0; padding: 10px 4px; color: var(--text-d); display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; cursor: pointer; position: relative; }
.app-bottom button.on { color: var(--gold); }
.app-bottom button .ico { font-size: 20px; }
.app-bottom button .nav-badge { position: absolute; top: 6px; right: 28%; min-width: 16px; height: 16px; border-radius: 999px; background: var(--red); color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; }

/* ── Layout ───────────────────────────────────────────────────────────────── */
.scr { padding: 14px; }
.scr h2 { margin: 4px 0 14px 0; font-size: 18px; }
.empty { color: var(--text-d); padding: 30px 10px; text-align: center; }

/* ── Cards (legacy) — components/list-row supersedes these in new screens ── */
.card { background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; cursor: pointer; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card h3 { margin: 0 0 4px 0; font-size: 15px; font-weight: 600; }
.card .meta { color: var(--text-d); font-size: 12px; }

/* ── Status pills (Phase 2 component) ─────────────────────────────────────── */
.pri, .pill { font-size: 10px; padding: 2px 6px; border-radius: 4px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; border: 1px solid var(--line); color: var(--text-d); }
.pri.urgent, .pill.urgent { color: #fff; background: var(--red);    border-color: var(--red); }
.pri.high,   .pill.high   { color: #fff; background: var(--orange); border-color: var(--orange); }
.pri.medium, .pill.medium { color: #fff; background: #6b7280;       border-color: #6b7280; }
.pri.low,    .pill.low    { color: var(--text-d); }
.pill.ok    { color: #04071a; background: var(--green);  border-color: var(--green); }
.pill.info  { color: #fff;    background: var(--accent); border-color: var(--accent); }
.pill.warn  { color: #04071a; background: var(--gold);   border-color: var(--gold); }

/* ── Progress bar ─────────────────────────────────────────────────────────── */
.progbar { height: 4px; border-radius: 999px; background: var(--bg-2); margin-top: 8px; overflow: hidden; }
.progbar > span { display: block; height: 100%; background: var(--gold); }

/* ── Step list ────────────────────────────────────────────────────────────── */
.steps { list-style: none; padding: 0; margin: 0; }
.step  { display: flex; align-items: flex-start; gap: 12px; padding: 11px 4px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.step .check { width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%; border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; font-size: 14px; transition: all .12s; cursor: pointer; }
.step.done .check { background: var(--gold); border-color: var(--gold); color: #04071a; }
.step.done .name  { color: var(--text-d); text-decoration: line-through; }
.step .name { flex: 1; }
.step .when { font-size: 11px; color: var(--text-d); margin-top: 2px; display: block; }
.step.queued .check { border-color: #93c5fd; }

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 11px 16px; color: var(--text); cursor: pointer; font-weight: 600; min-height: var(--tap-min); }
.btn.primary  { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.success  { background: var(--green);  border-color: var(--green);  color: #04071a; }
.btn.danger   { background: var(--red);    border-color: var(--red);    color: #fff; }
.btn.ghost    { background: transparent; }
.btn.block    { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }

input.input, select.input, textarea.input {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 8px;
  padding: 11px 12px; color: var(--text); margin-bottom: 12px;
}
input.input:focus, select.input:focus, textarea.input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ── Toast ────────────────────────────────────────────────────────────────── */
#toast-root { position: fixed; left: 0; right: 0; bottom: calc(70px + var(--safe-bottom)); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 200; pointer-events: none; }
.toast { pointer-events: auto; background: var(--bg-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; max-width: 88%; box-shadow: 0 6px 24px rgba(0,0,0,.4); animation: tin .2s; }
.toast.err { border-color: var(--red); }
.toast.ok  { border-color: var(--green); }
@keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* ── Modal (legacy small modal) ───────────────────────────────────────────── */
#modal-root:empty { display: none; }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 150; display: flex; align-items: flex-end; justify-content: center; }
.modal    { background: var(--bg-1); width: 100%; max-width: 520px; border-radius: 16px 16px 0 0; padding: 18px; max-height: 92vh; overflow: auto; padding-bottom: calc(18px + var(--safe-bottom)); }
.modal h3 { margin: 0 0 12px 0; }

/* ── Bottom-sheet (Phase 2 component, swipeable) ──────────────────────────── */
#sheet-root:empty { display: none; }
.sheet-bg {
  position: fixed; inset: 0; background: rgba(0,0,0,.55); z-index: 160;
  display: flex; align-items: flex-end; justify-content: center;
  animation: bgIn .18s ease-out;
}
.sheet {
  background: var(--bg-1); width: 100%; max-width: 560px;
  border-radius: 18px 18px 0 0; padding: 6px 18px 18px;
  max-height: 92vh; overflow: auto; padding-bottom: calc(18px + var(--safe-bottom));
  transform: translateY(0); will-change: transform; transition: transform .22s ease-out;
}
.sheet.dragging { transition: none; }
.sheet-grabber { width: 40px; height: 4px; background: var(--line); border-radius: 999px; margin: 6px auto 14px; }
.sheet h3 { margin: 0 0 12px 0; }
@keyframes bgIn { from { opacity: 0; } to { opacity: 1; } }

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; background: var(--bg-1); border: 1px solid var(--line); border-radius: 14px; padding: 28px; }
.login-card h1 { margin: 0 0 4px 0; font-size: 20px; }
.login-card .sub { color: var(--text-d); font-size: 13px; margin-bottom: 18px; }

/* ── Components: filter-chips ─────────────────────────────────────────────── */
.fc-strip {
  position: sticky; top: calc(48px + var(--safe-top)); z-index: 40;
  display: flex; gap: 6px; overflow-x: auto; padding: 8px 14px;
  background: var(--bg); border-bottom: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}
.fc {
  flex-shrink: 0; padding: 6px 12px; border-radius: 999px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text-d);
  font-size: 12px; font-weight: 600; cursor: pointer; min-height: 32px;
}
.fc.on { background: var(--gold); color: #04071a; border-color: var(--gold); }
.fc-count { opacity: .7; margin-left: 2px; }

/* ── Misc ─────────────────────────────────────────────────────────────────── */
.err  { color: var(--red);   font-size: 12px; margin-top: 6px; min-height: 16px; }
.muted{ color: var(--text-d); }
.refreshing { font-size: 12px; color: var(--text-d); text-align: center; padding: 6px; }

/* ── Components: list-row ─────────────────────────────────────────────────── */
.lr-wrap { position: relative; overflow: hidden; border-radius: 10px; margin-bottom: 10px; background: var(--bg-1); }
.lr {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; min-height: var(--row-h);
  background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; will-change: transform; transition: transform .18s ease-out;
}
.lr.dragging { transition: none; }
.lr-ico { font-size: 22px; flex-shrink: 0; width: 32px; text-align: center; }
.lr-body { flex: 1; min-width: 0; }
.lr-title { font-size: 15px; font-weight: 600; margin: 0 0 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-meta { color: var(--text-d); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lr-trail { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.lr-actions { position: absolute; inset: 0; display: flex; }
.lr-actions .lr-act { flex: 1; display: flex; align-items: center; justify-content: center; font-weight: 700; color: #fff; font-size: 13px; }
.lr-actions .lr-act.left { background: var(--green); }
.lr-actions .lr-act.right{ background: var(--accent); }

/* ── Components: pull-to-refresh ──────────────────────────────────────────── */
.pr-indicator {
  position: absolute; left: 0; right: 0; top: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  height: 0; overflow: hidden; color: var(--text-d); font-size: 12px;
  transition: height .15s ease-out;
}
.pr-indicator.pulling { height: 36px; }
.pr-indicator .pr-spinner {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--gold);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Components: skeleton ─────────────────────────────────────────────────── */
.sk { background: linear-gradient(90deg, var(--bg-1) 0%, var(--bg-2) 50%, var(--bg-1) 100%); background-size: 200% 100%; animation: skshine 1.2s ease-in-out infinite; border-radius: 6px; }
@keyframes skshine { from { background-position: 200% 0; } to { background-position: -200% 0; } }
.sk-row { height: var(--row-h); margin-bottom: 10px; }
.sk-line { height: 12px; margin: 6px 0; }

/* ── Components: empty-state ──────────────────────────────────────────────── */
.es { display: flex; flex-direction: column; align-items: center; gap: 10px; color: var(--text-d); padding: 40px 20px; text-align: center; }
.es-ico { font-size: 36px; }

/* ── Components: action-bar ───────────────────────────────────────────────── */
.action-bar {
  position: sticky; bottom: calc(56px + var(--safe-bottom)); left: 0; right: 0; z-index: 40;
  display: flex; gap: 8px; padding: 10px 14px; background: var(--bg-1); border-top: 1px solid var(--line);
}
.action-bar .btn { flex: 1; }

/* ── Components: photo-thumb ──────────────────────────────────────────────── */
.pt { position: relative; width: 80px; height: 80px; border-radius: 8px; overflow: hidden; background: var(--bg-2); border: 1px solid var(--line); flex-shrink: 0; }
.pt img { width: 100%; height: 100%; object-fit: cover; }
.pt .pt-status { position: absolute; bottom: 2px; right: 2px; font-size: 9px; padding: 1px 4px; border-radius: 3px; background: rgba(0,0,0,.7); color: #fff; }
.pt .pt-status.queued { background: rgba(245,158,11,.9); color: #04071a; }

/* ── Components: captain-card ─────────────────────────────────────────────── */
.cap-card { background: var(--bg-1); border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 10px; }
.cap-card .cap-name { font-weight: 700; font-size: 15px; }
.cap-card .cap-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.cap-card .cap-actions a, .cap-card .cap-actions button {
  flex: 1; min-width: 80px; padding: 8px 10px; border-radius: 8px;
  background: var(--bg-2); border: 1px solid var(--line); color: var(--text);
  text-align: center; text-decoration: none; font-size: 12px; font-weight: 600;
}
.cap-card .cap-actions a.disabled, .cap-card .cap-actions button.disabled { opacity: .4; pointer-events: none; }
.cap-card .quiet { color: var(--orange); font-size: 11px; margin-top: 6px; }

/* ── Vessel hub ───────────────────────────────────────────────────────────── */
.vh-section { margin: 16px 0 8px; font-size: 11px; color: var(--text-d); text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.vh-stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.vh-stat { background: var(--bg-1); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.vh-stat .v { font-size: 20px; font-weight: 700; }
.vh-stat .l { font-size: 11px; color: var(--text-d); }
.vh-photo-strip { display: flex; gap: 6px; overflow-x: auto; padding: 4px 0; -webkit-overflow-scrolling: touch; }
.vh-photo-strip .pt { width: 72px; height: 72px; }

/* ── Merge dialog ─────────────────────────────────────────────────────────── */
.merge-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.merge-col { background: var(--bg-2); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; }
.merge-col.picked { border-color: var(--accent); background: rgba(37,99,235,.12); }
.merge-col .lbl { font-size: 11px; color: var(--text-d); margin-bottom: 2px; }
.merge-col .val { font-size: 13px; word-break: break-word; }
.merge-field-label { font-size: 11px; color: var(--text-d); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
