:root {
  --bg: #f6f4ee; --bg-2: #efebe2; --surface: #fff; --text: #1b1a17; --muted: #625e55; --faint: #8d887c;
  --line: #e2ded3; --line-strong: #cfc9bb; --accent: #c4532d; --accent-hover: #a9431f; --accent-soft: #f6e3da;
  --on-accent: #fff; --ok: #2f7d4f; --ok-soft: #dcefe3; --warn: #a86a00; --warn-soft: #f8ecd2; --bad: #b3261e; --bad-soft: #f8dcd9;
  --shadow: 0 1px 2px rgba(30,25,15,.05), 0 8px 24px -8px rgba(30,25,15,.14);
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141310; --bg-2: #1b1a16; --surface: #1f1e1a; --text: #f2efe7; --muted: #aaa598; --faint: #7f7a6f;
    --line: #2f2d27; --line-strong: #444037; --accent: #e2754d; --accent-hover: #ef8a63; --accent-soft: #3a2219;
    --on-accent: #1a0f0a; --ok: #5fbf86; --ok-soft: #1b3326; --warn: #e0b04a; --warn-soft: #3a2f14; --bad: #ef6a55; --bad-soft: #3d1e19;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14.5px/1.5 var(--sans); -webkit-font-smoothing: antialiased; }
h2 { font-size: 19px; margin: 0 0 14px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
code, .mono { font-family: var(--mono); }
small { color: var(--muted); font-weight: 400; }

/* бренд */
.brand { display: flex; align-items: center; gap: 9px; }
.brand .mark { width: 26px; height: 26px; border-radius: 7px; background: var(--text); position: relative; overflow: hidden; flex: none; }
.brand .mark::after { content: ""; position: absolute; inset: 6px; background: linear-gradient(135deg, transparent 50%, var(--accent) 50%); border-radius: 0 0 4px 0; }
.brand b { font-size: 18px; font-weight: 800; letter-spacing: -.03em; }
.brand b span { color: var(--accent); }
.brand small { font-size: 13px; }

/* кнопки и поля */
.btn { height: 36px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent; font: 600 14px var(--sans); cursor: pointer; white-space: nowrap; color: var(--text); background: transparent; }
.btn.sm { height: 30px; padding: 0 12px; font-size: 13px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: var(--accent-hover); }
.btn.ghost { border-color: var(--line-strong); }
.btn.ghost:hover { border-color: var(--text); }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn.danger:hover { background: var(--bad-soft); }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea {
  font: 14.5px var(--sans); color: var(--text); background: var(--bg); border: 1px solid var(--line-strong);
  border-radius: 10px; padding: 8px 11px; width: 100%; min-width: 0;
}
input.mono, textarea.mono { font-family: var(--mono); font-size: 13px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
label { display: grid; gap: 5px; font-weight: 600; font-size: 13.5px; }
label.check { display: flex; align-items: center; gap: 9px; font-weight: 500; }
label.check input { width: 17px; height: 17px; accent-color: var(--accent); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.error { color: var(--bad); min-height: 1.4em; margin: 0; }
.msg { min-height: 1.4em; margin: 0; color: var(--muted); }
.msg.bad { color: var(--bad); }
.msg.good { color: var(--ok); }
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.hint.inline { flex-basis: 100%; }
.warn { color: var(--warn); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 16px; }
.login-card .brand { margin-bottom: 6px; }
.login-card .btn { height: 42px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 20px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; color: var(--muted); font: 600 14px var(--sans); padding: 7px 12px; border-radius: 999px; cursor: pointer; }
.tabs button:hover { color: var(--text); }
.tabs button.on { background: var(--bg-2); color: var(--text); }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; color: var(--muted); }
.wrap { max-width: 1400px; margin: 0 auto; padding: 20px; }

/* сводка */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; }
.stat b { display: block; font-size: 22px; letter-spacing: -.02em; }
.stat span { color: var(--muted); font-size: 12.5px; }
.stat.alert b { color: var(--bad); }

/* таблицы */
.toolbar { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; align-items: center; }
.toolbar input[type=search] { flex: 1 1 320px; }
.toolbar select { width: auto; }
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.grid { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.grid th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--faint); font-weight: 700;
  padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--bg-2); }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr.click { cursor: pointer; }
.grid tbody tr.click:hover td { background: var(--bg-2); }
.grid .num { text-align: right; white-space: nowrap; }
.grid .key { font-family: var(--mono); font-size: 13px; white-space: nowrap; }
.grid .machine { font-family: var(--mono); font-size: 12px; color: var(--muted); max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .date { white-space: nowrap; color: var(--muted); }
.grid .note { color: var(--muted); max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.grid .empty { text-align: center; color: var(--muted); padding: 28px; }
.grid .acts { white-space: nowrap; text-align: right; }
.grid .acts .btn { margin-left: 4px; }
.more { display: flex; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 13px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.free { background: var(--bg-2); color: var(--muted); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }

/* диалоги */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text);
  width: min(640px, calc(100vw - 32px)); box-shadow: var(--shadow); }
dialog::backdrop { background: rgba(10, 8, 5, .45); }
.dialog-body { display: grid; gap: 14px; padding: 22px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-all; }
.actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }
.result { background: var(--bg-2); border-radius: 12px; padding: 12px 14px; font-family: var(--mono); font-size: 14px; display: grid; gap: 4px; }
.narrow { max-width: 460px; display: grid; gap: 14px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--text); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-weight: 600; box-shadow: var(--shadow); z-index: 20; }

@media (max-width: 700px) {
  .top { padding: 10px 12px; gap: 10px; }
  .wrap { padding: 12px; }
  .row2 { grid-template-columns: 1fr; }
  .who span { display: none; }
}
