/* ── Reset & Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1a202c;
  --text-muted: #718096;
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --green: #22c55e;
  --green-bg: #f0fdf4;
  --red: #ef4444;
  --red-bg: #fef2f2;
  --amber: #f59e0b;
  --amber-bg: #fffbeb;
  --blue: #3b82f6;
  --blue-bg: #eff6ff;
  --radius: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
}

body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
       background: var(--bg); color: var(--text); line-height: 1.6; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Nav ──────────────────────────────────────────────────────────── */
.nav { background: var(--surface); border-bottom: 1px solid var(--border);
       padding: 0 1.5rem; display: flex; align-items: center;
       justify-content: space-between; height: 56px; position: sticky; top: 0; z-index: 10; }
.nav__brand { font-weight: 700; font-size: 1.1rem; color: var(--text); letter-spacing: -.3px; }
.beta-badge { font-size: .6rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
              background: var(--amber); color: #fff; padding: .1rem .35rem; border-radius: 3px;
              vertical-align: middle; margin-left: .25rem; }
.nav__links { display: flex; align-items: center; gap: 1.25rem; }
.nav__links a { color: var(--text-muted); font-size: .9rem; }
.nav__links a:hover { color: var(--text); }

/* ── Main ─────────────────────────────────────────────────────────── */
.main { max-width: 1400px; margin: 0 auto; padding: 2rem 1.5rem; }

/* ── Flash ────────────────────────────────────────────────────────── */
.flash { padding: .75rem 1rem; border-radius: var(--radius); margin-bottom: 1.25rem;
         font-size: .9rem; font-weight: 500; }
