/* Консоль «Настроя». Токены — из дизайн-системы продукта. */

@font-face { font-family: 'Onest'; src: url('/admin/fonts/Onest-Regular.ttf') format('truetype'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Onest'; src: url('/admin/fonts/Onest-SemiBold.ttf') format('truetype'); font-weight: 600; font-display: swap; }
@font-face { font-family: 'Onest'; src: url('/admin/fonts/Onest-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }
@font-face { font-family: 'Unbounded'; src: url('/admin/fonts/Unbounded-Bold.ttf') format('truetype'); font-weight: 700; font-display: swap; }

:root {
  color-scheme: light;
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --raised: #F2F2EE;
  --text: #141414;
  --text-2: #595955;
  --divider: #E6E5E1;
  --border: #8C8C88;
  --accent: #E5531A;
  --primary: #141414;
  --on-primary: #FFFFFF;
  --success: #1B6E37;
  --warning: #8A5200;
  --danger: #B3261E;
  --font: 'Onest', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --mono: ui-monospace, 'Cascadia Mono', Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0B0B0C;
    --surface: #17171A;
    --raised: #222226;
    --text: #EDEDEA;
    --text-2: #A6A6A2;
    --divider: #2E2E33;
    --border: #6E6E76;
    --accent: #D7FF3F;
    --primary: #D7FF3F;
    --on-primary: #0B0B0C;
    --success: #7BD88F;
    --warning: #F0B849;
    --danger: #FF8F85;
  }
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 20px;
  overflow-x: hidden;
}

h1, h2, h3, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding: 0; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 8px; top: -48px; z-index: 10;
  background: var(--primary); color: var(--on-primary);
  padding: 6px 12px; border-radius: 4px; text-decoration: none;
}
.skip-link:focus { top: 8px; }

.noscript { padding: 24px; }

/* ---------- типографика ---------- */

.title { font-size: 20px; line-height: 28px; font-weight: 600; }
.subtitle { font-size: 16px; line-height: 24px; font-weight: 600; }
.caption, .hint { font-size: 12px; line-height: 16px; color: var(--text-2); }
.muted { color: var(--text-2); }
.strong { font-weight: 600; }
.prose { white-space: pre-wrap; overflow-wrap: anywhere; }
.value { overflow-wrap: anywhere; }

.brand { font-weight: 600; font-size: 14px; line-height: 20px; white-space: nowrap; }
.brand-name { font-family: 'Unbounded', var(--font); font-weight: 700; letter-spacing: 0.01em; }

.link { color: var(--text); text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; overflow-wrap: anywhere; }
.link:hover { text-decoration-color: var(--text); }

/* ---------- кнопки ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 32px; padding: 0 12px;
  border: 0; border-radius: 4px;
  font: inherit; font-weight: 600; line-height: 20px;
  cursor: pointer; white-space: nowrap;
  background: transparent; color: var(--text);
}
.btn:disabled { opacity: 0.5; cursor: default; }
.btn-primary { background: var(--primary); color: var(--on-primary); }
.btn-primary:hover:not(:disabled) { filter: brightness(1.15); }
.btn-text { padding: 0 8px; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
.btn-text:hover:not(:disabled) { background: var(--raised); }
.btn-danger { background: transparent; color: var(--danger); border: 1px solid var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--raised); }

.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.actions-wrap { gap: 4px 8px; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.seg {
  min-height: 32px; padding: 0 12px; border: 0; background: transparent; color: var(--text);
  font: inherit; cursor: pointer;
}
.seg + .seg { border-left: 1px solid var(--border); }
.seg[aria-pressed="true"] { background: var(--raised); font-weight: 600; }
.seg:focus-visible { outline-offset: -2px; }

/* ---------- поля ---------- */

.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label { font-weight: 600; }

.input {
  width: 100%; min-height: 32px; padding: 5px 10px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--text);
  font: inherit;
}
.input:disabled { background: var(--raised); color: var(--text-2); }
.input::placeholder { color: var(--text-2); }
select.input { padding-right: 28px; }
.textarea { resize: vertical; min-height: 72px; }
.textarea-tall { min-height: 200px; font-family: var(--mono); font-size: 13px; line-height: 20px; }
.input-code { max-width: 160px; font-size: 20px; line-height: 28px; letter-spacing: 0.3em; font-variant-numeric: tabular-nums; }
.input-num { min-width: 120px; }

.fieldset { border: 1px solid var(--divider); border-radius: 6px; padding: 12px 16px 16px; margin: 0; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.fieldset:disabled { opacity: 0.7; }
.fieldset > legend { padding: 0 4px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; min-height: 32px; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.switch-track {
  position: relative; flex: none; width: 36px; height: 20px; border-radius: 10px;
  background: var(--raised); border: 1px solid var(--border);
}
.switch-track::after {
  content: ''; position: absolute; top: 2px; left: 2px; width: 14px; height: 14px; border-radius: 50%;
  background: var(--text-2);
}
.switch input:checked + .switch-track { background: var(--primary); border-color: var(--primary); }
.switch input:checked + .switch-track::after { left: 18px; background: var(--on-primary); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switch input:disabled + .switch-track { opacity: 0.5; }

.msg { font-size: 14px; }
.msg-error { color: var(--danger); }
.msg-ok { color: var(--success); }

/* ---------- статус ---------- */

.status { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: var(--text-2); }
.status-success .dot { background: var(--success); }
.status-warning .dot { background: var(--warning); }
.status-danger .dot { background: var(--danger); }
.status-accent .dot { background: var(--accent); }
.status-muted .dot { background: var(--text-2); }

/* ---------- вход ---------- */

.login { min-height: 100vh; display: flex; align-items: flex-start; justify-content: center; padding: 64px 16px 32px; }
.login-card {
  width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 16px;
  background: var(--surface); border: 1px solid var(--divider); border-radius: 8px; padding: 24px;
}
.note { display: flex; flex-direction: column; gap: 8px; padding: 12px; border-radius: 6px; background: var(--raised); }

/* ---------- каркас ---------- */

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 24px; border-bottom: 1px solid var(--divider); background: var(--surface);
}
.who { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.who-login { font-weight: 600; overflow-wrap: anywhere; }
.who-role { color: var(--text-2); }

.layout { display: flex; align-items: flex-start; min-height: calc(100vh - 53px); }
.nav { flex: none; width: 220px; padding: 16px 12px; position: sticky; top: 0; }
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }
.nav-link {
  display: block; padding: 6px 12px; border-radius: 4px;
  color: var(--text-2); text-decoration: none; white-space: nowrap;
}
.nav-link:hover { background: var(--raised); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--raised); color: var(--text); font-weight: 600; }

.main { flex: 1; min-width: 0; padding: 16px 24px 48px; }
.view { display: flex; flex-direction: column; gap: 16px; max-width: 1200px; }
.view:focus { outline: none; }

.screen-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.back { font-size: 14px; }
.toolbar { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.toolbar .field { min-width: 200px; flex: 0 1 280px; }
.inline-form { display: flex; align-items: flex-end; gap: 8px 12px; flex-wrap: wrap; }
.inline-form .msg { flex-basis: 100%; }
.inline-edit { display: flex; flex-direction: column; gap: 8px; min-width: 200px; }

.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--divider); overflow-x: auto; }
.subnav-link {
  padding: 6px 12px; color: var(--text-2); text-decoration: none; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.subnav-link[aria-current="page"] { color: var(--text); font-weight: 600; border-bottom-color: var(--text); }

.banner {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  margin-bottom: 16px; padding: 8px 8px 8px 16px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--danger); max-width: 1200px;
}
.banner-text { overflow-wrap: anywhere; }
.banner-error .banner-text { color: var(--danger); }
.banner-ok { border-color: var(--success); }
.banner-ok .banner-text { color: var(--success); }

.card {
  background: var(--surface); border: 1px solid var(--divider); border-radius: 8px;
  padding: 16px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.loading, .empty { color: var(--text-2); padding: 16px 0; }

.meta { display: flex; flex-wrap: wrap; gap: 4px 16px; color: var(--text-2); }

/* ---------- таблицы ---------- */

.table-wrap {
  overflow-x: auto; max-width: 100%;
  border: 1px solid var(--divider); border-radius: 8px; background: var(--surface);
}
.table { border-collapse: collapse; width: 100%; }
.table th, .table td {
  padding: 8px 12px; text-align: left; vertical-align: top;
  border-bottom: 1px solid var(--divider);
}
.table thead th {
  font-size: 12px; line-height: 16px; font-weight: 600; color: var(--text-2);
  background: var(--raised); white-space: nowrap;
}
.table tbody th { font-weight: 400; }
.table tbody tr:last-child > * { border-bottom: 0; }
.table tfoot th, .table tfoot td { font-weight: 600; border-top: 1px solid var(--divider); border-bottom: 0; }
.table tr.editing > * { background: var(--raised); }
.cell-stack { display: flex; flex-direction: column; gap: 2px; min-width: 140px; }

.devices { list-style: none; display: flex; flex-direction: column; gap: 8px; min-width: 200px; }
.device { display: flex; flex-direction: column; gap: 2px; align-items: flex-start; }
.device + .device { border-top: 1px solid var(--divider); padding-top: 8px; }
.device .btn { margin-left: -8px; }

/* ---------- подтверждение и секреты ---------- */

.confirm {
  display: flex; flex-direction: column; gap: 8px; margin-top: 8px; padding: 12px;
  border: 1px solid var(--danger); border-radius: 6px; background: var(--surface); max-width: 420px;
}
.confirm-text { white-space: normal; }

.secret {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  border: 2px solid var(--warning); border-radius: 8px; background: var(--surface);
}
.secret-title { font-weight: 600; }
.secret-items { display: flex; flex-direction: column; gap: 12px; }
.secret-item { display: flex; flex-direction: column; gap: 4px; }
.secret-label { font-size: 12px; line-height: 16px; color: var(--text-2); }
.copy-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.secret-value { flex: 1 1 240px; font-family: var(--mono); font-size: 16px; line-height: 24px; background: var(--raised); }

/* ---------- заявки ---------- */

.kv { display: grid; grid-template-columns: minmax(80px, max-content) 1fr; gap: 4px 16px; }
.kv dt { color: var(--text-2); overflow-wrap: anywhere; }
.kv dd { min-width: 0; overflow-wrap: anywhere; }
.kv-wide { gap: 12px 24px; }
.kv-wide dt { font-weight: 600; color: var(--text); }

.pre {
  margin: 0; padding: 8px; border-radius: 6px; background: var(--raised);
  font-family: var(--mono); font-size: 12px; line-height: 16px;
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 360px; overflow: auto;
}

.plan { padding-left: 20px; display: flex; flex-direction: column; gap: 8px; }
.plan-title { font-weight: 600; overflow-wrap: anywhere; }

.history { list-style: none; display: flex; flex-direction: column; gap: 12px; }
.history > li + li { border-top: 1px solid var(--divider); padding-top: 12px; }

/* ---------- журнал ---------- */

.log { list-style: none; display: flex; flex-direction: column; border: 1px solid var(--divider); border-radius: 8px; background: var(--surface); }
.log-item { padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.log-item + .log-item { border-top: 1px solid var(--divider); }
.log-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.log-time { font-variant-numeric: tabular-nums; color: var(--text-2); }
.log-kind { font-weight: 600; }

/* ---------- выключатель агента ---------- */

.killswitch { border-width: 2px; border-color: var(--success); }
.killswitch-off { border-color: var(--danger); }

/* ---------- узкий экран ---------- */

@media (max-width: 760px) {
  .topbar { padding: 8px 16px; }
  .layout { flex-direction: column; align-items: stretch; }
  .nav { width: auto; padding: 0; position: static; border-bottom: 1px solid var(--divider); background: var(--surface); }
  .nav-list { flex-direction: row; overflow-x: auto; padding: 6px 12px; gap: 4px; }
  .main { padding: 16px 16px 40px; }
  .toolbar .field { flex: 1 1 100%; }
  .kv, .kv-wide { grid-template-columns: 1fr; gap: 2px; }
  .kv dd + dt { margin-top: 8px; }
  .login { padding-top: 32px; }
  .login-card { padding: 16px; }
}
