/* Self-hosted, because the CSP is `style-src 'self'` and a remote @import is blocked.
 *
 * The remote Google Fonts import was the only source of these families, so in
 * production the console has been falling back to a system font on every page load
 * and logging a CSP violation each time. Self-hosting also stops sending every
 * customer's IP to a third party on login and lets the console render offline, which
 * matters for a product sold to companies that may not allow outbound font requests.
 * Files are woff2, latin + latin-ext only: en, de and cs all live in those ranges. */
@import url('/static/fonts/fonts.css');

/* Skavio Agents — the same light design language as getskavio.com.
   Tokens first, so the palette stays consistent across every component.

   These values are copied from the live site's own stylesheet
   (../skavio-web-rebuild/frontend/src/style.css), not invented to look similar:
   --ink #101a35, --purple #6c5cff, --soft #f6f8fd, --line #e4e9f3, and the DM Sans /
   Manrope pairing. Keeping the literal values means a change on the marketing site can
   be diffed against this file rather than eyeballed. */
:root {
  --ink: #101a35;
  --ink-soft: #42516e;
  --ink-mute: #63708a;
  --line: #e4e9f3;
  --line-strong: #d3dbeb;
  --surface: #ffffff;
  --surface-sunk: #f6f8fd;
  --surface-raised: #ffffff;
  /* The site's action colour. `--brand` is kept as the name the rest of the stylesheet
     already uses, so this is a repaint rather than a rename that would touch 500 lines. */
  --brand: #6c5cff;
  --brand-ink: #5744e0;
  --brand-soft: #f0edff;
  --purple: #6c5cff;
  --soft: #f6f8fd;
  --ok: #149983;
  --ok-soft: #e5faf5;
  --warn: #9a6100;
  --warn-soft: #fdf3e2;
  --risk: #b3261e;
  --risk-soft: #fdecea;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(16, 26, 53, .04), 0 14px 34px -18px rgba(16, 26, 53, .18);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: "DM Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Manrope", "DM Sans", sans-serif;
}

* { box-sizing: border-box; }

/* Headings use Manrope on the marketing site; body copy stays DM Sans. One rule per
   family, so a section cannot drift into a third look. */
h1, h2, h3, h4, .brandtext { font-family: var(--display); letter-spacing: -.02em; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0 0 .5rem; }
h2 { font-size: 1.1rem; line-height: 1.3; margin: 0 0 .5rem; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--surface-sunk);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--surface);
  padding: .6rem 1rem;
  border-radius: var(--radius-sm);
  z-index: 50;
}
.skip:focus { left: 1rem; top: 1rem; }

/* ---------------------------------------------------------------- topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .7rem clamp(1rem, 4vw, 2rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: .6rem; }
.brandtext { font-weight: 620; letter-spacing: -.01em; }
.brandtext em { font-style: normal; color: var(--ink-mute); font-weight: 500; }
.mark {
  display: grid;
  place-items: center;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 9px;
  /* The site's gradient: purple into the lighter periwinkle used on its logo bars. */
  background: linear-gradient(160deg, var(--purple), #97a9ff);
  color: #fff;
  font-weight: 800;
  font-size: .95rem;
  font-family: var(--display);
}
.brand.big .mark { width: 2.1rem; height: 2.1rem; font-size: 1.05rem; }
.brand.big .brandtext { font-size: 1.05rem; }
.topbar-right { display: flex; align-items: center; gap: .6rem; }

/* Language switch. Two buttons rather than a dropdown: there are only two
   languages, and the current one should be visible without opening anything. */
