:root {
  --bg: #0d1117;
  --surface: #151b23;
  --elevated: #1b222c;
  --border: #262e3a;
  --border-soft: #1f2731;
  --text: #e6edf3;
  --muted: #8b98a6;
  --accent: #e8a33d;
  --accent-dim: rgba(232, 163, 61, .14);
  --ok: #46b978;
  --ok-dim: rgba(70, 185, 120, .14);
  --err: #f0645a;
  --err-dim: rgba(240, 100, 90, .14);
  --info: #5b9de8;
  --info-dim: rgba(91, 157, 232, .14);
  --radius: 10px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }

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

.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 20% -10%, rgba(232, 163, 61, .10), transparent 60%),
    radial-gradient(700px 500px at 110% 110%, rgba(91, 157, 232, .08), transparent 60%),
    var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 32px 28px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .45);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 22px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent), #c07a1e);
  display: grid; place-items: center;
  font-size: 17px;
}

.brand-name { font-weight: 800; letter-spacing: -.02em; font-size: 17px; }
.brand-sub { color: var(--muted); font-size: 12px; }

/* ---------- общее ---------- */

.eyebrow {
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .14em;
  color: var(--muted);
  font-weight: 700;
}

h1 { font-size: 22px; font-weight: 800; letter-spacing: -.02em; margin: 0 0 4px; }
h2 { font-size: 16px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 12px; }

label { display: block; font-size: 13px; color: var(--muted); margin: 14px 0 6px; }

input[type=text], input[type=password], input[type=number], select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 8px;
  padding: 10px 12px;
  outline: none;
  transition: border-color .15s;
}

input:focus, select:focus, textarea:focus { border-color: var(--accent); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  background: var(--accent);
  color: #17120a;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  padding: 11px 18px;
  cursor: pointer;
  transition: filter .15s, opacity .15s;
}
.btn:hover { filter: brightness(1.07); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-wide { width: 100%; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 600;
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
.btn-ghost:hover { border-color: var(--muted); }
.btn-sm { padding: 6px 11px; font-size: 13px; }
.btn-danger { color: var(--err); border-color: rgba(240, 100, 90, .35); }

.msg { margin-top: 14px; font-size: 13.5px; min-height: 20px; }
.msg.err { color: var(--err); }
.msg.ok { color: var(--ok); }

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

.shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 216px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar .brand { margin-bottom: 24px; padding: 0 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--muted);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--elevated); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }
.nav-spacer { flex: 1; }

.nav-user {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  font-size: 13px;
  color: var(--muted);
}
.nav-user b { color: var(--text); display: block; font-size: 14px; }

.main { flex: 1; min-width: 0; padding: 28px 32px 60px; }
.main-inner { max-width: 1060px; margin: 0 auto; }

.page-head { margin-bottom: 22px; }
.page-head p { color: var(--muted); margin: 0; font-size: 14px; }

/* ---------- карточки ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* ---------- выбор режима ---------- */

.choice-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }

.choice {
  border: 1px solid var(--border);
  background: var(--bg);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color .15s, background .15s;
}
.choice:hover { border-color: var(--muted); }
.choice.active { border-color: var(--accent); background: var(--accent-dim); }
.choice b { display: block; font-size: 14.5px; margin-bottom: 3px; }
.choice span { font-size: 12.5px; color: var(--muted); line-height: 1.35; display: block; }

.count-grid { display: grid; grid-template-columns: repeat(10, 1fr); gap: 6px; }
.count-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 0;
  cursor: pointer;
  font-weight: 700;
}
.count-btn:hover { border-color: var(--muted); }
.count-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* ---------- задачи ---------- */

.job {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
}
.job-top { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.job-title { font-weight: 600; font-size: 14.5px; line-height: 1.35; }
.job-title.empty { color: var(--muted); font-weight: 500; }
.job-meta { font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.job-step { font-size: 13px; color: var(--accent); margin-top: 8px; font-variant-numeric: tabular-nums; }
.job-err { font-size: 13px; color: var(--err); margin-top: 8px; word-break: break-word; }

.bar {
  height: 5px;
  background: var(--border-soft);
  border-radius: 3px;
  overflow: hidden;
  margin-top: 10px;
}
.bar > i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #f0c070);
  border-radius: 3px;
  transition: width .6s ease;
}
.bar.run > i { animation: pulse 1.8s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .65; } }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 20px;
  white-space: nowrap;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.pill.queued { background: var(--border-soft); color: var(--muted); }
.pill.running { background: var(--info-dim); color: var(--info); }
.pill.done { background: var(--ok-dim); color: var(--ok); }
.pill.error { background: var(--err-dim); color: var(--err); }
.pill.cancelled { background: var(--border-soft); color: var(--muted); }

.file-links { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
}
.file-link:hover { border-color: var(--accent); text-decoration: none; }
.file-link.primary { border-color: rgba(232, 163, 61, .5); color: var(--accent); }

.prompt-box {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.55;
  color: #cfd8e3;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 190px;
  overflow-y: auto;
  margin-top: 10px;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  font-size: 14px;
}

/* ---------- статистика ---------- */

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.stat .v { font-size: 24px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 12px; color: var(--muted); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--muted); padding: 8px 10px 8px 0; border-bottom: 1px solid var(--border);
}
td { padding: 9px 10px 9px 0; border-bottom: 1px solid var(--border-soft); font-variant-numeric: tabular-nums; }

.key-status { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

.toast {
  position: fixed;
  bottom: 22px; left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
  z-index: 50;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .4);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hint { font-size: 12.5px; color: var(--muted); margin-top: 6px; }
.sep { height: 1px; background: var(--border); margin: 18px 0; }

.voice-list { max-height: 260px; overflow-y: auto; margin-top: 10px; }
.voice-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: 8px; cursor: pointer; font-size: 13.5px;
}
.voice-row:hover { background: var(--elevated); }
.voice-row.active { background: var(--accent-dim); color: var(--accent); }
.voice-row small { color: var(--muted); font-size: 12px; }

@media (max-width: 860px) {
  .shell { flex-direction: column; }
  .sidebar {
    width: 100%; height: auto; position: static;
    flex-direction: row; overflow-x: auto; padding: 10px;
    border-right: none; border-bottom: 1px solid var(--border); gap: 6px;
  }
  .sidebar .brand, .nav-spacer, .nav-user { display: none; }
  .nav-item { width: auto; white-space: nowrap; }
  .main { padding: 18px 16px 50px; }
  .grid-2, .choice-grid, .stat-grid { grid-template-columns: 1fr; }
  .count-grid { grid-template-columns: repeat(5, 1fr); }
}
