:root {
  --bg: oklch(0.98 0.003 250);
  --card: white;
  --side: oklch(0.99 0.002 250);
  --line: oklch(0.91 0.004 250);
  --line-soft: oklch(0.95 0.003 250);
  --input-line: oklch(0.88 0.004 250);
  --text: oklch(0.22 0.01 250);
  --muted: oklch(0.55 0.01 250);
  --muted-strong: oklch(0.4 0.01 250);
  --accent: oklch(0.55 0.15 250);
  --accent-text: oklch(0.5 0.14 250);
  --accent-soft: oklch(0.93 0.03 250);
  --danger: oklch(0.5 0.18 30);
  --danger-line: oklch(0.85 0.1 30);
  --warn-bg: oklch(0.95 0.06 85);
  --warn-text: oklch(0.4 0.09 70);
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: -apple-system, 'Helvetica Neue', Arial, sans-serif; font-size: 14px; }
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: oklch(0.85 0.005 250); border-radius: 4px; }
input, select, textarea, button { font-family: inherit; font-size: 14px; }
h1 { font-size: 22px; font-weight: 700; margin: 0; }
.mono { font-family: ui-monospace, Menlo, monospace; }
.muted { color: var(--muted); }

/* ---- кнопки и поля ---- */
.btn { border-radius: 8px; padding: 10px 16px; font-weight: 600; cursor: pointer; border: 1px solid var(--input-line); background: white; color: var(--muted-strong); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn.danger { border-color: var(--danger-line); color: var(--danger); }
.btn.small { padding: 6px 10px; font-size: 12px; border-radius: 6px; font-weight: 500; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: none; color: var(--accent-text); font-weight: 600; cursor: pointer; padding: 0; font-size: 13px; }
.field { display: block; }
.field > label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.input { width: 100%; padding: 10px 12px; border: 1px solid var(--input-line); border-radius: 8px; background: white; outline: none; }
.input:focus { border-color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
.pad { padding: 18px; }
.card-title { font-size: 14px; font-weight: 700; }

/* ---- бейджи ---- */
.badge { display: inline-block; padding: 4px 9px; border-radius: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.b-queued, .b-pending { color: oklch(0.5 0.01 250); background: oklch(0.93 0.004 250); }
.b-running, .b-cancelling, .b-awaiting_payment { color: oklch(0.45 0.13 80); background: oklch(0.94 0.05 80); }
.b-done, .b-created { color: oklch(0.4 0.1 155); background: oklch(0.93 0.05 155); }
.b-checked { color: oklch(0.42 0.1 250); background: oklch(0.94 0.04 250); }
.b-cancelled { color: oklch(0.45 0.01 250); background: oklch(0.91 0.004 250); }
.b-error, .b-cancel_error { color: oklch(0.48 0.18 30); background: oklch(0.94 0.06 30); }

/* ---- вход ---- */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login form { width: 320px; padding: 28px; display: flex; flex-direction: column; gap: 16px; }
.brand { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
.error-text { color: var(--danger); font-size: 13px; }

/* ---- каркас ---- */
.app { display: flex; height: 100vh; overflow: hidden; }
.side { width: 224px; flex: 0 0 224px; background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 20px 12px; gap: 4px; overflow-y: auto; }
.side .brand { padding: 8px 10px 20px; }
.nav { text-align: left; padding: 9px 10px; border-radius: 8px; border: none; background: transparent; color: oklch(0.35 0.01 250); font-weight: 500; cursor: pointer; width: 100%; }
.nav.active { background: var(--accent-soft); color: oklch(0.4 0.15 250); font-weight: 700; }
.side .logout { margin-top: auto; width: 100%; }
.main { flex: 1; min-width: 0; padding: 32px 40px; max-width: 1280px; overflow-y: auto; }
.banner { background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; padding: 10px 14px; margin-bottom: 20px; font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ---- список ТЗ ---- */
.tabs { display: flex; gap: 20px; margin: 20px 0 16px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 4px; background: none; border: none; border-bottom: 2px solid transparent; font-weight: 500; color: var(--muted); cursor: pointer; }
.tab.active { border-bottom-color: var(--accent); font-weight: 700; color: var(--text); }
.filters { display: flex; gap: 10px; margin-bottom: 14px; }
.filters .input { max-width: 320px; }
.filters select { width: auto; }
.table { overflow-x: auto; }
.table > div { min-width: 820px; }
.tr { display: grid; grid-template-columns: minmax(150px, 1fr) 130px 130px 130px 100px 90px; gap: 8px; padding: 12px 16px; align-items: center; border-bottom: 1px solid var(--line-soft); }
.tr.head { font-size: 12px; font-weight: 600; color: oklch(0.5 0.01 250); padding: 10px 16px; border-bottom-color: oklch(0.93 0.004 250); }
.tr.click { cursor: pointer; }
.tr.click:hover { background: oklch(0.985 0.003 250); }
.empty { padding: 40px; text-align: center; color: var(--muted); }

/* ---- форма ТЗ ---- */
.form { max-width: 560px; padding: 24px; display: flex; flex-direction: column; gap: 18px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.seg { display: flex; gap: 8px; }
.seg label { flex: 1; text-align: center; padding: 9px; border: 1px solid var(--input-line); border-radius: 8px; cursor: pointer; font-weight: 600; color: var(--muted-strong); }
.seg input { display: none; }
.seg label.on { background: var(--accent-soft); border-color: var(--accent); color: oklch(0.4 0.15 250); }
.plan { font-size: 13px; color: var(--muted-strong); background: var(--bg); border-radius: 8px; padding: 10px 12px; }

/* ---- карточка ТЗ ---- */
.progress { background: oklch(0.93 0.004 250); border-radius: 6px; height: 8px; overflow: hidden; }
.progress > div { background: var(--accent); height: 100%; border-radius: 6px; transition: width .3s; }
.card-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid oklch(0.93 0.004 250); }
.item { padding: 14px 18px; border-bottom: 1px solid var(--line-soft); }
.item .top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 4px; }
.item .name { font-weight: 600; font-size: 13px; }
.item .meta { font-size: 13px; color: var(--muted-strong); line-height: 1.5; }
.item .err { font-size: 13px; color: var(--danger); margin-top: 4px; line-height: 1.4; }
.log { display: flex; gap: 10px; font-size: 13px; padding: 6px 0; border-bottom: 1px solid oklch(0.96 0.002 250); }
.log .t { color: var(--muted); flex: 0 0 118px; white-space: nowrap; }
.log.error .x { color: var(--danger); }

/* ---- аккаунты ---- */
.acc-grid { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.acc-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.acc-row.active { background: white; border-color: var(--input-line); }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.dot.s-checking { background: oklch(0.65 0.15 80); }
.dot.s-free { background: oklch(0.6 0.15 155); } .dot.s-busy { background: oklch(0.65 0.15 80); }
.dot.s-error, .dot.s-proxy { background: oklch(0.55 0.18 30); } .dot.s-paused, .dot.s-provisioning { background: oklch(0.75 0.005 250); }
.dot.s-login, .dot.s-manual { background: oklch(0.6 0.14 250); }
.acc-hint { padding: 9px 14px; font-size: 13px; background: var(--accent-soft); color: oklch(0.38 0.1 250); border-bottom: 1px solid var(--line); }
.acc-hint.err { background: oklch(0.95 0.04 30); color: var(--danger); }
.screen { position: relative; display: flex; flex: 1; }
.screen-note { position: absolute; top: 8px; right: 8px; background: oklch(0.25 0.01 250 / .75); color: white; font-size: 12px; padding: 4px 8px; border-radius: 6px; pointer-events: none; }
.viewport { flex: 1; height: min(calc(100vh - 230px), 820px); min-height: 420px; border: 0; width: 100%; background: repeating-linear-gradient(135deg, oklch(0.95 0.003 250) 0 12px, oklch(0.97 0.002 250) 12px 24px); display: flex; align-items: center; justify-content: center; text-align: center; padding: 20px; }
.viewport .ph { background: white; border: 1px solid var(--input-line); padding: 12px 18px; border-radius: 8px; color: var(--muted-strong); max-width: 420px; line-height: 1.5; }

/* ---- настройки ---- */
.settings { max-width: 640px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat { font-size: 24px; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: flex-start; }
.check input { margin-top: 3px; }

/* ---- модалки ---- */
.overlay { position: fixed; inset: 0; background: oklch(0.2 0.01 250 / 0.45); display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: white; border-radius: 12px; max-width: 640px; width: 90%; max-height: 80vh; overflow-y: auto; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: white; font-size: 15px; font-weight: 700; }
.modal-head button { background: none; border: none; font-size: 20px; line-height: 1; cursor: pointer; color: var(--muted); }
.modal-body { padding: 8px 20px 16px; }
.modal-body.form-body { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: oklch(0.25 0.01 250); color: white; padding: 10px 16px; border-radius: 8px; z-index: 60; font-size: 13px; max-width: 80vw; }

@media (max-width: 820px) {
  .app { flex-direction: column; height: auto; overflow: visible; }
  .side { width: auto; flex: none; flex-direction: row; flex-wrap: wrap; padding: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .side .brand { padding: 6px 10px; } .side .logout { margin: 0 0 0 auto; width: auto; }
  .nav { width: auto; } .main { padding: 20px 16px; overflow: visible; }
  .acc-grid, .grid2, .form .two { grid-template-columns: 1fr; }
}
