/* firok-hub admin panel. Design: .agent/DESIGN-SYSTEM.md (Kancelaria, Mono palette).
   Colours live only in the two token blocks below, everything else uses tokens. */

@font-face {
  font-family: 'Literata Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url('/admin/static/fonts/literata-latin-ext-opsz-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Literata Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 200 900;
  src: url('/admin/static/fonts/literata-latin-opsz-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/admin/static/fonts/inter-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'Inter Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 900;
  src: url('/admin/static/fonts/inter-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

@font-face {
  font-family: 'JetBrains Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('/admin/static/fonts/jetbrains-mono-latin-ext-wght-normal.woff2') format('woff2');
  unicode-range: U+0100-02BA,U+02BD-02C5,U+02C7-02CC,U+02CE-02D7,U+02DD-02FF,U+0304,U+0308,U+0329,U+1D00-1DBF,U+1E00-1E9F,U+1EF2-1EFF,U+2020,U+20A0-20AB,U+20AD-20C0,U+2113,U+2C60-2C7F,U+A720-A7FF;
}

@font-face {
  font-family: 'JetBrains Mono Variable';
  font-style: normal;
  font-display: swap;
  font-weight: 100 800;
  src: url('/admin/static/fonts/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0304,U+0308,U+0329,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
}

:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --selected: #e8ecf5;
  --ink: #14214d;
  --body: #3b4768;
  --muted: #566180;
  --rule: #d3d9e6;
  --input-border: #6e7e9f;
  --action: #14214d;
  --action-hover: #26356b;
  --on-action: #ffffff;
  --accent: #7f92c4;
  --sidebar: #14214d;
  --sidebar-text: #dce3f3;
  --sidebar-active: #26356b;
  --on-sidebar: #ffffff;
  --focus-ring: #14214d;
  --info-text: #14214d;
  --disabled-bg: #e8ecf5;
  --disabled-text: #7a86a3;
  --ok-bg: #e3f4ea;
  --ok-text: #14532d;
  --warn-bg: #fff1d6;
  --warn-text: #7a4b00;

  --font-display: 'Literata Variable', Georgia, serif;
  --font-sans: 'Inter Variable', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono Variable', ui-monospace, monospace;

  --radius-control: 6px;
  --radius-card: 8px;
  --radius-pill: 999px;
  color-scheme: light;
}

:root[data-theme='dark'] {
  --bg: #0b1329;
  --surface: #121c3a;
  --selected: #1a2650;
  --ink: #f1f4fb;
  --body: #c3cbe0;
  --muted: #94a0bf;
  --rule: #26335f;
  --input-border: #6e7e9f;
  --action: #e8ecf5;
  --action-hover: #ffffff;
  --on-action: #14214d;
  --accent: #7f92c4;
  --sidebar: #080e20;
  --sidebar-text: #c3cbe0;
  --sidebar-active: #1f2d5c;
  --on-sidebar: #f1f4fb;
  --focus-ring: #e8ecf5;
  --info-text: #f1f4fb;
  --disabled-bg: #1a2650;
  --disabled-text: #7a86a3;
  --ok-bg: #123524;
  --ok-text: #8fe0b0;
  --warn-bg: #3a2a0a;
  --warn-text: #ffd27a;
  color-scheme: dark;
}

/* ---- base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--body); font: 400 15px/22px var(--font-sans); -webkit-font-smoothing: antialiased; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.015em; color: var(--ink); margin: 0; }
h1 { font-size: 32px; line-height: 38px; letter-spacing: -0.02em; }
h2 { font-size: 24px; line-height: 30px; }
h3 { font-size: 20px; line-height: 26px; }
p { margin: 0; }
a { color: var(--action); }
img, svg { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.num { font-family: var(--font-mono); font-weight: 500; font-size: 13px; line-height: 20px; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; font-weight: 500; letter-spacing: 0.1em; text-transform: uppercase; color: var(--action); }
.muted { color: var(--muted); }
.small { font-size: 13px; line-height: 18px; }
.right { text-align: right; }
.visually-hidden { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; left: 12px; top: -64px; z-index: 10; padding: 10px 16px; background: var(--action); color: var(--on-action); border-radius: var(--radius-control); font-weight: 600; }
.skip-link:focus { top: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-lg { display: flex; flex-direction: column; gap: 24px; }
.row { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.row-between { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }

/* ---- shell: sidebar and main ---- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 240px; flex-shrink: 0; background: var(--sidebar); color: var(--sidebar-text); padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.sidebar :focus-visible { outline-color: var(--on-sidebar); }
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 0 12px 20px; color: var(--on-sidebar); text-decoration: none; }
.sidebar-brand img { width: 42px; height: 42px; flex-shrink: 0; }
.sidebar-brand span { font-family: var(--font-display); font-weight: 600; font-size: 20px; letter-spacing: -0.015em; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border-radius: var(--radius-control); color: var(--sidebar-text); text-decoration: none; font-weight: 500; border-left: 3px solid transparent; }
.sidebar nav a:hover { background: var(--sidebar-active); }
.sidebar nav a[aria-current='page'] { background: var(--sidebar-active); color: var(--on-sidebar); border-left-color: var(--accent); }
.sidebar nav svg { width: 20px; height: 20px; flex-shrink: 0; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-foot { margin-top: auto; padding: 20px 12px 0; display: flex; flex-direction: column; gap: 12px; }
.sidebar-user { font-size: 13px; line-height: 18px; word-break: break-all; }
.sidebar-foot .btn { width: 100%; background: transparent; border: 1px solid color-mix(in srgb, var(--on-sidebar) 45%, transparent); color: var(--on-sidebar); }
.sidebar-foot .btn:hover { background: var(--sidebar-active); }
.sidebar-mark { display: block; width: 112px; height: auto; }
.main { flex: 1; min-width: 0; padding: 28px 32px 48px; display: flex; flex-direction: column; gap: 24px; }
.content { width: 100%; max-width: 1200px; margin-inline: auto; display: flex; flex-direction: column; gap: 24px; }
@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; padding: 16px; }
  .sidebar-brand { padding-bottom: 12px; }
  .sidebar nav { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); }
  .sidebar-foot { flex-direction: row; flex-wrap: wrap; align-items: center; justify-content: space-between; padding-top: 12px; }
  .sidebar-foot .btn { width: auto; }
  .sidebar-mark { width: 96px; }
  .main { padding: 20px 16px 40px; }
}

/* ---- page header ---- */
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-header .subtitle { margin-top: 4px; font-size: 14px; line-height: 20px; color: var(--muted); }
.page-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; }
.search { display: flex; gap: 8px; }
.search .field { width: 230px; max-width: 100%; }

/* ---- buttons and links ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 20px; border-radius: var(--radius-control); border: 1px solid transparent; font: 600 15px/22px var(--font-sans); text-decoration: none; cursor: pointer; transition: background-color .15s; }
.btn-primary { background: var(--action); color: var(--on-action); }
.btn-primary:hover { background: var(--action-hover); }
.btn-secondary { background: var(--surface); border-color: var(--input-border); color: var(--ink); }
.btn-secondary:hover { background: var(--selected); }
.btn:disabled, .btn[aria-disabled='true'] { background: var(--disabled-bg); color: var(--disabled-text); border-color: transparent; cursor: not-allowed; }
.link-text { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; color: var(--action); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 4px; }
.link-arrow { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 8px 16px; border: 1px solid var(--input-border); border-radius: var(--radius-control); font-weight: 600; color: var(--ink); text-decoration: none; transition: background-color .15s; }
.link-arrow::after { content: ''; width: 18px; height: 18px; flex-shrink: 0; background: currentColor; transition: transform .2s; -webkit-mask: url('/admin/static/img/arrow.svg') center / contain no-repeat; mask: url('/admin/static/img/arrow.svg') center / contain no-repeat; }
.link-arrow:hover { background: var(--selected); }
.link-arrow:hover::after { transform: translateX(4px); }
.row-link { display: inline-flex; align-items: center; min-height: 44px; min-width: 44px; color: var(--ink); font-weight: 600; text-decoration: none; }
.row-link:hover { text-decoration: underline; text-underline-offset: 3px; }
@media (prefers-reduced-motion: reduce) { .link-arrow:hover::after { transform: none; } .btn, .link-arrow, .link-arrow::after { transition: none; } }

/* ---- tags ---- */
.tag { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: var(--radius-pill); font-size: 13px; line-height: 18px; font-weight: 500; background: var(--selected); color: var(--info-text); white-space: nowrap; }
.tag::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag-ok { background: var(--ok-bg); color: var(--ok-text); }
.tag-warn { background: var(--warn-bg); color: var(--warn-text); }

/* ---- forms ---- */
.form { display: flex; flex-direction: column; gap: 20px; max-width: 640px; }
.form-wide { max-width: 880px; }
.form-full { max-width: none; }
.align-start { align-self: flex-start; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink); }
.field { width: 100%; min-height: 44px; padding: 10px 12px; background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--radius-control); color: var(--ink); font: 400 15px/22px var(--font-sans); }
textarea.field { min-height: 96px; resize: vertical; }
select.field { appearance: none; padding-right: 40px; background-image: url('/admin/static/img/chevron-dark.svg'); background-position: right 12px center; background-size: 16px 16px; background-repeat: no-repeat; }
:root[data-theme='dark'] select.field { background-image: url('/admin/static/img/chevron-light.svg'); }
.field:hover { border-color: var(--ink); }
.field::placeholder { color: var(--muted); }
.field[aria-invalid='true'] { border-color: var(--warn-text); }
.field-hint { margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--muted); }
.field-error { margin-top: 6px; font-size: 13px; line-height: 18px; color: var(--warn-text); font-weight: 500; }
.field-mono { font-family: var(--font-mono); font-weight: 500; font-size: 14px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.check input { appearance: none; flex-shrink: 0; width: 20px; height: 20px; margin: 0; border: 1.5px solid var(--input-border); border-radius: 4px; background: var(--surface); display: grid; place-content: center; cursor: pointer; }
.check input:checked { background: var(--action); border-color: var(--action); }
.check input:checked::after { content: ''; width: 5px; height: 10px; margin-top: -2px; border: solid var(--on-action); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.checks { display: flex; flex-wrap: wrap; gap: 4px 24px; }
.fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
.fieldset legend { padding: 0; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.quick .btn { min-height: 44px; padding: 8px 14px; font-size: 14px; }
@media (max-width: 640px) { .grid-2 { grid-template-columns: minmax(0, 1fr); } }

/* ---- panels, lists, tables ---- */
.panel { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-card); padding: 24px; }
.panel-flush { padding: 0; overflow: hidden; }
.panel > h2, .panel > h3 { margin-bottom: 16px; }
.hairline-list > * + * { border-top: 1px solid var(--rule); }
.kv { display: grid; grid-template-columns: minmax(110px, 160px) minmax(0, 1fr); gap: 4px 16px; padding: 10px 0; align-items: baseline; }
.kv dt { font-size: 13px; line-height: 18px; color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }
/* narrow screens: the label sits above the value, so numbers and tags keep their width */
@media (max-width: 480px) { .kv { grid-template-columns: minmax(0, 1fr); gap: 2px; } }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { height: 40px; padding: 0 16px; background: var(--bg); text-align: left; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.table td { height: 52px; padding: 8px 16px; border-top: 1px solid var(--rule); color: var(--body); vertical-align: middle; }
.table td.num, .table th.num { text-align: right; font-family: var(--font-mono); font-weight: 500; white-space: nowrap; }
.table td.mono { font-family: var(--font-mono); font-weight: 500; font-size: 13px; white-space: nowrap; }
.table td:first-child, .table th:first-child { min-width: 150px; }
.table-wrap > .table { min-width: 680px; }
.table tbody tr:hover td { background: var(--selected); }
.table tr.is-muted td { color: var(--muted); }
.table .actions { text-align: right; white-space: nowrap; }
.table-note { padding: 14px 16px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }

/* ---- tabs, pagination ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--rule); overflow-x: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; font-size: 15px; font-weight: 600; color: var(--muted); text-decoration: none; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-current='page'] { color: var(--ink); border-bottom-color: var(--action); }
.pagination { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--rule); }
.pagination-info { font-size: 13px; color: var(--muted); }
.pages { display: flex; flex-wrap: wrap; gap: 6px; }
.page-btn { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px; padding: 0 12px; border: 1px solid var(--input-border); border-radius: var(--radius-control); background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; font-family: var(--font-mono); font-size: 13px; }
a.page-btn:hover { background: var(--selected); }
.page-btn[aria-current='page'] { background: var(--action); border-color: var(--action); color: var(--on-action); }
.page-btn[aria-disabled='true'] { background: var(--disabled-bg); color: var(--disabled-text); border-color: transparent; }
.page-gap { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--muted); }

/* ---- KPI ---- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--radius-card); padding: 20px 22px; }
.kpi-label { font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-value { font-family: var(--font-display); font-weight: 600; font-size: 36px; line-height: 1.1; color: var(--ink); margin-top: 6px; }
.kpi-note { font-size: 13px; color: var(--body); margin-top: 4px; }

/* ---- dog-ear card ---- */
.card-frame { background: var(--rule); padding: 1px; clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%); }
.card-frame > .card { height: 100%; clip-path: polygon(0 0, calc(100% - 23px) 0, 100% 23px, 100% 100%, 0 100%); }
.card { position: relative; background: var(--surface); padding: 24px; }
.card > form > .btn { width: 100%; }
.card::after { content: ''; position: absolute; top: 0; right: 0; width: 24px; height: 24px; background: var(--accent); clip-path: polygon(0 0, 0 100%, 100% 100%); }
.card-lg.card-frame { clip-path: polygon(0 0, calc(100% - 48px) 0, 100% 48px, 100% 100%, 0 100%); }
.card-lg.card-frame > .card { clip-path: polygon(0 0, calc(100% - 47px) 0, 100% 47px, 100% 100%, 0 100%); padding: 32px; }
.card-lg .card::after { width: 48px; height: 48px; }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.two-col > * { min-width: 0; }
@media (max-width: 900px) { .two-col { grid-template-columns: minmax(0, 1fr); } }

/* ---- messages, empty state, key ---- */
.alert { padding: 12px 16px; border-radius: var(--radius-control); font-size: 14px; line-height: 20px; font-weight: 500; }
.alert-ok { background: var(--ok-bg); color: var(--ok-text); }
.alert-warn { background: var(--warn-bg); color: var(--warn-text); }
.empty { margin: 48px auto; max-width: 420px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.empty-icon { width: 56px; height: 56px; color: var(--muted); }
.empty-icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.key-box { padding: 20px; background: var(--surface); border: 1px solid var(--input-border); border-radius: var(--radius-control); font-family: var(--font-mono); font-weight: 500; font-size: 22px; line-height: 30px; color: var(--ink); letter-spacing: 0.04em; overflow-wrap: anywhere; user-select: all; }
.secret-box { padding: 14px 16px; background: var(--selected); border-radius: var(--radius-control); font-family: var(--font-mono); font-weight: 500; font-size: 15px; color: var(--ink); overflow-wrap: anywhere; user-select: all; }

/* ---- login ---- */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-box { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 24px; }
.login-logo { width: 180px; max-width: 70%; height: auto; }
.login-box .btn-primary { width: 100%; }
/* the wordmark is dark, so the dark theme shows the white one, a hidden image is ignored by screen readers */
.logo-on-dark { display: none; }
:root[data-theme='dark'] .logo-on-light { display: none; }
:root[data-theme='dark'] .logo-on-dark { display: block; }
