/* ============================================================
   Flight Registry — theme-driven styles
   Palette + fonts are injected as CSS variables from app.js
   (data-theme + data-mode on <html>). This file is structure.
============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --r: 16px;          /* card radius */
  --r-sm: 11px;       /* control radius */
  --gap: 14px;
  --maxw: 540px;
  --pad: clamp(16px, 5vw, 22px);
  --shadow: 0 1px 2px rgba(15,30,50,.04), 0 8px 24px rgba(15,30,50,.06);
  --shadow-lg: 0 12px 40px rgba(15,30,50,.16);
  --ring: 0 0 0 3px color-mix(in oklch, var(--accent) 28%, transparent);
}

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body, system-ui, sans-serif);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  min-height: 100dvh;
  transition: background .35s ease;
}

/* subtle atmospheric wash at the top — "airy / sky" */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 320px;
  background: var(--wash);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) var(--pad)
           calc(40px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

h1, h2, h3 { font-family: var(--font-display, var(--font-body)); font-weight: 600; letter-spacing: -.01em; }

/* ---------- header ---------- */
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding-top: 4px; }
.greet .hello { font-family: var(--font-display); font-size: 1.5rem; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.greet .sub { color: var(--muted); font-size: .82rem; margin-top: 3px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.seg button {
  border: 0; background: transparent; color: var(--muted);
  font: inherit; font-size: .76rem; font-weight: 600; letter-spacing: .03em;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; line-height: 1;
  transition: background .2s, color .2s;
}
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.icon-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  display: grid; place-items: center;
  border: 1px solid var(--border); background: var(--surface);
  border-radius: 50%; color: var(--text); cursor: pointer;
  transition: background .2s, transform .1s, border-color .2s;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { transform: scale(.94); }
.icon-btn svg { width: 18px; height: 18px; }

.logout {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .78rem; font-weight: 600;
  padding: 8px 12px; border-radius: 999px; cursor: pointer;
  transition: background .2s, color .2s;
}
.logout:hover { background: var(--surface-2); color: var(--text); }
.logout svg { width: 15px; height: 15px; }

/* ---------- summary ---------- */
.summary { display: flex; flex-direction: column; gap: 10px; }

.summary-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r); padding: 14px 16px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; align-items: center;
}
.s-hero {
  display: flex; flex-direction: column; align-items: flex-start;
  padding-right: 14px; border-right: 1px solid var(--border); height: 100%;
  justify-content: center;
}
.s-label { color: var(--muted); font-size: .7rem; font-weight: 600; letter-spacing: .03em; display: flex; align-items: center; gap: 5px; margin-bottom: 5px; text-transform: uppercase; }
.s-label svg { width: 13px; height: 13px; color: var(--accent); }
.s-big { font-family: var(--font-display); font-size: clamp(2rem, 9vw, 2.6rem); font-weight: 600; letter-spacing: -.03em; line-height: 1; display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.s-flights { font-size: .78rem; font-weight: 600; color: var(--muted); letter-spacing: 0; font-family: var(--font-body); }
.s-unit { font-size: .85rem; font-weight: 600; color: var(--muted); margin-left: 2px; }
.s-stats { display: flex; flex-direction: column; gap: 5px; }
.s-row { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.s-row span { color: var(--muted); font-size: .78rem; font-weight: 500; white-space: nowrap; }
.s-row b { font-family: var(--font-display); font-weight: 600; color: var(--text); font-size: .9rem; white-space: nowrap; }

.manage-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.manage {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  width: 100%; border: 1px dashed var(--border); background: transparent;
  color: var(--text); font: inherit; font-size: .82rem; font-weight: 600;
  padding: 10px; border-radius: var(--r-sm); cursor: pointer;
  transition: background .2s, border-color .2s;
}
.manage:hover { background: var(--surface-2); border-color: color-mix(in oklch, var(--accent) 50%, var(--border)); }
.manage svg { width: 15px; height: 15px; color: var(--accent); }

/* ---------- add-flight primary button ---------- */
.add-flight {
  width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  background: var(--accent); color: var(--accent-ink);
  border: 0; border-radius: var(--r); cursor: pointer;
  font: inherit; font-family: var(--font-display); font-size: 1.06rem; font-weight: 600; letter-spacing: -.01em;
  padding: 18px; box-shadow: 0 8px 22px color-mix(in oklch, var(--accent) 35%, transparent);
  transition: transform .12s ease, filter .2s ease, box-shadow .2s ease;
}
.add-flight:hover { filter: brightness(1.05); box-shadow: 0 10px 28px color-mix(in oklch, var(--accent) 45%, transparent); }
.add-flight:active { transform: translateY(1px) scale(.995); }
.add-flight svg { width: 21px; height: 21px; }

/* ---------- log list ---------- */
.log-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: -4px; padding: 6px 0; }
.log-head h2 { font-size: 1.02rem; }
.log-head .right { display: flex; align-items: center; gap: 8px; }
.log-head .count { color: var(--muted); font-size: .82rem; font-weight: 600; }
.csv-btn {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--muted); font: inherit; font-size: .74rem; font-weight: 700;
  padding: 5px 10px; border-radius: 999px; cursor: pointer; letter-spacing: .03em;
  transition: background .15s, border-color .15s, color .15s;
}
.csv-btn:hover { border-color: var(--accent); color: var(--accent); background: color-mix(in oklch, var(--accent) 8%, var(--surface)); }
.csv-btn svg { width: 12px; height: 12px; }

