/* ============================================================
   UH-60L Auction Tracker — styles aligned with UH-60 Maintenance Tool
   Palette: navy #1a4b7c | teal #0f766e | highlight #dce8f5
   Font: Source Sans Pro (Streamlit default)
   ============================================================ */

:root {
  --navy:       #1a4b7c;
  --navy-dark:  #133a62;
  --navy-light: #2563a8;
  --teal:       #0f766e;
  --teal-light: #14b8a6;
  --hi:         #dce8f5;
  --hi-alt:     #f0f7ff;
  --border:     #aaaaaa;
  --border-lt:  #d1d5db;
  --ink:        #0f172a;
  --subtext:    #475569;
  --bg:         #f0f4f8;
  --card:       #ffffff;
  --danger:     #b91c1c;
  --danger-bg:  #fee2e2;
  --shadow:     0 2px 8px rgba(26, 75, 124, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Source Sans Pro", "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
}

body.app-locked {
  overflow: hidden;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(15, 23, 42, 0.68);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.access-gate.is-hidden {
  display: none;
}

.access-card {
  width: min(420px, 100%);
  background: #ffffff;
  border: 1px solid var(--border-lt);
  border-radius: 8px;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.28);
  padding: 1.1rem;
  display: grid;
  gap: 0.55rem;
}

.access-logo {
  height: 2.1rem;
  width: auto;
  margin-bottom: 0.2rem;
}

.access-card h2 {
  font-size: 1.05rem;
  color: var(--navy);
}

.access-copy {
  margin: 0;
  color: var(--subtext);
  font-size: 0.92rem;
}

.access-error {
  margin: 0.2rem 0 0;
  min-height: 1rem;
  color: #b91c1c;
  font-size: 0.85rem;
  font-weight: 600;
}

/* ── Top banner ──────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  color: #fff;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 3.9rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.25);
}

.acehawk-logo {
  height: 2.3rem;
  width: auto;
  object-fit: contain;
  flex-shrink: 0;
}

.site-header .brand {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.site-header .brand-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.75;
}

.site-header .brand-title {
  font-size: 1.1rem;
  font-weight: 700;
}

/* ── Page shell ──────────────────────────────────────────────── */
.page-shell {
  width: min(1200px, 96vw);
  margin: 1.5rem auto 3rem;
  display: grid;
  gap: 0.85rem;
}

/* ── Cards ───────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-radius: 6px;
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
}

.card h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--hi);
  padding-bottom: 0.4rem;
}

/* ── Typography ──────────────────────────────────────────────── */
h1, h2, h3 {
  margin: 0;
}

/* ── Form ────────────────────────────────────────────────────── */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 0.8rem;
  margin-top: 0.75rem;
}

.filters-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(175px, 1fr));
  gap: 0.8rem;
  margin-top: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  font-weight: 600;
  font-size: 0.88rem;
  color: var(--subtext);
}

input {
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.46rem 0.6rem;
  font: inherit;
  font-size: 0.93rem;
  background: #fff;
  color: var(--ink);
}

input:focus {
  outline: 2px solid rgba(26, 75, 124, 0.3);
  border-color: var(--navy-light);
}

input[readonly] {
  background: var(--hi-alt);
  color: var(--subtext);
}

/* ── Buttons ─────────────────────────────────────────────────── */
.form-actions {
  margin-top: 0.9rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

button {
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 4px;
  border: none;
  padding: 0.48rem 0.85rem;
  cursor: pointer;
  background: var(--teal);
  color: #fff;
  transition: background 0.15s;
}

button:hover {
  background: var(--teal-light);
}

button.primary {
  background: var(--navy);
}

button.primary:hover {
  background: var(--navy-light);
}

button.ghost {
  background: #e8eef4;
  color: var(--navy);
  border: 1px solid var(--border-lt);
}

button.ghost:hover {
  background: var(--hi);
}

button.ghost.danger {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: #fca5a5;
}

button.ghost.danger:hover {
  background: #fecaca;
}

.file-import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  border: 1px solid var(--border-lt);
  padding: 0.48rem 0.85rem;
  cursor: pointer;
  background: #e8eef4;
  color: var(--navy);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  transition: background 0.15s;
}

.file-import-btn:hover {
  background: var(--hi);
}

/* ── Status message ──────────────────────────────────────────── */
.form-message {
  min-height: 1.2rem;
  margin: 0.65rem 0 0;
  font-size: 0.88rem;
  color: var(--teal);
  font-weight: 600;
}

/* ── Filters active highlight ────────────────────────────────── */
#filters-card.filters-active {
  border-color: var(--navy-light);
  box-shadow: 0 2px 10px rgba(26, 75, 124, 0.18);
}

/* ── Active filter chips ─────────────────────────────────────── */
.active-filters-summary {
  margin: 0.4rem 0 0;
  font-size: 0.88rem;
  color: var(--navy);
}

