/**
 * CAMO Fleet – shared design system
 * Source of visual truth: dashboard (index.html) look & tokens.
 *
 * Typography is resolved locally. The pages used to pull Inter and JetBrains
 * Mono from an external webfont host; that request is gone, so the named
 * families are honoured only when the device already has them and otherwise
 * fall through to the platform's own UI and monospace faces.
 */
:root {
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, 'SF Mono',
    Menlo, Consolas, 'Liberation Mono', monospace;

  --bg-primary: #d1d5db;
  --bg-secondary: #e5e7eb;
  --bg-card: #ffffff;
  --bg-card-hover: #fafafa;
  --border: #c7ccd4;
  --border-light: #9ca3af;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --accent-blue: #2563eb;
  --accent-cyan: #0891b2;
  --navy: #1e3a5f;
  --brand: #2c5aa0;
  --brand-star: #c9a227;
  --status-green: #059669;
  --status-green-bg: rgba(5, 150, 105, 0.15);
  --status-yellow: #d97706;
  --status-yellow-bg: rgba(217, 119, 6, 0.15);
  --status-red: #dc2626;
  --status-red-bg: rgba(220, 38, 38, 0.15);
  --status-purple: #7c3aed;
  --status-purple-bg: rgba(124, 58, 237, 0.15);
  --status-gray: #6b7280;
  --status-gray-bg: rgba(107, 114, 128, 0.15);
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-modal: 0 20px 60px rgba(0, 0, 0, 0.3);
  --safe-b: env(safe-area-inset-bottom, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  scrollbar-gutter: stable;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.5;
}

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

/* ─── App shell header (matches dashboard) ─── */
.app-header,
.header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(10px);
}

.app-header-inner,
.header-content {
  max-width: 1800px;
  margin: 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.app-header-brand,
.logo-section {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}

/* Instance brand mark (COMPANY_NAME, server/instance.js) — single brand signal across all pages */
.brand-badge,
a.brand-badge,
.app-logo,
a.app-logo {
  background: var(--brand);
  padding: 0.4rem 0.8rem;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
  flex-shrink: 0;
  color: #fff;
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  white-space: nowrap;
  line-height: 1.2;
  width: auto;
  height: auto;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.brand-badge .brand-star,
.app-logo .brand-star {
  color: var(--brand-star);
  font-size: 1.15rem;
  line-height: 1;
}

.app-header-titles h1,
.header-title h1 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.app-header-titles p,
.app-header-titles span,
.header-title span {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 400;
}

.app-header-actions,
.header-meta,
.header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.header-meta {
  flex-wrap: nowrap;
  max-width: 100%;
}

.header-time-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: nowrap;
  max-width: 100%;
}

.header-actions-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  max-width: 100%;
}

.camo-clocks {
  display: grid;
  grid-template-columns: auto auto;
  gap: 0.15rem 0.75rem;
  align-items: center;
  max-width: 100%;
  padding: 0.3rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-secondary);
  font-family: var(--font-mono), monospace;
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
}

.camo-clocks span {
  white-space: nowrap;
}

.camo-clocks small {
  color: var(--text-muted);
  font: inherit;
  font-size: 0.9em;
}

.auth-brand .camo-clocks {
  grid-column: 1 / -1;
  flex-basis: 100%;
  order: 2;
  overflow: hidden;
  margin-top: 0.35rem;
}

