:root {
  --navy: #0a2a4a;
  --navy-light: #123a63;
  --grey-bg: #f4f6f8;
  --border: #dde2e7;
  --text: #1a1a1c;
  --text-muted: #66707a;
  --danger: #b22222;
  --danger-bg: #fdecec;
}

* { box-sizing: border-box; }

/* ---------------------------------------------------------------
   Typography — one scale for the whole system.

   The critical rule is `font: inherit` on form controls. Browsers do
   NOT inherit font-family or font-size into input/select/button/
   textarea; they use an OS default (typically 13px Arial). Screens
   heavy with form controls therefore looked like a different app from
   screens that were mostly text. This is the fix, and removing it
   brings the inconsistency straight back.
   --------------------------------------------------------------- */

:root {
  --font-body: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;

  --text-xs:  0.78rem;   /* uppercase labels, table headers */
  --text-sm:  0.875rem;  /* secondary text, hints, nav */
  --text-base: 1rem;     /* body copy, form controls */
  --text-lg:  1.15rem;
  --text-xl:  1.35rem;
  --text-2xl: 1.6rem;
}

html { font-size: 16px; }

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: 1.55;
}

input, select, button, textarea {
  font: inherit;
  color: inherit;
}

code, pre, .mono { font-family: var(--font-mono); }

h1 { font-size: var(--text-2xl); line-height: 1.25; }
h2 { font-size: var(--text-xl);  line-height: 1.3; }
h3 { font-size: var(--text-lg);  line-height: 1.35; }

.hint { font-size: var(--text-sm); }


body {
  margin: 0;
  color: var(--text);
  background: var(--grey-bg);
}