.flash--success { background: var(--green-bg); color: #15803d; border: 1px solid #bbf7d0; }
.flash--error   { background: var(--red-bg);   color: #dc2626; border: 1px solid #fecaca; }

/* ── Buttons ──────────────────────────────────────────────────────── */
.btn { display: inline-flex; align-items: center; justify-content: center;
       padding: .5rem 1rem; border-radius: var(--radius); font-size: .875rem;
       font-weight: 500; cursor: pointer; border: 1px solid transparent;
       transition: background .15s, border-color .15s; text-decoration: none; }
.btn--primary { background: var(--primary); color: #fff; }
.btn--primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn--ghost { background: transparent; border-color: var(--border); color: var(--text); }
.btn--ghost:hover { background: var(--bg); text-decoration: none; }
.btn--danger { background: var(--red-bg); color: var(--red); border-color: #fecaca; }
.btn--danger:hover { background: #fee2e2; }
.btn--sm { padding: .25rem .6rem; font-size: .8rem; }

/* ── Card ─────────────────────────────────────────────────────────── */
.card { background: var(--surface); border: 1px solid var(--border);
        border-radius: var(--radius); padding: 1.5rem; margin-bottom: 1.5rem;
        box-shadow: var(--shadow); }

/* ── Page Header ──────────────────────────────────────────────────── */
.page-header { margin-bottom: 1.5rem; }
.page-header h1 { font-size: 1.75rem; font-weight: 700; }
.subtitle { color: var(--text-muted); margin-top: .25rem; }

/* ── Auth ─────────────────────────────────────────────────────────── */
.auth-card { max-width: 420px; margin: 3rem auto;
             background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 2rem; box-shadow: var(--shadow); }
.auth-card h1 { margin-bottom: 1.5rem; font-size: 1.5rem; }
.auth-link { margin-top: 1rem; font-size: .875rem; color: var(--text-muted); }
.error { color: var(--red); font-size: .875rem; margin-bottom: 1rem;
         background: var(--red-bg); padding: .5rem .75rem; border-radius: var(--radius); }

/* ── Forms ────────────────────────────────────────────────────────── */
label { display: flex; flex-direction: column; gap: .35rem;
        font-size: .875rem; font-weight: 500; margin-bottom: .75rem; }
input[type=text], input[type=email], input[type=password],
input[type=date], input[type=time], input[type=number], input[type=file],
select, textarea {
  padding: .5rem .75rem; border: 1px solid var(--border); border-radius: var(--radius);
  font-size: .875rem; background: var(--surface); color: var(--text);
  transition: border-color .15s; width: 100%; }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59,130,246,.15); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem 1rem; }
.checkbox-label { flex-direction: row; align-items: center; gap: .5rem; }
.checkbox-label input { width: auto; }

/* ── Stats Grid ───────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
              gap: 1rem; margin-bottom: 1.5rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border);
             border-radius: var(--radius); padding: 1.25rem 1rem; text-align: center;
             box-shadow: var(--shadow); }
.stat-card__value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-card__label { font-size: .8rem; color: var(--text-muted); margin-top: .25rem; text-transform: uppercase; letter-spacing: .5px; }

/* ── Currency ─────────────────────────────────────────────────────── */
.currency-section { margin-bottom: 1.5rem; }
.currency-section h2 { font-size: 1.1rem; font-weight: 600; margin-bottom: .75rem; }
.currency-card { border: 1px solid var(--border); border-radius: var(--radius);
                 background: var(--surface); padding: 1.25rem; box-shadow: var(--shadow); }
.currency-card--current { border-left: 4px solid var(--green); }
.currency-card--expired  { border-left: 4px solid var(--red); }
.currency-card__header { display: flex; align-items: center; gap: 1rem; margin-bottom: 1rem; }

.badge { display: inline-block; padding: .25rem .6rem; border-radius: 999px;
         font-size: .75rem; font-weight: 700; letter-spacing: .3px; text-transform: uppercase; }
.badge--current { background: var(--green-bg); color: #15803d; }
.badge--expired  { background: var(--red-bg);   color: var(--red); }
.badge--info     { background: var(--blue-bg);  color: var(--blue); }

.expiry { font-size: .85rem; }
.expiry--ok      { color: #15803d; }
.expiry--warning { color: var(--amber); }
.expiry--expired { color: var(--red); }

.req-row { display: flex; align-items: baseline; gap: .75rem;
           padding: .5rem 0; border-bottom: 1px solid var(--border); font-size: .875rem; }
.req-row:last-child { border-bottom: none; }
.req-row__icon { font-weight: 700; width: 1rem; flex-shrink: 0; }
.req-row--met   .req-row__icon { color: var(--green); }
.req-row--unmet .req-row__icon { color: var(--red); }
.req-row__label { flex: 1; }
.req-row__progress { color: var(--text-muted); white-space: nowrap; }
.req-row__note { font-size: .75rem; color: var(--amber); }

/* ── Tabs ─────────────────────────────────────────────────────────── */
.tabs { display: flex; gap: .5rem; border-bottom: 1px solid var(--border);
        margin: -1.5rem -1.5rem 1.5rem; padding: 0 1.5rem; }
.tab { background: none; border: none; padding: .75rem 1rem; cursor: pointer;
       font-size: .875rem; color: var(--text-muted); border-bottom: 2px solid transparent;
       margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab:hover { color: var(--text); }
.tab--active { color: var(--primary); border-bottom-color: var(--primary); font-weight: 500; }

/* ── Table ────────────────────────────────────────────────────────── */
.table-wrapper { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th { background: var(--bg); text-align: left; padding: .5rem .6rem;
                 font-weight: 600; font-size: .7rem; text-transform: uppercase;
                 letter-spacing: .4px; color: var(--text-muted);
                 border-bottom: 2px solid var(--border); white-space: nowrap; }
.data-table td { padding: .5rem .6rem; border-bottom: 1px solid var(--border);
                 vertical-align: middle; font-size: .82rem; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg); }
.data-table th.sortable:hover { background: var(--border); color: var(--text); }
.data-table th.sortable { user-select: none; }
.sort-icon { color: var(--primary); font-style: normal; }
.actions { display: flex; gap: .5rem; }
.empty-state { color: var(--text-muted); padding: 2rem; text-align: center; }

.source-badge { display: inline-block; padding: .1rem .45rem; border-radius: 4px;
                font-size: .7rem; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.source-badge--igc    { background: #e0f2fe; color: #0369a1; }
.source-badge--xlsx   { background: #dcfce7; color: #15803d; }
.source-badge--manual { background: #f3e8ff; color: #7e22ce; }
.source-badge--gpx    { background: #fff7ed; color: #c2410c; }
.source-badge--lxnav  { background: #fdf4ff; color: #7e22ce; }

/* ── Table header row ─────────────────────────────────────────────── */
.table-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; }
.table-header h2 { margin-bottom: 0; }
.flight-count { font-size: .9rem; font-weight: 400; color: var(--text-muted); }

/* ── IGC Viewer ───────────────────────────────────────────────────── */
.viewer-header { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap;
                 margin-bottom: 1rem; }
.viewer-meta { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap;
               font-size: .9rem; color: var(--text-muted); }
.viewer-meta span { display: flex; align-items: center; gap: .25rem; }
.viewer-meta span + span::before { content: '·'; margin-right: .5rem; }
.viewer-date { font-weight: 600; color: var(--text); font-size: 1rem; }
#map { height: 60vh; min-height: 400px; border-radius: var(--radius);
       border: 1px solid var(--border); margin-bottom: 1rem; position: relative; }
.chart-wrapper { height: 220px; background: var(--surface); border: 1px solid var(--border);
                 border-radius: var(--radius); padding: 1rem; }

.map-info { position: absolute; top: 12px; right: 12px; z-index: 1000;
            background: rgba(255,255,255,0.92); backdrop-filter: blur(4px);
            border: 1px solid var(--border); border-radius: var(--radius);
            padding: .6rem .85rem; font-size: .85rem; line-height: 1.7;
            box-shadow: var(--shadow); min-width: 140px; }
.map-info--hidden { display: none; }
.map-info__row { display: flex; align-items: center; gap: .5rem; }
.map-info__icon { font-size: .9rem; width: 1.1rem; text-align: center; }

/* ── Filter Panel ─────────────────────────────────────────────────── */
.filter-panel { border: 1px solid var(--border); border-radius: var(--radius);
                background: var(--bg); padding: 1rem; margin-bottom: 1rem; }
.filter-panel--hidden { display: none; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .5rem 1rem; }
.filter-grid label { margin-bottom: 0; }

/* ── Column picker ────────────────────────────────────────────────── */
.col-picker { position: absolute; top: calc(100% + 4px); right: 0; z-index: 200;
              background: var(--surface); border: 1px solid var(--border);
              border-radius: var(--radius); box-shadow: 0 4px 12px rgba(0,0,0,.1);
              padding: .4rem; min-width: 170px; display: none; }
.col-picker--open { display: block; }
.col-picker__item { display: flex; align-items: center; gap: .5rem;
                    padding: .3rem .5rem; font-size: .875rem; font-weight: 400;
                    border-radius: 4px; cursor: pointer; margin: 0; }
.col-picker__item:hover { background: var(--bg); }
.col-picker__item input { width: auto; cursor: pointer; }

/* ── Column resize handle ─────────────────────────────────────────── */
.col-resize-handle { position: absolute; right: 0; top: 0; bottom: 0; width: 5px;
                     cursor: col-resize; z-index: 1; }
.col-resize-handle:hover, .col-resize-handle:active { background: var(--primary); opacity: .4; }

/* ── Column drag states ───────────────────────────────────────────── */
.col-dragging  { opacity: .4; }
.col-drag-over { background: var(--blue-bg) !important; outline: 2px dashed var(--primary); }

/* ── Declared task cell ───────────────────────────────────────────── */
.declared-task-cell { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Misc ─────────────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 1rem 0; }
h2 { font-size: 1.25rem; font-weight: 600; margin-bottom: 1rem; }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5);
                  display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-box { background: var(--surface); border-radius: var(--radius); padding: 1.5rem;
             width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto;
             box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1rem; }
.modal-header h2 { font-size: 1.1rem; margin: 0; }
.modal-close { background: none; border: none; font-size: 1.5rem; cursor: pointer;
               color: var(--text-muted); line-height: 1; padding: 0 .25rem; }
.modal-close:hover { color: var(--text); }

/* ── Badge extras ─────────────────────────────────────────────────── */
.badge--danger { background: var(--red-bg); color: var(--red); }
.badge--warn   { background: var(--amber-bg); color: var(--amber); }
.badge--ok     { background: var(--green-bg); color: var(--green); }
