/* ==========================================================================
   Opies Portal — design system
   Oceania Polytechnic Institute of Education
   Editorial, restrained, print-like. Brand blue lifted from the wordmark.
   ========================================================================== */

:root {
  /* Brand */
  --brand: #0918E0;
  --brand-deep: #0A12A8;
  --brand-ink: #070C5C;
  --brand-soft: #EEF0FF;
  --brand-soft-2: #DDE1FF;

  /* Ink */
  --ink: #111216;
  --ink-2: #3B3D45;
  --ink-3: #6A6D78;
  --ink-4: #9C9FA9;
  --ink-5: #C6C8CF;

  /* Paper */
  --bg: #F4F4F1;
  --bg-2: #ECECE8;
  --surface: #FFFFFF;
  --surface-2: #FAFAF8;
  --line: #E3E3DE;
  --line-2: #EEEEEA;
  --line-strong: #CFCFC8;

  /* Sidebar */
  --side-bg: #0B0C11;
  --side-bg-2: #13141B;
  --side-text: #A9ACB8;
  --side-text-strong: #FFFFFF;
  --side-line: rgba(255,255,255,.08);

  /* Status */
  --ok: #1E7A4C;      --ok-bg: #E7F4EC;     --ok-line: #BFE1CC;
  --warn: #8A5A00;    --warn-bg: #FFF4DB;   --warn-line: #F1D89A;
  --bad: #B0261E;     --bad-bg: #FCEAE8;    --bad-line: #F2C1BC;
  --info: var(--brand); --info-bg: var(--brand-soft); --info-line: var(--brand-soft-2);
  --muted-bg: #F0F0EC; --muted-line: #DCDCD6;

  /* Type */
  --font-body: "Instrument Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;

  /* Radii, shadow */
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow-1: 0 1px 2px rgba(17,18,22,.04), 0 1px 1px rgba(17,18,22,.03);
  --shadow-2: 0 6px 24px -8px rgba(17,18,22,.14), 0 2px 6px -2px rgba(17,18,22,.06);
  --shadow-3: 0 24px 60px -20px rgba(17,18,22,.28);

  /* Layout */
  --side-w: 264px;
  --top-h: 64px;
  --content-max: 1280px;
  --gutter: 32px;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font-body); font-size: 14.5px; line-height: 1.5;
  font-feature-settings: "ss01", "cv11"; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5 { margin: 0; font-weight: 500; line-height: 1.2; letter-spacing: -0.01em; color: var(--ink); }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 17px; } h4 { font-size: 15px; }
