/* ═══════════════════════════════════════════════════════════
   ORPHEUS Container Tracking Dashboard — NAMU brand theme
   Light theme based on /branding/namu_theme.css
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Brand palette ───────────────────────────────────────── */
:root {
  /* NAMU brand */
  --namu-navy: #0A192F;
  --namu-sky: #4CC9F0;
  --namu-sky-deep: #0284C7;
  --namu-white: #FFFFFF;
  --namu-slate: #8892B0;
  --namu-slate-strong: #475569;
  --namu-bg-alt: #F8FAFC;
  --namu-border: #E2E8F0;
  --namu-border-strong: #CBD5E1;

  /* Surface tokens */
  --bg-base: var(--namu-bg-alt);
  --bg-surface: var(--namu-white);
  --bg-elevated: var(--namu-white);
  --bg-hover: #F1F5F9;
  --bg-active: rgba(76, 201, 240, 0.08);
  --border-subtle: var(--namu-border);
  --border-medium: var(--namu-border-strong);

  /* Text tokens */
  --text-primary: var(--namu-navy);
  --text-secondary: var(--namu-slate-strong);
  --text-muted: var(--namu-slate);

  /* Status accents — tuned for white background readability */
  --accent-blue: var(--namu-sky-deep);
  --accent-blue-dim: rgba(2, 132, 199, 0.10);
  --accent-sky: var(--namu-sky);
  --accent-sky-dim: rgba(76, 201, 240, 0.14);
  --accent-green: #15803D;
  --accent-green-dim: rgba(21, 128, 61, 0.10);
  --accent-amber: #B45309;
  --accent-amber-dim: rgba(180, 83, 9, 0.10);
  --accent-red: #B91C1C;
  --accent-red-dim: rgba(185, 28, 28, 0.08);
  --accent-purple: #6D28D9;
  --accent-purple-dim: rgba(109, 40, 217, 0.08);
  --accent-cyan: #0E7490;
  --accent-cyan-dim: rgba(14, 116, 144, 0.10);

  /* Glass / shadow */
  --glass-bg: rgba(255, 255, 255, 0.85);
  --glass-border: rgba(255, 255, 255, 1);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 3px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);
  --glass-glow: 0 10px 30px -12px rgba(15, 23, 42, 0.18);

  /* Radii / motion */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --font-sans: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-normal: 250ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-sans);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Subtle ambient gradient anchored to the brand sky tone */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 70% 50% at 0% 0%, rgba(76, 201, 240, 0.06), transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(2, 132, 199, 0.04), transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── Layout ───────────────────────────────────────────────── */
.app-wrapper { position: relative; z-index: 1; }

.container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ── Header ───────────────────────────────────────────────── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border-subtle);
  padding: 14px 0;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

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

.brand-logo {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
}

.brand-logo img {
  height: 38px;
  width: auto;
  display: block;
}

.brand-divider {
  width: 1px;
  height: 28px;
  background: var(--border-subtle);
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; min-width: 0; }

.brand-title {
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--namu-navy);
  line-height: 1.15;
}

.brand-subtitle {
  font-size: 0.72rem;
  color: var(--namu-slate);
  font-weight: 500;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.header-actions { display: flex; align-items: center; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--namu-white);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
}

.btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

.btn-primary {
  background: var(--namu-navy);
  border-color: var(--namu-navy);
  color: #fff;
  box-shadow: 0 4px 14px -6px rgba(10, 25, 47, 0.4);
}

.btn-primary:hover {
  background: #0F2A4D;
  border-color: #0F2A4D;
  color: #fff;
}

.btn .icon { font-size: 1rem; }

/* ── Metrics Strip ────────────────────────────────────────── */
.metrics-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  padding: 24px 0 12px;
}

.metric-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
}

