:root {
  --bg:           #f4f5f7;
  --card:         #ffffff;
  --text:         #1a1d23;
  --text-muted:   #5b6168;
  --border:       #d8dce1;
  --border-strong:#b9bfc6;
  --primary:      #1c3d5a;
  --primary-hover:#2a5278;
  --danger:       #c43d3d;
  --danger-bg:    #fdecec;
  --danger-bd:    #f5c3c3;
  --success:      #2d7a4f;
  --success-bg:   #e8f5ec;
  --success-bd:   #c3e3cf;
  --warning:      #b56600;
  --accent:       #fb8c00;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  min-height: 100vh;
}

main {
  padding: 1.5rem 2rem 3rem;
  max-width: 1200px;
  margin: 0 auto;
}

h1 { font-size: 1.5rem; margin: 0 0 1rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; font-weight: 600; }
p  { margin: 0 0 0.75rem; }
ul { margin: 0.25rem 0 0.75rem 1.25rem; padding: 0; }
li { margin: 0.25rem 0; }
code { font-family: ui-monospace, "SF Mono", Consolas, monospace; background: var(--bg); padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.88em; }

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

.muted { color: var(--text-muted); }

/* ---------- Nav ---------- */
.nav {
  background: var(--primary);
  color: white;
  padding: 0.75rem 2rem;
  display: flex;
  align-items: center;
  gap: 2rem;
}
.nav .brand {
  color: white;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  font-size: 0.92rem;
}
.nav .brand:hover { text-decoration: none; opacity: 0.9; }
.nav-links {
  display: flex;
  gap: 1.25rem;
  flex: 1;
}
.nav-links a {
  color: rgba(255,255,255,0.78);
  font-size: 0.92rem;
  padding: 0.25rem 0;
  border-bottom: 2px solid transparent;
}
.nav-links a:hover { color: white; text-decoration: none; }
.nav-links a.active {
  color: white;
  border-bottom-color: var(--accent);
}
.nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: rgba(255,255,255,0.85);
}
.inline-form { display: inline; margin: 0; padding: 0; }
.link {
  background: transparent;
  border: 0;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  padding: 0;
  font: inherit;
  text-decoration: underline;
}
.link:hover { color: white; }
.link.small { font-size: 0.85rem; color: var(--primary); }
main .link.small { color: var(--primary); }

/* ---------- Cards ---------- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 1.25rem 1.4rem;
  margin-bottom: 1.25rem;
}
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.card-link {
  display: block;
  color: inherit;
  transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}
.card-link:hover {
  text-decoration: none;
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.card-link h2 { color: var(--primary); }
.card-link p { color: var(--text-muted); margin: 0; font-size: 0.92rem; }

/* ---------- Forms ---------- */
label {
  display: block;
  margin-bottom: 0.75rem;
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 500;
}
input, select, textarea {
  display: block;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  background: white;
  color: var(--text);
  margin-top: 0.25rem;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(28, 61, 90, 0.15);
}
button[type="submit"], .btn {
  background: var(--primary);
  color: white;
  border: 0;
  padding: 0.55rem 1.1rem;
  border-radius: 4px;
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
button[type="submit"]:hover, .btn:hover { background: var(--primary-hover); }

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem 1rem;
  align-items: end;
}
.form-grid .form-actions {
  grid-column: 1 / -1;
}

/* ---------- Login ---------- */
.login-body { background: var(--bg); }
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  max-width: none;
}
.login-card {
  width: 360px;
  max-width: 100%;
  margin: 0;
}
.login-card h1 {
  font-size: 1.1rem;
  text-align: center;
  margin-bottom: 1.5rem;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: var(--primary);
  font-weight: 700;
}
.login-card button[type="submit"] {
  width: 100%;
  margin-top: 0.5rem;
}

/* ---------- Tables ---------- */
.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.data th {
  text-align: left;
  font-weight: 600;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
}
.data td {
  padding: 0.625rem 0.75rem;
  border-bottom: 1px solid var(--border);
}
.data tr:last-child td { border-bottom: 0; }
.row-disabled td { color: var(--text-muted); }

.role {
  display: inline-block;
  padding: 0.1rem 0.5rem;
  border-radius: 3px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 500;
}
.role-admin { background: #e4ecf3; color: var(--primary); }
.role-pilot { background: #fff1e0; color: var(--warning); }

/* ---------- Flash ---------- */
.flash {
  padding: 0.6rem 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  font-size: 0.92rem;
  border: 1px solid;
}
.flash-error   { background: var(--danger-bg);  color: var(--danger);  border-color: var(--danger-bd); }
.flash-success { background: var(--success-bg); color: var(--success); border-color: var(--success-bd); }

/* ---------- Error stack ---------- */
.error-stack {
  background: var(--bg);
  padding: 0.75rem;
  border-radius: 4px;
  font-size: 0.82rem;
  overflow: auto;
  color: var(--text-muted);
}

/* ---------- Tablet ---------- */
@media (max-width: 720px) {
  .nav { flex-wrap: wrap; padding: 0.5rem 1rem; gap: 0.5rem 1rem; }
  .nav-links { width: 100%; order: 3; flex-wrap: wrap; }
  main { padding: 1rem; }
  .form-grid { grid-template-columns: 1fr; }
}

/* ---------- MyFlightbook status ---------- */
.status-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin: 0 0 0.5rem;
}
.status-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-on  { background: var(--success); box-shadow: 0 0 0 2px var(--success-bg); }
.status-off { background: var(--text-muted); box-shadow: 0 0 0 2px var(--bg); }

.btn-secondary {
  display: inline-block;
  background: white;
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 0.45rem 0.9rem;
  font-size: 0.92rem;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: var(--bg); border-color: var(--text-muted); }

.small { font-size: 0.85rem; }
.inline-form { display: inline-block; margin: 0; }

.card.warn {
  border-left: 4px solid var(--warning);
  background: #fffaf2;
}

/* ---------- Data tables ---------- */
.data-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.75rem;
  font-size: 0.9rem;
}
.data-table th,
.data-table td {
  text-align: left;
  padding: 0.45rem 0.6rem;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--bg);
  font-weight: 600;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-muted);
}
.data-table tr:hover { background: var(--bg); }
.data-table code { font-size: 0.85em; }
