:root {
  --bg: #0f0f0f;
  --surface: #1a1a1a;
  --surface2: #242424;
  --accent: #f59e0b;
  --red: #ef4444;
  --green: #22c55e;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --radius: 12px;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-size: 14px;
  min-height: 100vh;
}

#app { max-width: 480px; margin: 0 auto; padding-bottom: 24px; }

/* Шапка */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--surface2);
}
.header h1 { font-size: 18px; font-weight: 700; color: var(--accent); }
.date { font-size: 12px; color: var(--text-dim); }

/* Навигация */
.nav {
  display: flex;
  gap: 4px;
  padding: 8px 16px;
  border-bottom: 1px solid var(--surface2);
}
.nav-btn {
  flex: 1;
  padding: 8px 4px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 13px;
  cursor: pointer;
  border-radius: 8px;
  transition: all 0.2s;
}
.nav-btn.active {
  background: var(--accent);
  color: #000;
  font-weight: 600;
}

/* Табы */
.tab { display: none; padding: 16px; }
.tab.active { display: block; }

/* Карточки объектов */
.objects-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}
.object-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
}
.object-card h3 { font-size: 13px; margin-bottom: 10px; }
.object-stats { display: flex; flex-direction: column; gap: 6px; }
.stat { display: flex; justify-content: space-between; align-items: center; }
.stat-label { font-size: 12px; color: var(--text-dim); }
.stat-val { font-size: 15px; font-weight: 700; }
.stat-val.red { color: var(--red); }
.stat-val.green { color: var(--green); }

/* Сводные карточки */
.summary-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.summary-card h3 { font-size: 13px; margin-bottom: 10px; }

/* Список задач */
.task-list { list-style: none; }
.task-list li {
  padding: 10px 0;
  border-bottom: 1px solid var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.task-list li:last-child { border-bottom: none; }
.task-title { font-size: 13px; font-weight: 500; }
.task-meta { font-size: 11px; color: var(--text-dim); }

.task-list.full li { padding: 12px; background: var(--surface); border-radius: 8px; margin-bottom: 8px; border-bottom: none; }

/* Статус бейджи */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 10px;
  font-weight: 600;
}
.badge-pending { background: #1e3a5f; color: #60a5fa; }
.badge-in_progress { background: #1e4620; color: #4ade80; }
.badge-overdue { background: #4c1d1d; color: #f87171; }
.badge-done { background: #1a2e1a; color: #86efac; }

/* Фильтры */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.filter-row select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--surface2);
  color: var(--text);
  padding: 8px;
  border-radius: 8px;
  font-size: 13px;
}

/* Финансы */
.finance-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.fin-tab {
  padding: 8px 16px;
  background: var(--surface);
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}
.fin-tab.active { background: var(--accent); color: #000; font-weight: 600; }

.budget-bar-wrap {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 12px;
}
.budget-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.budget-bar {
  height: 8px;
  background: var(--surface2);
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 8px;
}
.budget-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 4px;
  transition: width 0.5s;
}
.budget-numbers {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}

.expense-list { list-style: none; }
.expense-list li {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--surface);
  border-radius: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}
.expense-list li span:last-child { font-weight: 700; color: var(--accent); }

/* Команда */
.period-select {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.period-btn {
  padding: 6px 16px;
  background: var(--surface);
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.period-btn.active { background: var(--accent); color: #000; font-weight: 600; }

.team-list { list-style: none; }
.team-list li {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}
.team-info { flex: 1; }
.team-name { font-size: 13px; font-weight: 600; }
.team-role { font-size: 11px; color: var(--text-dim); margin-top: 2px; }
.team-rate {
  font-size: 16px;
  font-weight: 700;
}
.rate-good { color: var(--green); }
.rate-ok { color: var(--accent); }
.rate-bad { color: var(--red); }

/* Пустое состояние */
.empty {
  text-align: center;
  color: var(--text-dim);
  padding: 24px 0;
  font-size: 13px;
}

/* Прогноз — таблица недель */
.weeks-btn {
  padding: 6px 14px;
  background: var(--surface);
  border: none;
  color: var(--text-dim);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.weeks-btn.active { background: var(--accent); color: #000; font-weight: 600; }

.week-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
  border-left: 3px solid var(--surface2);
}
.week-card.deficit { border-left-color: var(--red); }
.week-card.surplus { border-left-color: var(--green); }
.week-card.zero { border-left-color: var(--surface2); }

.week-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}
.week-title { font-size: 13px; font-weight: 700; }
.week-dates { font-size: 11px; color: var(--text-dim); }

.week-totals {
  display: flex;
  gap: 12px;
  margin-bottom: 8px;
  font-size: 12px;
}
.week-totals .inc { color: var(--green); }
.week-totals .exp { color: var(--red); }
.week-totals .net { font-weight: 700; }

.week-running {
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.week-running .neg { color: var(--red); font-weight: 700; }

.week-objects {
  border-top: 1px solid var(--surface2);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.obj-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
.obj-name { color: var(--text-dim); }
.obj-net.positive { color: var(--green); }
.obj-net.negative { color: var(--red); }

.alert-banner {
  background: rgba(239, 68, 68, 0.12);
  border-left: 3px solid var(--red);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 12px;
  font-size: 12px;
  color: #fca5a5;
}

/* AI-извлечения с кнопками подтверждения */
.week-items {
  border-top: 1px solid var(--surface2);
  padding-top: 8px;
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.cf-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 6px 0;
  font-size: 12px;
  align-items: center;
}
.cf-item .cf-text {
  color: var(--text);
  line-height: 1.3;
}
.cf-item .cf-meta {
  color: var(--text-dim);
  font-size: 11px;
  margin-top: 2px;
}
.cf-item.ai {
  background: rgba(245, 158, 11, 0.06);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 8px 10px;
}
.cf-item.ai .ai-badge {
  display: inline-block;
  background: var(--accent);
  color: #000;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 5px;
  letter-spacing: .05em;
}
.cf-actions {
  display: flex;
  gap: 4px;
}
.cf-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  font-size: 14px;
  cursor: pointer;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cf-btn.confirm {
  background: var(--green);
  color: #000;
}
.cf-btn.cancel {
  background: var(--red);
  color: #fff;
}
.cf-btn:active { transform: scale(0.9); }
.cf-btn:disabled { opacity: 0.3; cursor: default; }
.cf-amt-inc { color: var(--green); font-weight: 700; }
.cf-amt-exp { color: var(--red); font-weight: 700; }