.list { display: flex; flex-direction: column; gap: 10px; }

.entry {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 14px 15px; box-shadow: var(--shadow);
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px;
  cursor: pointer; transition: border-color .2s, transform .1s;
}
.entry:hover { border-color: color-mix(in oklch, var(--accent) 45%, var(--border)); }
.entry:active { transform: scale(.995); }
.entry .date-badge {
  width: 50px; text-align: center; border-radius: 10px; padding: 7px 0;
  background: var(--surface-2); border: 1px solid var(--border);
}
.entry .date-badge .d { font-family: var(--font-display); font-size: 1.25rem; font-weight: 600; line-height: 1; }
.entry .date-badge .m { font-size: .62rem; color: var(--muted); font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-top: 2px; }
.entry .mid .loc { font-weight: 600; font-size: .98rem; display: flex; align-items: center; gap: 6px; }
.entry .mid .meta { color: var(--muted); font-size: .8rem; margin-top: 3px; display: flex; flex-wrap: wrap; gap: 4px 10px; }
.entry .mid .meta .vehicle { color: var(--accent); font-weight: 600; }
.entry .stat { text-align: right; }
.entry .stat .big { font-family: var(--font-display); font-size: 1.18rem; font-weight: 600; line-height: 1; }
.entry .stat .small { color: var(--muted); font-size: .72rem; margin-top: 3px; }

.empty {
  text-align: center; color: var(--muted); padding: 34px 20px;
  border: 1px dashed var(--border); border-radius: var(--r); background: var(--surface);
}
.empty svg { width: 34px; height: 34px; color: var(--accent); opacity: .8; margin-bottom: 10px; }
.empty p { font-size: .9rem; }

/* ---------- modal ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  background: color-mix(in oklch, var(--bg) 30%, rgba(10,20,35,.55));
  backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s ease;
}
.scrim.open { opacity: 1; pointer-events: auto; }

.sheet {
  width: 100%; max-width: var(--maxw);
  background: var(--bg); color: var(--text);
  border-radius: 22px 22px 0 0;
  max-height: 92dvh; display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(100%); transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.scrim.open .sheet { transform: translateY(0); }
@media (min-width: 600px) {
  .scrim { align-items: center; padding: 24px; }
  .sheet { border-radius: 20px; max-height: 88dvh; }
  .scrim.open .sheet { transform: none; }
  .scrim:not(.open) .sheet { transform: translateY(20px); }
}

.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px var(--pad) 14px; border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 2;
}
.sheet-head .grab { position: absolute; top: 7px; left: 50%; transform: translateX(-50%); width: 38px; height: 4px; border-radius: 99px; background: var(--border); }
@media (min-width: 600px) { .sheet-head .grab { display: none; } }
.sheet-head h2 { font-size: 1.2rem; }
.sheet-body { overflow-y: auto; padding: 18px var(--pad) calc(20px + env(safe-area-inset-bottom)); -webkit-overflow-scrolling: touch; }

/* ---------- form ---------- */
.field { margin-bottom: 15px; }
.field > label { display: block; font-size: .78rem; font-weight: 600; color: var(--muted); margin-bottom: 6px; letter-spacing: .01em; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

input, select, textarea {
  width: 100%; font: inherit; font-size: .98rem; color: var(--text);
  background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--r-sm); padding: 12px 13px; outline: none;
  transition: border-color .15s, box-shadow .15s;
  appearance: none; -webkit-appearance: none;
}
textarea { min-height: 72px; resize: vertical; line-height: 1.4; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: var(--ring); }
input::placeholder, textarea::placeholder { color: color-mix(in oklch, var(--muted) 80%, transparent); }
select {
  background-color: color-mix(in oklch, var(--accent) 7%, var(--surface));
  background-image: var(--chev);
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 15px;
  padding-right: 38px;
  border-color: color-mix(in oklch, var(--accent) 30%, var(--border));
  font-weight: 500;
  cursor: pointer;
}
select:focus { background-color: var(--surface); }
input[list]::-webkit-calendar-picker-indicator { opacity: .35; }

/* ---------- section headers (modal) ---------- */
.sec-head {
  display: flex; align-items: center; gap: 7px;
  font-size: .68rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase;
  color: var(--accent); margin: 18px 0 11px;
}
.sec-head:first-child { margin-top: 2px; }
.sec-head::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.sec-head svg { width: 13px; height: 13px; flex-shrink: 0; }