.langswitch { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 6px; overflow: hidden; }
.langswitch .lang {
  font: inherit; font-size: .78rem; font-weight: 600; letter-spacing: .02em;
  padding: .3rem .55rem; background: transparent; color: var(--ink-mute);
  border: 0; cursor: pointer; min-width: 2.4rem;
}
.langswitch .lang[aria-pressed="true"] { background: var(--brand); color: #fff; }
.langswitch .lang:not([aria-pressed="true"]):hover { background: var(--surface-sunk); }


.pill {
  font-size: .78rem;
  color: var(--ink-soft);
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  padding: .2rem .6rem;
  border-radius: 999px;
  white-space: nowrap;
  max-width: 16rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ------------------------------------------------------------------ tabs --- */
.tabs {
  display: flex;
  gap: .15rem;
  padding: 0 clamp(.5rem, 4vw, 1.6rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 3.05rem;
  z-index: 19;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  appearance: none;
  border: 0;
  background: none;
  font: inherit;
  font-size: .88rem;
  color: var(--ink-mute);
  padding: .7rem .75rem;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: .4rem;
}
.tab:hover { color: var(--ink); }
.tab[aria-current="page"] { color: var(--brand-ink); border-bottom-color: var(--brand); font-weight: 560; }
.badge {
  background: var(--risk);
  color: #fff;
  border-radius: 999px;
  font-size: .68rem;
  font-weight: 700;
  padding: .05rem .4rem;
  min-width: 1.15rem;
  text-align: center;
}

/* ------------------------------------------------------------------ main --- */
main {
  max-width: 62rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(1rem, 4vw, 2rem) 4rem;
}
.view { display: grid; gap: 1rem; }
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: clamp(1rem, 2.5vw, 1.5rem);
  box-shadow: var(--shadow);
}
.panel h2 { font-size: 1.02rem; margin: 0 0 .35rem; letter-spacing: -.01em; }
.panel h3 { font-size: .9rem; margin: 1.2rem 0 .5rem; color: var(--ink-soft); text-transform: uppercase; letter-spacing: .04em; }
.lede { color: var(--ink-soft); margin: 0 0 1rem; font-size: .92rem; max-width: 46rem; }

.banner {
  margin-bottom: 1rem;
  padding: .7rem .9rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-strong);
  background: var(--surface);
  font-size: .9rem;
}
.banner.ok { background: var(--ok-soft); border-color: #bfe5d4; color: var(--ok); }
.banner.warn { background: var(--warn-soft); border-color: #f0dcb4; color: var(--warn); }
.banner.risk { background: var(--risk-soft); border-color: #f4c9c4; color: var(--risk); }

/* ----------------------------------------------------------------- cards --- */
.grid-cards {
  display: grid;
  gap: .85rem;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
}
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}
.card .label { font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); }
.card .value { font-size: 1.45rem; font-weight: 620; letter-spacing: -.02em; margin-top: .1rem; }
.card .sub { font-size: .82rem; color: var(--ink-mute); margin-top: .2rem; }
.card.attention { border-color: #f0dcb4; background: linear-gradient(0deg, var(--warn-soft), var(--surface) 60%); }

/* ----------------------------------------------------------------- forms --- */
.form { display: grid; gap: .9rem; }
label { display: grid; gap: .3rem; font-size: .86rem; color: var(--ink-soft); font-weight: 500; }
label.check { display: flex; align-items: center; gap: .5rem; font-weight: 400; }
label.check input { margin: 0; }
.hint { margin: -.5rem 0 0; font-size: .8rem; color: var(--ink-mute); }
input[type="email"], input[type="password"], input[type="date"], input[type="text"],
input[type="number"], select, textarea {
  font: inherit;
  font-size: .92rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .65rem;
  width: 100%;
}
textarea { resize: vertical; }
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible,
.tab:focus-visible, .drop:focus-within {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
}
.row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.row > label { flex: 1 1 10rem; }

.drop {
  display: grid;
  place-items: center;
  gap: .35rem;
  padding: 1.6rem 1rem;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius);
  background: var(--surface-sunk);
  cursor: pointer;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 400;
}
.drop:hover, .drop.active { border-color: var(--brand); background: var(--brand-soft); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { font-size: 1.2rem; color: var(--brand); }
.drop-text { font-size: .9rem; }
.drop-file { font-family: var(--mono); font-size: .82rem; color: var(--ink); }

/* --------------------------------------------------------------- buttons --- */
.btn {
  font: inherit;
  font-size: .9rem;
  font-weight: 540;
  border-radius: var(--radius-sm);
  padding: .5rem .9rem;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-sunk); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-ink); border-color: var(--brand-ink); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-soft); }
