/* ==========================================================================
   Northern Spain 2027 Hub — Offline-First Mobile-First Styles
   Zero external fonts or CDN assets. Tuned for 390px thumb ergonomics.
   ========================================================================== */

:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-alt: #efece5;
  --border: #dcd6ca;
  --border-strong: #c2b9a8;
  --ink: #131c26;
  --ink-muted: #4a5766;
  --accent: #0c6b6b;
  --accent-strong: #084f4f;
  --accent-soft: #e3f3f2;
  --accent-ink: #ffffff;

  --warm: #b84a27;
  --warm-soft: #fdf0eb;

  --danger: #b42318;
  --danger-bg: #fef2f2;
  --danger-border: #f04438;
  --danger-ink: #7a1212;

  --action: #9a4d00;
  --action-bg: #fff8eb;
  --action-border: #d97706;
  --action-ink: #6d3600;

  --timing: #1d4ed8;
  --timing-bg: #eff6ff;
  --timing-border: #3b82f6;
  --timing-ink: #1e3a8a;

  --ok: #0f766e;
  --ok-bg: #ecfdf5;
  --ok-border: #10b981;
  --ok-ink: #065f46;

  --tbd-bg: #fef3c7;
  --tbd-border: #d97706;
  --tbd-ink: #78350f;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-sm: 0 1px 2px rgba(19, 28, 38, 0.06);
  --shadow-md: 0 6px 20px rgba(19, 28, 38, 0.12);

  --header-h: 58px;
  --nav-h: 64px;
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}

:root[data-theme="dark"] {
  --bg: #0d131a;
  --surface: #151e28;
  --surface-alt: #1d2836;
  --border: #2a3747;
  --border-strong: #3e5066;
  --ink: #f1f5f9;
  --ink-muted: #9eb0c4;
  --accent: #32b5ad;
  --accent-strong: #53cfc7;
  --accent-soft: #132d2e;
  --accent-ink: #061b1c;

  --warm: #f2845c;
  --warm-soft: #2e1b14;

  --danger: #f87171;
  --danger-bg: #2c1215;
  --danger-border: #ef4444;
  --danger-ink: #fecaca;

  --action: #fbbf24;
  --action-bg: #2b200d;
  --action-border: #f59e0b;
  --action-ink: #fde68a;

  --timing: #60a5fa;
  --timing-bg: #12213a;
  --timing-border: #3b82f6;
  --timing-ink: #dbeafe;

  --ok: #34d399;
  --ok-bg: #0f2922;
  --ok-border: #10b981;
  --ok-ink: #a7f3d0;

  --tbd-bg: #31230c;
  --tbd-border: #d97706;
  --tbd-ink: #fcd34d;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 10px 28px rgba(0, 0, 0, 0.55);
}

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

html, body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

a {
  color: var(--accent);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* App Shell */
.app-shell {
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top, 0px);
}

.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 12px;
  min-height: var(--header-h);
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  min-width: 0;
}

.brand-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.015em;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  color: var(--ink-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-online {
  background: #10b981;
}

.status-offline {
  background: #f59e0b;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn, .icon-pill-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  transition: background 0.15s ease, border-color 0.15s ease;
}

.icon-pill-btn {
  padding: 0 10px;
  font-size: 12.5px;
  font-weight: 650;
}

.icon-pill-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Simulator Bar & Panel */
.sim-active-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--timing-bg);
  border-top: 1px solid var(--timing-border);
  color: var(--timing-ink);
  font-size: 12.5px;
  font-weight: 600;
}

.link-btn {
  border: none;
  background: none;
  color: inherit;
  text-decoration: underline;
  font-weight: 700;
  font-size: 12.5px;
  padding: 2px 4px;
}

.sim-panel {
  padding: 10px 12px 12px;
  background: var(--surface-alt);
  border-top: 1px solid var(--border);
}

.sim-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.sim-title {
  font-size: 12.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.btn-ghost-sm {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 8px;
  padding: 4px 9px;
  font-size: 12px;
  font-weight: 650;
}

.sim-controls {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 8px;
  margin-bottom: 8px;
}

.date-input, .select-input {
  width: 100%;
  min-width: 0;
  height: 38px;
  padding: 0 9px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
}

.sim-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip-btn {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.2;
}

.chip-btn.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

/* Main Content */
.main-content {
  flex: 1;
  padding: 12px 12px calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 20px);
  width: 100%;
}

.view-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.view-panel[hidden] {
  display: none;
}

/* Cards & Sections */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
  overflow-wrap: anywhere;
}

.card-hero {
  border-top: 3px solid var(--accent);
}

.section-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 4px 2px 0;
}

.section-heading h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.section-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

/* Alerts & Safety Banners */
.banner {
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  border: 1px solid;
  border-left-width: 5px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  overflow-wrap: anywhere;
}

.banner-critical {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-ink);
}

