/* Visionem - colours taken from Learning_Progress_Tracker.xlsx:
   headers #1F4E5F, yellow = you type, grey = calculated, data bars #4BA3C3. */
:root {
  --brand: #1F4E5F;
  --brand-dark: #163945;
  --muted: #5A6B73;
  --text: #222222;
  --example: #7A7A7A;
  --input-bg: #FFF6D5;
  --calc-bg: #EEF2F4;
  --bar: #4BA3C3;
  --border: #D5DDE1;
  --page: #F7F9FA;
  --danger: #8B1A1A;
  --radius: 6px;
  font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
  font-size: 14px;
  color: var(--text);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--page); }
[hidden] { display: none !important; }
a { color: var(--brand); }
h1, h2, h3 { color: var(--brand); margin: 0; }
h1 { font-size: 22px; }
h2 { font-size: 16px; margin-bottom: 8px; }
h3 { font-size: 14px; margin-bottom: 6px; }
.subtitle { color: var(--muted); font-size: 12px; margin: 4px 0 16px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- Buttons & inputs ------------------------------------------------------------------ */
.btn {
  font: inherit; cursor: pointer; border: 1px solid var(--border); background: #fff;
  color: var(--brand); padding: 6px 12px; border-radius: var(--radius); white-space: nowrap;
}
.btn:hover { border-color: var(--brand); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: bold; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); }
.btn.link { border: none; background: none; padding: 4px 6px; text-decoration: underline; }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn:disabled { opacity: .55; cursor: default; }

input, select, textarea {
  font: inherit; color: var(--text); background: var(--input-bg);
  border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid var(--bar); outline-offset: -1px; }
input[type="checkbox"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; min-height: 54px; }
label { display: block; font-weight: bold; font-size: 12px; color: var(--muted); }
label > input, label > select, label > textarea { margin-top: 4px; font-weight: normal; }
.form-error { color: var(--danger); font-size: 13px; margin: 8px 0; }