.site-header {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.9rem 1.5rem;
  background: var(--navy);
  color: white;
}
.site-header .brand { font-weight: 700; }
.site-header nav a { color: white; text-decoration: none; opacity: 0.9; }
.site-header nav a:hover { opacity: 1; text-decoration: underline; }
.logout-form { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.user-email { opacity: 0.85; font-size: var(--text-sm); }
.logout-form button, .add-category button, .edit-form button {
  background: var(--navy-light);
  color: white;
  border: none;
  padding: 0.4rem 0.9rem;
  border-radius: 4px;
  cursor: pointer;
}
.logout-form button:hover { background: #1d4d80; }

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

.login-wrap { display: flex; justify-content: center; margin-top: 4rem; }
.login-form {
  background: white;
  padding: 2rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.login-form h1 { margin: 0 0 0.5rem; font-size: var(--text-xl); text-align: center; }
.login-form label { display: flex; flex-direction: column; gap: 0.3rem; font-size: var(--text-sm); }
.login-form input { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; }
.login-form button {
  margin-top: 0.5rem;
  background: var(--navy);
  color: white;
  border: none;
  padding: 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
}
.form-error { background: var(--danger-bg); color: var(--danger); padding: 0.5rem 0.75rem; border-radius: 4px; font-size: var(--text-sm); }

.hint { color: var(--text-muted); max-width: 60ch; }

.add-category, .tree-section {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.add-category form { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.add-category input[type=text] { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; flex: 1; min-width: 150px; }
.add-category select { padding: 0.5rem; border: 1px solid var(--border); border-radius: 4px; }

.tree-header { display: flex; justify-content: space-between; align-items: baseline; }
.tree-header a { font-size: var(--text-sm); color: var(--navy); }

ul.category-tree, ul.category-children { list-style: none; padding-left: 0; margin: 0.5rem 0 0; }
ul.category-children { padding-left: 1.25rem; border-left: 2px solid var(--border); margin-top: 0.5rem; }

.category-node { margin-bottom: 0.5rem; }
.category-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--grey-bg);
  border-radius: 6px;
}
.category-node.archived .category-row { opacity: 0.55; }
.category-name { font-weight: 600; }
.category-desc { color: var(--text-muted); font-size: var(--text-sm); }
.category-actions { margin-left: auto; display: flex; gap: 0.4rem; }
.category-actions button { font-size: var(--text-sm); padding: 0.3rem 0.6rem; border-radius: 4px; border: 1px solid var(--border); background: white; cursor: pointer; }
.category-actions button.danger { color: var(--danger); border-color: var(--danger); }
.inline-form { display: inline; }

.edit-form { display: none; gap: 0.5rem; padding: 0.6rem 0.75rem; flex-wrap: wrap; }
.edit-form.open { display: flex; }
.edit-form input, .edit-form select { padding: 0.4rem; border: 1px solid var(--border); border-radius: 4px; }
.edit-form input[type=text] { flex: 1; min-width: 120px; }

.empty-state { color: var(--text-muted); font-style: italic; }
.hidden { display: none; }

/* Documentation section */
.docs-page { max-width: 1100px; margin: 0 auto; }

.todo-panel { background: #fffaf0; border: 1px solid #f0d9a8; border-left: 4px solid #e0a52c; border-radius: 8px; padding: 1.25rem 1.5rem; margin-bottom: 1.5rem; }
.todo-panel h2 { margin-top: 0; }
.todo-panel ul { margin-bottom: 0; padding-left: 1.25rem; }
.todo-panel li { margin-bottom: 0.5rem; }
.todo-panel li:last-child { margin-bottom: 0; }

.dashboard { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.5rem; margin-bottom: 1.5rem; }
.dashboard-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.stat-card { background: var(--grey-bg); border-radius: 6px; padding: 1rem; }
.stat-label { font-size: var(--text-xs); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; }
.stat-value { font-size: 1.4rem; font-weight: 700; margin-top: 0.25rem; word-break: break-word; }
.commit-line { color: var(--text-muted); font-size: var(--text-sm); }

.dashboard-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin: 1.5rem 0; }
@media (max-width: 700px) { .dashboard-columns { grid-template-columns: 1fr; } }

.stats-table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.stats-table th, .stats-table td { text-align: left; padding: 0.4rem 0.5rem; border-bottom: 1px solid var(--border); }
.stats-table th { color: var(--text-muted); font-weight: 600; font-size: var(--text-xs); text-transform: uppercase; }
.files-table { display: block; max-height: 320px; overflow-y: auto; }
.files-table code { font-size: var(--text-xs); }

.docs-sections { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.25rem 1.5rem; }
.docs-section-list { list-style: none; padding: 0; margin: 0.5rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.docs-section-list a { color: var(--navy); font-weight: 600; text-decoration: none; }
.docs-section-list a:hover { text-decoration: underline; }

.back-link { display: inline-block; margin-bottom: 1rem; color: var(--navy); text-decoration: none; font-size: var(--text-sm); }
.back-link:hover { text-decoration: underline; }

.docs-layout { display: grid; grid-template-columns: 220px 1fr; gap: 2rem; align-items: start; }
@media (max-width: 700px) { .docs-layout { grid-template-columns: 1fr; } }

.docs-sidebar ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.docs-sidebar a { display: block; padding: 0.5rem 0.75rem; border-radius: 6px; color: var(--text); text-decoration: none; font-size: var(--text-sm); }
.docs-sidebar a:hover { background: var(--grey-bg); }
.docs-sidebar a.active { background: var(--navy); color: white; }

.docs-content { background: white; border: 1px solid var(--border); border-radius: 8px; padding: 1.75rem 2rem; line-height: 1.6; }
.docs-content h1 { margin-top: 0; }
.docs-content h2 { margin-top: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3rem; }
.docs-content h3 { margin-top: 1.5rem; }
.docs-content code { background: var(--grey-bg); padding: 0.1rem 0.35rem; border-radius: 3px; font-size: 0.88em; }
.docs-content pre { background: #1a1a1c; color: #e8e8e8; padding: 1rem; border-radius: 6px; overflow-x: auto; }
.docs-content pre code { background: none; color: inherit; padding: 0; }
.docs-content ul, .docs-content ol { padding-left: 1.4rem; }
.docs-content table { border-collapse: collapse; width: 100%; margin: 1rem 0; }
.docs-content th, .docs-content td { border: 1px solid var(--border); padding: 0.4rem 0.6rem; text-align: left; }
.docs-content blockquote { border-left: 3px solid var(--border); margin: 1rem 0; padding: 0.25rem 1rem; color: var(--text-muted); }

/* ---------------------------------------------------------------
   ATF Portal additions — main menu and admin.
   Everything above this line is shared verbatim with the platform
   apps; keep it that way so all three read as one system.
   --------------------------------------------------------------- */

.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1rem;
  margin: 1.5rem 0 2rem;
}

.platform-card {
  display: block;
  padding: 1.25rem 1.35rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #fff;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.platform-card:hover,
.platform-card:focus-visible {
  border-color: var(--navy);
  box-shadow: 0 1px 6px rgba(10, 42, 74, 0.12);
}

.platform-card h2 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  color: var(--navy);
}

.platform-card p {
  margin: 0 0 0.6rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.platform-path {
  font-family: ui-monospace, Consolas, monospace;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.flash {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.95rem;
  border: 1px solid var(--border);
  border-left: 3px solid var(--navy);
  background: var(--grey-bg);
  font-size: 0.92rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.75rem;
}

.inline-form label {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-size: 0.85rem;
}

/* Irreversible actions are marked in the danger color everywhere they
   appear. Granting one of these is not a routine click. */
.danger-tag {
  display: inline-block;
  margin-left: 0.4rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
}

.session-entry {
  border-top: 1px solid var(--border);
  padding-top: 1.1rem;
  margin-top: 1.4rem;
}
.session-date {
  margin: 0 0 0.5rem;
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-muted);
}

/* ---------------------------------------------------------------
   System health panel (/documentation).
   Shared verbatim across platforms — keep it that way.

   Green when every check passes, red when any fails, and never
   anything in between. The panel exists because on 2026-08-23 four
   separate faults each looked exactly like nothing being wrong; an
   ambiguous colour here would reproduce that.
   --------------------------------------------------------------- */

.health-panel {
  margin: 0 0 1.75rem;
  padding: 1.1rem 1.25rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: 5px;
  background: #fff;
}

.health-panel h2 {
  margin: 0 0 0.6rem;
  font-size: var(--text-lg);
}

.health-panel.health-ok { border-left-color: #24471f; }
.health-panel.health-bad { border-left-color: var(--danger); background: var(--danger-bg); }

.health-verdict {
  margin: 0 0 0.9rem;
  color: #24471f;
  font-weight: 600;
}

.health-problems {
  margin: 0 0 1rem;
  padding-left: 1.1rem;
  color: var(--danger);
  font-weight: 600;
}

.health-problems li { margin: 0.2rem 0; }

.health-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.9rem;
  margin-bottom: 0.5rem;
}

.health-item .stat-label {
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
}

.health-item .stat-value {
  font-size: var(--text-xl);
  line-height: 1.2;
  color: var(--navy);
}

.health-item .hint {
  margin: 0.15rem 0 0;
  color: var(--text-muted);
}

.health-deps { margin-top: 0.9rem; }

.health-note { margin: 0.75rem 0 0; }

.health-note code {
  font-size: var(--text-sm);
  word-break: break-word;
}