.banner-action {
  background: var(--action-bg);
  border-color: var(--action-border);
  color: var(--action-ink);
}

.banner-timing {
  background: var(--timing-bg);
  border-color: var(--timing-border);
  color: var(--timing-ink);
}

.banner-resolved {
  background: var(--ok-bg);
  border-color: var(--ok-border);
  color: var(--ok-ink);
}

.banner-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.banner-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.25;
}

.banner-body {
  margin: 0;
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.4;
}

.banner-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.banner-btn {
  border: 1px solid currentColor;
  background: transparent;
  color: inherit;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* Badges & TBD Pills */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.35;
  white-space: nowrap;
  max-width: 100%;
}

.badge-accent {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.badge-ok {
  background: var(--ok-bg);
  color: var(--ok-ink);
  border: 1px solid var(--ok-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-ink);
  border: 1px solid var(--danger-border);
}

.badge-timing {
  background: var(--timing-bg);
  color: var(--timing-ink);
  border: 1px solid var(--timing-border);
}

.badge-action {
  background: var(--action-bg);
  color: var(--action-ink);
  border: 1px solid var(--action-border);
}

.badge-neutral {
  background: var(--surface-alt);
  color: var(--ink-muted);
  border: 1px solid var(--border);
}

.tbd-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 6px;
  background: var(--tbd-bg);
  border: 1px dashed var(--tbd-border);
  color: var(--tbd-ink);
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
  max-width: 100%;
}

/* Timeline Day Strip */
.day-strip-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 4px;
  scrollbar-width: thin;
}

.day-strip {
  display: flex;
  gap: 6px;
  width: max-content;
}

.day-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 54px;
  padding: 6px 8px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  position: relative;
}

.day-pill-mo {
  font-size: 10px;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-muted);
}

.day-pill-num {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.15;
}

.day-pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  margin-top: 2px;
}

.day-pill.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.day-pill.is-selected .day-pill-mo {
  color: var(--accent-ink);
  opacity: 0.9;
}

/* Focused Day Card */
.day-hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.day-nav-arrows {
  display: flex;
  gap: 6px;
}

.mini-arrow-btn {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mini-arrow-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.day-hero-title {
  margin: 4px 0 4px;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.02em;
}

.day-hero-summary {
  margin: 0 0 10px;
  font-size: 13.5px;
  color: var(--ink-muted);
}

.base-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--surface-alt);
  font-size: 13px;
  margin-bottom: 10px;
}

.base-strip strong {
  font-weight: 700;
}

.stops-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.stop-item {
  padding: 10px 11px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
}

.stop-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.stop-name {
  font-weight: 750;
  font-size: 14px;
  line-height: 1.25;
}

.stop-detail {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

.stop-callout {
  margin-top: 6px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 12.5px;
  font-weight: 700;
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.stop-callout-tide {
  background: var(--timing-bg);
  color: var(--timing-ink);
  border: 1px solid var(--timing-border);
}

.stop-callout-permit {
  background: var(--action-bg);
  color: var(--action-ink);
  border: 1px solid var(--action-border);
}

.stop-callout-time {
  background: var(--timing-bg);
  color: var(--timing-ink);
  border: 1px solid var(--timing-border);
}

/* Compact Booking Snippets inside Timeline */
.day-bookings {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sub-label {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-muted);
  margin: 0;
}

.mini-booking {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-alt);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.mini-booking-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.mini-booking-title {
  font-weight: 750;
  font-size: 13.5px;
}

.mini-booking-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Notes Box */
.notes-block {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.notes-textarea {
  width: 100%;
  min-height: 62px;
  margin-top: 6px;
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  resize: vertical;
}

/* Full Chronological Timeline List */
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.timeline-row {
  width: 100%;
  text-align: left;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.timeline-row.is-selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.timeline-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.timeline-row-date {
  font-size: 12px;
  font-weight: 750;
  color: var(--accent);
}

.timeline-row-region {
  font-size: 11.5px;
  color: var(--ink-muted);
  font-weight: 600;
}

.timeline-row-title {
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
}

.timeline-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

/* Countdown Banner */
.countdown-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 11px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 12.5px;
  font-weight: 700;
}

/* Bookings Tab */
.filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-pill {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  min-height: 36px;
}

.filter-pill.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}

.booking-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.booking-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.booking-title {
  margin: 2px 0 0;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.25;
}

.booking-provider {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 750;
  color: var(--ink-muted);
}

.booking-dates {
  font-size: 13px;
  color: var(--ink-muted);
  font-weight: 600;
}

.code-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
}

.code-box-left {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.code-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  color: var(--ink-muted);
}

.code-value {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.btn-copy {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 11px;
  min-height: 36px;
  border-radius: 9px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12.5px;
  font-weight: 700;
  flex-shrink: 0;
}

.btn-copy-subtle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 10px;
  min-height: 34px;
  border-radius: 9px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--ink);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

.detail-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.detail-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: 13px;
}

