:root {
  --bg: #0b1020;
  --surface: #131b31;
  --surface-2: #1b2644;
  --border: rgba(148, 163, 184, 0.16);
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #6366f1;
  --accent-hover: #818cf8;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --radius: 14px;
  --nav-h: 68px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

.app-shell {
  max-width: 760px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: 16px 14px calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand img {
  width: 34px;
  height: 34px;
  border-radius: 9px;
}

.brand h1 {
  font-size: 1.05rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand span {
  display: block;
  font-size: 0.72rem;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}

.badge.ok {
  color: #34d399;
  border-color: rgba(16, 185, 129, 0.35);
  background: rgba(16, 185, 129, 0.1);
}

.badge.warn {
  color: #fbbf24;
  border-color: rgba(245, 158, 11, 0.35);
  background: rgba(245, 158, 11, 0.1);
}

.badge.err {
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.35);
  background: rgba(239, 68, 68, 0.1);
}

.panel {
  display: none;
  flex-direction: column;
  gap: 14px;
}

.panel.active {
  display: flex;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px;
}

.card-title {
  margin: 0 0 10px;
  font-size: 0.95rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.subtext {
  margin: 0 0 12px;
  font-size: 0.8rem;
  color: var(--muted);
}

label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"],
input[type="password"],
input[type="number"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.15s ease;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 76px;
}

.field {
  margin-bottom: 12px;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

button.btn {
  appearance: none;
  border: none;
  border-radius: 10px;
  min-height: 44px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s ease, opacity 0.15s ease, background 0.15s ease;
}

button.btn:active {
  transform: scale(0.98);
}

button.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  flex: 1;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-success {
  background: var(--success);
  color: #042f2e;
  flex: 1;
}

.btn-icon {
  min-width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-size: 0.9rem;
}

.btn-icon.danger {
  color: #fca5a5;
}

.queue-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
}

.queue-item-text {
  font-size: 0.88rem;
  word-break: break-word;
  flex: 1;
}

.queue-idx {
  color: var(--accent-hover);
  font-weight: 700;
  margin-right: 6px;
}

.queue-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.score-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border-radius: 10px;
  border: 1px solid var(--border);
  margin-bottom: 10px;
}

.score-big {
  font-size: 1.4rem;
  font-weight: 800;
}

.score-big.strong { color: var(--success); }
.score-big.workable { color: var(--warning); }
.score-big.weak { color: var(--danger); }

.bars {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 10px;
}

.bar-row {
  display: grid;
  grid-template-columns: 92px 1fr 34px;
  align-items: center;
  gap: 8px;
  font-size: 0.74rem;
}

.bar-track {
  height: 8px;
  background: var(--bg);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--success));
  border-radius: 999px;
}

.lint-list {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.8rem;
}

.lint-ok { color: #34d399; }
.lint-warn { color: #fbbf24; }

.chips {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 6px;
  margin-bottom: 8px;
  scrollbar-width: thin;
}

.chip {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--muted);
  border-radius: 999px;
  padding: 6px 11px;
  font-size: 0.74rem;
  cursor: pointer;
}

.chip.active, .chip:hover {
  border-color: var(--accent);
  color: var(--text);
  background: rgba(99, 102, 241, 0.16);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 12px;
  font-size: 0.85rem;
}

.run-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
}

.run-meta {
  font-size: 0.75rem;
  color: var(--muted);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 12px);
  transform: translateX(-50%) translateY(20px);
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid rgba(99, 102, 241, 0.5);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  max-width: 92vw;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: rgba(11, 16, 32, 0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  z-index: 50;
}

.nav-btn {
  appearance: none;
  background: transparent;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
}

.nav-btn .ico {
  font-size: 1.2rem;
  line-height: 1;
}

.nav-btn.active {
  color: var(--accent-hover);
}

@media (min-width: 900px) {
  .app-shell {
    padding-top: 24px;
  }
  .bottom-nav {
    max-width: 760px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-radius: 16px 16px 0 0;
  }
}