@media (max-width: 640px) {
  .app-header,
  .header {
    position: static;
    padding: 0.65rem 0.75rem;
  }

  .app-header-inner,
  .header-content {
    gap: 0.55rem;
  }

  .camo-clocks {
    width: 100%;
    grid-template-columns: 1fr;
    gap: 0.1rem;
    overflow: hidden;
  }

  .camo-clocks span {
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

/* ─── Buttons ─── */
.manage-btn,
.btn {
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  transition: all 0.2s;
  line-height: 1.2;
}

.manage-btn:hover,
.btn:hover {
  border-color: var(--accent-blue);
  color: var(--accent-blue);
}

.btn-primary,
.manage-btn.primary {
  background: var(--accent-blue);
  color: #fff;
  border-color: var(--accent-blue);
}

.btn-primary:hover,
.manage-btn.primary:hover {
  background: var(--accent-blue-hover, #1d4ed8);
  border-color: var(--accent-blue-hover, #1d4ed8);
  color: #fff;
}

.btn-success,
.manage-btn.success {
  background: var(--status-green);
  color: #fff;
  border-color: var(--status-green);
}

.btn-success:hover,
.manage-btn.success:hover {
  background: #047857;
  border-color: #047857;
  color: #fff;
}

.btn-danger {
  background: var(--status-red);
  color: #fff;
  border-color: var(--status-red);
}

.btn-danger:hover {
  background: #b91c1c;
  color: #fff;
}

.btn-ghost {
  background: var(--bg-card);
  color: var(--text-secondary);
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* ─── Cards / layout ─── */
.page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 1.25rem;
}

.page-narrow {
  max-width: 640px;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.2rem;
  margin-bottom: 0.9rem;
}

.card-title {
  margin: 0 0 0.85rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.card h2 {
  margin: 0 0 0.85rem;
  font-size: 1.05rem;
  color: var(--navy);
  font-weight: 600;
}

/* ─── Forms ─── */
.field {
  margin-bottom: 0.75rem;
}

.field:last-child {
  margin-bottom: 0;
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.3rem;
}

input,
select,
textarea {
  width: 100%;
  padding: 0.65rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.95rem;
  font-family: inherit;
  background: #fff;
  color: var(--text-primary);
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(37, 99, 235, 0.3);
  border-color: var(--accent-blue);
}

textarea {
  min-height: 80px;
  resize: vertical;
}

.hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 0.35rem;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.65rem;
}

@media (max-width: 700px) {
  .grid2,
  .grid3 {
    grid-template-columns: 1fr;
  }
}

/* ─── Tables ─── */
.table-wrap {
  overflow-x: auto;
}

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

table.data th,
table.data td {
  text-align: left;
  padding: 0.65rem 0.5rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

table.data th {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
}

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
}

/* ─── Badges / chips ─── */
.badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-blue);
}

.badge-green {
  background: var(--status-green-bg);
  color: var(--status-green);
}

.badge-red {
  background: var(--status-red-bg);
  color: var(--status-red);
}

.badge-yellow {
  background: var(--status-yellow-bg);
  color: var(--status-yellow);
}

.badge-gray,
.badge-user,
.badge-expired,
.badge-inactive {
  background: var(--status-gray-bg);
  color: var(--status-gray);
}

.badge-admin {
  background: rgba(37, 99, 235, 0.12);
  color: var(--accent-blue);
}

.badge-pending {
  background: var(--status-yellow-bg);
  color: var(--status-yellow);
}

.badge-accepted {
  background: var(--status-green-bg);
  color: var(--status-green);
}

/* ─── Stats strip ─── */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.stat {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.9rem 1rem;
}

.stat b {
  display: block;
  font-size: 1.35rem;
  color: var(--navy);
  font-weight: 700;
}

.stat span {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

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

/* ─── Tabs ─── */
.tabs {
  display: flex;
  gap: 0.4rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.5rem 0.95rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85rem;
  font-family: inherit;
  color: var(--text-secondary);
}

.tab.active {
  background: var(--navy);
  color: #fff;
  border-color: var(--navy);
}

.panel {
  display: none;
}

.panel.active {
  display: block;
}

/* ─── Modals ─── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay.show {
  display: flex;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: 92vh;
  overflow: auto;
  box-shadow: var(--shadow-modal);
}

.modal-header,
.modal-head {
  padding: 1.1rem 1.35rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 2;
}

.modal-header h2,
.modal-header h3,
.modal-head h3 {
  margin: 0;
  font-size: 1.15rem;
  color: var(--accent-blue);
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0.25rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--status-red);
}

.modal-body {
  padding: 1.25rem 1.35rem;
}

.modal-actions {
  padding: 1rem 1.35rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  background: var(--bg-secondary);
}

/* ─── Messages / toast ─── */
.msg {
  display: none;
  margin-bottom: 0.85rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  border: 1px solid transparent;
}

.msg.ok {
  display: block;
  background: var(--status-green-bg);
  color: var(--status-green);
  border-color: rgba(5, 150, 105, 0.25);
}

.msg.err,
.msg.error {
  display: block;
  background: var(--status-red-bg);
  color: var(--status-red);
  border-color: rgba(220, 38, 38, 0.25);
}

.toast {
  position: fixed;
  top: 76px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 0.7rem 1.1rem;
  border-radius: 10px;
  font-size: 0.9rem;
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  max-width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.toast.show {
  opacity: 1;
}

.toast.err,
.toast.error {
  background: var(--status-red);
}

/* ─── Auth pages (login / invite) ─── */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--bg-primary);
}

.auth-wrap {
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

/* Instance logo (light artwork for dark backgrounds): shown only over the sign-in photo */
.auth-logo {
  display: none;
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2rem;
  box-shadow: 0 12px 32px rgba(15, 23, 42, 0.08);
}

.auth-brand {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.auth-brand .brand-badge,
.auth-brand .app-logo {
  font-size: 0.8rem;
}

.auth-brand-text {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-blue);
}

.auth-card h1 {
  margin: 0 0 0.35rem;
  font-size: 1.45rem;
  color: var(--navy);
  font-weight: 600;
}

.auth-card .sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.35rem;
}

.auth-card .field {
  margin-bottom: 1rem;
}

.divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  margin: 1.1rem 0;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Sign-in over the instance photo (LOGIN_BG_URL): dark overlay in the brand colour */
html:has(> body.auth-photo) {
  background: var(--brand-dark, #0f1f33);
}

.auth-body.auth-photo {
  background:
    linear-gradient(180deg, rgba(0, 10, 28, 0.45) 0%, rgba(0, 10, 28, 0.82) 100%),
    var(--login-bg) center / cover no-repeat,
    var(--brand-dark, #0f1f33);
  background-attachment: fixed;
}

.auth-photo .auth-logo {
  display: block;
  width: min(240px, 70%);
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.45));
}

.auth-photo .auth-card {
  border: 0;
  border-top: 4px solid var(--brand);
  border-radius: 4px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

.auth-photo .auth-brand .brand-badge {
  display: none;
}

.auth-photo .auth-brand-text {
  color: var(--brand);
}

.auth-photo .auth-card h1 {
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 1.3rem;
}

.auth-photo .btn-primary {
  border-radius: 2px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.auth-hint {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.4;
}

/* ─── Crew sticky bottom bar ─── */
.bottom-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 0.75rem 1rem calc(0.75rem + var(--safe-b));
}

.bottom-bar-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  gap: 0.6rem;
}

.bottom-bar .btn {
  flex: 1;
  padding: 0.9rem 1rem;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1rem;
}

/* ─── Misc helpers ─── */
.actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

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

.leg-box,
.leg {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem;
  margin-bottom: 0.7rem;
  background: var(--bg-secondary);
}

.leg-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.65rem;
}

.leg-badge {
  background: var(--navy);
  color: #fff;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.btn-text {
  background: none;
  border: none;
  color: var(--status-red);
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
  font-family: inherit;
}

.btn-add {
  width: 100%;
  padding: 0.8rem;
  border: 1.5px dashed var(--border);
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  font-weight: 600;
  color: var(--accent-blue);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.95rem;
}

.btn-add:hover {
  border-color: var(--accent-blue);
  background: rgba(37, 99, 235, 0.04);
}

.totals {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.tot {
  background: var(--bg-secondary);
  border-radius: 10px;
  padding: 0.6rem;
  text-align: center;
  border: 1px solid var(--border);
}

.tot b {
  display: block;
  font-size: 1.05rem;
  color: var(--navy);
}

.tot span {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.filters .field {
  min-width: 140px;
  margin-bottom: 0;
}

/* ---------------------------------------------------------------------------
 * Flight status — dashboard tabs, ATC strips, map area, mobile bottom sheet.
 *
 * Colour is never the only carrier: a selected strip has the word SELECTED and
 * a red outline, a stale position has the label LAST POSITION, a warning has
 * its own icon and text. Every control is at least 44px tall and reachable by
 * tap, so nothing here depends on hover.
 * ------------------------------------------------------------------------- */

.dashboard-tabs {
  display: flex;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem 0;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.dashboard-tab {
  flex: 1 1 0;
  min-width: 150px;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.15rem;
  padding: 0.6rem 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}

.dashboard-tab:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

.dashboard-tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.dashboard-tab-title {
  font-weight: 600;
}

.dashboard-tab-meta {
  font-size: 0.72rem;
  opacity: 0.8;
}

/* --- layout ------------------------------------------------------------- */

.flight-panel {
  padding: 1rem 1.5rem 1.5rem;
  overflow-x: hidden;
}

.flight-layout {
  display: grid;
  grid-template-columns: 340px minmax(0, 1fr);
  gap: 1rem;
  align-items: stretch;
  min-height: 60vh;
  overflow-x: hidden;
}

.flight-strips {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.75rem;
  max-height: 78vh;
  overflow-y: auto;
}

.flight-sheet-handle {
  display: none;
}

.flight-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.flight-count b {
  font-family: var(--font-mono), monospace;
  color: var(--navy);
}

.flight-stale {
  color: var(--status-yellow);
  font-weight: 600;
}

.strip-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.strip-filter,
.flight-tool {
  min-height: 44px;
  padding: 0.4rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.8rem;
  cursor: pointer;
}

.strip-filter.active,
.flight-tool[aria-pressed='true'] {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}

.strip-filter:focus-visible,
.flight-tool:focus-visible,
.strip-card:focus-visible {
  outline: 3px solid var(--accent-blue);
  outline-offset: 2px;
}

.strip-search-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.strip-search {
  min-height: 44px;
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}

.flight-map-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

/* --- strips ------------------------------------------------------------- */

.strip-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.strip-card {
  display: block;
  width: 100%;
  min-height: 44px;
  text-align: left;
  padding: 0.6rem 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--status-gray);
  border-radius: var(--radius);
  font-family: inherit;
  cursor: pointer;
}

.strip-card[data-state='AIRBORNE'] {
  border-left-color: var(--accent-blue);
}

.strip-card[data-state='ACTIVE_ON_GROUND'],
.strip-card[data-state='ACTIVE'] {
  border-left-color: var(--status-green);
}

.strip-card.selected {
  border-color: var(--status-red);
  border-left-color: var(--status-red);
  box-shadow: inset 0 0 0 2px var(--status-red);
  background: var(--status-red-bg);
}

.strip-head {
  display: flex;
  align-items: baseline;
  gap: 0.4rem;
  flex-wrap: wrap;
}

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

.strip-card.selected .strip-icon {
  color: var(--status-red);
}

.strip-reg {
  font-family: var(--font-mono), monospace;
  font-weight: 700;
  font-size: 1rem;
  color: var(--navy);
}

.strip-type {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.strip-state {
  margin-left: auto;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  background: var(--status-gray-bg);
  color: var(--text-secondary);
}

.strip-card[data-state='AIRBORNE'] .strip-state {
  background: rgba(37, 99, 235, 0.15);
  color: var(--accent-blue);
}

.strip-selected-label {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--status-red);
  letter-spacing: 0.06em;
}

.strip-times {
  display: flex;
  gap: 0.9rem;
  margin-top: 0.35rem;
}

.strip-time b {
  display: block;
  font-family: var(--font-mono), monospace;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.strip-time span {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.strip-facts {
  margin-top: 0.35rem;
  display: grid;
  gap: 0.15rem;
  font-size: 0.74rem;
  color: var(--text-secondary);
}

.strip-fact-stale {
  color: var(--status-yellow);
  font-weight: 600;
}

.strip-warning {
  margin-top: 0.35rem;
  font-size: 0.74rem;
  font-weight: 600;
  color: var(--status-red);
}

.strip-note {
  font-size: 0.7rem;
  color: var(--status-red);
}

.strip-actions {
  margin-top: 0.45rem;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
}

.strip-action {
  min-height: 44px;
  padding: 0.3rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-secondary);
  font-family: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}

.strip-empty,
.strip-status {
  margin: 0.4rem 0;
  padding: 0.6rem;
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: center;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
}

/* --- Block Start -------------------------------------------------------- */

.block-start {
  margin-top: auto;
  display: grid;
  gap: 0.4rem;
  padding-top: 0.6rem;
  border-top: 1px solid var(--border);
}

.block-start h3 {
  margin: 0;
  font-size: 0.85rem;
  color: var(--navy);
}

.block-start label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
}

.block-start select {
  min-height: 44px;
  padding: 0.4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
}

.block-start-ack {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 0.75rem;
  text-transform: none;
  color: var(--text-secondary);
}

.block-start-ack input {
  width: 22px;
  height: 22px;
}

.block-start-confirm {
  margin: 0;
  font-size: 0.8rem;
  color: var(--navy);
}

.block-start-confirm b {
  font-family: var(--font-mono), monospace;
}

.block-start-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--status-yellow);
}

.block-start button[disabled] {
  opacity: 0.55;
  cursor: not-allowed;
}

/* --- map ---------------------------------------------------------------- */

.flight-map-area {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 60vh;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* A tall sticky mobile header must not cover the map. */
@media (max-width: 700px) {
  header.header { position: static !important; }
}

.flight-map {
  flex: 1 1 auto;
  min-height: 55vh;
  background: var(--bg-secondary);
}

.flight-map-note {
  margin: 0;
  padding: 0.4rem 0.6rem calc(0.4rem + var(--safe-b));
  font-size: 0.68rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
}

.flight-layers {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 500;
  width: min(280px, calc(100% - 1.2rem));
  padding: 0.7rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
  font-size: 0.78rem;
}

.flight-view-switch {
  display: none;
}

/* --- tablet: the strip column narrows and can be collapsed -------------- */

@media (max-width: 1100px) {
  .flight-layout {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .flight-layout[data-view='map'] {
    grid-template-columns: minmax(0, 1fr);
  }

  .flight-layout[data-view='map'] .flight-strips {
    display: none;
  }

  .flight-view-switch {
    display: flex;
    gap: 0.35rem;
    padding: 0.4rem;
    border-top: 1px solid var(--border);
  }
}

/* --- mobile: map fills the content, list is a bottom sheet -------------- */

@media (max-width: 760px) {
  .dashboard-tabs {
    padding: 0.5rem 0.75rem 0;
  }

  .flight-panel {
    padding: 0.5rem 0.75rem 0;
  }

  .flight-layout {
    grid-template-columns: minmax(0, 1fr);
    min-height: 0;
  }

  .flight-map-area {
    min-height: 62vh;
  }

  .flight-strips {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 900;
    max-height: none;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.2);
    padding-bottom: calc(0.75rem + var(--safe-b));
    /* Three heights: compact handle, partial list, full list. */
    height: 42vh;
    transition: height 0.18s ease-out;
  }

  .flight-strips[data-sheet-height='compact'] {
    height: calc(64px + var(--safe-b));
    overflow: hidden;
  }

  .flight-strips[data-sheet-height='partial'] {
    height: 46vh;
  }

  .flight-strips[data-sheet-height='full'] {
    height: 88vh;
  }

  .flight-sheet-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    min-height: 44px;
    background: transparent;
    border: none;
    font-family: inherit;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: grab;
    touch-action: none;
  }

  .flight-sheet-grip {
    display: block;
    width: 44px;
    height: 5px;
    border-radius: 3px;
    background: var(--border-light);
  }

  .flight-layout[data-view='map'] .flight-strips[data-sheet-height='full'] {
    height: calc(64px + var(--safe-b));
  }
}

/* --- map markers -------------------------------------------------------- */

.map-aircraft {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
  pointer-events: auto;
}

.map-aircraft-glyph {
  font-size: 1.4rem;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.4));
}

