:root {
  --bg: #0D1117;
  --surface: #161B22;
  --surface2: #1e2530;
  --border: rgba(255,255,255,0.07);
  --border2: rgba(255,255,255,0.13);
  --accent: #00E5A0;
  --accent-d: #00a371;
  --accent-hover: #00ffb3;
  --accent-light: rgba(0,229,160,0.08);
  --blue: #3b82f6;
  --blue-light: #0f1e3a;
  --success: #00E5A0;
  --warning: #FFE566;
  --danger: #FF4D8D;
  --text: #E8E8E8;
  --text-muted: #888888;
  --sidebar-w: 230px;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 3px, rgba(0,0,0,0.02) 3px, rgba(0,0,0,0.02) 4px);
  pointer-events: none;
  z-index: 9999;
}

/* ── Sidebar ── */
#sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

#sidebar .logo {
  padding: 22px 20px 18px;
  font-size: 15px;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
  letter-spacing: 0.02em;
  display: flex;
  align-items: center;
  gap: 8px;
}

#sidebar nav { flex: 1; padding: 14px 10px; }

#sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 13px;
  border-radius: 8px;
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 3px;
  letter-spacing: 0.1px;
}

#sidebar nav a:hover { background: var(--surface2); color: var(--text); }
#sidebar nav a.active {
  background: var(--accent-light);
  color: var(--accent);
  border-left: 2px solid var(--accent);
  padding-left: 11px;
}
#sidebar nav a .icon { font-size: 15px; width: 20px; text-align: center; opacity: 0.85; }

#sidebar .sidebar-user {
  padding: 14px 18px;
  border-top: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 12px;
}

/* ── Main ── */
#main {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

#page-content {
  flex: 1;
  padding: 28px 32px;
  max-width: 1100px;
}

h1 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
h2 { font-size: 16px; font-weight: 600; margin-bottom: 14px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

/* ── Stat tiles ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 28px;
}

.stat-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-tile .label { color: var(--text-muted); font-size: 11px; margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.08em; font-family: 'JetBrains Mono', monospace; }
.stat-tile .value { font-size: 32px; font-weight: 700; line-height: 1; }
.stat-tile .value.accent { color: var(--accent); }
.stat-tile .value.success { color: var(--accent); }
.stat-tile .value.warning { color: var(--warning); }
.stat-tile .value.danger { color: var(--danger); }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: opacity 0.15s, background 0.15s;
  text-decoration: none;
}

.btn:hover { opacity: 0.85; }
.btn-primary {
  background: var(--accent);
  color: #0D1117;
  font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  letter-spacing: 0.04em;
  box-shadow: 3px 3px 0 var(--accent-d);
  transition: transform 0.1s, box-shadow 0.1s, opacity 0.15s;
}
.btn-primary:hover { opacity: 1; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--accent-d); }
.btn-success { background: var(--success); color: #0D1117; font-weight: 700; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: var(--surface2); color: var(--text); border: 1px solid var(--border2); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-lg { padding: 12px 28px; font-size: 14px; border-radius: var(--radius); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Apply toggle ── */
.apply-toggle {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 28px;
}

.apply-toggle .status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
}

.apply-toggle .status-dot.active {
  background: var(--success);
  box-shadow: 0 0 8px var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.apply-toggle .status-text { flex: 1; }
.apply-toggle .status-text strong { display: block; font-size: 15px; }
.apply-toggle .status-text span { color: var(--text-muted); font-size: 12px; }

/* ── Forms list ── */
.forms-list { display: flex; flex-direction: column; gap: 12px; }

.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.form-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
}

.form-card-header:hover { background: var(--surface2); }
.form-card-header .title { flex: 1; font-weight: 600; color: var(--text); }
.form-card-header .title a { color: var(--text); text-decoration: none; }
.form-card-header .title a:hover { text-decoration: underline; }
.form-card-header .subtitle { font-size: 12px; color: var(--text-muted); }