.metric-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.metric-card[data-type="total"]::before     { background: var(--namu-sky); }
.metric-card[data-type="transit"]::before   { background: var(--accent-purple); }
.metric-card[data-type="arriving"]::before  { background: var(--accent-amber); }
.metric-card[data-type="action"]::before    { background: var(--accent-red); }
.metric-card[data-type="margin"]::before    { background: var(--accent-green); }
.metric-card[data-type="completed"]::before { background: var(--accent-cyan); }

.metric-value {
  font-size: 1.85rem;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1.1;
  color: var(--namu-navy);
}

.metric-card[data-type="total"]     .metric-value { color: var(--namu-sky-deep); }
.metric-card[data-type="transit"]   .metric-value { color: var(--accent-purple); }
.metric-card[data-type="arriving"]  .metric-value { color: var(--accent-amber); }
.metric-card[data-type="action"]    .metric-value { color: var(--accent-red); }
.metric-card[data-type="margin"]    .metric-value { color: var(--accent-green); }
.metric-card[data-type="completed"] .metric-value { color: var(--accent-cyan); }

.metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  font-weight: 600;
  margin-top: 4px;
}

/* ── Filter Bar ───────────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  max-width: 360px;
  position: relative;
}

.search-box .icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
  pointer-events: none;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 36px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  transition: all var(--transition-fast);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
  border-color: var(--namu-sky);
  box-shadow: 0 0 0 3px var(--accent-sky-dim);
}

.filter-select {
  padding: 9px 32px 9px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%238892B0'%3E%3Cpath d='M2 4l4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
  transition: all var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.filter-select:focus {
  border-color: var(--namu-sky);
  box-shadow: 0 0 0 3px var(--accent-sky-dim);
}

/* ── Data Table ───────────────────────────────────────────── */
.table-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface);
}

.table-title {
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--namu-navy);
}

.table-count {
  font-size: 0.72rem;
  color: var(--namu-slate-strong);
  background: var(--namu-bg-alt);
  border: 1px solid var(--border-subtle);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.table-wrapper { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--namu-bg-alt);
  padding: 10px 14px;
  text-align: left;
  font-weight: 700;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: color var(--transition-fast);
}

.data-table thead th:hover { color: var(--namu-navy); }
.data-table thead th.sorted { color: var(--namu-sky-deep); }

.data-table tbody tr {
  border-bottom: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.data-table tbody tr:hover { background: var(--bg-hover); }
.data-table tbody tr.selected { background: var(--bg-active); }
.data-table tbody tr:last-child { border-bottom: none; }

.data-table td {
  padding: 12px 14px;
  white-space: nowrap;
  vertical-align: middle;
  color: var(--text-primary);
}

.data-table td.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  letter-spacing: -0.3px;
  color: var(--namu-slate-strong);
}

/* ── Status Badge ─────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
  border: 1px solid transparent;
}

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

.status-badge.in_transit    { background: var(--accent-purple-dim); color: var(--accent-purple); border-color: rgba(109,40,217,0.18); }
.status-badge.in_transit .dot { background: var(--accent-purple); }
.status-badge.arriving_soon { background: var(--accent-amber-dim); color: var(--accent-amber); border-color: rgba(180,83,9,0.20); }
.status-badge.arriving_soon .dot { background: var(--accent-amber); animation: pulse-dot 2s infinite; }
.status-badge.arrived       { background: var(--accent-sky-dim); color: var(--namu-sky-deep); border-color: rgba(2,132,199,0.20); }
.status-badge.arrived .dot  { background: var(--namu-sky-deep); }
.status-badge.completed     { background: var(--accent-green-dim); color: var(--accent-green); border-color: rgba(21,128,61,0.18); }
.status-badge.completed .dot { background: var(--accent-green); }
.status-badge.loading       { background: var(--accent-cyan-dim); color: var(--accent-cyan); border-color: rgba(14,116,144,0.18); }
.status-badge.loading .dot  { background: var(--accent-cyan); }
.status-badge.booked        { background: var(--accent-sky-dim); color: var(--namu-sky-deep); border-color: rgba(2,132,199,0.20); }
.status-badge.booked .dot   { background: var(--namu-sky-deep); }
.status-badge.pending       { background: var(--namu-bg-alt); color: var(--text-muted); border-color: var(--border-subtle); }
.status-badge.pending .dot  { background: var(--text-muted); }
.status-badge.cancelled     { background: var(--accent-red-dim); color: var(--accent-red); border-color: rgba(185,28,28,0.18); text-decoration: line-through; }
.status-badge.cancelled .dot { background: var(--accent-red); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Document Readiness Bar ───────────────────────────────── */
.readiness-bar {
  display: flex;
  align-items: center;
  gap: 8px;
}

