/* SETSTUD — адмін-панель банку завдань НМТ. Світла тема, системний шрифт. */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --border: #e1e4e9;
  --border-strong: #c9cfd7;
  --text: #1b2230;
  --muted: #586273;
  --faint: #8790a0;
  --primary: #2350b5;
  --primary-hover: #1b4096;
  --primary-soft: #e8eefa;
  --danger: #b9342a;
  --danger-hover: #9a2a22;
  --danger-soft: #fcebe9;
  --success: #1b7a3a;
  --success-soft: #e4f3e9;
  --warning: #a65908;
  --warning-soft: #fff0dd;
  --correct: #1b7a3a;
  --correct-bg: #eaf6ee;
  --correct-border: #9fd3b0;
  --radius: 8px;
  --radius-sm: 5px;
  --shadow: 0 1px 2px rgba(20, 30, 50, .06);
  --shadow-lg: 0 10px 30px rgba(20, 30, 50, .18);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.3; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }
p { margin: 0 0 8px; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { margin: 0; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-word; }
hr { border: 0; border-top: 1px solid var(--border); margin: 12px 0; }
.boot { padding: 40px; color: var(--muted); }

/* ---------- верхня панель ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: 52px; padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.brand-mark {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--primary); color: #fff; font-size: 13px; font-weight: 700;
}
.brand-sub { color: var(--muted); font-weight: 500; letter-spacing: 0; }
.tabs { display: flex; gap: 2px; height: 100%; overflow-x: auto; scrollbar-width: none; flex: 1; min-width: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
  display: flex; align-items: center; padding: 0 12px; height: 100%;
  color: var(--muted); font-weight: 500; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; background: var(--surface-2); }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.topbar-right { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.env-pill { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; }
@media (max-width: 1020px) {
  /* вузький екран: вкладки переносяться в другий рядок */
  .topbar { flex-wrap: wrap; height: auto; padding: 8px 16px 0; row-gap: 6px; }
  .topbar-right { margin-left: auto; }
  .tabs { order: 3; flex-basis: 100%; height: 40px; margin: 0 -4px; }
  .tabs a { padding: 0 10px; }
}
@media (max-width: 560px) { .brand-sub { display: none; } }

/* ---------- сторінка ---------- */
.page { max-width: 1440px; margin: 0 auto; padding: 20px 20px 60px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 14px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 2px; }
.page-head-actions { display: flex; gap: 8px; align-items: center; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 16px; min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.card-head .hint { color: var(--muted); font-size: 12.5px; font-weight: 400; }
.card-body { padding: 14px 16px; }
.card-body.flush { padding: 0; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.section-title { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 0 0 6px; }

.cols { display: grid; gap: 16px; align-items: start; }
.cols-detail { grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); }
.cols-side { grid-template-columns: 300px minmax(0, 1fr); }
@media (max-width: 1000px) {
  .cols-detail, .cols-side { grid-template-columns: minmax(0, 1fr); }
}

.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 10px; }
.pre { white-space: pre-wrap; word-break: break-word; }
.hidden { display: none !important; }
.sep { color: var(--border-strong); margin: 0 2px; }