.btn.ghost:hover { background: var(--surface-sunk); color: var(--ink); }
.btn.danger { background: var(--risk); border-color: var(--risk); color: #fff; }
.btn.danger:hover { filter: brightness(.94); }
.btn.wide { width: 100%; justify-content: center; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn.small { padding: .3rem .6rem; font-size: .82rem; }

/* ---------------------------------------------------------------- status --- */
.status { margin-top: 1rem; font-size: .9rem; color: var(--ink-soft); display: flex; align-items: center; gap: .55rem; }
.spinner {
  width: 1rem; height: 1rem; border-radius: 50%;
  border: 2px solid var(--line-strong); border-top-color: var(--brand);
  animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- tables --- */
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-mute); font-weight: 600; }
tbody tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono { font-family: var(--mono); font-size: .84rem; }
.scroll { overflow-x: auto; }

/* ----------------------------------------------------------------- flags --- */
.flag {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: .6rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .87rem;
  border: 1px solid var(--line);
  margin-bottom: .45rem;
  background: var(--surface-sunk);
}
.flag .tag {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 700;
  padding: .12rem .4rem;
  border-radius: 4px;
  align-self: start;
  white-space: nowrap;
}
.flag.blocking { background: var(--risk-soft); border-color: #f4c9c4; }
.flag.blocking .tag { background: var(--risk); color: #fff; }
.flag.warning { background: var(--warn-soft); border-color: #f0dcb4; }
.flag.warning .tag { background: var(--warn); color: #fff; }
.flag.note, .flag.info { background: var(--brand-soft); border-color: #cfdffb; }
.flag.note .tag, .flag.info .tag { background: var(--brand); color: #fff; }
.flag.attention { background: var(--warn-soft); border-color: #f0dcb4; }
.flag.attention .tag { background: var(--warn); color: #fff; }
.flag.risk { background: var(--risk-soft); border-color: #f4c9c4; }
.flag.risk .tag { background: var(--risk); color: #fff; }

.kv { display: grid; grid-template-columns: minmax(7rem, 12rem) 1fr; gap: .3rem .9rem; font-size: .89rem; }
.kv dt { color: var(--ink-mute); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.big-total { font-size: 1.5rem; font-weight: 640; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }

.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: 1.1rem; }
.muted { color: var(--ink-mute); font-size: .85rem; }
.empty { color: var(--ink-mute); font-size: .9rem; padding: .6rem 0; }

.steps { margin: 0; padding-left: 1.2rem; color: var(--ink-soft); font-size: .91rem; display: grid; gap: .35rem; }
.steps b { color: var(--ink); font-weight: 600; }

.activity { display: grid; gap: .1rem; font-size: .89rem; }
.act-row {
  display: grid;
  grid-template-columns: 9.5rem 1fr auto;
  gap: .7rem;
  padding: .45rem .1rem;
  border-bottom: 1px solid var(--line);
  align-items: baseline;
}
.act-row:last-child { border-bottom: 0; }
.act-row time { color: var(--ink-mute); font-family: var(--mono); font-size: .78rem; }
.chip {
  font-size: .72rem;
  padding: .1rem .45rem;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  color: var(--ink-soft);
  white-space: nowrap;
}
.chip.ok { background: var(--ok-soft); border-color: #bfe5d4; color: var(--ok); }
.chip.warn { background: var(--warn-soft); border-color: #f0dcb4; color: var(--warn); }
.chip.risk { background: var(--risk-soft); border-color: #f4c9c4; color: var(--risk); }
.chip.info { background: var(--brand-soft); border-color: #cfdffb; color: var(--brand-ink); }

/* ---------------------------------------------------------------- modal --- */
/* The `hidden` attribute must win over an author `display`.
 *
 * `.modal` sets `display: grid`, and a class rule outranks the UA stylesheet's
 * `[hidden] { display: none }`. The closed dialog therefore stayed laid out as a
 * full-viewport overlay: the console rendered dimmed behind an empty white card and
 * every click landed on the overlay instead of the page. Any element styled with a
 * display value and toggled via the attribute needs this rule.
 */
[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(20, 24, 31, .45);
  display: grid;
  place-items: center;
  padding: 1rem;
  z-index: 40;
}
.modal-card {
  background: var(--surface);
  border-radius: 12px;
  padding: 1.25rem;
  max-width: 34rem;
  width: 100%;
  max-height: 88vh;
  overflow: auto;
  box-shadow: 0 24px 60px -20px rgba(20, 24, 31, .4);
}
.modal-card h2 { font-size: 1.05rem; margin: 0 0 .6rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: 1.2rem; }

/* ---------------------------------------------------------------- login --- */
.login-body { display: grid; place-items: center; min-height: 100vh; padding: 1.5rem; }
.login-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1.75rem;
  width: 100%;
  max-width: 24rem;
  box-shadow: 0 20px 50px -24px rgba(20, 24, 31, .3);
}
.login-card h1 { font-size: 1.2rem; margin: 1rem 0 .2rem; }
.error { color: var(--risk); font-size: .86rem; margin: .2rem 0 0; }

/* ------------------------------------------------------------ responsive --- */
@media (max-width: 640px) {
  html, body { font-size: 14.5px; }
  /* The header carries brand, tenant, language and sign-out. On a 390px screen the
     tenant name is the part that can go: the language switch must stay reachable. */
  .topbar { gap: .5rem; padding: .6rem .8rem; }
  .topbar-right { gap: .4rem; }
  #tenant-pill { display: none; }
  .brandtext { font-size: .95rem; }
  .tabs { top: 3rem; }
  .act-row { grid-template-columns: 1fr auto; }
  .act-row time { grid-column: 1 / -1; order: -1; }
  .kv { grid-template-columns: 1fr; }
  .kv dt { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
  .panel { padding: 1rem; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media (prefers-color-scheme: dark) {
  /* Kept light on purpose: accounting screens are printed and reviewed on paper,
     and a light surface matches the Skavio console the customer already uses. */
}

/* ---- operator alert page -------------------------------------------------
   Internal tool, English only. It reuses the console tokens so it looks like the
   same product to whoever is on call at 02:00. */
.card.risk { border-color: #f4c9c4; background: linear-gradient(0deg, var(--risk-soft), var(--surface) 60%); }
.card.warn { border-color: #f0dcb4; background: linear-gradient(0deg, var(--warn-soft), var(--surface) 60%); }

.ops-table { margin-top: .8rem; }
.ops-table th {
  text-align: left; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .05em; color: var(--ink-mute); font-weight: 600;
  padding: 0 .6rem .45rem 0; border-bottom: 1px solid var(--line);
}
.ops-table td { padding: .6rem .6rem .6rem 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.ops-table tr.row-critical td:first-child { box-shadow: inset 3px 0 0 var(--risk); padding-left: .5rem; }
.ops-table tr.row-warning td:first-child { box-shadow: inset 3px 0 0 var(--warn); padding-left: .5rem; }

.sev {
  display: inline-block; padding: .12rem .45rem; border-radius: 999px;
  font-size: .72rem; font-weight: 620; letter-spacing: .02em; white-space: nowrap;
}
.sev-critical { background: var(--risk-soft); color: var(--risk); }
.sev-warning { background: var(--warn-soft); color: var(--warn); }

@media (max-width: 640px) {
  /* Four columns do not fit a phone; the summary already carries the meaning. */
  .ops-table th:nth-child(4), .ops-table td:nth-child(4) { display: none; }
}

/* ------------------------------------------------------------- office (32) --- */
/* A horizontal task picker rather than five tabs: the five office tasks share one
   form, and adding five more top-level tabs would push the real navigation off a
   phone screen. */
.office-picker {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  margin: .2rem 0 1.1rem;
  padding-bottom: .7rem;
  border-bottom: 1px solid var(--line);
}
.office-task {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: var(--surface);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: .38rem .85rem;
  font: inherit;
  font-size: .86rem;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.office-task:hover { border-color: var(--brand); color: var(--brand-ink); }
.office-task[aria-pressed="true"] {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
  font-weight: 560;
}
.office-task:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

/* The price sits next to Create, so the cost is read at the moment of spending. It is
   muted rather than a warning: it is a preview, and the ledger is authoritative. */
.office-price {
  margin-left: .6rem;
  font-size: .85rem;
  color: var(--ink-mute);
  vertical-align: middle;
}

/* The draft text must be selectable and copyable exactly as produced, so it keeps
   monospace and wraps rather than truncating. */
.office-copy {
  margin: .5rem 0 .8rem;
  padding: .9rem 1rem;
  background: var(--surface-sunk);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .84rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 24rem;
  overflow-y: auto;
  user-select: text;
}

/* ------------------------------------------------------ document library (32) ---
   The library and editor are the "work on a document you already have" half of the
   product. Layout is a list that becomes a two-column editor, and on a phone both
   collapse to one column with the version panel below the text -- the text is what
   the customer came for, so it must never be the thing that scrolls off. */
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .8rem;
  flex-wrap: wrap;
  margin-bottom: .8rem;
}
.panel-head h2 { margin: 0; }
.panel-actions { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }

.lib-toolbar { display: flex; gap: .6rem; align-items: center; margin-bottom: .8rem; flex-wrap: wrap; }
.lib-toolbar input[type="search"] {
  flex: 1 1 14rem;
  min-width: 0;
  font: inherit;
  font-size: .9rem;
  padding: .5rem .7rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
}
.lib-toolbar input[type="search"]:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

.drop-inline {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  cursor: pointer;
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius-sm);
  padding: .5rem .8rem;
  font-size: .88rem;
  color: var(--ink-soft);
  background: var(--surface-sunk);
}
.drop-inline:hover, .drop-inline.over { border-color: var(--brand); color: var(--brand-ink); background: var(--brand-soft); }

.doc-list { display: flex; flex-direction: column; gap: .3rem; }
.doc-row { display: flex; align-items: center; gap: .5rem; }
.doc-open {
  flex: 1;
  display: flex;
  align-items: center;
  gap: .7rem;
  text-align: left;
  font: inherit;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: .55rem .6rem;
  cursor: pointer;
  min-width: 0;
}
.doc-open:hover { background: var(--surface-sunk); border-color: var(--line); }
.doc-open:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.doc-name {
  font-weight: 560;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1 1 auto;
}
.doc-detail { font-size: .8rem; color: var(--ink-mute); white-space: nowrap; }
.doc-when { font-size: .78rem; color: var(--ink-mute); white-space: nowrap; }
.doc-badge {
  flex: 0 0 auto;
  font-size: .66rem;
  font-weight: 700;
  letter-spacing: .04em;
  padding: .18rem .4rem;
  border-radius: 5px;
  background: var(--brand-soft);
  color: var(--brand-ink);
  font-family: var(--mono);
}
/* Format colour is a cue, not decoration: a red PDF reads as "read only" before the
   label is parsed. */
.doc-badge.badge-pdf { background: var(--risk-soft); color: var(--risk); }
.doc-badge.badge-xlsx { background: var(--ok-soft); color: var(--ok); }
.doc-badge.badge-docx { background: #eaf2ff; color: #2456a6; }

.editor-title { display: flex; align-items: center; gap: .6rem; min-width: 0; flex: 1 1 18rem; }
.editor-title input {
  font: inherit;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 620;
  border: 1px solid transparent;
  background: transparent;
  border-radius: var(--radius-sm);
  padding: .3rem .5rem;
  color: var(--ink);
  min-width: 0;
  flex: 1;
}
.editor-title input:hover { border-color: var(--line); }
.editor-title input:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; background: var(--surface); }
.editor-meta { font-size: .78rem; color: var(--ink-mute); white-space: nowrap; }

.editor-body { display: grid; grid-template-columns: minmax(0, 1fr) 16rem; gap: 1rem; align-items: start; }
#editor-text {
  font: inherit;
  font-size: .94rem;
  line-height: 1.65;
  min-height: 24rem;
  /* A4-ish proportions: the editor should read like the page it becomes, and a
     full-bleed textarea on a wide monitor is unreadable at 100 characters a line. */
  width: 100%;
  padding: .9rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  font-family: var(--sans);
}
#editor-text:read-only { background: var(--surface-sunk); color: var(--ink-soft); }
#editor-text:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; border-color: var(--brand); }

.editor-side h3 {
  font-size: .74rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--ink-mute);
  margin: 1rem 0 .5rem;
}
.editor-side h3:first-child { margin-top: 0; }
.version-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .3rem; }
.version-list li {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .1rem .4rem;
  padding: .4rem .5rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: .82rem;
}
.version-list li.current { border-color: var(--brand); background: var(--brand-soft); }
.version-open {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  gap: .45rem;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  text-align: left;
  cursor: pointer;
  color: inherit;
  min-width: 0;
}
.version-number { font-family: var(--mono); font-weight: 700; font-size: .78rem; }
.version-meta { color: var(--ink-mute); font-size: .76rem; }
.version-when { margin-left: auto; color: var(--ink-mute); font-size: .72rem; white-space: nowrap; }
.version-note { grid-column: 1 / -1; color: var(--ink-soft); font-size: .76rem; font-style: italic; }
.version-restore {
  grid-column: 2;
  justify-self: end;
  font: inherit;
  font-size: .74rem;
  background: none;
  border: 1px solid var(--line-strong);
  border-radius: 5px;
  padding: .1rem .45rem;
  color: var(--ink-soft);
  cursor: pointer;
}
.version-restore:hover { border-color: var(--brand); color: var(--brand-ink); }

.export-row { display: flex; gap: .35rem; flex-wrap: wrap; }
.export-row .btn { text-decoration: none; }
.empty { color: var(--ink-mute); font-size: .9rem; }
.muted { color: var(--ink-mute); font-size: .82rem; }

/* The navigation is now task-first with eleven entries, so it scrolls. A fade at the
   right edge is the only cue that there is more; without it the last tab looks cut off
   rather than scrolled past. */
.tabs {
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.tabs::after {
  content: "";
  position: sticky;
  right: 0;
  flex: 0 0 1.5rem;
  pointer-events: none;
}

@media (max-width: 860px) {
  .editor-body { grid-template-columns: 1fr; }
  #editor-text { min-height: 18rem; }
  .editor-side { border-top: 1px solid var(--line); padding-top: .5rem; }
}

@media (max-width: 640px) {
  .doc-detail, .doc-when { display: none; }
  .doc-name { font-size: .92rem; }
  .panel-head { align-items: flex-start; }
  .editor-title { flex-basis: 100%; }
  .editor-title input { font-size: 1rem; }
  .editor-meta { display: none; }
  /* 16px stops iOS Safari zooming the page when the field is focused. */
  #editor-text { font-size: 16px; }
}
