/* ESS Brain admin: "white lab" futuristic look, after the client's reference.
   Cool grey-white ground, hairline frames, wide uppercase display type (Michroma), Inter for reading,
   one electric-blue signal colour, near-black primary buttons, soft deep shadows on white cards. */
:root {
  --bg: #eef1f5; --bg-2: #f6f8fb; --card: #fbfcfd; --surface: #f1f4f8; --ink: #0f141c; --ink-2: #2a3340; --muted: #6a7585;
  --line: #dde3ea; --line-strong: #c5ced9; --frame: #d3dae3;
  --signal: #2563eb; --signal-soft: rgb(37 99 235 / .12);
  --action: #0f141c; --action-ink: #ffffff; --danger: #c0392b; --ok: #15803d;
  /* departments: no violet */
  --dept-0: #15803d; --dept-1: #2563eb; --dept-2: #c27a12; --dept-3: #d1453b; --dept-4: #0e8a94; --dept-5: #5b6470;
  --font-display: "Michroma", "Eurostile", system-ui, sans-serif;
  --font-text: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Consolas, monospace;
  --r-sm: 8px; --r: 12px; --r-lg: 22px;
  --shadow: 0 30px 60px -20px rgb(15 20 28 / .14), 0 2px 6px rgb(15 20 28 / .04);
  --ease: cubic-bezier(.2,.8,.2,1); --ease-enter: cubic-bezier(.22,1,.36,1);
  --m-in: 150ms; --m-out: 120ms; --m-press: 90ms;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
html { min-height: 100%; background:
    radial-gradient(1200px 700px at 30% 20%, #fbfcfe 0%, transparent 70%),
    repeating-linear-gradient(90deg, transparent 0 119px, rgb(15 20 28 / .045) 119px 120px),
    linear-gradient(180deg, var(--bg-2), var(--bg)); }
body { margin: 0; color: var(--ink); font: 400 14.5px/1.6 var(--font-text); background: transparent; }
.side { min-height: 100vh; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 400; margin: 0; line-height: 1.2; color: var(--ink); }
h1 { font-size: clamp(24px, 2.3vw, 32px); letter-spacing: .02em; }
h2 { font-size: 15px; letter-spacing: .06em; text-transform: uppercase; }
p { margin: 0; }
a { color: inherit; text-decoration: none; }
code, pre { font-family: var(--font-mono); font-size: 12.5px; }
.muted { color: var(--muted); font-size: 13px; }
.mono-label, .eyebrow, th, .side__label, .tag-line {
  font-family: var(--font-display); font-size: 10.5px; letter-spacing: .22em; text-transform: uppercase; color: var(--muted); font-weight: 400; }
.eyebrow { color: var(--signal); }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: var(--r-sm); z-index: 10; }
.skip:focus { top: 12px; }
:focus-visible { outline: 2px solid var(--signal); outline-offset: 2px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 260px 1fr; min-height: 100vh; }
.side { position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 26px 18px 20px;
  background: rgb(251 252 253 / .72); backdrop-filter: blur(10px); border-right: 1px solid var(--frame); }
.brand { display: flex; align-items: center; gap: 12px; font: 400 15px/1 var(--font-display); letter-spacing: .28em; text-transform: uppercase; padding: 4px 8px 8px; }
.brand--lg { font-size: 17px; padding: 0; }
.mark { position: relative; width: 22px; height: 22px; border-radius: 50%; flex: none;
  background: radial-gradient(circle at 35% 30%, #ffffff, #c9d2de 70%); box-shadow: inset 0 -2px 4px rgb(15 20 28 / .12), 0 2px 6px rgb(15 20 28 / .12); }
.mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--signal); box-shadow: 0 0 0 3px var(--signal-soft), 0 0 8px rgb(37 99 235 / .6); }
.tag-line { padding: 0 8px 18px; color: #9aa4b2; font-size: 9px; }
.side nav, .side__depts { display: flex; flex-direction: column; }

/* level 1: section headings */
.side__label { display: flex; align-items: center; gap: 10px; margin: 22px 8px 8px; padding-bottom: 9px; color: var(--ink);
  border-bottom: 1px solid var(--ink); }
.side__label::before { content: ""; width: 5px; height: 5px; background: var(--signal); border-radius: 50%; box-shadow: 0 0 6px rgb(37 99 235 / .7); }
/* level 2: links */
.side nav > a, .side__depts > a { position: relative; display: flex; align-items: center; gap: 10px; min-height: 36px; margin-left: 13px; padding: 6px 12px;
  border-left: 1px solid var(--line); color: var(--muted); font-size: 14px;
  transition: color var(--m-out) var(--ease), background-color var(--m-out) var(--ease); }
.side a[aria-current="page"] { color: var(--ink); font-weight: 500; background: linear-gradient(90deg, var(--signal-soft), transparent 85%); }
.side a[aria-current="page"]::before { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; background: var(--signal); box-shadow: 0 0 8px rgb(37 99 235 / .6); }
.side__out { margin-top: auto; padding-top: 20px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--muted)); flex: none; display: inline-block; }