.map-aircraft-label {
  font-family: var(--font-mono), monospace;
  font-size: 0.68rem;
  font-weight: 700;
  color: var(--navy);
  background: rgba(255, 255, 255, 0.88);
  border-radius: 3px;
  padding: 0 3px;
  white-space: nowrap;
}

.map-aircraft.selected .map-aircraft-glyph {
  color: var(--status-red);
}

.map-aircraft.selected .map-aircraft-label {
  color: #fff;
  background: var(--status-red);
}

.map-aircraft.stale .map-aircraft-glyph {
  opacity: 0.65;
}

.map-aircraft-stale {
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--status-yellow);
  background: rgba(255, 255, 255, 0.9);
  border-radius: 3px;
  padding: 0 3px;
  white-space: nowrap;
}

.flight-map-status {
  position: absolute;
  left: 0.6rem;
  bottom: 2.6rem;
  z-index: 500;
  margin: 0;
  max-width: min(420px, calc(100% - 1.2rem));
  padding: 0.4rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* Leaflet's own panes must stay under our controls but over the background. */
.flight-map .leaflet-container {
  font-family: inherit;
}

/* --- weather layers panel ----------------------------------------------- */

.flight-layers {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 600;
  width: min(300px, calc(100% - 1.2rem));
  padding: 0.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.flight-layers h4 {
  margin: 0 0 0.4rem;
  font-size: 0.8rem;
  color: var(--navy);
}

.layer-state {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

.layer-state.unavailable {
  color: var(--status-yellow);
}

.layer-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 44px;
  font-size: 0.82rem;
}

.layer-toggle input {
  width: 20px;
  height: 20px;
}

.layer-toggle input:disabled + span {
  color: var(--text-muted);
}

.layer-opacity {
  display: block;
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--text-secondary);
}

#weatherOpacity {
  width: 100%;
  min-height: 32px;
}

