/* ForgeFarm Panel — flat skin (по эталону atom-tz minimal-skins .d3 / wireframes v3)
   Правила: строгий flat - никаких теней, градиентных заливок и blur-фильтров. */

/* ================= FLAT TOKENS ================= */
:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --line-soft: #eef0f2;
  --ink: #2c3e50;
  --ink-2: #34495e;
  --muted: #95a5a6;
  --accent: #3498db;
  --accent-hover: #2980b9;
  --ok: #2ecc71;
  --warn: #f39c12;
  --danger: #e74c3c;
  --teal: #1abc9c;
  --violet: #9b59b6;
  --orange: #e67e22;
  --dark: #34495e;
  --radius: 6px;
  --radius-sm: 4px;
  --nav-active-bg: #eaf3fb;
  --nav-active-ink: #2980b9;
  --bar: #aed6f1;
  --bar-today: #1abc9c;
  --geo-bg: #ecf0f1;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  letter-spacing: -0.011em;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; min-height: 100vh; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; }
a { text-decoration: none; color: inherit; }

/* ================= SIDEBAR ================= */
.sidebar {
  width: 236px; flex-shrink: 0;
  background: var(--panel);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.logo { display: flex; align-items: center; gap: 10px; padding: 18px 20px; }
.logo-mark { width: 22px; height: 22px; background: var(--accent); border-radius: 4px; display: grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; }
.logo-name { font-weight: 700; font-size: 14px; letter-spacing: -0.02em; }
.logo-ver { font-size: 11px; color: var(--muted); margin-left: auto; font-weight: 500; }
.nav { padding: 10px; display: flex; flex-direction: column; gap: 1px; overflow-y: auto; }
.nav-label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 10px 10px 6px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500; font-size: 13.5px;
  cursor: pointer; transition: background 120ms, color 120ms;
}
.nav-item svg { width: 15px; height: 15px; stroke-width: 1.7; flex-shrink: 0; }
.nav-item:hover { background: var(--nav-active-bg); }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-ink); font-weight: 600; }
.nav-item.disabled { color: var(--muted); cursor: default; opacity: .65; }
.nav-item.disabled:hover { background: transparent; }
.sidebar-foot { margin-top: auto; padding: 14px; display: grid; grid-template-columns: 28px minmax(0, 1fr); align-items: center; gap: 10px; }
.avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--dark); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 600; }
.sidebar-foot .who { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.sidebar-foot .role { font-size: 11px; color: var(--muted); }
.sidebar-foot .identity-source { font-size: 11px; color: var(--ink-2); margin-top: 4px; }
.sidebar-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 8px; }
.sidebar-actions .chip-outline { margin-left: 0; }
.btn-mini[aria-disabled="true"], .chip-outline[aria-disabled="true"] { opacity: .5; cursor: default; }
.chip-outline { margin-left: auto; font-size: 10.5px; font-weight: 600; background: var(--geo-bg); border-radius: var(--radius-sm); padding: 2px 8px; color: var(--ink-2); }