/* ---------- page frame ---------- */
.page { position: relative; padding: 46px clamp(22px, 4vw, 60px) 70px; max-width: 1280px; width: 100%; }
.page--full { max-width: none; padding: 0; }
.page::before { content: attr(data-tag); position: absolute; top: 16px; left: clamp(22px, 4vw, 60px);
  font: 400 9.5px/1 var(--font-display); letter-spacing: .26em; color: #9aa4b2; }
.page--full::before, .page--login::before { display: none; }
.head { margin-bottom: 30px; display: flex; flex-direction: column; gap: 10px; }
.lead { color: var(--muted); font-size: 15px; }
h1[data-enter] { margin-bottom: 22px; }
.head h1[data-enter] { margin: 0; }
.section-head { margin: 44px 0 14px; }

@media (prefers-reduced-motion: no-preference) {
  [data-enter] { animation: enter 650ms var(--ease-enter) both; }
  [data-enter] > * { animation: enter 750ms var(--ease-enter) both; }
  [data-enter] > *:nth-child(2) { animation-delay: 90ms; }
  [data-enter] > *:nth-child(3) { animation-delay: 180ms; }
  [data-enter] > *:nth-child(4) { animation-delay: 270ms; }
  @keyframes enter { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
}

/* ---------- cards ---------- */
.card { background: var(--card); border: 1px solid rgb(255 255 255 / .9); outline: 1px solid var(--line); border-radius: var(--r-lg); padding: 24px; box-shadow: var(--shadow); }
.card--link { display: block; transition: transform var(--m-out) var(--ease), box-shadow var(--m-out) var(--ease), outline-color var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .card--link:hover { transform: translateY(-2px); outline-color: var(--line-strong); box-shadow: 0 36px 70px -22px rgb(15 20 28 / .2), 0 2px 6px rgb(15 20 28 / .05); transition-duration: 180ms; }
}
.depts { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 20px; }
.dept { display: grid; grid-template-columns: auto 1fr; align-items: baseline; column-gap: 10px; row-gap: 4px; position: relative; overflow: hidden; }
.dept::before { content: ""; position: absolute; left: 24px; right: 24px; top: 0; height: 2px; background: var(--c); box-shadow: 0 0 10px var(--c); }
.dept__name { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; font: 400 11.5px/1 var(--font-display); letter-spacing: .18em; text-transform: uppercase; margin-bottom: 16px; }
.dept__num { font: 400 46px/1 var(--font-display); letter-spacing: -.01em; }
.dept__unit { color: var(--muted); font: 400 10px/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; }
.dept__split { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; margin-top: 18px; padding-top: 14px; border-top: 1px dashed var(--line-strong); font-size: 13px; color: var(--muted); }
.dept__split b { color: var(--ink); font-weight: 600; }
.dept__week { grid-column: 1 / -1; font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---------- buttons, links, forms ---------- */
.btn { font: 400 11px/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 22px; border-radius: var(--r); border: 1px solid transparent; cursor: pointer; white-space: nowrap;
  transition: transform var(--m-out) var(--ease), background-color var(--m-out) var(--ease), border-color var(--m-out) var(--ease), box-shadow var(--m-out) var(--ease); }
.btn--primary { background: var(--action); color: var(--action-ink); box-shadow: 0 10px 20px -10px rgb(15 20 28 / .5); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.side .btn--ghost { width: 100%; }
.btn--sm { min-height: 34px; padding: 0 14px; font-size: 9.5px; border-radius: var(--r-sm); }
.btn--danger { background: transparent; color: var(--danger); border-color: rgb(192 57 43 / .4); min-height: 36px; padding: 0 14px; font-size: 9.5px; border-radius: var(--r-sm); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover { transform: translateY(-1px); transition-duration: var(--m-in); }
  .btn--primary:hover { background: #222b38; }
  .btn--ghost:hover { background: var(--card); border-color: var(--ink-2); }
  .btn--danger:hover { background: rgb(192 57 43 / .07); border-color: var(--danger); }
  .side nav > a:hover, .side__depts > a:hover { color: var(--ink); background: linear-gradient(90deg, var(--surface), transparent 85%); transition-duration: var(--m-in); }
}
.btn:active { transform: translateY(1px) scale(.985); transition-duration: var(--m-press); }
.link, .note a, td a, .listing a, .crumbs a, .result a, .fold__note, .fold__open {
  color: var(--signal); background: linear-gradient(currentColor, currentColor) 0 100% / 0 1px no-repeat; transition: background-size var(--m-out) var(--ease); }
@media (hover: hover) and (pointer: fine) {
  .link:hover, .note a:hover, td a:hover, .listing a:hover, .crumbs a:hover, .result a:hover, .fold__note:hover, .fold__open:hover { background-size: 100% 1px; transition-duration: var(--m-in); }
}

label { display: flex; flex-direction: column; gap: 8px; font: 400 10px/1 var(--font-display); letter-spacing: .2em; text-transform: uppercase; color: var(--ink-2); }
input, select, textarea { font: 400 14.5px/1.4 var(--font-text); letter-spacing: 0; text-transform: none; color: var(--ink); background: #fff; border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 0 14px; min-height: 48px; transition: border-color var(--m-out) var(--ease), box-shadow var(--m-out) var(--ease); }
textarea { padding: 14px; font-family: var(--font-mono); font-size: 13px; line-height: 1.65; width: 100%; }
input:focus, select:focus, textarea:focus { border-color: var(--signal); outline: none; box-shadow: 0 0 0 4px var(--signal-soft); }
input[type=checkbox] { min-height: 0; accent-color: var(--signal); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.card { padding: 16px; }
.between { justify-content: space-between; }
.cols { display: grid; grid-template-columns: 1fr 360px; gap: 26px; align-items: start; }

/* ---------- tables, lists ---------- */
table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--card); border-radius: var(--r-lg); overflow: hidden; font-size: 14px;
  outline: 1px solid var(--line); box-shadow: var(--shadow); }
th, td { text-align: left; padding: 13px 18px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
th { font-size: 9.5px; background: var(--bg-2); }
td form { margin: 0; }
tr.revoked td { color: var(--muted); }
tr.revoked td:not(:last-child) { text-decoration: line-through; }
.nowrap { white-space: nowrap; }
h2 + table, h2 + .listing { margin-top: 14px; }
.page > h2 { margin: 36px 0 0; }

.listing { list-style: none; margin: 0; padding: 8px; background: var(--card); outline: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow); }
.listing li { padding: 11px 14px; border-radius: var(--r-sm); display: flex; align-items: center; gap: 10px; }
.listing li + li { border-top: 1px dashed var(--line); }
.crumbs { font-family: var(--font-mono); color: var(--muted); font-size: 12px; margin-bottom: 12px; }
.pill { display: inline-flex; align-items: center; font: 400 9.5px/1 var(--font-display); letter-spacing: .14em; text-transform: uppercase; padding: 7px 11px; border-radius: 99px;
  background: #fff; outline: 1px solid var(--line); color: var(--muted); margin: 0 6px 6px 0; }
.pill.tag { color: var(--signal); outline-color: rgb(37 99 235 / .25); background: var(--signal-soft); }
.meta { display: flex; flex-wrap: wrap; }

.note { background: var(--card); outline: 1px solid var(--line); box-shadow: var(--shadow); border-radius: var(--r-lg); padding: 16px clamp(22px, 4vw, 52px) 36px; margin-top: 16px; max-width: 860px; }
.note h1 { font-size: 26px; margin: 26px 0 10px; }
.note h2 { font-size: 12px; margin: 30px 0 8px; color: var(--signal); }
.note p, .note li { color: var(--ink-2); font-size: 15px; }
.note pre { background: var(--surface); padding: 14px; border-radius: var(--r-sm); overflow-x: auto; }
.result { padding: 18px 0; border-bottom: 1px dashed var(--line-strong); display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.result p { flex-basis: 100%; }
.result strong { font: 400 15px/1.3 var(--font-display); letter-spacing: .02em; }
pre { background: var(--surface); padding: 12px 14px; border-radius: var(--r-sm); overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.flash { padding: 13px 18px; border-radius: var(--r); margin-bottom: 22px; font-size: 14px; background: #fff; outline: 1px solid rgb(21 128 61 / .35); box-shadow: inset 3px 0 0 var(--ok); }
.flash.error { outline-color: rgb(192 57 43 / .35); box-shadow: inset 3px 0 0 var(--danger); }
.new-key { outline: 1px solid var(--signal); box-shadow: 0 0 0 6px var(--signal-soft), var(--shadow); margin-bottom: 22px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.new-key pre { width: 100%; margin: 0; }

/* ---------- folders (collapsible) ---------- */
.tree-card { padding: 14px 14px 18px; }
.tree-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 4px 6px 12px; margin-bottom: 6px; border-bottom: 1px dashed var(--line-strong); }
.fold { margin-left: 0; }
.fold .fold { margin-left: 18px; }
.fold > summary { list-style: none; display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 6px 10px; border-radius: var(--r-sm); cursor: pointer; user-select: none;
  transition: background-color var(--m-out) var(--ease); }
.fold > summary::-webkit-details-marker { display: none; }
@media (hover: hover) and (pointer: fine) { .fold > summary:hover { background: var(--surface); transition-duration: var(--m-in); } }
.fold__chev { width: 12px; height: 12px; color: var(--muted); flex: none; transition: transform 200ms var(--ease); }
.fold[open] > summary .fold__chev { transform: rotate(90deg); color: var(--signal); }
.fold__name { font-weight: 500; }
.fold__count { font: 400 9.5px/1 var(--font-display); letter-spacing: .1em; color: var(--muted); padding: 5px 8px; border-radius: 99px; outline: 1px solid var(--line); background: #fff; }
.fold__open { margin-left: auto; font-size: 12.5px; opacity: 0; transition: opacity var(--m-out) var(--ease); }
.fold > summary:hover .fold__open, .fold > summary:focus-visible .fold__open { opacity: 1; }
.fold__body { margin-left: 15px; padding: 2px 0 6px 10px; border-left: 1px solid var(--line); display: flex; flex-direction: column; }
.fold__note { align-self: flex-start; font-size: 13.5px; padding: 7px 10px; font-family: var(--font-mono); font-size: 12.5px; }
.fold__note--root { margin-left: 4px; }
.fold__empty { color: var(--muted); font-size: 12.5px; padding: 6px 10px; }
@media (hover: none) { .fold__open { opacity: 1; } }

/* ---------- login ---------- */
.page--login { display: grid; place-items: center; min-height: 100vh; max-width: none; padding: 32px; }
.lab { position: relative; width: min(1376px, 100%); min-height: min(836px, calc(100vh - 64px)); border: 1px solid var(--frame); border-radius: 34px;
  display: grid; grid-template-columns: 1.15fr 1fr; align-items: center; gap: 40px; padding: 60px clamp(28px, 6vw, 96px); }
.lab__tag { position: absolute; top: -8px; left: 40px; padding: 0 10px; background: var(--bg-2); font: 400 10px/16px var(--font-display); letter-spacing: .26em; color: var(--muted); }
.orbit { width: 100%; max-width: 560px; justify-self: center; overflow: visible; }
.orbit text { font-family: var(--font-display); font-size: 10.5px; letter-spacing: .26em; fill: var(--ink-2); }
@media (prefers-reduced-motion: no-preference) {
  .orbit__spin { transform-origin: 280px 280px; animation: spin 28s linear infinite; }
  .orbit__arc { transform-origin: 280px 280px; animation: spin 14s linear infinite reverse; }
  .orbit__pulse { transform-origin: 280px 280px; animation: pulse 3.2s ease-in-out infinite; }
  @keyframes spin { to { transform: rotate(360deg); } }
  @keyframes pulse { 0%, 100% { opacity: .35; transform: scale(1); } 50% { opacity: .9; transform: scale(1.25); } }
}
.login { width: 100%; max-width: 460px; justify-self: end; padding: 44px 44px 40px; display: flex; flex-direction: column; gap: 10px; }
.login h1 { font-size: 30px; margin-top: 24px; }
.login .lead { margin-bottom: 18px; color: var(--ink-2); }
.login .btn { width: 100%; min-height: 54px; margin-top: 4px; }
.login__note { color: var(--muted); font-size: 13.5px; margin-top: 14px; }

/* ---------- graph ---------- */
.graph-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 12px 18px; padding: 16px 24px; border-bottom: 1px solid var(--frame); background: rgb(251 252 253 / .8); backdrop-filter: blur(8px); }
.graph-bar input[type=search] { width: 260px; min-height: 40px; }
#legend { display: flex; flex-wrap: wrap; gap: 8px; }
#legend button { display: inline-flex; align-items: center; gap: 8px; font: 400 9.5px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
  background: #fff; border: 0; outline: 1px solid var(--line); border-radius: 99px; padding: 9px 13px; cursor: pointer; transition: opacity var(--m-out) var(--ease), transform var(--m-out) var(--ease); }
#legend button[aria-pressed="false"] { opacity: .35; }
#legend button:active { transform: scale(.97); }
.graph-bar label { flex-direction: row; align-items: center; gap: 8px; }
.graph-wrap { position: relative; height: calc(100vh - 74px); }
#graph { position: absolute; inset: 0; }
.graph-hint { position: absolute; left: 24px; bottom: 18px; font: 400 9.5px/1 var(--font-display); letter-spacing: .22em; text-transform: uppercase; color: var(--muted); pointer-events: none; }

/* ---------- small screens ---------- */
@media (max-width: 960px) {
  .lab { grid-template-columns: 1fr; padding: 48px 20px; }
  .orbit { max-width: 360px; }
  .login { justify-self: center; padding: 32px 24px; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--frame); padding: 16px; }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side__label, .side__depts, .tag-line { display: none; }
  .side nav > a { margin: 0; border-left: 0; }
  .side a[aria-current="page"]::before { display: none; }
  .side__out { margin: 0; padding-top: 10px; }
  .cols { grid-template-columns: 1fr; }
  .graph-wrap { height: 75vh; }
  table { display: block; overflow-x: auto; }
}
