/* Look and feel follows the xpert.IT website: navy ink, green accent, Segoe UI. */
:root {
  --g: #a7c928;
  --g-ink: #5a6e00;
  --bg: #fff;
  --bg-soft: #f3f6f9;
  --surface: #fff;
  --text: #071b3b;
  --m: #60718a;
  --line: #dce5ec;
  --danger: #b3261e;
  --shadow: 0 10px 28px rgba(7, 27, 59, .12);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --g-ink: #a7c928;
    --bg: #07111f;
    --bg-soft: #0a1829;
    --surface: #0d2038;
    --text: #f3f7fb;
    --m: #c7d4e3;
    --line: #35506d;
    --danger: #ff9a92;
    --shadow: 0 10px 28px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html { overflow-x: hidden; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Segoe UI", Arial, sans-serif;
  overflow-wrap: anywhere;
}

h1 { margin: 0 0 8px; font-size: clamp(28px, 4vw, 40px); line-height: 1.1; }
h2 { margin: 0 0 10px; font-size: 22px; line-height: 1.2; }
h3 { margin: 0; font-size: 17px; }
p { margin: 0 0 12px; }
a { color: inherit; }
code { padding: 1px 5px; border-radius: 4px; background: var(--bg-soft); font: .92em Consolas, "Courier New", monospace; }

.muted { color: var(--m); }
.small { font-size: 14px; }
.eyebrow { margin: 0 0 4px; color: var(--g-ink); font-weight: 900; text-transform: uppercase; letter-spacing: .5px; font-size: 14px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
.skip { position: fixed; left: -9999px; }
.skip:focus { left: 8px; top: 8px; z-index: 99; background: var(--surface); padding: 12px; }

/* ---- header ---- */

.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  min-height: 68px;
  padding: 8px 4%;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand { font-size: 28px; font-weight: 900; white-space: nowrap; }
.brand b { color: var(--g); }
.brand small { margin-left: 10px; font-size: 12px; font-weight: 700; color: var(--m); }

.topnav { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.topnav > a { padding: 8px 12px; border-radius: 7px; text-decoration: none; font-weight: 700; }
.topnav > a[aria-current="page"] { box-shadow: inset 0 -3px 0 var(--g); border-radius: 0; }
.topnav form { display: flex; align-items: center; gap: 10px; margin-left: 12px; }
.who { color: var(--m); font-size: 14px; }

/* ---- controls ---- */

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 9px 18px;
  border: 2px solid var(--g);
  border-radius: 7px;
  background: var(--g);
  color: #071b3b;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
  transition: box-shadow .2s ease, transform .2s ease, background-color .2s ease;
}
.btn-ghost { background: transparent; color: var(--text); }
.btn-link { min-height: 32px; padding: 2px 6px; border-color: transparent; background: none; color: var(--g-ink); font-weight: 700; }
.btn-link.danger { color: var(--danger); }
.btn:hover:not(:disabled), .btn:focus-visible { box-shadow: 0 0 0 3px rgba(167, 201, 40, .34), 0 8px 20px rgba(112, 137, 0, .24); transform: translateY(-1px); }
.btn-link:hover:not(:disabled), .btn-link:focus-visible { box-shadow: none; transform: none; text-decoration: underline; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
:focus-visible { outline: 3px solid var(--g); outline-offset: 2px; }

label { display: grid; gap: 4px; font-weight: 700; font-size: 14px; }
input, select, textarea {
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  font-size: 16px;
  font-weight: 400;
}
textarea { resize: vertical; line-height: 1.5; }
input[type="file"] { padding: 8px; }

/* ---- layout ---- */

.wrap { max-width: 1280px; margin: 0 auto; padding: 36px 24px 60px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.stack { display: grid; gap: 14px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }

.panel {
  margin-bottom: 20px;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 5px solid var(--g);
  border-radius: 10px;
}
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 { margin-bottom: 20px; }
details.panel > summary { cursor: pointer; }
details.panel > summary h2 { display: inline; margin: 0; }
details.panel[open] > summary { margin-bottom: 12px; }

.notice { margin: 0 0 16px; padding: 12px 16px; border-left: 5px solid var(--g); border-radius: 6px; background: var(--bg-soft); }
.notice-error { border-left-color: var(--danger); }
.credentials { margin: 8px 0 0; line-height: 1.9; }

body.centered main { display: grid; place-items: center; min-height: calc(100vh - 70px); padding: 24px; }
.login { display: grid; gap: 14px; width: min(100%, 420px); box-shadow: var(--shadow); }
.message { width: min(100%, 560px); text-align: center; }

.crumbs { margin-bottom: 14px; color: var(--m); font-size: 14px; }
.crumbs a { color: var(--g-ink); font-weight: 700; text-decoration: none; }
.crumbs a:hover { text-decoration: underline; }
.strong-link { font-weight: 700; text-decoration: none; }
.strong-link:hover { text-decoration: underline; }
.danger-zone { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--line); }
.btn-ghost.danger { border-color: var(--danger); color: var(--danger); }

/* ---- stat tiles ---- */

.tiles { display: grid; grid-template-columns: 1.6fr repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 28px; }
.tile {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 18px 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.tile-hero { border-top: 5px solid var(--g); }
.tile-label { color: var(--m); font-size: 14px; font-weight: 700; line-height: 1.3; }
.tile-value { font-size: 30px; font-weight: 600; line-height: 1.15; }
.tile-hero .tile-value { font-size: 52px; }
.tile-note { color: var(--m); font-size: 14px; }

.meter { display: block; height: 8px; border-radius: 4px; background: color-mix(in srgb, var(--g) 22%, var(--surface)); overflow: hidden; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: var(--g); }

/* ---- tables ---- */

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; margin-bottom: 14px; }
.filters label { min-width: 180px; }
.filters label:first-child { flex: 1 1 260px; max-width: 420px; }
#filter-count { padding-bottom: 10px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.panel .table-wrap { margin: 12px 0; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); overflow-wrap: normal; }
tbody tr:last-child td { border-bottom: 0; }
thead th { background: var(--bg-soft); font-size: 14px; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tbody tr:hover { background: color-mix(in srgb, var(--surface) 93%, var(--g)); }

.sortable thead button { all: unset; cursor: pointer; font-weight: 700; }
.sortable thead button::after { content: " ↕"; color: var(--m); font-weight: 400; }
.sortable th[aria-sort="ascending"] button::after { content: " ↑"; color: var(--text); }
.sortable th[aria-sort="descending"] button::after { content: " ↓"; color: var(--text); }
.sortable thead button:focus-visible { outline: 3px solid var(--g); outline-offset: 2px; }

.rowmeter { display: inline-flex; align-items: center; gap: 10px; }
.rowmeter .meter { width: 80px; }

.status { display: inline-flex; align-items: center; gap: 6px; font-weight: 700; white-space: nowrap; }
.status-open { color: var(--m); font-weight: 400; }
.status-error { color: var(--danger); }
/* Drawn rather than typed, so the three states differ in shape on every system font. */
.dot { flex: none; width: 12px; height: 12px; border: 2px solid var(--g-ink); border-radius: 50%; }
.status-done .dot { background: var(--g-ink); }
.status-progress .dot { background: linear-gradient(90deg, var(--g-ink) 50%, transparent 50%); }
.status-open .dot { border-color: var(--m); }
td.date { white-space: nowrap; }

.empty { margin: 0; padding: 28px; text-align: center; color: var(--m); }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions form { display: inline; }

.send-row { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; padding-top: 14px; border-top: 1px solid var(--line); }
.send-row label { flex: 1 1 200px; }
.job { margin-bottom: 14px; padding: 12px 16px; border-radius: 6px; background: var(--bg-soft); border-left: 5px solid var(--m); }
.job[data-state="done"] { border-left-color: var(--g); }
.inline-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 14px; }
.inline-form label { flex: 1 1 220px; max-width: 340px; }
#import-result { margin-top: 14px; }
#import-result ul { margin: 6px 0 0; padding-left: 20px; }

/* ---- training viewer ---- */

body.viewer-page { display: flex; flex-direction: column; height: 100dvh; min-height: 520px; background: var(--bg-soft); }
body.viewer-page main { flex: 1; display: flex; min-height: 0; }
.viewer { flex: 1; display: flex; flex-direction: column; gap: 14px; width: 100%; max-width: 1500px; margin: 0 auto; padding: 16px 20px 20px; }
.viewer-head p { margin: 0; color: var(--m); }
.viewer-head .notice { margin-top: 10px; background: var(--surface); color: var(--text); }

.stage { position: relative; flex: 1; display: grid; place-items: center; min-height: 240px; }
/* Out of flow, so the size of the slide never dictates how much room the stage gets. */
.stage img { position: absolute; inset: 0; margin: auto; max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; box-shadow: var(--shadow); }
.stage-note { position: absolute; margin: 0; padding: 10px 16px; border-radius: 6px; background: var(--surface); color: var(--m); }

.controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 18px; }
.position { display: grid; gap: 6px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.position .meter { width: min(100%, 520px); margin: 0 auto; }
#offline { margin: 0; }

/* ---- small screens ---- */

@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tile-hero { grid-column: 1 / -1; }
}

@media (max-width: 860px) {
  .grid-2 { grid-template-columns: 1fr; }
  .row-actions { white-space: normal; }
}

@media (max-width: 600px) {
  .topbar { padding: 8px 16px; }
  .brand small { display: none; }
  .wrap { padding: 24px 16px 40px; }
  .panel { padding: 18px 16px; }
  .tiles { grid-template-columns: 1fr; }
  .viewer { padding: 12px 16px 16px; }
  .controls { gap: 10px; }
  .controls .btn { padding: 9px 12px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; }
}