.detail-key {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink-muted);
}

.address-box {
  padding: 9px 10px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.address-text {
  font-size: 13px;
  line-height: 1.35;
}

.map-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.booking-note-text {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

/* Checklists Tab */
.progress-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.progress-track {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: var(--surface-alt);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.2s ease;
}

.checklist-group-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.checklist-group-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 800;
}

.checklist-group-sub {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.check-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px;
  border-radius: 11px;
  border: 1px solid var(--border);
  background: var(--bg);
  cursor: pointer;
  min-height: 46px;
}

.check-item.is-critical {
  border-color: var(--danger-border);
  background: var(--danger-bg);
}

.check-item.is-done {
  opacity: 0.7;
}

.check-item input[type="checkbox"] {
  width: 22px;
  height: 22px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex-shrink: 0;
  cursor: pointer;
}

.check-item-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.check-item-text {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.35;
}

.check-item.is-done .check-item-text {
  text-decoration: line-through;
}

.check-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.delete-custom-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 700;
}

.add-item-form {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.text-input {
  flex: 1;
  min-width: 0;
  height: 40px;
  padding: 0 11px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
}

/* Quick Ref Tab */
.emergency-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.em-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 11px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
}

.em-card-primary {
  grid-column: 1 / -1;
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-ink);
}

.em-card-wide {
  grid-column: 1 / -1;
}

.em-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
}

.em-num {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: -0.02em;
  font-family: var(--font-mono);
}

.em-call-tag {
  font-size: 11.5px;
  font-weight: 750;
  text-transform: uppercase;
}

.em-name {
  font-size: 13.5px;
  font-weight: 750;
}

.em-detail {
  font-size: 12px;
  opacity: 0.9;
  line-height: 1.35;
}

.phrase-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.phrase-item {
  padding: 9px 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.phrase-es {
  font-weight: 750;
  font-size: 14px;
  margin-bottom: 2px;
}

.phrase-en {
  font-size: 12.5px;
  color: var(--ink-muted);
}

.medical-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 9px;
}

.medical-field label {
  font-size: 12px;
  font-weight: 750;
  color: var(--ink-muted);
}

.medical-field textarea {
  width: 100%;
  min-height: 52px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg);
  color: var(--ink);
  font-size: 13.5px;
  resize: vertical;
}

.leave-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 6px 0;
}

.ref-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ref-item {
  padding: 10px;
  border-radius: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
}

.ref-item-title {
  font-weight: 750;
  font-size: 13.5px;
  margin-bottom: 3px;
}

.ref-item-detail {
  margin: 0;
  font-size: 13px;
  color: var(--ink-muted);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 640px;
  z-index: 40;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 4px 6px calc(4px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -4px 16px rgba(19, 28, 38, 0.08);
}

.nav-tab {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 54px;
  padding: 4px 2px;
  border-radius: 12px;
  font-size: 11.5px;
  font-weight: 700;
}

.nav-tab.is-active {
  color: var(--accent);
  background: var(--accent-soft);
}

.nav-icon-wrap {
  position: relative;
  display: inline-flex;
}

.nav-badge {
  position: absolute;
  top: -5px;
  right: -10px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger-border);
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-badge-muted {
  background: var(--accent);
  color: var(--accent-ink);
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger, .btn-danger-outline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 13.5px;
  font-weight: 700;
  border: 1px solid transparent;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
}

.btn-secondary {
  background: var(--surface-alt);
  border-color: var(--border-strong);
  color: var(--ink);
}

.btn-danger {
  background: var(--danger);
  color: #ffffff;
}

.btn-danger-outline {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
  width: 100%;
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Modal Sheet */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 13, 20, 0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 12px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-sheet {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
}

.modal-header h2 {
  margin: 0;
  font-size: 16.5px;
  font-weight: 800;
}

.modal-body {
  padding: 14px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-label {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
}

.setting-help {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-alt);
}

.seg-btn {
  border: none;
  background: transparent;
  color: var(--ink-muted);
  border-radius: 9px;
  min-height: 36px;
  font-size: 13px;
  font-weight: 700;
}

.seg-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

.status-box {
  padding: 10px 12px;
  border-radius: 11px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}

.file-import-label {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px dashed var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 13.5px;
  font-weight: 700;
  cursor: pointer;
}

.file-import-label input[type="file"] {
  display: none;
}

.setting-danger {
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.reset-confirm {
  padding: 10px;
  border-radius: 10px;
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
}

.reset-warn-text {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--danger-ink);
}

/* Toast */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
  left: 50%;
  transform: translateX(-50%);
  z-index: 80;
  background: var(--ink);
  color: var(--bg);
  padding: 9px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  box-shadow: var(--shadow-md);
  max-width: calc(100vw - 32px);
  text-align: center;
}
