@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&family=DM+Mono:wght@400;500&display=swap');

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

:root {
  --font: 'DM Sans', sans-serif;
  --font-mono: 'DM Mono', monospace;

  --navy:       #0f2236;
  --navy-mid:   #1a3a5c;
  --navy-light: #2a5080;
  --sky:        #378add;
  --sky-light:  #c8d8f0;
  --green:      #1d9e75;
  --green-light:#d0e8d8;
  --amber:      #ba7517;
  --amber-light:#fef3cd;
  --red:        #c0392b;
  --red-light:  #fdecea;

  --bg:         #f4f6f9;
  --surface:    #ffffff;
  --surface-2:  #f0f4f8;
  --border:     #dde3ec;
  --border-mid: #c4cedb;
  --text:       #0f2236;
  --text-2:     #4a5a72;
  --text-3:     #8a98ab;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 3px rgba(15,34,54,0.08);
  --shadow:    0 2px 8px rgba(15,34,54,0.10);
}

html, body {
  font-family: var(--font);
  font-size: 15px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Hidden pages ── */
.page { display: none; }
.page.active { display: block; }

/* ── Nav bar ── */
#nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 60px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  z-index: 100;
}
#nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  text-decoration: none;
  color: var(--text-3);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: color 0.15s;
}
#nav a.active { color: var(--sky); }
#nav a svg { width: 22px; height: 22px; stroke-width: 1.75; }

/* ── Page header ── */
.page-header {
  background: var(--navy);
  color: #fff;
  padding: 52px 18px 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.page-header h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.page-header p {
  font-size: 13px;
  opacity: 0.65;
  margin-top: 2px;
}
.header-actions {
  position: absolute;
  right: 18px;
  top: 50px;
  display: flex;
  gap: 10px;
  align-items: center;
}

/* ── Scroll container ── */
.scroll-body {
  padding: 16px 16px 80px;
  min-height: calc(100vh - 60px);
}

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}
.card-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 12px;
}

/* ── Form elements ── */
.field { margin-bottom: 12px; }
.field label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.field input, .field select, .field textarea {
  width: 100%;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color 0.15s;
  -webkit-appearance: none;
}
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(55,138,221,0.12);
}
.field input[readonly] {
  background: var(--surface-2);
  color: var(--text-3);
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.field-row.trio {
  grid-template-columns: 1fr 1fr 1fr;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 18px;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  text-decoration: none;
}
.btn:active { transform: scale(0.98); }
.btn-primary {
  background: var(--navy);
  border-color: var(--navy);
  color: #fff;
}
.btn-primary:active { background: var(--navy-mid); }
.btn-full { width: 100%; padding: 13px; font-size: 15px; border-radius: var(--radius); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { color: var(--red); border-color: var(--red-light); }

/* ── Logbook table ── */
.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.month-nav h2 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.month-nav button {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  width: 32px; height: 32px;
  cursor: pointer;
  color: var(--text-2);
  display: flex; align-items: center; justify-content: center;
}

/* ── Compact flight list ── */
.flight-list-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.flight-row {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.12s;
  min-width: 0;
}
.flight-row:last-child { border-bottom: none; }
.flight-row:active { background: var(--surface-2); }
.fr-date {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 28px;
  flex-shrink: 0;
}
.fr-day {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  line-height: 1;
}
.fr-mon {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 1px;
}
.fr-rego {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  min-width: 58px;
  flex-shrink: 0;
}
.fr-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}
.fr-detail {
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: block;
}
.fr-chips {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.fr-chip {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  white-space: nowrap;
}
.fr-chip-lbl {
  font-size: 9px;
  font-weight: 500;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.fr-total {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--navy-mid);
  white-space: nowrap;
  min-width: 36px;
  text-align: right;
  flex-shrink: 0;
}

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-3);
}
.empty-state svg { width: 48px; height: 48px; opacity: 0.3; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Totals strip ── */
.totals-strip {
  background: var(--navy);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.totals-strip .tot-item .lbl {
  font-size: 10px;
  color: rgba(255,255,255,0.55);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.totals-strip .tot-item .val {
  font-size: 20px;
  font-weight: 600;
  color: #fff;
  font-family: var(--font-mono);
  margin-top: 2px;
}

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: 76px;
  right: 18px;
  width: 52px; height: 52px;
  background: var(--sky);
  border: none;
  border-radius: 50%;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(55,138,221,0.4);
  z-index: 90;
  transition: transform 0.15s, box-shadow 0.15s;
}
.fab:active { transform: scale(0.93); box-shadow: 0 2px 8px rgba(55,138,221,0.3); }
.fab svg { width: 24px; height: 24px; stroke-width: 2.5; }

/* ── Settings list ── */
.settings-list { list-style: none; }
.settings-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.settings-list li .name { flex: 1; font-size: 14px; font-weight: 500; }
.settings-list li .sub { font-size: 12px; color: var(--text-3); }
.settings-list .actions { display: flex; gap: 8px; }

/* ── Opening balance ── */
.ob-row {
  display: flex;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.ob-row:last-child { border-bottom: none; }
.ob-row .ob-label { flex: 1; font-size: 13px; color: var(--text-2); }
.ob-row input {
  width: 90px;
  padding: 7px 10px;
  font-family: var(--font-mono);
  font-size: 13px;
  text-align: right;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-3);
}
.ob-row input.unlocked {
  background: var(--surface);
  color: var(--text);
  border-color: var(--sky);
}
.padlock {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--text-3);
  font-size: 16px;
}
.padlock.unlocked { color: var(--amber); }

/* ── Reports ── */
.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
}
.report-card h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.report-card h3 svg { width: 18px; height: 18px; color: var(--sky); }

/* ── Login ── */
#login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
  background: var(--navy);
}
#login-page .logo {
  margin-bottom: 32px;
  text-align: center;
}
#login-page .logo h1 {
  font-size: 26px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.02em;
}
#login-page .logo p {
  font-size: 13px;
  color: rgba(255,255,255,0.5);
  margin-top: 4px;
}
#login-page .login-card {
  width: 100%;
  max-width: 360px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  padding: 24px;
}
#login-page .field label { color: rgba(255,255,255,0.7); }
#login-page .field input {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: #fff;
}
#login-page .field input::placeholder { color: rgba(255,255,255,0.3); }
#login-page .field input:focus {
  border-color: var(--sky);
  box-shadow: 0 0 0 3px rgba(55,138,221,0.25);
}
.error-msg {
  color: #ff6b6b;
  font-size: 13px;
  margin-top: 10px;
  text-align: center;
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 72px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--navy);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Autocomplete dropdown ── */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  z-index: 150;
  max-height: 180px;
  overflow-y: auto;
  display: none;
}
.autocomplete-list.open { display: block; }
.autocomplete-list li {
  padding: 10px 12px;
  font-size: 14px;
  cursor: pointer;
  list-style: none;
  border-bottom: 1px solid var(--border);
}
.autocomplete-list li:last-child { border-bottom: none; }
.autocomplete-list li:hover, .autocomplete-list li.highlighted { background: var(--surface-2); }