p { margin: 0 0 12px; } p:last-child { margin-bottom: 0; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 2px; }
small, .small { font-size: 12.5px; }
strong, b { font-weight: 600; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
img { max-width: 100%; display: block; }
code, .mono { font-family: var(--font-mono); font-size: 12.5px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
::selection { background: var(--brand-soft-2); color: var(--brand-ink); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.display { font-family: var(--font-display); font-weight: 400; letter-spacing: -0.005em; }
.display em, .display i { font-style: italic; color: var(--brand); }
.eyebrow { font-size: 11.5px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-3); }
.muted { color: var(--ink-3); } .faint { color: var(--ink-4); }
.num { font-variant-numeric: tabular-nums; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------------------
   App shell
   -------------------------------------------------------------------------- */
.shell { display: grid; grid-template-columns: var(--side-w) 1fr; min-height: 100vh; }

.side {
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
  background: var(--side-bg); color: var(--side-text);
  display: flex; flex-direction: column; border-right: 1px solid var(--side-line);
}
.side::before {
  content: ""; position: absolute; right: -60px; bottom: -40px; width: 300px; height: 340px;
  background: url("../img/sphinx-white.304ea12042c2.png") no-repeat center / contain; opacity: .045; pointer-events: none;
}
.side-brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 16px; border-bottom: 1px solid var(--side-line); }
.side-brand img { width: 40px; height: 40px; border-radius: 8px; flex: none; }
.side-brand .t { line-height: 1.15; }
.side-brand .t b { display: block; color: #fff; font-weight: 600; font-size: 13.5px; letter-spacing: .01em; }
.side-brand .t span { display: block; font-size: 11px; color: var(--side-text); letter-spacing: .06em; text-transform: uppercase; margin-top: 3px; }
.side-role { margin: 16px 20px 6px; font-size: 10.5px; letter-spacing: .14em; text-transform: uppercase; color: #6E7280; }
.side-nav { padding: 4px 12px; display: flex; flex-direction: column; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 8px;
  color: var(--side-text); font-size: 13.5px; font-weight: 500; position: relative; transition: background .12s, color .12s;
}
.side-nav a:hover { background: var(--side-bg-2); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(255,255,255,.07); color: #fff; }
.side-nav a.active::before { content: ""; position: absolute; left: -12px; top: 9px; bottom: 9px; width: 3px; background: var(--brand); border-radius: 0 3px 3px 0; box-shadow: 0 0 12px var(--brand); }
.side-nav svg { width: 17px; height: 17px; flex: none; opacity: .8; }
.side-nav a.active svg, .side-nav a:hover svg { opacity: 1; }
.side-nav .count { margin-left: auto; font-size: 11px; font-weight: 600; background: var(--brand); color: #fff; padding: 1px 7px; border-radius: 999px; min-width: 20px; text-align: center; }
.side-nav .count.quiet { background: rgba(255,255,255,.12); color: #fff; }
.side-foot { margin-top: auto; padding: 14px 16px 18px; border-top: 1px solid var(--side-line); }
.side-user { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-radius: 8px; }
.side-user .who { line-height: 1.2; min-width: 0; }
.side-user .who b { display: block; color: #fff; font-weight: 500; font-size: 13px; }
.side-user .who span { display: block; font-size: 11.5px; color: var(--side-text); }
.side-user form { margin-left: auto; }
.side-user button { background: none; border: 0; color: var(--side-text); padding: 6px; border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.side-user button:hover { color: #fff; background: var(--side-bg-2); }
.side-meta { padding: 10px 6px 0; font-size: 10.5px; color: #5F6270; letter-spacing: .04em; line-height: 1.6; }

.main { min-width: 0; display: flex; flex-direction: column; }
.top {
  position: sticky; top: 0; z-index: 30; height: var(--top-h);
  display: flex; align-items: center; gap: 16px; padding: 0 var(--gutter);
  background: rgba(244,244,241,.85); backdrop-filter: saturate(160%) blur(10px); -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--line);
}
.top .crumbs { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-3); min-width: 0; }
.top .crumbs a { color: var(--ink-3); } .top .crumbs a:hover { color: var(--ink); text-decoration: none; }
.top .crumbs .sep { color: var(--ink-5); }
.top .crumbs .cur { color: var(--ink); font-weight: 500; }
.top .spacer { flex: 1; }
.top-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  position: relative; width: 36px; height: 36px; border-radius: 8px; border: 1px solid transparent; background: transparent;
  display: grid; place-items: center; cursor: pointer; color: var(--ink-2); transition: background .12s, border-color .12s;
}
.icon-btn:hover { background: var(--surface); border-color: var(--line); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; background: var(--brand); border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); }
.menu-btn { display: none; }

.content { padding: 28px var(--gutter) 64px; max-width: var(--content-max); width: 100%; margin: 0 auto; }
.content.narrow { max-width: 880px; }

/* Page header */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 26px; flex-wrap: wrap; }
.page-head .eyebrow { margin-bottom: 6px; }
.page-head h1 { font-family: var(--font-display); font-weight: 400; font-size: 34px; letter-spacing: -0.01em; }
.page-head .lede { color: var(--ink-3); margin-top: 6px; max-width: 640px; font-size: 14.5px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* --------------------------------------------------------------------------
   Grid helpers
   -------------------------------------------------------------------------- */
.grid { display: grid; gap: 20px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0,1fr)); }
.grid.main-aside { grid-template-columns: minmax(0, 1fr) 340px; align-items: start; }
.grid.aside-main { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack.tight { gap: 12px; }
.row { display: flex; align-items: center; gap: 10px; }
.row.between { justify-content: space-between; }
.row.wrap { flex-wrap: wrap; }
.mt-1{margin-top:8px}.mt-2{margin-top:16px}.mt-3{margin-top:24px}.mt-4{margin-top:32px}
.mb-1{margin-bottom:8px}.mb-2{margin-bottom:16px}.mb-3{margin-bottom:24px}
.ml-auto{margin-left:auto}
.text-right{text-align:right}.text-center{text-align:center}

/* --------------------------------------------------------------------------
   Cards
   -------------------------------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.card-head h3 { font-size: 15px; font-weight: 600; }
.card-head > svg { width: 18px; height: 18px; flex: none; color: var(--ink-4); }
.card-head .sub { font-size: 12.5px; color: var(--ink-3); margin-top: 2px; }
.card-body { padding: 20px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 12px 20px; border-top: 1px solid var(--line-2); background: var(--surface-2); border-radius: 0 0 var(--r-lg) var(--r-lg); font-size: 13px; color: var(--ink-3); display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card.dark { background: var(--side-bg); border-color: transparent; color: #fff; position: relative; overflow: hidden; }
.card.dark::after { content: ""; position: absolute; right: -30px; bottom: -30px; width: 220px; height: 240px; background: url("../img/sphinx-white.304ea12042c2.png") no-repeat center / contain; opacity: .06; pointer-events: none; }
.card.dark .muted { color: #A9ACB8; }
.card.brand { background: var(--brand); border-color: transparent; color: #fff; }
.card.brand .muted { color: rgba(255,255,255,.75); }
.card.soft { background: var(--surface-2); box-shadow: none; }

/* Stat tiles */
.stat { padding: 18px 20px; display: flex; flex-direction: column; gap: 10px; min-height: 118px; }
.stat .label { font-size: 12.5px; color: var(--ink-3); font-weight: 500; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.stat .label svg { width: 16px; height: 16px; color: var(--ink-4); }
.stat .value { font-family: var(--font-display); font-size: 38px; line-height: 1; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .delta { font-size: 12.5px; color: var(--ink-3); margin-top: auto; }
.stat .delta.up { color: var(--ok); } .stat .delta.down { color: var(--bad); } .stat .delta.warn { color: var(--warn); }
.stat a { color: inherit; }

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  color: var(--ink); font-weight: 500; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, box-shadow .12s, transform .06s; box-shadow: var(--shadow-1);
}
.btn:hover { background: var(--surface-2); border-color: var(--ink-5); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(9,24,224,.25), inset 0 1px 0 rgba(255,255,255,.12); }
.btn.primary:hover { background: var(--brand-deep); border-color: var(--brand-deep); }
.btn.dark { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.dark:hover { background: #000; }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--ink-2); }
.btn.ghost:hover { background: var(--bg-2); color: var(--ink); }
.btn.danger { color: var(--bad); border-color: var(--bad-line); background: #fff; }
.btn.danger:hover { background: var(--bad-bg); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.ok { color: var(--ok); border-color: var(--ok-line); } .btn.ok:hover { background: var(--ok-bg); }
.btn.sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; } .btn.sm svg { width: 14px; height: 14px; }
.btn.lg { height: 44px; padding: 0 20px; font-size: 15px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn[disabled], .btn.disabled { opacity: .5; pointer-events: none; }
.btn-spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; display: inline-block; animation: btn-spin .7s linear infinite; flex: none; }
@keyframes btn-spin { to { transform: rotate(360deg); } }
.btn-group { display: inline-flex; gap: 8px; flex-wrap: wrap; }

/* --------------------------------------------------------------------------
   Badges & pills
   -------------------------------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 8px; border-radius: 999px;
  font-size: 11.5px; font-weight: 600; letter-spacing: .02em; border: 1px solid var(--muted-line); background: var(--muted-bg); color: var(--ink-2); white-space: nowrap;
}
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.ok { background: var(--ok-bg); color: var(--ok); border-color: var(--ok-line); }
.badge.warn { background: var(--warn-bg); color: var(--warn); border-color: var(--warn-line); }
.badge.bad { background: var(--bad-bg); color: var(--bad); border-color: var(--bad-line); }
.badge.info { background: var(--info-bg); color: var(--info); border-color: var(--info-line); }
.badge.plain::before { display: none; }
.badge.lg { height: 28px; padding: 0 12px; font-size: 12.5px; }
.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 6px; background: var(--bg-2); font-size: 12px; font-weight: 500; color: var(--ink-2); }
.pill svg { width: 13px; height: 13px; flex: none; color: var(--ink-3); }
.pill.brand { background: var(--brand-soft); color: var(--brand); }
.code-tag { font-family: var(--font-mono); font-size: 11.5px; padding: 2px 6px; background: var(--bg-2); border-radius: 4px; color: var(--ink-2); }

/* --------------------------------------------------------------------------
   Avatars
   -------------------------------------------------------------------------- */
.avatar {
  width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink);
  display: inline-grid; place-items: center; font-size: 12.5px; font-weight: 600; letter-spacing: .02em; flex: none; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 28px; height: 28px; font-size: 10.5px; }
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar.xl { width: 80px; height: 80px; font-size: 26px; }
.avatar.dark { background: var(--ink); color: #fff; }
.avatar.trainer { background: #F3E9D2; color: #6B4E0B; }
.avatar.admin { background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.who .name { font-weight: 500; line-height: 1.2; }
.who .meta { font-size: 12px; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Tables
   -------------------------------------------------------------------------- */
.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 11.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 13px 20px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .1s; }
.table tbody tr:hover { background: var(--surface-2); }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .row-link { color: inherit; font-weight: 500; }
.table .row-link:hover { color: var(--brand); text-decoration: none; }
.table.compact th, .table.compact td { padding: 9px 16px; }

/* --------------------------------------------------------------------------
   Lists
   -------------------------------------------------------------------------- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); }
.list > li:last-child { border-bottom: 0; }
.list > li a.main { color: inherit; font-weight: 500; }
.list > li a.main:hover { color: var(--brand); text-decoration: none; }
.list .meta { font-size: 12.5px; color: var(--ink-3); }
.list .end { margin-left: auto; text-align: right; flex: none; }
.list.hover > li { transition: background .1s; } .list.hover > li:hover { background: var(--surface-2); }

/* Definition list */
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 10px 20px; font-size: 13.5px; }
.dl dt { color: var(--ink-3); } .dl dd { margin: 0; }
.dl.stacked { grid-template-columns: 1fr; gap: 12px; }
.dl.stacked dt { font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; margin-bottom: 2px; }

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field label, .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--ink-3); }
.field .error { font-size: 12.5px; color: var(--bad); }
.field.inline { flex-direction: row; align-items: center; gap: 10px; }
.field.inline input[type=checkbox] { margin: 0; }
.input, input[type=text], input[type=email], input[type=password], input[type=date], input[type=datetime-local], input[type=time], input[type=number], input[type=url], input[type=search], input[type=tel], select, textarea {
  width: 100%; height: 38px; padding: 0 12px; border-radius: 8px; border: 1px solid var(--line-strong); background: var(--surface);
  font-size: 14px; color: var(--ink); transition: border-color .12s, box-shadow .12s; box-shadow: var(--shadow-1);
}
textarea { height: auto; min-height: 96px; padding: 10px 12px; resize: vertical; line-height: 1.5; }
select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%236A6D78' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 34px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft-2); }
input::placeholder, textarea::placeholder { color: var(--ink-4); }
input[type=checkbox], input[type=radio] { width: 16px; height: 16px; accent-color: var(--brand); }
input[type=file] { height: auto; padding: 8px 12px; font-size: 13px; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 0 16px; }
.form-row.cols-3 { grid-template-columns: repeat(3, minmax(0,1fr)); }
.form-actions { display: flex; gap: 8px; align-items: center; justify-content: flex-end; padding-top: 8px; }
.form-actions.start { justify-content: flex-start; }
.check { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); cursor: pointer; }
.check:hover { border-color: var(--line-strong); }
.check input { margin-top: 3px; }
.check.declaration { background: var(--surface-2); }
.check b { display: block; font-weight: 500; } .check span { font-size: 12.5px; color: var(--ink-3); }
.search { position: relative; }
.search input { padding-left: 36px; }
.search svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-4); }
.errorlist { list-style: none; margin: 0; padding: 0; font-size: 12.5px; color: var(--bad); }

/* Signature pad */
.sig-pad { border: 1px dashed var(--line-strong); border-radius: 10px; background: #fff; position: relative; touch-action: none; overflow: hidden; }
.sig-pad canvas { display: block; width: 100%; height: 200px; cursor: crosshair; }
.sig-pad .line { position: absolute; left: 24px; right: 24px; bottom: 44px; border-top: 1px solid var(--line-strong); pointer-events: none; }
.sig-pad .hint { position: absolute; left: 24px; bottom: 20px; font-size: 12px; color: var(--ink-4); pointer-events: none; }
.sig-pad .x { position: absolute; left: 24px; bottom: 40px; font-family: var(--font-display); font-size: 20px; color: var(--ink-4); pointer-events: none; }
.sig-tools { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }

/* --------------------------------------------------------------------------
   Progress
   -------------------------------------------------------------------------- */
.progress { height: 6px; background: var(--bg-2); border-radius: 999px; overflow: hidden; }
.progress > span { display: block; height: 100%; background: var(--brand); border-radius: 999px; transition: width .4s ease; }
.progress.ok > span { background: var(--ok); } .progress.warn > span { background: var(--warn); }
.progress.lg { height: 10px; }
.ring { --p: 0; --size: 56px; width: var(--size); height: var(--size); border-radius: 50%; display: grid; place-items: center; background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--bg-2) 0); position: relative; flex: none; }
.ring::before { content: ""; position: absolute; inset: 5px; background: var(--surface); border-radius: 50%; }
.ring span { position: relative; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Tabs, dropdowns, alerts, toasts, modals
   -------------------------------------------------------------------------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs a { padding: 10px 14px; color: var(--ink-3); font-weight: 500; font-size: 13.5px; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tabs a:hover { color: var(--ink); text-decoration: none; }
.tabs a.active { color: var(--ink); border-bottom-color: var(--brand); }
.tabs a .n { margin-left: 6px; font-size: 11px; background: var(--bg-2); padding: 1px 6px; border-radius: 999px; color: var(--ink-3); }
.seg { display: inline-flex; background: var(--bg-2); padding: 3px; border-radius: 9px; gap: 2px; }
.seg a, .seg button { padding: 5px 12px; border-radius: 7px; font-size: 12.5px; font-weight: 500; color: var(--ink-3); border: 0; background: transparent; cursor: pointer; }
.seg .active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-1); }

details.dropdown { position: relative; }
details.dropdown > summary { list-style: none; cursor: pointer; }
details.dropdown > summary::-webkit-details-marker { display: none; }
.dropdown-menu { position: absolute; right: 0; top: calc(100% + 6px); min-width: 220px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; box-shadow: var(--shadow-2); padding: 6px; z-index: 40; }
.dropdown-menu a, .dropdown-menu button { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border-radius: 7px; color: var(--ink); font-size: 13.5px; background: none; border: 0; text-align: left; cursor: pointer; }
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu svg { width: 15px; height: 15px; color: var(--ink-3); }
.dropdown-menu hr { margin: 6px 0; }
.dropdown-menu .danger { color: var(--bad); }

.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-size: 13.5px; }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.alert.info { background: var(--info-bg); border-color: var(--info-line); color: var(--brand-ink); }
.alert.ok { background: var(--ok-bg); border-color: var(--ok-line); color: #10502F; }
.alert.warn { background: var(--warn-bg); border-color: var(--warn-line); color: #5E3D00; }
.alert.bad { background: var(--bad-bg); border-color: var(--bad-line); color: #7A1A14; }
.alert b { font-weight: 600; }

.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: 380px; }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; background: var(--ink); color: #fff; border-radius: 10px; box-shadow: var(--shadow-3); font-size: 13.5px; animation: toast-in .25s ease; }
.toast svg { width: 16px; height: 16px; flex: none; margin-top: 2px; }
.toast.success svg { color: #6FD39A; } .toast.error svg { color: #F09A93; } .toast.warning svg { color: #F5CE6E; }
.toast button { margin-left: auto; background: none; border: 0; color: #9C9FA9; cursor: pointer; padding: 0 2px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

dialog.modal { border: 0; border-radius: 14px; padding: 0; width: min(560px, calc(100vw - 32px)); box-shadow: var(--shadow-3); background: var(--surface); color: var(--ink); }
dialog.modal::backdrop { background: rgba(17,18,22,.45); backdrop-filter: blur(2px); }
dialog.modal .card-head { padding: 16px 20px; } dialog.modal .card-body { padding: 20px; }

/* --------------------------------------------------------------------------
   Empty states, timeline, misc
   -------------------------------------------------------------------------- */
.empty { text-align: center; padding: 44px 24px; color: var(--ink-3); }
.empty .glyph { width: 44px; height: 44px; border-radius: 12px; background: var(--bg-2); display: grid; place-items: center; margin: 0 auto 12px; color: var(--ink-4); }
.empty .glyph svg { width: 20px; height: 20px; }
.empty h4 { font-weight: 500; color: var(--ink); margin-bottom: 4px; }
.empty p { font-size: 13px; max-width: 360px; margin: 0 auto; }
.empty .btn { margin-top: 14px; }

.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--line); }
.timeline li { position: relative; padding: 0 0 18px 28px; }
.timeline li:last-child { padding-bottom: 0; }
.timeline li::before { content: ""; position: absolute; left: 3px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--surface); border: 2px solid var(--ink-4); }
.timeline li.ok::before { border-color: var(--ok); background: var(--ok); }
.timeline li.brand::before { border-color: var(--brand); background: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.timeline li.bad::before { border-color: var(--bad); background: var(--bad); }
.timeline li.warn::before { border-color: var(--warn); background: var(--warn); }
.timeline .t { font-size: 12px; color: var(--ink-3); margin-bottom: 2px; }
.timeline .b { font-size: 13.5px; }

.steps { display: flex; gap: 0; counter-reset: s; }
.steps > div { flex: 1; position: relative; padding: 0 12px 0 0; font-size: 12.5px; color: var(--ink-3); display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.steps > div::before { counter-increment: s; content: counter(s); display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--line-strong); font-size: 11px; font-weight: 600; background: var(--surface); position: relative; z-index: 1; }
.steps > div.done::before { background: var(--ok); border-color: var(--ok); color: #fff; content: "✓"; }
.steps > div.cur::before { background: var(--brand); border-color: var(--brand); color: #fff; }
.steps > div.cur { color: var(--ink); font-weight: 500; }
.steps > div::after { content: ""; position: absolute; top: 11px; left: 30px; right: 8px; height: 1px; background: var(--line); }
.steps > div:last-child::after { display: none; }
.steps > div.done::after { background: var(--ok); }

.kv { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-2); font-size: 13.5px; }
.kv:last-child { border-bottom: 0; }
.kv .k { color: var(--ink-3); } .kv .v { text-align: right; font-weight: 500; }

.course-tile { position: relative; overflow: hidden; }
.course-tile .band { height: 6px; background: var(--brand); }
.course-tile .code { font-family: var(--font-mono); font-size: 11.5px; color: var(--ink-3); letter-spacing: .02em; }
.course-tile h3 { font-family: var(--font-display); font-weight: 400; font-size: 22px; margin-top: 6px; }

.doc { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.doc .ic { width: 38px; height: 44px; border-radius: 6px; background: var(--bg-2); display: grid; place-items: center; color: var(--ink-3); font-family: var(--font-mono); font-size: 10px; font-weight: 600; flex: none; border: 1px solid var(--line); }
.doc .ic.pdf { background: #FCEAE8; color: var(--bad); border-color: var(--bad-line); }
.doc .ic.video { background: var(--brand-soft); color: var(--brand); border-color: var(--brand-soft-2); }
.doc .ic.link { background: #E7F4EC; color: var(--ok); border-color: var(--ok-line); }
.doc .ic svg { width: 18px; height: 18px; }
.doc .t { min-width: 0; } .doc .t b { display: block; font-weight: 500; } .doc .t span { font-size: 12.5px; color: var(--ink-3); }
.doc .end { margin-left: auto; display: flex; align-items: center; gap: 8px; flex: none; }

.cal { display: grid; grid-template-columns: repeat(7, minmax(0,1fr)); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.cal .dow { padding: 8px 10px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.cal .day { min-height: 104px; padding: 8px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; }
.cal .day.out { background: var(--surface-2); color: var(--ink-4); }
.cal .day .d { font-weight: 600; font-variant-numeric: tabular-nums; display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; }
.cal .day.today .d { background: var(--brand); color: #fff; }
.cal .ev { display: block; margin-top: 4px; padding: 3px 6px; border-radius: 5px; font-size: 11.5px; background: var(--brand-soft); color: var(--brand-ink); border-left: 2px solid var(--brand); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal .ev.comm { background: var(--muted-bg); color: var(--ink-2); border-left-color: var(--ink-4); }
.cal .ev.ok { background: var(--ok-bg); color: #10502F; border-left-color: var(--ok); }
.cal .ev:hover { text-decoration: none; filter: brightness(.97); }

.msg { display: flex; gap: 12px; padding: 14px 0; }
.msg .bubble { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 10px 14px; max-width: 72%; font-size: 13.5px; }
.msg.mine { flex-direction: row-reverse; } .msg.mine .bubble { background: var(--brand); color: #fff; border-color: var(--brand); }
.msg .m { font-size: 11.5px; color: var(--ink-4); margin-top: 4px; }
.msg.mine .m { text-align: right; }

.notif { display: flex; gap: 12px; padding: 12px 20px; border-bottom: 1px solid var(--line-2); }
.notif.unread { background: var(--brand-soft); }
.notif .ic { width: 32px; height: 32px; border-radius: 8px; background: var(--bg-2); display: grid; place-items: center; color: var(--ink-2); flex: none; }
.notif .ic svg { width: 15px; height: 15px; }
.notif .t b { font-weight: 500; } .notif .t p { font-size: 13px; color: var(--ink-3); margin: 2px 0 0; }
.notif .when { margin-left: auto; font-size: 12px; color: var(--ink-4); white-space: nowrap; }

.pagination { display: flex; gap: 4px; align-items: center; justify-content: flex-end; padding: 12px 20px; font-size: 13px; }
.pagination a, .pagination span { padding: 5px 9px; border-radius: 6px; color: var(--ink-2); }
.pagination a:hover { background: var(--bg-2); text-decoration: none; }
.pagination .cur { background: var(--ink); color: #fff; }

.filters { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.filters .search { flex: 1; min-width: 220px; }
.filters select { width: auto; min-width: 160px; }

.audit-hash { font-family: var(--font-mono); font-size: 11px; color: var(--ink-3); word-break: break-all; }
.sig-preview { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 8px; max-width: 280px; }
.sig-preview img { max-height: 80px; margin: 0 auto; }

.cert { border: 1px solid var(--line); border-radius: 14px; background: #fff; padding: 36px 40px; position: relative; overflow: hidden; }
.cert::before { content: ""; position: absolute; inset: 10px; border: 1px solid var(--line-strong); border-radius: 8px; pointer-events: none; }
.cert::after { content: ""; position: absolute; right: -20px; bottom: -30px; width: 300px; height: 340px; background: url("../img/sphinx-white.304ea12042c2.png") no-repeat center / contain; opacity: .07; pointer-events: none; filter: invert(1); }
.cert .cert-title { font-family: var(--font-display); font-size: 36px; margin: 16px 0 4px; }
.cert .cert-name { font-family: var(--font-display); font-size: 30px; font-style: italic; color: var(--brand); margin: 10px 0; }

/* --------------------------------------------------------------------------
   Auth layout
   -------------------------------------------------------------------------- */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand { background: var(--side-bg); color: #fff; padding: 40px 48px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-brand::after { content: ""; position: absolute; right: -80px; bottom: -60px; width: 560px; height: 620px; background: url("../img/sphinx-white.304ea12042c2.png") no-repeat center / contain; opacity: .07; pointer-events: none; }
.auth-brand .logo { display: flex; align-items: center; gap: 14px; }
.auth-brand .logo img { width: 52px; height: 52px; border-radius: 10px; }
.auth-brand .logo b { display: block; font-size: 15px; font-weight: 600; letter-spacing: .01em; }
.auth-brand .logo span { display: block; font-size: 11.5px; color: var(--side-text); letter-spacing: .08em; text-transform: uppercase; margin-top: 3px; }
.auth-brand .hero { margin: auto 0; max-width: 520px; position: relative; }
.auth-brand .hero h1 { font-family: var(--font-display); font-weight: 400; font-size: 52px; line-height: 1.05; color: #fff; letter-spacing: -0.01em; }
.auth-brand .hero h1 em { color: #7C86FF; font-style: italic; }
.auth-brand .hero p { color: var(--side-text); font-size: 15.5px; margin-top: 18px; max-width: 440px; }
.auth-brand .facts { display: flex; gap: 28px; margin-top: 36px; }
.auth-brand .facts div b { display: block; font-family: var(--font-display); font-size: 26px; color: #fff; }
.auth-brand .facts div span { font-size: 12px; color: var(--side-text); letter-spacing: .06em; text-transform: uppercase; }
.auth-brand .foot { font-size: 12px; color: #6E7280; position: relative; }
.auth-panel { display: grid; place-items: center; padding: 40px 24px; background: var(--bg); }
.auth-card { width: 100%; max-width: 420px; }
.auth-card .wordmark { width: 220px; margin-bottom: 36px; }
.auth-card h2 { font-family: var(--font-display); font-weight: 400; font-size: 32px; margin-bottom: 6px; }
.auth-card .lede { color: var(--ink-3); margin-bottom: 28px; }
.otp-input { height: 60px !important; text-align: center; font-family: var(--font-mono); font-size: 28px !important; letter-spacing: .5em; padding-left: .5em !important; }
.otp-input::placeholder { letter-spacing: .5em; color: var(--ink-5); }
.otp-resend { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 18px; font-size: 13px; }
.auth-card .foot { margin-top: 24px; font-size: 12.5px; color: var(--ink-3); text-align: center; }

/* Error pages */
.errpage { min-height: 100vh; display: grid; place-items: center; padding: 40px; text-align: center; }
.errpage .code { font-family: var(--font-display); font-size: 120px; line-height: 1; color: var(--ink-5); }

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  .side, .top, .toasts, .no-print { display: none !important; }
  .shell { grid-template-columns: 1fr; }
  body { background: #fff; }
  .card { box-shadow: none; }
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1180px) {
  :root { --gutter: 24px; }
  .grid.cols-4 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid.main-aside, .grid.aside-main { grid-template-columns: 1fr; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: fixed; left: 0; top: 0; bottom: 0; width: var(--side-w); z-index: 50; transform: translateX(-100%); transition: transform .2s ease; box-shadow: none; }
  body.side-open .side { transform: none; box-shadow: var(--shadow-3); }
  body.side-open::before { content: ""; position: fixed; inset: 0; background: rgba(17,18,22,.4); z-index: 45; }
  .menu-btn { display: grid; }
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .auth { grid-template-columns: 1fr; }
  .auth-brand { display: none; }
  .dl { grid-template-columns: 1fr; gap: 4px 0; } .dl dt { margin-top: 8px; }
}
@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .content { padding-top: 20px; }
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
  .form-row, .form-row.cols-3 { grid-template-columns: 1fr; }
  .page-head h1 { font-size: 28px; }
  .stat .value { font-size: 32px; }
  .top .crumbs .hide-sm { display: none; }
  .steps { flex-direction: column; gap: 10px; } .steps > div::after { display: none; }
  .cal .day { min-height: 64px; padding: 4px; } .cal .ev { font-size: 10px; padding: 2px 4px; }
  .msg .bubble { max-width: 90%; }
  .card-head, .card-body, .list > li, .table th, .table td { padding-left: 16px; padding-right: 16px; }
}