/* ---------- форми ---------- */
.form-grid { display: grid; gap: 12px 16px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.span-12 { grid-column: span 12; } .span-9 { grid-column: span 9; } .span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; } .span-6 { grid-column: span 6; } .span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; } .span-3 { grid-column: span 3; } .span-2 { grid-column: span 2; }
@media (max-width: 900px) {
  .span-9, .span-8, .span-7, .span-6, .span-5, .span-4, .span-3, .span-2 { grid-column: span 12; }
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.field .help { font-size: 12px; color: var(--faint); }
input[type="text"], input[type="password"], input[type="number"], input[type="search"], input[type="url"], select, textarea {
  font: inherit; color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  min-height: 34px;
  width: 100%;
  min-width: 0;
}
textarea { min-height: 70px; resize: vertical; line-height: 1.45; }
textarea.code { font-family: var(--mono); font-size: 12.5px; min-height: 420px; tab-size: 2; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(35, 80, 181, .25); outline-offset: 0; border-color: var(--primary); }
input:disabled, select:disabled, textarea:disabled { background: var(--surface-2); color: var(--faint); }

/* Спадні списки. Власна стрілка — в усіх браузерах; сам розкритий список стилізується там,
   де є customizable select (Chromium 135+), в інших браузерах він лишається системним. */
select {
  appearance: none;
  padding-right: 30px;
  /* колір штриха = --muted (у data-URI змінні недоступні) */
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23586273' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.25 8 10.25l4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  background-size: 14px;
  cursor: pointer;
  transition: border-color .12s;
}
select:hover:not(:disabled, :focus) { border-color: var(--faint); }
select:disabled { cursor: not-allowed; }

@supports (appearance: base-select) {
  select, ::picker(select) { appearance: base-select; }
  select { background-image: none; padding-right: 9px; align-items: center; gap: 8px; }
  select::picker-icon {
    content: "";
    flex: none;
    width: 14px; height: 14px;
    margin-left: auto;
    background: var(--muted);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='1.75' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 6.25 8 10.25l4-4'/%3E%3C/svg%3E") center / 14px no-repeat;
    transition: rotate .2s cubic-bezier(.16, 1, .3, 1);
  }
  select:open { border-color: var(--primary); }
  select:open::picker-icon { rotate: 180deg; background: var(--primary); }
  select:disabled::picker-icon { background: var(--faint); }

  ::picker(select) {
    margin-block: 4px;
    padding: 4px;
    max-inline-size: min(480px, calc(100vw - 16px));
    max-block-size: min(460px, calc(100vh - 24px));
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-strong) transparent;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    translate: 0 -4px;
    transition: opacity .14s ease-out, translate .18s cubic-bezier(.16, 1, .3, 1), overlay .14s allow-discrete, display .14s allow-discrete;
  }
  ::picker(select):popover-open { opacity: 1; translate: 0 0; }
  @starting-style {
    ::picker(select):popover-open { opacity: 0; translate: 0 -4px; }
  }

  option {
    display: flex; align-items: center; gap: 12px;
    min-block-size: 32px;
    padding: 5px 10px;
    border-radius: var(--radius-sm);
    white-space: normal;
    cursor: pointer;
  }
  option + option { margin-top: 1px; }
  option:hover, option:focus-visible { background: var(--primary-soft); }
  option:focus-visible { outline: 2px solid rgba(35, 80, 181, .35); outline-offset: -2px; }
  option:checked { color: var(--primary); font-weight: 600; }
  /* позначка обраного — праворуч, намальована, а не системний символ */
  option::checkmark {
    content: "";
    order: 1;
    flex: none;
    width: 14px; height: 14px;
    margin-left: auto;
    background: currentColor;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / 14px no-repeat;
  }
  option:disabled { color: var(--faint); background: none; cursor: not-allowed; }

  /* заголовок групи — як .section-title; пункти групи повертають звичайний текст */
  optgroup {
    padding-top: 6px;
    font-size: 11.5px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    color: var(--muted);
  }
  optgroup + optgroup { margin-top: 6px; border-top: 1px solid var(--border); }
  optgroup > option { margin-top: 3px; font-size: 14px; font-weight: 400; letter-spacing: 0; text-transform: none; color: var(--text); }
  optgroup > option:checked { color: var(--primary); font-weight: 600; }
  optgroup > option:disabled { color: var(--faint); }

  @media (prefers-reduced-motion: reduce) {
    ::picker(select), select::picker-icon { transition: none; }
  }
}
input[type="number"] { font-variant-numeric: tabular-nums; }
input[type="file"] { font: inherit; font-size: 13px; }
.file-pick { position: relative; overflow: hidden; }
.file-pick input[type="file"] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: pointer; }
.file-pick:focus-within { outline: 2px solid rgba(35, 80, 181, .35); outline-offset: 1px; }
.check { display: inline-flex; align-items: center; gap: 7px; cursor: pointer; user-select: none; }
.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--primary); }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 12px 12px; margin: 0; min-width: 0; }
legend { font-size: 12.5px; font-weight: 600; color: var(--muted); padding: 0 4px; }
.input-suffix { display: flex; align-items: center; gap: 6px; }
.input-suffix input { width: 72px; text-align: right; }
.form-error { color: var(--danger); background: var(--danger-soft); border: 1px solid #f2c4bf; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.form-note { color: var(--muted); background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; }

/* розподіл за типами / складністю */
.mix-list { display: flex; flex-direction: column; gap: 6px; }
.mix-row { display: grid; grid-template-columns: minmax(0, 1fr) 76px; align-items: center; gap: 10px; }
.mix-row .lbl { font-size: 13px; line-height: 1.3; }
.mix-row .lbl small { display: block; color: var(--faint); font-size: 11.5px; }
.mix-row input { text-align: right; }
.mix-total { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--border); display: flex; justify-content: space-between; font-weight: 600; }
.mix-total.bad { color: var(--danger); }