.layer-legend {
  list-style: none;
  margin: 0.6rem 0 0;
  padding: 0;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

.layer-legend li {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-bottom: 0.25rem;
}

.legend-swatch {
  width: 16px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid var(--border);
}

.legend-clouds { background: linear-gradient(90deg, rgba(255,255,255,0.2), #94a3b8); }
.legend-precip { background: linear-gradient(90deg, rgba(59,130,246,0.15), #1d4ed8); }

.layer-note {
  margin: 0.6rem 0 0;
  font-size: 0.68rem;
  line-height: 1.35;
  color: var(--text-muted);
}

/* Recovery surfaces: an emergency release reads as one, and a closed operation
   that still owes a flight record is visible rather than implied. */
.strip-action-warn { border-color: var(--accent-amber, #b8860b); color: var(--accent-amber, #b8860b); }
.pending-panel { margin: 8px 0 0; padding: 8px; border: 1px solid var(--border, #2a3550); border-radius: 6px; }
.pending-title { margin: 0 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.pending-row { display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 0; font-size: 12px; }
.pending-row + .pending-row { border-top: 1px solid var(--border, #2a3550); }

/* ─── Ľavý panel (body.has-shell, js/shell.js): duplicitné prvky hlavičky ─────────────
   Panel už má značku, navigáciu, používateľa a odhlásenie. Titulok stránky a jej akčné
   tlačidlá ostávajú. Bez panela (bez UI_SHELL) sa nič z toho neuplatní. */
body.has-shell .brand-badge,
body.has-shell #authUserChip,
body.has-shell .nav-back,
body.has-shell .shell-dup {
  display: none !important;
}

/* ─── Mobil (≤ 640 px): nič neprečnieva, tabuľky sa posúvajú, tlačidlá ≥ 40 px ─── */
.table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  max-width: 100%;
}

@media (max-width: 640px) {
  .manage-btn,
  .btn,
  .refresh-btn,
  .modal-close,
  .tab,
  .doc-btn {
    min-height: 40px;
  }

  .modal-close {
    min-width: 40px;
  }

  input[type='text'],
  input[type='email'],
  input[type='password'],
  input[type='number'],
  input[type='date'],
  input[type='time'],
  input[type='search'],
  select,
  textarea {
    max-width: 100%;
    min-height: 40px;
    font-size: 16px; /* iOS nezväčšuje stránku pri zameraní poľa */
  }

  .modal-overlay {
    padding: 0.5rem;
  }

  .modal {
    max-width: 100% !important;
    width: 100%;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-actions .btn {
    flex: 1 1 auto;
  }

  .form-grid {
    grid-template-columns: minmax(0, 1fr) !important;
  }

  .form-grid > * {
    grid-column: 1 / -1 !important;
  }

  .card {
    max-width: 100%;
  }
}