.active-filter-chips {
  margin-top: 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-chip {
  border: 1px solid var(--navy-light);
  border-radius: 999px;
  background: var(--hi);
  color: var(--navy);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 0.22rem 0.6rem;
  cursor: pointer;
  transition: background 0.12s;
}

.filter-chip:hover {
  background: #bfdbfe;
}

/* ── KPI row ─────────────────────────────────────────────────── */
.kpi-grid {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 0.65rem;
}

.kpi {
  border: 1px solid var(--border-lt);
  border-top: 3px solid var(--navy);
  border-radius: 4px;
  padding: 0.65rem 0.8rem;
  background: var(--hi-alt);
}

.kpi-label {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--subtext);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.kpi-value {
  margin: 0.2rem 0 0;
  font-size: 1.35rem;

  .last-saved-msg {
    margin: 0.6rem 0 0;
    font-size: 0.82rem;
    color: var(--teal);
    font-weight: 600;
  }
  font-weight: 700;
  color: var(--navy);
}

/* ── Tabs ────────────────────────────────────────────────────── */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--navy);
  margin-bottom: 0;
}

.tab-btn {
  background: #e8eef4;
  color: var(--navy);
  border: 1px solid var(--border-lt);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 0.52rem 1.1rem;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  margin-right: 3px;
  transition: background 0.15s, color 0.15s;
}

.tab-btn:hover {
  background: var(--hi);
}

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

.tab-panel {
  display: none;
  background: var(--card);
  border: 1px solid var(--border-lt);
  border-top: none;
  border-radius: 0 0 6px 6px;
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
}

.tab-panel.active {
  display: block;
}

.tab-panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border-bottom: 2px solid var(--hi);
  padding-bottom: 0.4rem;
}

/* ── Tables ──────────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  font-size: 0.9rem;
}

thead tr {
  background: var(--navy);
  color: #fff;
}

th {
  padding: 0.55rem 0.65rem;
  text-align: left;
  font-weight: 700;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border: none;
}

td {
  padding: 0.5rem 0.65rem;
  border-bottom: 1px solid var(--border-lt);
  color: var(--ink);
}

tbody tr:nth-child(even) {
  background: var(--hi-alt);
}

tbody tr:last-child td {
  background: var(--hi);
  font-weight: 700;
}

tbody tr:hover {
  background: #e0eefd;
}

/* ── Charts ──────────────────────────────────────────────────── */
.chart-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}

.chart-panel--full {
  margin-top: 0.5rem;
}

.chart-panel {
  background: var(--hi-alt);
  border: 1px solid var(--border-lt);
  border-top: 3px solid var(--navy);
  border-radius: 4px;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
}

.chart-panel h3 {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--navy);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 0 0 0.65rem;
}

.chart-panel canvas {
  flex: 1;
  min-height: clamp(220px, 28vh, 380px);
  width: 100% !important;
}

.chart-panel--full canvas {
  height: 300px;
  min-height: 300px;
  max-height: 300px;
  width: 100% !important;
  display: block;
}

/* ── Tablet (721 – 1024 px) ──────────────────────────────────── */
@media (min-width: 721px) and (max-width: 1024px) {
  .chart-panel--full canvas {
    height: 320px;
    min-height: 320px;
    max-height: 320px;
  }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 720px) {
  /* Header */
  .site-header {
    padding: 0.55rem 0.85rem;
    gap: 0.55rem;
    flex-wrap: wrap;
    min-height: unset;
  }

  .acehawk-logo {
    height: 1.75rem;
  }

  .site-header .brand-title {
    font-size: 0.95rem;
  }

  /* Page shell — add horizontal breathing room */
  .page-shell {
    width: 100%;
    padding: 0 0.5rem;
    margin-top: 0.9rem;
    margin-bottom: 2rem;
  }

  .card,
  .tab-panel {
    padding: 0.75rem 0.8rem;
  }

  /* Fix iOS auto-zoom: inputs must be ≥ 16 px */
  input,
  select {
    font-size: 16px;
  }

  /* Touch targets: min 44 px tap height */
  button,
  .file-import-btn {
    min-height: 44px;
    padding: 0 0.85rem;
  }

  /* Tab bar — scrollable so tabs never wrap or overflow */
  .tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }

  .tab-bar::-webkit-scrollbar {
    display: none;
  }

  .tab-btn {
    flex: 1;
    min-width: 0;
    padding: 0.52rem 0.6rem;
    font-size: 0.82rem;
    white-space: nowrap;
    text-align: center;
  }

  /* KPI — 2-column grid on phones */
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .kpi-value {
    font-size: 1.15rem;
  }

  /* Chart — taller on mobile so data has room to breathe */
  .chart-panel--full canvas {
    height: 340px;
    min-height: 340px;
    max-height: 340px;
  }
}

/* Extra-small phones (≤ 400 px) */
@media (max-width: 400px) {
  .site-header .brand-title {
    font-size: 0.85rem;
  }

  .site-header .brand-eyebrow {
    font-size: 0.65rem;
  }

  .tab-btn {
    font-size: 0.78rem;
    padding: 0.52rem 0.45rem;
  }

  .kpi-value {
    font-size: 1.05rem;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .filters-grid {
    grid-template-columns: 1fr;
  }
}