/* ================= MAIN / TOPBAR ================= */
.main { flex: 1; min-width: 0; }
.topbar {
  min-height: 56px; background: var(--panel);
  display: flex; flex-wrap: wrap; align-items: center; gap: 14px; padding: 12px 32px;
  position: sticky; top: 0; z-index: 5;
}
.crumb { font-size: 13px; color: var(--muted); }
.crumb b { color: var(--ink); font-weight: 600; }
.topbar-right { margin-left: auto; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.shell-status { font-size: 11.5px; color: var(--ink-2); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 3px 10px; }
.tenant { font-size: 11.5px; font-weight: 600; color: var(--ink-2); background: var(--bg); border-radius: var(--radius-sm); padding: 3px 10px; }
.bell { position: relative; width: 32px; height: 32px; border-radius: var(--radius-sm); display: grid; place-items: center; cursor: pointer; background: var(--bg); transition: opacity 120ms; }
.bell:hover { opacity: .8; }
.bell svg { width: 15px; height: 15px; stroke-width: 1.7; color: var(--ink-2); }
.bell .dot {
  position: absolute; top: -5px; right: -5px; min-width: 15px; height: 15px;
  border-radius: 999px; background: var(--danger); color: #fff;
  font-size: 9px; font-weight: 700; display: grid; place-items: center; padding: 0 3px;
  border: 1.5px solid var(--panel);
}

/* ================= CONTENT ================= */
.content { padding: 32px; max-width: 1160px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 24px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.btn-primary {
  margin-left: auto;
  background: var(--accent); color: #fff; border: 0; border-radius: var(--radius-sm);
  font: 600 13px 'Inter', sans-serif; padding: 10px 18px; cursor: pointer;
  transition: background 120ms; letter-spacing: -0.011em;
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { background: var(--muted); cursor: default; }

/* ================= KPI (цветные плитки) ================= */
.kpis { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 12px; }
.kpi { border-radius: var(--radius); padding: 14px 16px; color: #fff; }
.kpi:nth-child(1) { background: #3498db; }
.kpi:nth-child(2) { background: #1abc9c; }
.kpi:nth-child(3) { background: #9b59b6; }
.kpi:nth-child(4) { background: #e67e22; }
.kpi:nth-child(5) { background: #34495e; }
.kpi .label { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: rgba(255,255,255,.75); }
.kpi .value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; margin-top: 6px; color: #fff; }
.kpi .value .unit { font-size: 15px; color: rgba(255,255,255,.8); font-weight: 600; }
.kpi .delta { font-size: 12px; color: rgba(255,255,255,.85); margin-top: 4px; }

/* ================= PANELS ================= */
.grid-2 { display: grid; grid-template-columns: 1.4fr 1fr; gap: 12px; }
.panel { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.panel-head { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.panel-head h2 { font-size: 13px; font-weight: 600; }
.panel-head .note { margin-left: auto; font-size: 11.5px; color: var(--muted); }
.panel-body { padding: 16px 18px; }
.placeholder-note { color: var(--muted); font-size: 13px; }

.event { display: flex; align-items: center; gap: 12px; padding: 11px 18px; border-bottom: 1px solid var(--line-soft); }
.event:last-child { border-bottom: 0; }
.event .dot { width: 8px; height: 8px; border-radius: 0; flex-shrink: 0; }
.event .dot.ok { background: var(--ok); }
.event .dot.warn { background: var(--warn); }
.event .dot.danger { background: var(--danger); }
.event .txt { font-size: 13px; }
.event .time { margin-left: auto; font-size: 11.5px; color: var(--muted); white-space: nowrap; }

/* Квадратные статус-точки */
.status-dot { width: 8px; height: 8px; border-radius: 0; display: inline-block; }
.status-dot.ok { background: var(--ok); }
.status-dot.warn { background: var(--warn); }
.status-dot.danger { background: var(--danger); }

/* ================= FORMS / LOGIN ================= */
.field-label { display: block; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 0 0 8px; }
.input {
  width: 100%; border: 0; border-radius: var(--radius-sm);
  font: 400 13.5px 'Inter', sans-serif; padding: 10px 12px; color: var(--ink);
  outline: none; background: var(--bg);
}
.input:focus { outline: 2px solid var(--accent); outline-offset: -2px; }

.login-page { display: grid; place-items: center; min-height: 100vh; }
.login-card { width: 340px; background: var(--panel); border-radius: var(--radius); padding: 28px; }
.login-logo { padding: 0; }
.login-sub { color: var(--muted); font-size: 13px; margin: 6px 0 20px; }
.login-error { background: #fdf0ef; color: var(--danger); font-size: 12.5px; font-weight: 600; border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 14px; }
.login-btn { width: 100%; margin-left: 0; margin-top: 16px; }

/* ================= ОБЗОР: bars / fleet (flat, только токены) ================= */
.section-gap { margin-top: 12px; }

.bars { display: flex; align-items: flex-end; gap: 14px; height: 120px; padding: 18px 18px 6px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; height: 100%; justify-content: flex-end; }
.bar { width: 100%; max-width: 34px; background: var(--bar); border-radius: 2px 2px 0 0; }
.bar.today { background: var(--bar-today); }
.bar-label { font-size: 10.5px; color: var(--muted); }
.bars-foot { padding: 10px 18px 14px; font-size: 12px; color: var(--ink-2); }

.fleet-row { display: flex; align-items: center; gap: 10px; padding: 9px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.fleet-row:last-child { border-bottom: 0; }
.fleet-row .name { font-weight: 600; }
.fleet-row .acc { color: var(--muted); font-size: 12px; }
.fleet-row .right { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 11.5px; color: var(--muted); }
.status-txt { font-weight: 600; font-size: 11.5px; }
.status-txt.ok { color: var(--ok); }
.status-txt.warn { color: var(--warn); }
.status-txt.danger { color: var(--danger); }
.status-txt.idle { color: var(--muted); }
.status-dot.idle { background: var(--muted); }

/* ================= КАМПАНИИ: карточки / бейджи / строки ================= */
.cards-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px 18px; display: block; }
.card.clickable { cursor: pointer; transition: background 120ms; }
.card.clickable:hover { background: #fafbfc; }
.card h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.card .meta { font-size: 12px; color: var(--muted); margin-top: 3px; }
.chip { display: inline-block; padding: 3px 9px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; background: var(--nav-active-bg); color: var(--nav-active-ink); }
.chip.grey { background: var(--geo-bg); color: var(--ink-2); }
.chip.teal { background: #e8f8f4; color: #16a085; }
.pbar { height: 6px; background: var(--line-soft); border-radius: 3px; overflow: hidden; }
.pbar > i { display: block; height: 100%; border-radius: 3px; background: var(--accent); }
.pbar > i.teal { background: var(--teal); }
.pbar > i.ok { background: var(--ok); }
.bigstat { font-size: 24px; font-weight: 700; letter-spacing: -0.02em; }
.bigstat.ok { color: var(--ok); }
.bigstat.err { color: var(--danger); }

.bdg { display: inline-block; padding: 3px 9px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; color: #fff; white-space: nowrap; }
.bdg.queue { background: #95a5a6; }
.bdg.run { background: var(--accent); }
.bdg.done { background: var(--ok); }
.bdg.err { background: var(--danger); }
.bdg.retry { background: var(--warn); }
.bdg.dark { background: var(--dark); }

.trow { display: grid; align-items: center; gap: 12px; padding: 10px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.trow:last-child { border-bottom: 0; }
.trow.head { padding: 10px 18px; font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.trow .mut { color: var(--muted); font-size: 12px; }

.detail-head { display: flex; align-items: center; gap: 14px; margin-bottom: 24px; }
.detail-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.detail-head .sub { color: var(--muted); font-size: 13px; margin-top: 4px; }
.detail-head .bdg { margin-left: auto; font-size: 12px; padding: 5px 12px; }
.back-btn { text-decoration: none; padding: 8px 14px; font-size: 12.5px; flex-shrink: 0; }

.rep-kpis { display: flex; gap: 8px; margin: 12px 0; }
.rep-kpi { flex: 1; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; text-align: center; }
.rep-kpi .rv { font-size: 19px; font-weight: 700; }
.rep-kpi .rl { font-size: 10.5px; color: var(--muted); margin-top: 2px; }

.empty-state { background: var(--panel); border-radius: var(--radius); padding: 48px 24px; text-align: center; }
.empty-state h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.01em; }
.empty-state p { color: var(--muted); font-size: 13px; line-height: 1.55; margin-top: 8px; }
.empty-ico { width: 44px; height: 44px; margin: 0 auto 14px; border-radius: var(--radius); background: var(--nav-active-bg); display: grid; place-items: center; }
.empty-ico svg { width: 20px; height: 20px; color: var(--nav-active-ink); stroke-width: 1.7; }

.note-link { color: var(--muted); text-decoration: underline dotted; cursor: default; }

/* ================= MODAL / WIZARD ================= */
.overlay { position: fixed; inset: 0; background: rgba(44,62,80,.45); display: none; place-items: center; z-index: 150; }
.overlay.open { display: grid; }
.modal { width: 560px; max-width: calc(100vw - 48px); max-height: calc(100vh - 64px); overflow-y: auto; background: var(--panel); border-radius: 8px; }
.modal-head { padding: 18px 22px 0; }
.modal-head h3 { font-size: 16px; font-weight: 700; letter-spacing: -0.02em; }
.steps { display: flex; align-items: center; gap: 8px; margin-top: 14px; }
.step-n { width: 22px; height: 22px; border-radius: 50%; background: var(--line-soft); display: grid; place-items: center; font-size: 11px; font-weight: 600; color: var(--muted); }
.step-n.cur { background: var(--accent); color: #fff; }
.step-n.done { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.step-line { flex: 1; height: 1px; background: var(--geo-bg); }
.modal-body { padding: 20px 22px 22px; }

.platforms { display: flex; gap: 8px; margin-top: 16px; }
.plat { flex: 1; border-radius: var(--radius-sm); padding: 10px; text-align: center; font-size: 12.5px; font-weight: 600; cursor: pointer; background: var(--bg); transition: background 120ms, color 120ms; }
.plat.sel { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.plat.dis { color: var(--muted); cursor: not-allowed; }
.plat .soon { display: block; font-size: 10px; font-weight: 500; color: var(--muted); margin-top: 2px; }

.presets { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 18px; }
.preset { border-radius: var(--radius-sm); padding: 12px; cursor: pointer; background: var(--bg); transition: background 120ms; }
.preset h4 { font-size: 13px; font-weight: 600; }
.preset p { font-size: 11.5px; color: var(--muted); margin-top: 3px; line-height: 1.4; }
.preset.sel { background: var(--nav-active-bg); }
.preset.sel h4 { color: var(--nav-active-ink); }

.slider-row { display: grid; grid-template-columns: 130px 1fr 64px; align-items: center; gap: 12px; margin-bottom: 12px; }
.slider-row label { font-size: 12.5px; font-weight: 500; color: var(--ink-2); }
.slider-row .val { font-size: 13px; font-weight: 700; text-align: right; }
input[type="range"] { -webkit-appearance: none; appearance: none; height: 2px; background: #e5e8ec; border-radius: 2px; outline: none; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #fff; }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); cursor: pointer; border: 2px solid #fff; }

.summary { background: var(--bg); border-radius: var(--radius-sm); }
.summary .row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 14px; border-bottom: 1px solid #e8eaed; font-size: 13px; }
.summary .row:last-child { border-bottom: 0; }
.summary .row .k { color: var(--muted); }
.summary .row .v { font-weight: 600; text-align: right; word-break: break-all; }

.modal-foot { display: flex; gap: 8px; padding: 0 22px 20px; }
.btn { border-radius: var(--radius-sm); font: 600 13px 'Inter', sans-serif; padding: 10px 16px; cursor: pointer; transition: background 120ms, opacity 120ms; border: 0; }
.btn-dark { background: var(--accent); color: #fff; }
.btn-dark:hover { background: var(--accent-hover); }
.btn-dark:disabled { background: var(--muted); cursor: default; }
.btn-ghost { background: var(--bg); color: var(--ink-2); }
.btn-ghost:hover { opacity: .75; }
.modal-foot .spacer { flex: 1; }

.form-error { background: #fdf0ef; color: var(--danger); font-size: 12.5px; font-weight: 600; border-radius: var(--radius-sm); padding: 9px 12px; margin-bottom: 14px; }

/* ================= TASKS ================= */
.fchips { display: flex; gap: 6px; flex-wrap: wrap; }
.fchip { display: inline-block; padding: 5px 12px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 600; color: var(--muted); background: var(--bg); border: 1px solid var(--line-soft); text-decoration: none; }
.fchip:hover { color: var(--dark); }
.fchip.cur { background: var(--dark); border-color: var(--dark); color: #fff; }

.trow.clickable { cursor: pointer; }
.trow.clickable:hover { background: var(--bg); }
.trow .act { display: flex; align-items: center; gap: 7px; min-width: 0; }
.trow .act svg { width: 14px; height: 14px; color: var(--muted); stroke-width: 1.7; flex: none; }
.evid { display: flex; justify-content: center; }
.evid svg { width: 15px; height: 15px; color: var(--muted); opacity: .45; stroke-width: 1.7; }
.evid.has svg { color: var(--accent); opacity: 1; }

.detail-row { padding: 0 18px; border-bottom: 1px solid var(--line-soft); background: var(--bg); }
.detail-row:empty { display: none; }
.detail-box { padding: 14px 0 16px; }
.detail-box-head { display: flex; align-items: center; gap: 12px; font-size: 14px; font-weight: 600; }
.detail-box-head .act { display: flex; align-items: center; gap: 7px; }
.detail-box-head .act svg { width: 15px; height: 15px; color: var(--muted); stroke-width: 1.7; }
.detail-close { margin-left: auto; background: none; border: 1px solid var(--line-soft); border-radius: var(--radius-sm); color: var(--muted); font-size: 11.5px; font-weight: 600; padding: 4px 10px; cursor: pointer; }
.detail-close:hover { color: var(--dark); }
.detail-box .kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px 14px; margin: 14px 0; }
.detail-box .kv .k, .detail-label { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.detail-box .kv .v { font-size: 13px; margin-top: 3px; }
.detail-label { margin: 12px 0 6px; }
.detail-box pre { background: var(--panel); border: 1px solid var(--line-soft); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 12px; line-height: 1.5; overflow-x: auto; max-height: 280px; margin: 0; }
.evid-links a { color: var(--accent); text-decoration: none; font-size: 13px; margin-right: 14px; }
.evid-links a:hover { text-decoration: underline; }
.evid-links .mut { color: var(--muted); font-size: 12.5px; }

/* ================= УСТРОЙСТВА (Ферма) ================= */
.fleet-summary { margin: 0 0 12px; color: var(--muted); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.farm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(230px, 100%), 1fr)); gap: 12px; }
.cvd-card { min-width: 0; background: var(--panel); border-radius: var(--radius); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.cvd-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.cvd-top .status-dot { flex: 0 0 8px; }
.cvd-top .nm { min-width: 0; font-weight: 700; font-size: 13.5px; overflow-wrap: anywhere; }
.cvd-top .geo { min-width: 0; margin-left: auto; overflow-wrap: anywhere; }
.geo { background: var(--geo-bg); border-radius: var(--radius-sm); padding: 1px 8px; font-weight: 600; color: var(--ink-2); font-size: 11px; }
.cvd-acc { min-width: 0; font-size: 12px; color: var(--ink-2); overflow-wrap: anywhere; }
.cvd-sub { min-width: 0; font-size: 11.5px; color: var(--muted); overflow-wrap: anywhere; }
.cvd-btns { display: flex; flex-wrap: wrap; gap: 6px; min-width: 0; margin-top: 2px; }
.btn-mini { border: 0; background: var(--bg); color: var(--ink-2); border-radius: var(--radius-sm); font: 600 11.5px 'Inter', sans-serif; padding: 6px 9px; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: opacity 120ms; }
.btn-mini:hover { opacity: .75; }
.btn-mini:disabled { color: var(--muted); cursor: not-allowed; opacity: .55; }
.btn-mini svg { width: 11px; height: 11px; stroke-width: 1.8; }
.btn-mini.danger-o { background: transparent; border: 1px solid var(--danger); color: var(--danger); }
.btn-mini.danger-o:disabled { border-color: var(--line-soft); color: var(--muted); }
.cvd-btns .btn-mini { min-width: 0; max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.cvd-btns .nucleus-control { flex: 1 1 100%; justify-content: center; text-align: center; background: var(--accent); color: #fff; }
.cvd-btns .nucleus-control:disabled { background: var(--bg); color: var(--muted); }
.cvd-btns .nucleus-control:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cvd-control-status { min-width: 0; color: var(--ink-2); font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; }
.cvd-control-status:empty { display: none; }
.cvd-control-status[data-state="pending"], .cvd-control-status[data-state="unknown"] { color: #805400; }
.cvd-control-status[data-state="succeeded"] { color: #1f6c43; }
.cvd-control-status[data-state="failed"], .cvd-control-status[data-state="rejected"], .cvd-control-status[data-state="not_sent"] { color: #b42318; }

/* provisioning-модалка: 7 шагов */
.prov-step { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 13px; border-bottom: 1px solid var(--line-soft); }
.prov-step:last-child { border-bottom: 0; }
.prov-step .ps-name { color: var(--muted); font-weight: 500; }
.prov-step.done .ps-name { color: var(--ink); font-weight: 600; }
.prov-step.failed .ps-name { color: var(--danger); font-weight: 600; }
.prov-step .ps-time { margin-left: auto; font-size: 11.5px; color: var(--muted); font-weight: 500; }
.ps-ico { width: 18px; height: 18px; display: grid; place-items: center; flex-shrink: 0; }
.ps-pend { width: 8px; height: 8px; border-radius: 0; background: var(--geo-bg); }
.ps-check { color: var(--ok); font-size: 13px; font-weight: 700; }
.ps-fail { color: var(--danger); font-size: 13px; font-weight: 700; }
.prov-log { margin-top: 14px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 11px; line-height: 1.7; color: var(--ink-2); max-height: 130px; overflow-y: auto; }
.prov-log:empty { display: none; }

/* Экран CVD (живой кадр 9:16) */
.screen-live { display: block; width: 240px; aspect-ratio: 9 / 16; object-fit: contain; background: #101418; border-radius: var(--radius); margin: 0 auto; }
.screen-off { border: 1px dashed #cfd6db; }
.screen-off svg line:last-child { stroke: var(--danger); }
.screen-cap-fail { color: var(--ink-2); }
.screen-cap-fail b { color: var(--danger); }
.screen-why { margin: 6px 0; word-break: break-word; line-height: 1.5; }

.screen-ph { width: 240px; aspect-ratio: 9 / 16; background: var(--geo-bg); border-radius: var(--radius); margin: 0 auto; display: grid; place-items: center; }
.screen-ph svg { width: 34px; height: 34px; color: #b7c1c8; stroke-width: 1.4; }
.screen-cap { text-align: center; font-size: 12px; color: var(--muted); margin-top: 12px; }

/* Живая консоль Cuttlefish на своей странице (/fleet/<cvd>/console). Высота —
   от вьюпорта, чтобы вытянутый экран телефона (720x1560) помещался целиком
   вместе с органами управления самой консоли: в модалке шириной 520 px он не
   помещался, ради чего страница и заведена. */
.screen-frame {
  width: 100%;
  height: 70vh;
  min-height: 420px;
  border: 0;
  border-radius: 8px;
  background: #000;
  display: block;
}
.screen-live-note { margin-top: 8px; font-size: 12px; color: var(--muted); text-align: center; }
.screen-live-note a { color: inherit; text-decoration: underline; }

/* Живая миниатюра экрана — первый элемент карточки устройства.
   240 px исходника показываются в ~140 CSS-px: на экране с двойной плотностью
   картинка остаётся чёткой, а карточка не превращается в плакат. Размеры
   картинке задаёт сам кадр (width/height в разметке), поэтому сетка не прыгает,
   пока миниатюра грузится, и не искажает пропорцию устройства. */
.cvd-shot { width: 100%; max-width: 140px; margin: 0 auto 2px; }
.cvd-shot-link { display: block; text-decoration: none; color: inherit; }
.cvd-thumb { display: block; width: 100%; height: auto; border-radius: var(--radius-sm); background: #0d1116; }
.cvd-thumb-off, .cvd-thumb-wait { aspect-ratio: 9 / 19.5; display: grid; place-items: center; background: var(--geo-bg); }
.cvd-thumb-wait { border: 1px dashed #cfd6db; }
.cvd-thumb-off { border: 1px dashed var(--danger); }
.cvd-thumb-off svg, .cvd-thumb-wait svg { width: 24px; height: 24px; color: #b7c1c8; stroke-width: 1.4; }
.cvd-thumb-off svg line:last-child { stroke: var(--danger); }
.cvd-shot-cap { text-align: center; font-size: 10.5px; line-height: 1.5; color: var(--muted); margin-top: 5px; }
.cvd-shot-external .cvd-shot-cap { font-size: 11.5px; overflow-wrap: anywhere; }
.cvd-shot-fail b { display: block; color: var(--danger); font-size: 11px; }
.cvd-shot-why { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-2); margin: 2px 0 3px; word-break: break-word; }
/* Кадр старше двух циклов обновления гаснет и подпись краснеет: застывшую
   картинку оператор не должен принимать за живой экран. Класс вешает счётчик
   возраста (partials/shot_age.html) — он же единственный, кто знает, сколько
   времени прошло ПОСЛЕ отрисовки. */
/* Правила нужны КАЖДОМУ владельцу data-shot-at, а не только миниатюре: класс
   is-stale скрипт вешает на любой такой элемент, и полный кадр на странице
   консоли раньше не гас вовсе — скрипт отрабатывал честно, а оператор не видел
   ничего и принимал застывший экран за живой. Сторожит
   test_every_frame_with_an_age_ticker_can_actually_go_stale. */
.cvd-shot-live.is-stale .cvd-thumb,
.cvd-screen.is-stale .screen-live { opacity: .35; filter: grayscale(.7); }
.cvd-shot-live.is-stale .shot-age,
.cvd-screen.is-stale .shot-age { color: var(--danger); font-weight: 700; }
.cvd-shot-live.htmx-request .cvd-shot-cap,
.cvd-screen.htmx-request .screen-cap { opacity: .55; }

/* Новый кадр уже назван в разметке, но ещё грузится в память браузера: всё это
   время на экране держится ПРЕДЫДУЩИЙ кадр (двойная буферизация,
   app/static/ff-shot.js). Гаснет только подпись — чтобы обновление было видно,
   а картинка не мигала. */
.cvd-shot-live.shot-loading .cvd-shot-cap,
.cvd-screen.shot-loading .screen-cap { opacity: .55; }
/* Новая картинка не догрузилась. Красным не бьём сразу: один потерянный кадр
   наверстается следующим циклом. Молчанием это тоже не становится — подпись
   возраста продолжает идти от момента съёмки и через два цикла краснеет
   (is-stale), а рамка показывает, что показанный кадр не последний. */
.cvd-shot-live.shot-load-failed .cvd-thumb,
.cvd-screen.shot-load-failed .screen-live { outline: 1px solid var(--line-soft); }

/* ЖИВОЙ ПОТОК ПО ТРЕБОВАНИЮ (app/static/ff-live.js). Поднимается кнопкой на
   карточке, не больше двух сразу; снимки остаются режимом по умолчанию. */
.cvd-live-slot:empty { display: none; }
.cvd-live-frame { display: block; width: 100%; height: 340px; border: 0; border-radius: var(--radius-sm); background: #000; }
/* Пока поток живой, снимок в этой карточке не показывается: два изображения
   одного экрана рядом — верный способ спутать живое с прошлым. */
.cvd-shot.is-live .cvd-shot-live { display: none; }
.cvd-shot.is-live { max-width: none; }
/* Живая карточка занимает две колонки: в 140 px WebRTC-поток бесполезен, а
   отдавать две колонки постоянно незачем — потоков максимум два. На узком
   экране колонка одна, и растягивать нечего. */
@media (min-width: 760px) { .cvd-card.is-live { grid-column: span 2; } }
/* Подпись режима. Пустая — значит смотрим снимок, и об этом говорит подпись
   кадра («снимок · N с назад»). Гадать оператору не приходится ни в одном из
   состояний. */
.cvd-live-bar { text-align: center; font-size: 10.5px; line-height: 1.5; margin: 5px 0 2px; color: var(--muted); }
.cvd-live-bar:empty { display: none; }
.cvd-live-bar.up { color: var(--ok); font-weight: 700; letter-spacing: .04em; }
.cvd-live-bar.unverified { color: var(--warn); }
.cvd-live-bar.failed { color: var(--danger); }
.btn-mini.on { background: var(--ok); color: #fff; }

/* ================= GENERATORS / PERSONAS ================= */
.gen-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.gen-card { background: var(--panel); border-radius: var(--radius); padding: 16px 18px; display: flex; flex-direction: column; gap: 10px; }
.gen-card.clickable:hover { background: #fafbfc; }
.gen-card.soon { opacity: .55; }
.gen-ico { width: 34px; height: 34px; border-radius: var(--radius); background: var(--nav-active-bg); display: grid; place-items: center; color: var(--nav-active-ink); }
.gen-ico svg { width: 17px; height: 17px; stroke-width: 1.7; }
.gen-card h3 { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.gen-card .desc { font-size: 12px; color: var(--muted); line-height: 1.5; flex: 1; }
.soon-badge { align-self: flex-start; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--geo-bg); border-radius: 3px; padding: 3px 9px; }
.persona-form-panel select.input { max-width: 220px; }
.persona-location { display: flex; align-items: baseline; gap: 12px; padding: 10px 0 18px; }
.persona-location .field-label { margin: 0; }
.persona-location span:last-child { color: var(--muted); font-size: 12px; }
.persona-style-fieldset { border: 0; min-width: 0; }
.persona-presets .preset { display: block; }
.persona-presets input { position: absolute; opacity: 0; pointer-events: none; }
.persona-presets strong, .persona-presets small { display: block; }
.persona-presets strong { font-size: 13px; }
.persona-presets small { color: var(--muted); font-size: 11.5px; line-height: 1.4; margin-top: 3px; }
.persona-presets label:has(input:checked) { background: var(--nav-active-bg); }
.persona-presets label:has(input:checked) strong { color: var(--nav-active-ink); }
.persona-presets label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.persona-presets label:has(input:disabled) { cursor: not-allowed; opacity: .58; }
.persona-submit-row { display: flex; align-items: center; gap: 10px; }
.persona-submit-row .meta { margin: 0; }
#persona-submit:disabled { cursor: wait; opacity: .65; }
#persona-submit-indicator { display: none; }
#persona-submit-indicator.htmx-request { display: inline; }
.persona-history { background: var(--panel); border-radius: var(--radius); overflow: hidden; }
.persona-history-head { background: var(--panel); }
#persona-jobs { background: var(--bg); display: grid; gap: 12px; padding-top: 12px; }
.persona-job { overflow: hidden; }
.persona-job-head .bdg { margin-left: auto; }
.persona-job-summary { display: flex; gap: 14px; color: var(--muted); font-size: 12px; margin-bottom: 9px; }
.persona-job-summary span:first-child { color: var(--ink-2); }
.persona-progress { margin-bottom: 10px; }
.persona-state-note { color: var(--muted); font-size: 12px; line-height: 1.5; }
.persona-failure { background: #fdf0ef; color: var(--danger); border-radius: var(--radius-sm); padding: 12px; }
.persona-failure p { color: var(--ink-2); font-size: 12px; line-height: 1.5; margin: 4px 0 10px; overflow-wrap: anywhere; }
.persona-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.persona-results { margin-top: 14px; }
.persona-card { padding: 14px; }
.persona-username { color: var(--accent); font-size: 12px; font-weight: 600; margin-top: 3px; overflow-wrap: anywhere; }
.persona-bio { color: var(--ink-2); font-size: 12px; line-height: 1.5; margin-top: 9px; }
.persona-interests { display: flex; gap: 5px; flex-wrap: wrap; margin: 10px 0; }
.mini-bars { display: flex; align-items: flex-end; gap: 3px; height: 30px; }
.mini-bars i { flex: 1; background: var(--bar); border-radius: 1px; display: block; }
.mini-bars i.pk { background: var(--teal); }
.persona-rhythm { margin-top: 6px; }
.persona-preview-count { margin-top: 10px; }
.persona-empty { border-radius: 0; padding: 28px 20px; }

/* ================= GENERATORS / TASK CAMPAIGN DRAFT ================= */
.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.task-generator-panel { overflow: visible; }
.task-strategy-fieldset { border: 0; min-width: 0; }
.strat-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px; margin-bottom: 18px;
}
.strat {
  position: relative; display: block; border-radius: var(--radius-sm); padding: 12px;
  cursor: pointer; background: var(--bg); transition: background 120ms;
}
.strat input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.strat-copy { display: block; position: relative; padding-right: 22px; }
.strat-copy::before {
  content: ""; position: absolute; top: 1px; right: 0; width: 14px; height: 14px;
  border: 1px solid var(--muted); border-radius: 50%; color: #fff;
  font-size: 10px; line-height: 14px; text-align: center;
}
.strat strong, .strat .mono-tag, .strat .strat-desc { display: block; }
.strat strong { font-size: 13px; font-weight: 600; }
.strat .mono-tag {
  margin-top: 2px; color: var(--muted); font: 10.5px ui-monospace, 'Cascadia Mono', Consolas, monospace;
}
.strat .strat-desc { margin-top: 4px; color: var(--muted); font-size: 11.5px; line-height: 1.4; }
.strat:has(input:checked) { background: var(--nav-active-bg); }
.strat:has(input:checked) strong { color: var(--nav-active-ink); }
.strat:has(input:checked) .strat-copy::before { content: "✓"; border-color: var(--accent); background: var(--accent); }
.strat input:focus-visible + .strat-copy { outline: 2px solid var(--accent); outline-offset: 5px; }
.strat:has(input:disabled) { cursor: not-allowed; opacity: .58; }
.task-sliders output { font-size: 13px; font-weight: 700; text-align: right; }
input[type="range"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 5px; }
input[type="range"]:disabled { cursor: not-allowed; opacity: .45; }
.task-sliders.is-disabled { opacity: .72; }
.waves-row { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; }
.wave-bar {
  flex: 1 0 160px; min-width: 160px; min-height: 64px; border-radius: var(--radius-sm);
  padding: 10px 12px; background: var(--nav-active-bg); display: flex;
  flex-direction: column; justify-content: center; gap: 3px;
}
.wave-bar .wb-name { color: var(--nav-active-ink); font-size: 12px; font-weight: 700; }
.wave-bar .wb-meta { color: var(--ink-2); font-size: 10.5px; white-space: nowrap; }
.task-generator-submit { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.task-generator-submit .meta { margin: 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

/* ================= GENERATORS / DEVICE PROFILES ================= */
.gen-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.gen-card.clickable:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.device-profile-form-panel { overflow: visible; }
.device-profile-form-panel select { max-width: 220px; }
.device-profile-form-panel select:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.device-profile-class-fieldset { border: 0; min-width: 0; }
.device-profile-class-chips .fchip { position: relative; cursor: pointer; color: var(--ink-2); }
.device-profile-class-chips .fchip input {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
}
.device-profile-class-chips .fchip:has(input:checked) { background: var(--dark); border-color: var(--dark); color: #fff; }
.device-profile-class-chips .fchip:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.device-profile-class-chips .fchip:has(input:disabled) { cursor: not-allowed; opacity: .68; }
.device-profile-submit-row { margin-top: 16px; }
#device-profile-submit:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.device-profile-catalog-note {
  margin-top: 12px; color: var(--ink-2); background: var(--panel); border-radius: var(--radius);
  padding: 12px 16px; font-size: 12px; line-height: 1.5;
}
.device-profile-status { margin-bottom: 10px; color: #19733d; font-size: 12.5px; font-weight: 700; }
.device-profile-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.device-profile-card { min-width: 0; background: var(--panel); border-radius: var(--radius); padding: 16px 18px; }
.device-profile-card h3 { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 14px; }
.geo-badge { margin-left: auto; background: var(--geo-bg); border-radius: var(--radius-sm); padding: 1px 8px; color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.device-profile-card dl { margin-top: 10px; }
.device-profile-card dt, .device-profile-card dd { padding: 5px 0; border-bottom: 1px solid var(--line-soft); }
.device-profile-card dt { color: #5b686a; font-size: 11.5px; }
.device-profile-card dd { min-width: 0; color: var(--ink-2); font-size: 12px; text-align: right; }
.device-profile-card dl { display: grid; grid-template-columns: minmax(66px, auto) minmax(0, 1fr); column-gap: 12px; }
.device-profile-serial,
.device-profile-gps { overflow-wrap: anywhere; word-break: break-word; }
.device-profile-compatibility { display: inline-block; margin-top: 10px; color: #5b686a; font-size: 10.5px; font-weight: 700; }
.device-profile-unavailable { background: #fdf0ef; border-radius: var(--radius); padding: 18px; }
.device-profile-unavailable h2 { color: #b42318; font-size: 14px; }
.device-profile-unavailable p { margin-top: 5px; color: var(--ink-2); font-size: 12px; line-height: 1.5; }
#device-profile-result .form-error { color: #b42318; background: #fdf0ef; }

@media (max-width: 900px) {
  .gen-grid, .persona-grid { grid-template-columns: 1fr 1fr; }
  .strat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .device-profile-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .app { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static; flex-direction: row; align-items: center;
  }
  .logo { padding: 10px 12px; flex: 0 0 auto; }
  .logo-ver, .nav-label, .sidebar-foot { display: none; }
  .nav {
    min-width: 0; flex: 1; flex-direction: row; overflow-x: auto; overflow-y: hidden;
    padding: 6px 10px; gap: 3px;
  }
  .nav-item { flex: 0 0 auto; padding: 7px 9px; }
  .main { width: 100%; }
  .topbar { min-height: 48px; height: auto; gap: 8px; padding: 8px 16px; }
  .crumb { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .topbar-right { gap: 8px; }
  .content { width: 100%; padding: 16px; }
  .gen-grid, .persona-grid, .strat-grid { grid-template-columns: 1fr; }
  .device-profile-cards { grid-template-columns: 1fr; }
  .persona-location, .persona-submit-row, .persona-job-summary, .task-generator-submit { align-items: flex-start; flex-direction: column; }
  .task-generator-head { align-items: flex-start; flex-wrap: wrap; }
  .device-profile-head { align-items: flex-start; flex-wrap: wrap; }
  .device-profile-head .bdg { margin-left: 0; }
  .device-profile-geo-row { grid-template-columns: 1fr; gap: 8px; }
  .device-profile-geo-row span { display: none; }
  .device-profile-form-panel select { max-width: none; }
  .task-generator-head .bdg { margin-left: 0; }
  .task-sliders .slider-row { grid-template-columns: 1fr 54px; gap: 10px; }
  .task-sliders .slider-row label { grid-column: 1 / -1; }
}


/* ================= НАСТРОЙКИ (эталон wireframes v3) ================= */
.atabs { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius-sm); padding: 4px; width: max-content; margin-bottom: 12px; flex-wrap: wrap; }
.atab { border: 0; background: transparent; border-radius: 3px; padding: 7px 16px; font: 600 12.5px 'Inter', sans-serif; color: var(--ink-2); cursor: pointer; }
.atab.cur { background: var(--panel); color: var(--ink); }
.atab.disabled { color: var(--muted); opacity: .5; cursor: not-allowed; }

.role-badge { display: inline-block; padding: 3px 9px; border-radius: var(--radius-sm); font-size: 11px; font-weight: 700; color: #fff; }

.num-field { display: grid; grid-template-columns: 240px 130px 1fr; align-items: center; gap: 14px; margin-bottom: 14px; }
.num-field label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.num-field .hint { font-size: 11.5px; color: var(--muted); }
.num-field .src { font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.num-field.wide { grid-template-columns: 240px 1fr; align-items: start; }
.num-field.wide .stack { min-width: 0; }
.num-field.wide .stack .input { width: 100%; }
.num-field.wide .stack .hint { display: block; margin-top: 6px; }
.num-group { font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin: 22px 0 12px; }
.num-group.first { margin-top: 0; }
.num-field .fld-err { font-size: 11.5px; color: var(--danger); font-weight: 600; }

.toggle { width: 36px; height: 20px; border-radius: 10px; background: #cbd3da; position: relative; cursor: pointer; transition: background 120ms; flex-shrink: 0; border: 0; padding: 0; }
.toggle::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; transition: left 120ms; }
.toggle.on { background: var(--ok); }
.toggle.on::after { left: 18px; }
.toggle.locked { background: var(--geo-bg); cursor: not-allowed; }
.toggle.locked::after { background: #d5dbde; }
.toggle.on.locked { background: var(--ok); opacity: .5; }
.toggle.on.locked::after { background: #fff; }

.rule-row { display: flex; align-items: center; gap: 14px; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.rule-row:last-child { border-bottom: 0; }
.rule-copy { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.rule-row .rname { font-weight: 600; }
.rule-row .rname .tgt { color: var(--muted); font-weight: 500; }
.rule-row .rnote { font-size: 11.5px; color: var(--muted); line-height: 1.4; }
.rule-row .rule-key { margin-left: auto; font-size: 11px; flex-shrink: 0; }
.rule-row.dis .rname { color: var(--muted); }

.conn-row { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.conn-row:last-child { border-bottom: 0; }
.conn-row .cname { font-weight: 600; }
.conn-row .cnote { font-size: 11.5px; color: var(--muted); }
.postmvp { font-size: 10.5px; font-weight: 600; color: var(--muted); background: var(--geo-bg); border-radius: 3px; padding: 2px 7px; }

.roles-wrap { display: grid; grid-template-columns: 260px 1fr; gap: 12px; align-items: start; }
.role-list { background: var(--bg); border-radius: var(--radius-sm); padding: 8px; display: flex; flex-direction: column; gap: 2px; }
.role-item { padding: 10px 12px; border-radius: var(--radius-sm); cursor: pointer; transition: background 120ms; border: 0; background: none; width: 100%; text-align: left; font-family: 'Inter', sans-serif; }
.role-item:hover { background: #eceff3; }
.role-item.cur { background: var(--nav-active-bg); }
.role-item .rl-name { font-weight: 700; font-size: 13px; }
.role-item.cur .rl-name { color: var(--nav-active-ink); }
.role-item .rl-desc { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 11px 18px; border-bottom: 1px solid var(--line-soft); font-size: 13px; }
.perm-row:last-child { border-bottom: 0; }
.perm-row input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex-shrink: 0; }
.perm-row input[type="checkbox"]:disabled { cursor: not-allowed; }

.code-block { background: var(--bg); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 11.5px; line-height: 1.7; color: var(--ink-2); overflow-x: auto; white-space: pre; }

.form-msg { font-size: 12.5px; line-height: 1.5; font-weight: 500; padding: 10px 13px; border-radius: var(--radius-sm); margin-bottom: 16px; }
.form-msg.ok { background: #e9f7ef; color: #1e7e46; }
.form-msg.err { background: #fdecea; color: var(--danger); }
.form-msg b { font-weight: 700; }
.form-msg code { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; background: rgba(255, 255, 255, .65); border-radius: 3px; padding: 1px 5px; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.filter-bar .input { flex: 0 1 auto; }
.filter-bar input[type="search"] { flex: 1 1 220px; min-width: 160px; }

.filters-wrap {
  padding: 14px 18px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--line-soft);
}
.filters-wrap .input { background: var(--panel); }
.filters { display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: end; }
.flt { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.flt > span { font-size: 10.5px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.flt .input {
  min-width: 168px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
}
.flt-grow { flex: 1 1 280px; }
.flt-grow .input { width: 100%; min-width: 0; }
.flt-dates { display: flex; align-items: center; gap: 6px; }
.flt-dates .input { min-width: 0; width: 148px; }
.flt-sep { color: var(--muted); font-size: 11px; font-weight: 600; }
.flt-reset { margin-left: auto; }
.flt-reset .btn { height: 36px; }

select.input {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%2395a5a6' d='M1.2 1.4L6 6.2l4.8-4.8 1.2 1.2L6 8.6 0 2.6z'/></svg>");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
input[type="date"].input { color-scheme: light; }

.seg {
  display: flex;
  height: 36px;
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}
.seg-opt { cursor: pointer; display: flex; }
.seg-opt input { position: absolute; opacity: 0; pointer-events: none; }
.seg-opt span {
  display: flex; align-items: center;
  padding: 0 12px; border-radius: 3px;
  font: 600 12px 'Inter', sans-serif; color: var(--ink-2);
  white-space: nowrap;
}
.seg-opt input:checked + span { background: var(--dark); color: #fff; }
.seg-opt input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.achip {
  border: 0;
  background: var(--panel);
  color: var(--nav-active-ink);
  border-radius: 999px;
  padding: 5px 10px 5px 12px;
  font: 600 12px 'Inter', sans-serif;
  cursor: pointer;
}
.achip:hover { background: var(--nav-active-bg); }
.achip .x { margin-left: 6px; color: var(--muted); font-weight: 700; }

.input.compact { padding: 7px 10px; font-size: 12px; }

.btn.tiny { padding: 5px 9px; font-size: 11.5px; }
.btn.tiny:disabled { opacity: .45; cursor: not-allowed; }

.row-actions { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; }

.trow.off { background: var(--bg); opacity: .72; }
.trow.off > span:first-child { text-decoration: line-through; text-decoration-color: var(--muted); }

.pager { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.pager-meta { font-size: 12px; color: var(--muted); font-weight: 500; }
.pager-pages { display: flex; gap: 4px; align-items: center; }
.pager-btn { min-width: 32px; height: 32px; padding: 0 8px; border: 0; background: var(--bg); border-radius: var(--radius-sm); font: 600 12.5px 'Inter', sans-serif; color: var(--ink-2); cursor: pointer; }
.pager-btn:hover:not(:disabled) { background: var(--nav-active-bg); color: var(--nav-active-ink); }
.pager-btn:disabled { opacity: .35; cursor: not-allowed; }
.pager-cur { min-width: 32px; height: 32px; display: grid; place-items: center; background: var(--dark); color: #fff; border-radius: var(--radius-sm); font: 600 12.5px 'Inter', sans-serif; }
.pager-gap { color: var(--muted); padding: 0 2px; font-weight: 600; }