.readiness-track {
  flex: 1;
  height: 5px;
  background: var(--namu-bg-alt);
  border-radius: 999px;
  overflow: hidden;
  min-width: 60px;
  border: 1px solid var(--border-subtle);
}

.readiness-fill {
  height: 100%;
  border-radius: 999px;
  transition: width var(--transition-slow);
}

.readiness-fill.high { background: var(--accent-green); }
.readiness-fill.medium { background: var(--accent-amber); }
.readiness-fill.low { background: var(--accent-red); }

.readiness-label {
  font-size: 0.72rem;
  font-weight: 700;
  min-width: 32px;
  text-align: right;
  color: var(--namu-slate-strong);
}

/* ── Detail Panel ─────────────────────────────────────────── */
.detail-panel {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  margin-bottom: 24px;
  overflow: hidden;
  animation: slideUp 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-md);
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--namu-bg-alt);
}

.detail-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--namu-navy);
}

.detail-route {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 2px;
}

.detail-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.2rem;
  transition: all var(--transition-fast);
}

.detail-close:hover {
  background: var(--bg-hover);
  color: var(--namu-navy);
  border-color: var(--border-subtle);
}

.detail-body {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1px;
  background: var(--border-subtle);
}

.detail-section {
  padding: 20px 24px;
  background: var(--bg-surface);
}

.section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 5px 0;
  font-size: 0.82rem;
}

.detail-row .label {
  color: var(--text-muted);
  font-weight: 500;
}

.detail-row .value {
  color: var(--text-primary);
  font-weight: 600;
  text-align: right;
  max-width: 60%;
  word-break: break-word;
}

.detail-row .value.mono {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
}

/* ── Document Checklist ───────────────────────────────────── */
.doc-checklist { list-style: none; }

.doc-checklist li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  font-size: 0.82rem;
}

.doc-check {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  flex-shrink: 0;
}

.doc-check.done {
  background: var(--accent-green-dim);
  color: var(--accent-green);
  border: 1px solid rgba(21,128,61,0.25);
}

.doc-check.missing {
  background: var(--namu-bg-alt);
  color: var(--text-muted);
  border: 1px dashed var(--border-medium);
}

.doc-label-done { color: var(--text-primary); }
.doc-label-missing { color: var(--text-muted); }

/* ── Journey Timeline ─────────────────────────────────────── */
.journey-track {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 16px 0 8px;
}

.journey-node {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  position: relative;
  z-index: 1;
}

.journey-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 2px solid var(--border-medium);
  background: var(--bg-surface);
  transition: all var(--transition-normal);
}

.journey-dot.active {
  border-color: var(--namu-sky);
  background: var(--namu-sky);
  box-shadow: 0 0 0 4px var(--accent-sky-dim);
}

.journey-dot.done {
  border-color: var(--accent-green);
  background: var(--accent-green);
}

.journey-label {
  font-size: 0.62rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  white-space: nowrap;
}

.journey-line {
  flex: 1;
  height: 2px;
  background: var(--border-subtle);
  min-width: 24px;
  margin-bottom: 18px;
}

.journey-line.done { background: var(--accent-green); }
.journey-line.active {
  background: linear-gradient(90deg, var(--accent-green), var(--namu-sky));
}

/* ── Loading State ────────────────────────────────────────── */
.loading-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  gap: 16px;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--namu-sky);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-text {
  color: var(--text-muted);
  font-size: 0.85rem;
}

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