/* ---------- кнопки ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; font-size: 13.5px;
  min-height: 34px; padding: 6px 14px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: #b5bcc6; text-decoration: none; }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #156530; border-color: #156530; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); border-color: var(--danger-hover); }
.btn-danger-outline { color: var(--danger); border-color: #e7b3ad; }
.btn-danger-outline:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); border-color: transparent; }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 12.5px; }
.btn-link { background: none; border: 0; padding: 0; min-height: 0; color: var(--primary); font: inherit; cursor: pointer; }
.btn-link:hover { text-decoration: underline; }
.btn-group { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.busy { position: relative; color: transparent !important; }
.busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,.6); border-top-color: transparent;
  animation: spin .7s linear infinite;
}
.btn:not(.btn-primary):not(.btn-danger):not(.btn-success).busy::after { border-color: var(--faint); border-top-color: transparent; }
@keyframes spin { to { transform: rotate(360deg); } }

.confirm-inline { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--danger-soft); border: 1px solid #f0c3be; border-radius: var(--radius-sm); padding: 4px 6px 4px 10px; }
.confirm-inline .q { color: var(--danger); font-size: 13px; font-weight: 500; }

/* ---------- бейджі ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 600; line-height: 1;
  padding: 4px 8px; border-radius: 999px; white-space: nowrap;
  background: #eef0f3; color: #495363; border: 1px solid transparent;
}
.badge-sm { font-size: 11px; padding: 3px 7px; }
.badge .n { font-variant-numeric: tabular-nums; opacity: .85; }
.st-draft { background: #eef0f4; color: #4b5566; }
.st-verifying { background: #e4edff; color: #1d4fc4; }
.st-fixing { background: #efe7ff; color: #6430c9; }
.st-needs_attention { background: #ffeed8; color: #a24f00; }
.st-review { background: #dff3f1; color: #0b6d64; }
.st-published { background: #e0f3e6; color: #17703a; }
.st-rejected { background: #fbe4e2; color: #a92b22; }
.gs-queued { background: #eef0f4; color: #4b5566; }
.gs-running { background: #e4edff; color: #1d4fc4; }
.gs-done { background: #e0f3e6; color: #17703a; }
.gs-failed { background: #fbe4e2; color: #a92b22; }
.sev-critical { background: #c62f24; color: #fff; }
.sev-major { background: #f08a1c; color: #fff; }
.sev-minor { background: #e3e6eb; color: #4b5566; }
.verdict-ok { background: #e0f3e6; color: #17703a; }
.verdict-fix { background: #ffeed8; color: #a24f00; }
.verdict-reject { background: #fbe4e2; color: #a92b22; }
.badge-outline { background: transparent; border-color: var(--border-strong); color: var(--muted); }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.pulse { width: 7px; height: 7px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: .25; } }
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 12.5px; padding: 2px 4px 2px 10px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); border: 1px solid #c9d6f2;
}
.chip button { border: 0; background: transparent; color: inherit; cursor: pointer; font-size: 15px; line-height: 1; padding: 0 6px; border-radius: 999px; }
.chip button:hover { background: rgba(35,80,181,.12); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 4px; background: #eef0f3; color: #4b5566; margin: 0 4px 4px 0; }
.keycode { font-family: var(--mono); font-size: 12.5px; background: #f1f3f6; border: 1px solid var(--border); border-radius: 4px; padding: 1px 6px; white-space: nowrap; }

/* ---------- таблиці ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
table.data th { font-size: 12px; font-weight: 600; color: var(--muted); background: var(--surface-2); white-space: nowrap; position: sticky; top: 0; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover td { background: #f7f9fd; }
table.data tbody tr.selected td { background: #f0f4fd; }
table.data td.cb, table.data th.cb { width: 34px; padding-right: 0; }
table.data tfoot td { font-weight: 600; background: var(--surface-2); border-top: 1px solid var(--border); }
table.data .err-row td { background: #fff8f7; color: var(--danger); font-size: 12.5px; padding-top: 0; }
table.data.compact th, table.data.compact td { padding: 6px 10px; }
table.data td.actions { white-space: nowrap; text-align: right; }
table.data input[type="text"], table.data textarea { min-height: 30px; padding: 4px 7px; font-size: 13px; }
table.data textarea { min-height: 54px; }

.stem-preview {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  min-width: 220px; max-width: 620px; line-height: 1.45; color: var(--text);
}
.keycode-wrap { white-space: normal; display: inline-block; max-width: 118px; line-height: 1.45; }
.stem-preview a { color: inherit; }
.cell-sub { font-size: 12px; color: var(--muted); }

.empty { padding: 36px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--text); margin-bottom: 4px; }
.loading { padding: 28px 16px; text-align: center; color: var(--faint); }

/* ---------- фільтри / пагінація ---------- */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.filters .field { width: 180px; }
.filters .field.grow { flex: 1; min-width: 200px; width: auto; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.seg button {
  font: inherit; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
}
.seg button:hover { border-color: #aab2bd; }
.seg button.active { background: var(--text); border-color: var(--text); color: #fff; }
.seg button .n { font-variant-numeric: tabular-nums; font-size: 12px; padding: 0 7px; border-radius: 999px; background: #eef0f3; color: var(--muted); }
.seg button.active .n { background: rgba(255,255,255,.18); color: #fff; }
.seg .dot { width: 8px; height: 8px; border-radius: 50%; }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--border); }
.bulkbar {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 16px; background: #f0f4fd; border-bottom: 1px solid #d5def3;
}
.bulkbar .count { font-weight: 600; margin-right: 6px; }

/* ---------- конвеєр ---------- */
.pipeline { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin: 0 0 14px; }
.pipeline .step { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; padding: 3px 11px; color: var(--text); }
.pipeline .arrow { color: var(--faint); }

/* ---------- toast ---------- */
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 100; display: flex; flex-direction: column; gap: 8px; max-width: min(440px, calc(100vw - 32px)); }
.toast {
  display: flex; gap: 10px; align-items: flex-start;
  background: var(--text); color: #fff; padding: 10px 12px 10px 14px;
  border-radius: var(--radius); box-shadow: var(--shadow-lg); font-size: 13.5px;
  border-left: 4px solid #6b7a90; animation: toast-in .18s ease-out;
}
.toast.error { border-left-color: #f0645a; }
.toast.success { border-left-color: #4cc27a; }
.toast .msg { flex: 1; white-space: pre-wrap; word-break: break-word; }
.toast button { background: none; border: 0; color: #c9d0da; cursor: pointer; font-size: 16px; line-height: 1; padding: 0 2px; }
.toast button:hover { color: #fff; }
@keyframes toast-in { from { transform: translateY(6px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ---------- вхід ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: 380px; max-width: 100%; }
.login .brand { margin-bottom: 4px; font-size: 16px; }
.login .card-body { padding: 22px; }

/* ---------- рендер завдання ---------- */
.item-view { font-size: 15px; line-height: 1.6; }
.item-view .katex { font-size: 1.08em; }
.stimulus { background: #fbfaf6; border: 1px solid #ebe6d6; border-left: 3px solid #d8cfae; border-radius: var(--radius-sm); padding: 10px 14px; margin-bottom: 12px; }
.stimulus .lbl { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: #8a7d55; font-weight: 600; margin-bottom: 4px; }
.gap { display: inline-block; font-size: 11.5px; font-weight: 700; line-height: 1; padding: 3px 6px; margin: 0 2px; border-radius: 4px; background: #fff3c4; color: #7a5a00; border: 1px solid #ecd47a; vertical-align: 1px; font-family: var(--mono); }
table.stim-table { border-collapse: collapse; margin: 8px 0 12px; font-size: 14px; }
table.stim-table th, table.stim-table td { border: 1px solid var(--border-strong); padding: 5px 10px; text-align: left; vertical-align: top; }
table.stim-table th { background: var(--surface-2); font-weight: 600; }
.media { margin: 6px 0 14px; }
.media img { display: block; max-width: 100%; max-height: 380px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: #fff; }
.media .caption { font-size: 13px; color: var(--muted); margin-top: 6px; }
.media .editor-note { font-size: 12px; color: var(--faint); margin-top: 4px; border-top: 1px dashed var(--border); padding-top: 4px; }
.warn-box { background: var(--warning-soft); color: var(--warning); border: 1px solid #f5d1a1; border-radius: var(--radius-sm); padding: 8px 10px; font-size: 13px; margin: 6px 0 12px; }
.stem { font-size: 15.5px; margin: 4px 0 14px; }
.opts { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; }
.opt {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: start; gap: 10px;
  padding: 7px 10px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface);
}
.opt .k {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 5px; background: #eef0f3; color: #3a4352;
  font-weight: 700; font-size: 13.5px; font-family: var(--font);
}
.opt .t { padding-top: 1px; min-width: 0; overflow-wrap: anywhere; }
.opt .mark { font-size: 11.5px; font-weight: 600; color: var(--correct); padding-top: 4px; white-space: nowrap; }
.opt.correct { background: var(--correct-bg); border-color: var(--correct-border); }
.opt.correct .k { background: var(--correct); color: #fff; }
.match-cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
@media (max-width: 700px) { .match-cols { grid-template-columns: minmax(0, 1fr); } }
.answer-line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; padding: 8px 10px; background: var(--correct-bg); border: 1px solid var(--correct-border); border-radius: var(--radius-sm); }
.answer-line .lbl { font-size: 12px; font-weight: 600; color: var(--correct); text-transform: uppercase; letter-spacing: .04em; }
.pair { display: inline-flex; align-items: center; gap: 4px; font-weight: 600; background: #fff; border: 1px solid var(--correct-border); border-radius: 4px; padding: 1px 8px; }
.pair .arr { color: var(--faint); font-weight: 400; }
.order-steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding-left: 0; list-style: none; counter-reset: ord; }
.order-steps li { display: grid; grid-template-columns: 26px 30px minmax(0,1fr); gap: 8px; align-items: start; }
.order-steps li::before { counter-increment: ord; content: counter(ord) "."; color: var(--faint); font-weight: 600; padding-top: 3px; text-align: right; }
.order-steps .k {
  display: inline-flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; border-radius: 5px; background: var(--correct); color: #fff; font-weight: 700; font-size: 13.5px;
}
.order-steps .t { padding-top: 2px; min-width: 0; overflow-wrap: anywhere; }
.groups { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
@media (max-width: 800px) { .groups { grid-template-columns: minmax(0, 1fr); } }
.group h4 { font-size: 13px; color: var(--muted); margin-bottom: 6px; }
.short-parts { border-collapse: collapse; margin-top: 4px; }
.short-parts th, .short-parts td { border: 1px solid var(--correct-border); padding: 6px 12px; text-align: left; }
.short-parts th { background: var(--correct-bg); font-size: 12.5px; color: var(--correct); }
.short-parts td.v { font-family: var(--mono); font-size: 15px; font-weight: 700; }
.answer-box { display: inline-flex; gap: 4px; margin-top: 4px; }
.answer-box span { width: 28px; height: 34px; border: 1px solid var(--border-strong); border-radius: 4px; background: #fff; }
.questions { display: flex; flex-direction: column; gap: 14px; margin-top: 14px; }
.question .qh { display: flex; gap: 8px; align-items: baseline; margin-bottom: 6px; }
.question .qn { font-weight: 700; }
.question .opts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
@media (max-width: 800px) { .question .opts { grid-template-columns: minmax(0, 1fr); } }

/* блок для вчителя */
.teacher dl { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 10px 16px; margin: 0; }
.teacher dt { font-size: 12.5px; font-weight: 600; color: var(--muted); padding-top: 1px; }
.teacher dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
@media (max-width: 700px) { .teacher dl { grid-template-columns: minmax(0, 1fr); } .teacher dt { padding-top: 6px; } }
.teacher .solution { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px; }
.dist-dominant td { background: #fff8ec; }
.p-bar { display: inline-block; width: 60px; height: 6px; background: #e8ebef; border-radius: 3px; vertical-align: middle; margin-left: 6px; overflow: hidden; }
.p-bar i { display: block; height: 100%; background: #8aa6dd; }

/* заголовок завдання */
.item-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.item-head .title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.item-head .meta { display: flex; gap: 6px 16px; flex-wrap: wrap; color: var(--muted); font-size: 12.5px; margin-top: 8px; }
.item-head .meta b { color: var(--text); font-weight: 600; }
.actions-bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.version-banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border-radius: var(--radius-sm); background: #fff6e2; border: 1px solid #f1d9a0; color: #7a5300; margin-bottom: 12px; font-size: 13px; }

/* рецензії */
.review { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.review + .review { margin-top: 10px; }
.review.resolved { background: var(--surface-2); }
.review.resolved .comments, .review.resolved .rv-details { opacity: .62; }
.review .rv-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.review .rv-head .src { font-weight: 600; }
.review .rv-head .when { color: var(--faint); font-size: 12px; margin-left: auto; }
.review .resolved-note { font-size: 12px; color: var(--success); font-weight: 500; }
.comments { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.comments li { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; align-items: start; }
.comments .ctext { min-width: 0; overflow-wrap: anywhere; }
.comments .field-name { font-family: var(--mono); font-size: 11.5px; color: var(--muted); background: #f1f3f6; border-radius: 3px; padding: 0 5px; margin-right: 4px; }
.comments .sugg { color: var(--muted); font-size: 13px; margin-top: 2px; }
.comments .sugg::before { content: "Пропозиція: "; font-weight: 600; }
.rv-details { margin-top: 8px; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 3px 12px; font-size: 12.5px; background: var(--surface-2); border-radius: var(--radius-sm); padding: 7px 10px; }
.rv-details dt { color: var(--muted); }
.rv-details dd { margin: 0; overflow-wrap: anywhere; }
.yes { color: var(--success); font-weight: 600; }
.no { color: var(--danger); font-weight: 600; }
details.more summary { cursor: pointer; color: var(--primary); font-size: 12.5px; }
details.more[open] summary { margin-bottom: 4px; }

/* версії */
.versions { list-style: none; margin: 0; padding: 0; }
.versions li { border-bottom: 1px solid var(--border); }
.versions li:last-child { border-bottom: 0; }
.versions button.vbtn {
  all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 9px 16px;
}
.versions button.vbtn:hover { background: var(--surface-2); }
.versions button.vbtn:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.versions li.active button.vbtn { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.versions .vhead { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.versions .vnum { font-weight: 700; }
.versions .note { margin-top: 6px; font-size: 12.5px; color: var(--muted); background: #fff; border: 1px solid var(--border); border-radius: 4px; padding: 6px 8px; white-space: pre-wrap; word-break: break-word; max-height: 180px; overflow: auto; }

.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 14px; font-size: 13px; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.kv.kv-right { grid-template-columns: minmax(0, 1fr) auto; gap: 6px 12px; }
.kv.kv-right dd { text-align: right; white-space: nowrap; overflow-wrap: normal; }
.stat-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; margin-bottom: 12px; }
.stat-tile { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; }
.stat-tile .v { font-size: 18px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat-tile .l { font-size: 12px; color: var(--muted); }

/* ---------- предмети ---------- */
.subject-list { list-style: none; margin: 0; padding: 0; }
.subject-list li + li { border-top: 1px solid var(--border); }
.subject-list button {
  all: unset; box-sizing: border-box; display: block; width: 100%; cursor: pointer; padding: 10px 14px;
}
.subject-list button:hover { background: var(--surface-2); }
.subject-list button:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; }
.subject-list li.active button { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.subject-list .sname { font-weight: 600; }
.subject-list .scounts { font-size: 12px; color: var(--muted); margin-top: 2px; }
.subject-list .sbadges { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }

/* ---------- банк фото ---------- */
.img-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.img-card {
  all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}
.img-card:hover { border-color: #aab4c3; }
.img-card:focus-visible { outline: 2px solid var(--primary); }
.img-card.active { border-color: var(--primary); box-shadow: 0 0 0 2px rgba(35,80,181,.25); }
.img-card .thumb { aspect-ratio: 4 / 3; background: #eef0f3 center / contain no-repeat; border-bottom: 1px solid var(--border); }
.img-card .body { padding: 8px 10px 10px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.img-card .ttl { font-weight: 600; font-size: 13px; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.img-card .kw { font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.img-card .lic { font-size: 11.5px; }
.lic-missing { color: var(--warning); font-weight: 600; }
.topic-checks { display: flex; flex-direction: column; gap: 4px; max-height: 170px; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 6px 10px; background: var(--surface-2); }
.topic-checks .check { font-size: 13px; }

/* бокова панель (редагування фото) */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(20, 28, 40, .25); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 41;
  width: 520px; max-width: 100vw; background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.drawer-body { flex: 1; overflow: auto; padding: 16px; }
.drawer-foot { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.drawer .preview img { display: block; max-width: 100%; max-height: 300px; margin: 0 auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }

/* ---------- ключі API ---------- */
.keybox { background: #fffbea; border: 1px solid #f0d77c; border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.keybox .k { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; }
.keybox input { font-family: var(--mono); font-size: 13px; background: #fff; }
.usage-hint code { background: #f1f3f6; border-radius: 3px; padding: 1px 5px; }
.endpoint-list { list-style: none; margin: 8px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.endpoint-list li { display: grid; grid-template-columns: 56px minmax(0, 260px) minmax(0, 1fr); gap: 10px; font-size: 13px; align-items: baseline; }
.endpoint-list .m { font-family: var(--mono); font-size: 11.5px; font-weight: 700; color: var(--primary); }
.endpoint-list .p { font-family: var(--mono); font-size: 12.5px; }
@media (max-width: 800px) { .endpoint-list li { grid-template-columns: 50px minmax(0, 1fr); } .endpoint-list li .d { grid-column: 2; } }

/* ---------- витрати ---------- */
.summary-tiles { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
@media (max-width: 800px) { .summary-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.tile .v { font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tile .l { color: var(--muted); font-size: 12.5px; }
.err-text { font-family: var(--mono); font-size: 12px; color: var(--danger); white-space: pre-wrap; word-break: break-word; max-height: 220px; overflow: auto; background: #fff8f7; border: 1px solid #f3d1cd; border-radius: 4px; padding: 6px 8px; margin-top: 4px; }

/* ---------- Промпти ---------- */
.prompt-list li.group-title {
  padding: 12px 16px 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; color: var(--muted); background: var(--surface-2);
}
.prompt-list li.group-title + li { border-top: 0; }
.prompt-pre {
  margin: 0; padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word;
  max-height: 360px; overflow: auto;
}
.prompt-pre.tall { max-height: 560px; }
.prompt-history { list-style: none; margin: 0; padding: 0; }
.prompt-history li { padding: 10px 0; }
.prompt-history li + li { border-top: 1px solid var(--border); }
.prompt-history pre { margin-top: 8px; }

/* пам’ятка в картці «Моделі ШІ» */
.memo { margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--border); }
.memo-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 28px; margin-top: 8px; }
.memo-grid ul { margin: 0; padding-left: 18px; font-size: 13px; }
.memo-grid li + li { margin-top: 5px; }
@media (max-width: 900px) { .memo-grid { grid-template-columns: minmax(0, 1fr); } }

/* розшифровка P, кодів Т і П у картці «Для вчителя» */
.has-tip { border-bottom: 1px dotted var(--faint); cursor: help; }
.tag[title] { cursor: help; }
.legend { margin-bottom: 14px; padding-bottom: 12px; border-bottom: 1px dashed var(--border); }
.legend > dl { margin-top: 8px; font-size: 13px; }
.legend-codes { list-style: none; margin: 6px 0 0; padding: 0; columns: 2; column-gap: 28px; font-size: 13px; }
.legend-codes li { display: flex; align-items: baseline; gap: 6px; break-inside: avoid; margin-bottom: 4px; }
.legend-codes .tag { flex: none; min-width: 34px; margin: 0; text-align: center; }
.legend-codes.inline { columns: 1; margin: 0; font-size: inherit; }
@media (max-width: 900px) { .legend-codes { columns: 1; } }