/* ---------- duration cards (proposal B) ---------- */
.dur-card {
  background: color-mix(in oklch, var(--accent) 7%, var(--surface));
  border: 1.5px solid color-mix(in oklch, var(--accent) 25%, var(--border));
  border-radius: var(--r); padding: 14px; margin-bottom: 13px;
}
.dur-card > label { display: block; font-size: .74rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; letter-spacing: .01em; }
.dur-card-row { display: grid; grid-template-columns: 1fr auto 1fr; gap: 8px; align-items: center; }
.dur-card-sep { text-align: center; font-size: .9rem; color: var(--accent); font-weight: 700; }
.dur-card input[type="time"] { text-align: center; font-size: .93rem; font-weight: 600; background: var(--surface); }
.dur-total {
  margin-top: 10px; padding: 8px 12px;
  background: var(--surface); border-radius: var(--r-sm);
  display: flex; align-items: baseline; justify-content: flex-end; gap: 4px;
}
.dt-u { font-size: .82rem; color: var(--muted); font-weight: 600; }
.dur-result-input {
  font-family: var(--font-display); font-size: 1.5rem; font-weight: 600;
  color: var(--accent); letter-spacing: -.02em; text-align: right;
  width: 72px; border: 1.5px solid transparent; background: transparent;
  padding: 3px 4px; border-radius: 8px; outline: none;
  -moz-appearance: textfield;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.dur-result-input::-webkit-outer-spin-button,
.dur-result-input::-webkit-inner-spin-button { -webkit-appearance: none; }
.dur-result-input:focus { border-color: var(--accent); background: color-mix(in oklch, var(--accent) 6%, var(--surface)); box-shadow: var(--ring); }
input.stale { background: color-mix(in oklch, var(--muted) 14%, var(--surface)) !important; color: var(--muted) !important; border-color: var(--border) !important; box-shadow: none !important; }

/* ---------- buttons row ---------- */
.actions { display: flex; gap: 10px; margin-top: 6px; }
.btn {
  flex: 1; border: 0; border-radius: var(--r-sm); padding: 14px;
  font: inherit; font-weight: 600; font-size: .98rem; cursor: pointer;
  transition: filter .2s, background .2s, transform .1s;
}
.btn:active { transform: scale(.99); }
.btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 16px color-mix(in oklch, var(--accent) 32%, transparent); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-ghost { background: var(--surface-2); color: var(--text); border: 1px solid var(--border); flex: 0 0 auto; padding-inline: 20px; }
.btn-ghost:hover { background: var(--surface); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid color-mix(in oklch, var(--danger) 45%, var(--border)); flex: 0 0 auto; padding-inline: 16px; }
.btn-danger:hover { background: color-mix(in oklch, var(--danger) 12%, transparent); }

/* ---------- vehicles ---------- */
.veh-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.veh-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 13px 14px; display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.veh-card .nm { font-weight: 600; font-size: .98rem; display: flex; align-items: center; gap: 8px; }
.veh-card .tag { font-size: .66rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--accent); background: color-mix(in oklch, var(--accent) 14%, transparent); padding: 2px 7px; border-radius: 999px; }
.veh-card .det { color: var(--muted); font-size: .8rem; margin-top: 4px; }
.veh-card .ed { background: transparent; border: 0; color: var(--muted); cursor: pointer; padding: 4px; border-radius: 8px; }
.veh-card .ed:hover { color: var(--accent); background: var(--surface-2); }
.veh-card .ed svg { width: 17px; height: 17px; display: block; }
.add-veh { width: 100%; border: 1px dashed var(--border); background: transparent; color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; padding: 13px; border-radius: var(--r-sm); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 7px; }
.add-veh:hover { background: var(--surface-2); }
.add-veh svg { width: 16px; height: 16px; color: var(--accent); }

/* ---------- login overlay ---------- */
.login {
  position: fixed; inset: 0; z-index: 80; background: var(--bg);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: var(--pad); gap: 18px; text-align: center;
}
.login .mark { width: 64px; height: 64px; border-radius: 20px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; box-shadow: 0 10px 26px color-mix(in oklch, var(--accent) 38%, transparent); }
.login .mark svg { width: 46px; height: 46px; }
.login h1 { font-size: 1.6rem; }
.login p { color: var(--muted); font-size: .92rem; max-width: 300px; }
.login form { width: 100%; max-width: 320px; display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px);
  background: var(--text); color: var(--bg); font-size: .88rem; font-weight: 600;
  padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow-lg); z-index: 90;
  opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* entrance — transform only (never holds content invisible) */
@media (prefers-reduced-motion: no-preference) {
  .summary { animation: rise .45s cubic-bezier(.2,.7,.2,1) both; }
  .log { animation: rise .45s cubic-bezier(.2,.7,.2,1) .06s both; }
}
@keyframes rise { from { transform: translateY(9px); } to { transform: none; } }