.empty-state .icon { font-size: 2.5rem; margin-bottom: 12px; }
.empty-state .message { font-size: 0.9rem; }

/* ── Fade-in Animations ──────────────────────────────────── */
.fade-in {
  animation: fadeIn 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.stagger-1 { animation-delay: 0.05s; }
.stagger-2 { animation-delay: 0.10s; }
.stagger-3 { animation-delay: 0.15s; }
.stagger-4 { animation-delay: 0.20s; }
.stagger-5 { animation-delay: 0.25s; }

/* ── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-medium); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--namu-slate); }

/* ── Ad-hoc tracked containers section ───────────────────── */
.adhoc-section {
  margin-top: 32px;
  padding: 22px 24px;
  background: linear-gradient(135deg, rgba(76, 201, 240, 0.06), var(--bg-surface));
  border: 1px solid rgba(2, 132, 199, 0.18);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.adhoc-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px 16px;
  align-items: center;
  margin-bottom: 16px;
}
.adhoc-title {
  grid-column: 1 / 2;
  font-size: 1rem;
  font-weight: 700;
  color: var(--namu-navy);
  display: flex;
  align-items: center;
  gap: 10px;
}
.adhoc-count {
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--namu-sky-deep);
  background: var(--accent-sky-dim);
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid rgba(2,132,199,0.18);
  font-weight: 600;
}
.adhoc-subtitle {
  grid-column: 1 / 2;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.adhoc-add-btn {
  grid-row: 1 / 3;
  grid-column: 2 / 3;
  background: var(--namu-sky-deep);
  color: #fff;
  border: 1px solid var(--namu-sky-deep);
  font-weight: 600;
}
.adhoc-add-btn:hover {
  background: #036A9F;
  border-color: #036A9F;
  color: #fff;
}

.adhoc-empty {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.adhoc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 14px;
}
.adhoc-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-fast);
}
.adhoc-card:hover { box-shadow: var(--shadow-md); border-color: var(--border-medium); }
.adhoc-card.live {
  border-color: rgba(76, 201, 240, 0.45);
  background: linear-gradient(135deg, rgba(76, 201, 240, 0.06), var(--bg-surface));
}
.adhoc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.adhoc-card-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.adhoc-label {
  font-weight: 700;
  font-size: 0.92rem;
  color: var(--namu-navy);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.adhoc-container {
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.adhoc-remove {
  background: none;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.adhoc-remove:hover { color: var(--accent-red); background: var(--accent-red-dim); border-color: rgba(185,28,28,0.18); }

.adhoc-card-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.adhoc-carrier {
  font-size: 0.72rem;
  color: var(--namu-slate-strong);
  font-weight: 600;
  padding: 2px 8px;
  background: var(--namu-bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
}

.adhoc-card-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.adhoc-grid-row {
  display: grid;
  grid-template-columns: 90px 1fr;
  gap: 10px;
  font-size: 0.78rem;
  align-items: baseline;
  color: var(--text-secondary);
}
.adhoc-grid-row > :first-child { color: var(--text-muted); font-weight: 500; }
.adhoc-grid-row > :last-child { color: var(--text-primary); font-weight: 500; }

.adhoc-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 4px;
}
.adhoc-progress .live-progress-track { flex: 1; height: 4px; }
.adhoc-progress .live-progress-label {
  min-width: 36px;
  text-align: right;
  font-size: 0.7rem;
}

/* Ad-hoc form */
.adhoc-form {
  background: var(--namu-bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.adhoc-form-type {
  display: flex;
  gap: 18px;
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}
.adhoc-radio {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}
.adhoc-radio input[type=radio] { accent-color: var(--namu-sky-deep); }
.adhoc-form-row {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 12px;
}
.adhoc-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.adhoc-form label .req { color: var(--accent-red); margin-left: 2px; }
.adhoc-form input,
.adhoc-form select {
  padding: 8px 10px;
  background: var(--namu-white);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 0.85rem;
}
.adhoc-form input:focus,
.adhoc-form select:focus {
  outline: none;
  border-color: var(--namu-sky);
  box-shadow: 0 0 0 3px var(--accent-sky-dim);
}
.adhoc-form input[name=container_number] {
  font-family: var(--font-mono);
  text-transform: uppercase;
}
.adhoc-form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
}
.adhoc-form-msg { flex: 1; font-size: 0.78rem; }
.adhoc-form-msg.error { color: var(--accent-red); }
.adhoc-form-msg.ok { color: var(--accent-green); }
.btn-ghost {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--border-medium);
  transition: all var(--transition-fast);
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-sans);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--namu-navy); }

@media (max-width: 768px) {
  .adhoc-form-row { grid-template-columns: 1fr; }
}

/* ── Auto-refresh indicator (header chip) ────────────────── */
.auto-refresh-chip {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--namu-bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
}
.auto-refresh-chip.active { display: inline-flex; }
.auto-refresh-chip .ar-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(21,128,61,0.18);
  animation: pulse-live 2s infinite;
}
.auto-refresh-chip .ar-text { color: var(--namu-navy); font-weight: 600; }
.auto-refresh-chip .ar-last { color: var(--text-muted); }