/* ---- Login ----------------------------------------------------------------------------- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card {
  width: 100%; max-width: 360px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 28px; display: grid; gap: 14px;
}
.login-card .subtitle { margin: 0 0 6px; }
.brand-big { font-size: 28px; }

/* ---- Top bar --------------------------------------------------------------------------- */
.topbar {
  display: flex; align-items: center; gap: 20px; background: var(--brand); color: #fff;
  padding: 0 20px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap;
}
.brand { color: #fff; font-weight: bold; font-size: 18px; text-decoration: none; padding: 12px 0; }
.tabs { display: flex; gap: 2px; flex: 1; overflow-x: auto; }
.tabs a {
  color: #D7E6EC; text-decoration: none; padding: 14px 12px; white-space: nowrap;
  border-bottom: 3px solid transparent;
}
.tabs a:hover { color: #fff; }
.tabs a.active { color: #fff; font-weight: bold; border-bottom-color: var(--bar); }
.user-menu { display: flex; align-items: center; gap: 8px; }
.user-menu a { color: #fff; text-decoration: none; }
.user-menu a.active { text-decoration: underline; }
.user-menu .btn.link { color: #D7E6EC; }

/* ---- Page layout ----------------------------------------------------------------------- */
.view { padding: 20px; max-width: 1500px; margin: 0 auto; outline: none; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.page-head .subtitle { margin-bottom: 12px; }
.panel { background: #fff; border: 1px solid var(--border); border-radius: 8px; padding: 16px; }
.grid-2 { display: grid; grid-template-columns: minmax(280px, 420px) 1fr; gap: 20px; }
.stack { display: grid; gap: 20px; }
@media (max-width: 860px) { .grid-2 { grid-template-columns: 1fr; } }

/* At a glance */
.glance { width: 100%; border-collapse: collapse; }
.glance td { padding: 6px 0; border-bottom: 1px solid #EDF1F3; }
.glance td.value {
  text-align: right; font-weight: bold; color: var(--brand); background: var(--calc-bg);
  padding: 6px 10px; width: 90px; font-size: 15px;
}
.howto ol { margin: 0 0 12px; padding-left: 20px; line-height: 1.6; }
.legend { display: grid; gap: 6px; margin-bottom: 12px; }
.swatch { display: inline-block; padding: 3px 8px; border-radius: 3px; font-size: 12px; }
.swatch.input { background: var(--input-bg); }
.swatch.calc { background: var(--calc-bg); }

/* ---- Spreadsheet-style tables ---------------------------------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
table.sheet { border-collapse: collapse; width: 100%; font-size: 13px; }
table.sheet th {
  background: var(--brand); color: #fff; font-weight: bold; text-align: left;
  padding: 8px 10px; white-space: nowrap; vertical-align: bottom; position: sticky; top: 0;
}
table.sheet td { padding: 7px 10px; border-bottom: 1px solid #E6ECEF; vertical-align: top; }
table.sheet tr:last-child td { border-bottom: none; }
table.sheet td.calc { background: var(--calc-bg); }
table.sheet td.input { background: var(--input-bg); }
table.sheet td.num, table.sheet th.num { text-align: right; white-space: nowrap; }
table.sheet td.nowrap { white-space: nowrap; }
table.sheet td.wrap { min-width: 220px; max-width: 360px; white-space: pre-wrap; }
table.sheet td.actions { white-space: nowrap; text-align: right; }
table.sheet tr.current td:first-child { box-shadow: inset 4px 0 0 var(--bar); }
table.sheet td textarea { min-width: 200px; min-height: 60px; background: var(--input-bg); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* % complete data bar */
.bar { position: relative; min-width: 110px; height: 20px; background: #fff; border: 1px solid #D9E6EB; border-radius: 3px; }
.bar > span { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 2px; }
.bar > em { position: absolute; inset: 0; font-style: normal; font-size: 12px; line-height: 20px; text-align: center; color: var(--text); font-weight: bold; }

/* Status pills - same colours as the spreadsheet's conditional formatting */
.pill { display: inline-block; padding: 2px 8px; border-radius: 10px; font-weight: bold; font-size: 12px; white-space: nowrap; }
.pill.done, .pill.yes { color: #1E6B34; background: #D4EDDA; }
.pill.on-track, .pill.in-progress { color: #1F4E79; background: #DCEBF7; }
.pill.behind { color: #9C3A00; background: #FCE4D6; }
.pill.overdue, .pill.no { color: #8B1A1A; background: #F8D7DA; }
.pill.not-started { color: #555555; background: #EEEEEE; }
.pill.add-details { color: #7A5B00; background: #FFF3CD; }

/* ---- Forms ----------------------------------------------------------------------------- */
.quick-add {
  display: grid; gap: 10px; align-items: end;
  grid-template-columns: 150px minmax(160px, 1.2fr) 110px 120px minmax(180px, 2fr) auto;
  margin-bottom: 4px;
}
@media (max-width: 960px) { .quick-add { grid-template-columns: 1fr 1fr; } }
.form-grid { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.form-grid .full { grid-column: 1 / -1; }
.inline-fields { display: flex; gap: 12px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.inline-fields label { min-width: 170px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: normal; color: var(--text); font-size: 14px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin: 14px 0 10px; flex-wrap: wrap; }
.toolbar select { width: auto; min-width: 200px; }
.saved-note { font-size: 11px; color: var(--muted); }

dialog {
  border: 1px solid var(--border); border-radius: 10px; padding: 0; width: min(720px, 94vw);
  color: var(--text);
}
dialog::backdrop { background: rgba(22, 57, 69, .45); }
dialog form { padding: 20px; display: grid; gap: 14px; }
dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }

/* ---- Toast ----------------------------------------------------------------------------- */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--brand-dark); color: #fff; padding: 10px 16px; border-radius: 6px;
  box-shadow: 0 4px 14px rgba(0,0,0,.2); max-width: 90vw;
}
.toast.error { background: var(--danger); }
