* { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --navy: #0e2a47;
  --navy2: #173e63;
  --accent: #1f7ae0;
  --accent2: #14b39a;
  --bg: #eef2f6;
  --line: #d9e0e8;
  --text: #1c2733;
  --muted: #6b7a8d;
  --danger: #c0392b;
  --warn: #d98a00;
  --ok: #1f9d55;
}
body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
.hidden { display: none !important; }

/* ---- Login ---- */
#login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy), var(--navy2));
}
.login-card {
  background: #fff;
  width: 360px;
  padding: 32px;
  border-radius: 10px;
  box-shadow: 0 12px 40px rgba(0,0,0,.3);
}
.login-card h1 { font-size: 20px; color: var(--navy); margin-bottom: 4px; }
.login-card .sub { color: var(--muted); font-size: 12px; margin-bottom: 22px; }
.login-card label { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 4px; }
.login-card input { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 14px; }
.login-card button { width: 100%; margin-top: 20px; }
.login-err { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 16px; }
.login-hint { font-size: 11px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ---- App shell ---- */
header.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 56px;
}
header .brand { font-size: 18px; font-weight: 600; }
header .brand .plane { color: var(--accent2); margin-right: 6px; }
header .ref { font-size: 11px; color: #aac4dd; margin-left: 10px; }
header .spacer { flex: 1; }
header .who { font-size: 12px; color: #cdddee; margin-right: 14px; }

nav.tabs { background: var(--navy2); display: flex; padding: 0 12px; }
nav.tabs button {
  background: transparent; border: none; color: #c7d7e6; cursor: pointer;
  padding: 12px 18px; font-size: 14px; border-bottom: 3px solid transparent;
}
nav.tabs button:hover { color: #fff; }
nav.tabs button.active { color: #fff; border-bottom-color: var(--accent2); font-weight: 600; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=text], .toolbar select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; }
.toolbar .grow { flex: 1; }
.section-title { font-size: 16px; color: var(--navy); margin-bottom: 4px; }
.section-sub { color: var(--muted); font-size: 12px; margin-bottom: 14px; }

/* ---- Buttons ---- */
button.btn { padding: 8px 14px; border: none; border-radius: 6px; cursor: pointer; font-size: 13px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #1668c4; }
.btn-ok { background: var(--ok); color: #fff; }
.btn-light { background: #fff; border: 1px solid var(--line); color: var(--text); }
.btn-light:hover { background: #f4f7fa; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 5px 9px; font-size: 12px; }

/* ---- Tables ---- */
table.grid { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
table.grid th, table.grid td { padding: 9px 11px; text-align: left; border-bottom: 1px solid var(--line); font-size: 13px; vertical-align: top; }
table.grid th { background: #f3f6f9; color: var(--navy); font-weight: 600; }
table.grid tr:hover td { background: #f7fafd; }
table.grid .actions { display: flex; flex-wrap: wrap; gap: 6px; }
.empty { text-align: center; color: var(--muted); padding: 26px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 12px; font-size: 11px; font-weight: 600; }
.badge.active { background: #e3f5ec; color: var(--ok); }
.badge.completed { background: #e3edfb; color: var(--accent); }
.badge.suspended { background: #fbeed0; color: var(--warn); }
.badge.withdrawn { background: #f7e2e0; color: var(--danger); }
.badge.type { background: #eef2f6; color: var(--navy2); }
.warn-exp { color: var(--danger); font-weight: 600; }

/* ---- Modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(14,42,71,.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 30px 16px; overflow-y: auto; z-index: 50;
}
.modal {
  background: #fff; border-radius: 10px; width: 760px; max-width: 100%;
  box-shadow: 0 16px 50px rgba(0,0,0,.35);
}
.modal.small { width: 460px; }
.modal h2 { background: var(--navy); color: #fff; padding: 14px 20px; font-size: 16px; border-radius: 10px 10px 0 0; }
.modal .body { padding: 20px; }
.modal .foot { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 10px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.form-grid .full { grid-column: 1 / -1; }
.fieldset { grid-column: 1 / -1; margin-top: 6px; border-top: 1px solid var(--line); padding-top: 10px; }
.fieldset legend { font-size: 12px; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .04em; }
label.fld { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=date], input[type=email], input[type=number], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; font-size: 13px; font-family: inherit;
}
textarea { resize: vertical; min-height: 56px; }
.err-line { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }

.perm-box { border: 1px solid var(--line); border-radius: 6px; padding: 12px; grid-column: 1 / -1; }
.perm-box .row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.perm-box input[type=checkbox] { width: auto; }

.log-panel { background: #fff; border: 1px solid var(--line); border-radius: 8px; max-height: 360px; overflow-y: auto; }
.log-panel .row { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; display: flex; gap: 12px; }
.log-panel .row .t { color: var(--muted); white-space: nowrap; }
.subnote { font-size: 12px; color: var(--muted); margin: 6px 0 14px; }
.crumb { font-size: 13px; color: var(--accent); cursor: pointer; }
.crumb:hover { text-decoration: underline; }

/* ---- Progress (Flight Training) ---- */
.progress-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
.pcard { background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 14px; }
.pcard .lbl { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.pcard .big { font-size: 22px; font-weight: 700; color: var(--navy); margin: 4px 0; }
.pcard .sub2 { font-size: 12px; color: var(--muted); }
.pcard .rem { color: var(--accent); font-weight: 600; }
.pcard .done { color: var(--ok); font-weight: 600; }

.bar { height: 8px; background: #e7edf3; border-radius: 5px; overflow: hidden; margin-top: 8px; }
.bar > span { display: block; height: 100%; background: var(--accent2); }
.bar.full > span { background: var(--ok); }

.mini-bar { height: 6px; width: 90px; background: #e7edf3; border-radius: 4px; overflow: hidden; display: inline-block; vertical-align: middle; margin-left: 8px; }
.mini-bar > span { display: block; height: 100%; background: var(--accent2); }
.mini-bar.full > span { background: var(--ok); }
.cell-prog { white-space: nowrap; }
.flt-notes { font-size: 12px; color: var(--muted); max-width: 320px; }
.flt-notes b { color: var(--text); }

/* ---- Documentation ---- */
.subtabs { display: flex; gap: 6px; margin: 0 0 14px; border-bottom: 1px solid var(--line); }
.subtabs button { background: transparent; border: none; border-bottom: 3px solid transparent; padding: 8px 14px; cursor: pointer; color: var(--muted); font-size: 13px; }
.subtabs button:hover { color: var(--navy); }
.subtabs button.active { color: var(--navy); border-bottom-color: var(--accent); font-weight: 600; }
label.chk { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 5px; }
label.chk input { width: auto; }
.grp-row { cursor: pointer; }
.grp-row:hover td { background: #eef4fb; }
.sub-row td { background: #f7fafd; }
.tri { display: inline-block; width: 12px; color: var(--muted); font-size: 11px; }
.roval { padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: #f4f7fa; font-size: 13px; min-height: 34px; color: var(--text); }