/* ── Tracking badge (table inline) ───────────────────────── */
.tracking-badge {
  display: inline-flex;
  align-items: center;
  margin-left: 6px;
  padding: 1px 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
}
.tracking-badge.live {
  color: var(--namu-sky-deep);
  background: var(--accent-sky-dim);
  border: 1px solid rgba(2,132,199,0.35);
}
.tracking-badge.live::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  margin-right: 4px;
  border-radius: 50%;
  background: var(--namu-sky);
  box-shadow: 0 0 0 2px rgba(76,201,240,0.4);
  animation: pulse-live 2s infinite;
}
@keyframes pulse-live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.tracking-badge.projected {
  color: var(--accent-purple);
  background: var(--accent-purple-dim);
  border: 1px solid rgba(109,40,217,0.25);
}

/* ── Live tracking section (detail panel) ────────────────── */
.live-tracking {
  margin: 0 24px 16px;
  padding: 14px 18px;
  background: var(--namu-bg-alt);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
}
.live-tracking.live {
  border-color: rgba(76, 201, 240, 0.45);
  background: linear-gradient(135deg, rgba(76, 201, 240, 0.07), var(--bg-surface));
}
.live-tracking.projected {
  border-color: rgba(109, 40, 217, 0.20);
}
.live-tracking.unavailable {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.live-icon { font-size: 1.1rem; }
.live-empty { font-style: italic; }

.live-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.live-source {
  font-weight: 700;
  font-size: 0.85rem;
  color: var(--namu-navy);
}
.live-fetched {
  margin-left: auto;
  font-size: 0.7rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.live-progress {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.live-progress-track {
  flex: 1;
  height: 6px;
  background: var(--namu-white);
  border: 1px solid var(--border-subtle);
  border-radius: 999px;
  overflow: hidden;
}
.live-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--namu-sky), var(--namu-sky-deep));
  border-radius: 999px;
  transition: width var(--transition-slow);
}
.live-tracking.projected .live-progress-fill {
  background: linear-gradient(90deg, var(--accent-purple), #c4b5fd);
}
.live-progress-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-weight: 500;
  min-width: 90px;
  text-align: right;
}

.live-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px 18px;
}
.live-grid > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 0.8rem;
}
.live-key {
  color: var(--text-muted);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
}
.live-val { color: var(--text-primary); font-weight: 600; }
.live-val.mono { font-family: var(--font-mono); font-size: 0.75rem; font-weight: 500; }

/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 768px) {
  .container { padding: 0 16px; }
  .metrics-strip { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: none; }
  .detail-body { grid-template-columns: 1fr; }
  .header-inner { flex-wrap: wrap; }
  .live-grid { grid-template-columns: 1fr 1fr; }
  .live-fetched { display: none; }
  .brand-divider { display: none; }
  .brand-logo img { height: 32px; }
}