.form-card-body {
  padding: 0 18px 16px;
  display: none;
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.form-card-body.open { display: block; }

.qa-item { margin-bottom: 12px; }
.qa-item .q { color: var(--text-muted); font-size: 12px; margin-bottom: 4px; }
.qa-item .a { font-size: 13px; }
.qa-item .a.empty { color: var(--text-muted); font-style: italic; }
.qa-item .by { font-size: 11px; color: var(--accent); margin-left: 6px; }
.qa-answer-row { display: flex; align-items: flex-start; gap: 8px; flex-wrap: wrap; }
.qa-answer-row .qa-edit-btn { flex-shrink: 0; }

/* Варианты ответов в анкетах (read mode) */
.q-opts-display { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; flex: 1; }
.q-opt {
  display: inline-block; padding: 3px 10px; border-radius: 12px;
  font-size: 12px; background: var(--surface2); color: var(--text-muted);
  border: 1px solid var(--border);
}
.q-opt-selected {
  background: var(--accent-light); color: var(--accent);
  border-color: rgba(0,229,160,0.3); font-weight: 600;
}

/* radio/checkbox в режиме редактирования в анкетах */
.form-card .q-radio-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.form-card .q-radio-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; padding: 4px 0;
}
.form-card .q-radio-label input { accent-color: var(--accent); }

/* ── Badge ── */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-ready { background: rgba(0,229,160,0.1); color: var(--accent); }
.badge-partial { background: rgba(255,229,102,0.1); color: var(--warning); }
.badge-new { background: var(--surface2); color: var(--text-muted); }
.badge-submitted { background: rgba(0,229,160,0.1); color: var(--accent); }
.badge-error { background: rgba(255,77,141,0.12); color: #FF4D8D; }

/* ── Questions ── */
.questions-list { display: flex; flex-direction: column; gap: 14px; }

.question-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}

.question-card .q-text { font-weight: 600; margin-bottom: 4px; }
.question-card .q-hint { font-size: 12px; color: var(--text-muted); margin-bottom: 10px; }
.question-card .q-options { margin-bottom: 10px; }
.question-card .q-options-label { font-size: 11px; color: var(--text-muted); margin-bottom: 5px; }
.question-card .q-option-chip {
  display: inline-block; padding: 2px 9px; margin: 2px 3px 2px 0;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: 12px; font-size: 12px; color: var(--text-muted);
}
.question-card .q-radio-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.question-card .q-radio-label {
  display: flex; align-items: center; gap: 8px;
  font-size: 13px; cursor: pointer; padding: 4px 0;
}
.question-card .q-radio-label input { accent-color: var(--accent); }
.question-card .q-priority { font-size: 11px; color: var(--accent); margin-bottom: 8px; }

.question-card textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 10px 12px;
  resize: vertical;
  min-height: 70px;
  outline: none;
  font-family: inherit;
}

.question-card textarea:focus { border-color: var(--accent); }
.question-card .answered-text { color: var(--success); font-size: 13px; margin-top: 6px; }

/* ── Profile ── */
.profile-textarea {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 14px;
  resize: vertical;
  min-height: 320px;
  outline: none;
  font-family: 'JetBrains Mono', 'Menlo', 'Consolas', monospace;
  line-height: 1.7;
}

.profile-textarea:focus { border-color: var(--accent); }

/* ── Settings form ── */
.settings-form { display: flex; flex-direction: column; gap: 18px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; font-family: 'JetBrains Mono', monospace; }

.field input[type="text"],
.field input[type="number"],
.field select {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  font-family: inherit;
  appearance: none;
}

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

.field .checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip-checkbox { display: none; }
.chip-label {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface2);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
  user-select: none;
}
.chip-checkbox:checked + .chip-label {
  background: var(--accent-light);
  border-color: var(--accent);
  color: var(--accent-hover);
}

/* ── Toast ── */
#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s ease;
}

#toast.show { transform: translateY(0); opacity: 1; }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error { border-color: var(--danger); color: var(--danger); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; }
.tab-btn {
  padding: 7px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}
.tab-btn:hover { background: var(--surface2); color: var(--text); }
.tab-btn.active { background: var(--accent-light); color: var(--accent); border: 1px solid rgba(0,229,160,0.2); }

/* ── Empty state ── */
.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 40px; margin-bottom: 12px; }
.empty-state p { font-size: 14px; }

/* ── Loading ── */
.loading { color: var(--text-muted); padding: 20px 0; }

.row { display: flex; align-items: center; gap: 12px; }
.spacer { flex: 1; }

/* ── Applications table ── */
.apps-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.apps-table th {
  text-align: left;
  padding: 11px 18px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.apps-table td {
  padding: 11px 18px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.apps-table tr:last-child td { border-bottom: none; }
.apps-table tr:hover td { background: var(--surface2); }

.apps-table .apps-title a {
  color: var(--text);
  text-decoration: none;
}
.apps-table .apps-title a:hover { text-decoration: underline; color: var(--accent-hover); }

.apps-date { color: var(--text-muted); white-space: nowrap; }
