@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

:root {
  /* Palette */
  --primary:       #3B82F6;
  --primary-dark:  #2563EB;
  --primary-light: #EFF6FF;
  --primary-dim:   #DBEAFE;

  --success:       #10B981;
  --success-light: #ECFDF5;
  --success-dim:   #A7F3D0;

  --warning:       #F59E0B;
  --warning-light: #FFFBEB;
  --warning-dim:   #FDE68A;

  --danger:        #EF4444;
  --danger-dark:   #DC2626;
  --danger-light:  #FEF2F2;

  --purple:        #8B5CF6;
  --purple-light:  #F5F3FF;
  --purple-dim:    #DDD6FE;

  --teal:          #14B8A6;
  --teal-light:    #F0FDFA;
  --teal-dim:      #99F6E4;

  --amber:         #D97706;
  --amber-light:   #FFFBEB;
  --amber-dim:     #FDE68A;

  /* Neutrals */
  --bg:            #F1F5F9;
  --surface:       #FFFFFF;
  --surface-2:     #F8FAFC;
  --border:        #E2E8F0;
  --border-dark:   #CBD5E1;
  --text:          #0F172A;
  --text-muted:    #64748B;
  --text-light:    #94A3B8;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.06);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.07), 0 2px 4px -2px rgba(0,0,0,.05);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.10), 0 8px 10px -6px rgba(0,0,0,.04);

  /* Table row colors */
  --row-period-bg:  #1E3A8A;
  --row-period-fg:  #FFFFFF;
  --row-total-bg:   #FFFBEB;
  --row-total-fg:   #78350F;
  --row-camp-hbg:   #ECFDF5;
  --row-camp-hfg:   #065F46;
  --row-title-hbg:  #FFF7ED;
  --row-title-hfg:  #9A3412;
  --row-text-hbg:   #F5F3FF;
  --row-text-hfg:   #4C1D95;
  --row-img-hbg:    #F0FDFA;
  --row-img-hfg:    #134E4A;

  --radius-sm: 6px;
  --radius:    10px;
  --radius-lg: 14px;
  --radius-xl: 20px;

  /* Расширенная палитра (hover/active состояния) */
  --primary-darker:  #1D4ED8;
  --success-dark:    #059669;
  --success-darker:  #047857;
  --danger-border:   #FECACA;

  /* Строки таблицы — hover */
  --row-camp-hover:  #F0FDF4;
  --row-title-hover: #FFF7ED;
  --row-text-hover:  #F5F3FF;
  --row-img-hover:   #F0FDFA;

  /* Строка субтотал */
  --row-subtotal-bg:     #EFF6FF;
  --row-subtotal-fg:     #1D4ED8;
  --row-subtotal-border: #BFDBFE;

  /* Типографическая шкала */
  --text-xs:   10px;
  --text-sm:   12px;
  --text-base: 13px;
  --text-md:   14px;
  --text-lg:   16px;
  --text-xl:   22px;
}

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

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

/* ─── Layout ─────────────────────────────────────────────────────────────────── */

#app { display: flex; height: 100vh; overflow: hidden; }

#sidebar {
  width: 232px;
  min-width: 232px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: var(--shadow-xs);
  z-index: 10;
}

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */

.sidebar-header {
  padding: 18px 16px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(150deg, var(--primary-light) 0%, var(--surface) 80%);
}

.sidebar-logo {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 2px 6px rgba(59,130,246,.35);
  flex-shrink: 0;
}

.sidebar-logo svg { fill: var(--row-period-fg); /* #FFFFFF через токен */ }

.sidebar-brand {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.3px;
}

.sidebar-brand span { color: var(--primary); }

.project-list {
  flex: 1;
  overflow-y: auto;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.project-list-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .8px;
  color: var(--text-light);
  padding: 4px 8px 6px;
}

.project-item {
  padding: 9px 6px 9px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: background .13s, color .13s;
}

.project-item:hover { background: var(--surface-2); color: var(--text); }

.project-item.active {
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--primary);
}

.project-item-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

/* Шестерёнка настроек — появляется при hover/active */
.btn-project-settings {
  flex-shrink: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: transparent;          /* скрыта по умолчанию */
  padding: 4px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .13s, background .13s;
  line-height: 0;
}

.project-item:hover .btn-project-settings {
  color: var(--text-muted);
}

.project-item.active .btn-project-settings {
  color: var(--primary-dark);
  opacity: .6;
}

.project-item:hover .btn-project-settings:hover,
.project-item.active .btn-project-settings:hover {
  color: var(--primary-dark);
  background: rgba(37,99,235,.12);
  opacity: 1;
}

.project-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border-dark); flex-shrink: 0;
  transition: background .13s, width .13s, height .13s;
}

.project-item.active .project-dot {
  background: var(--primary);
  width: 9px; height: 9px;
}

.sidebar-actions {
  padding: 10px 8px;
  border-top: 1px solid var(--border);
}

.btn-sidebar {
  width: 100%;
  padding: 8px 12px;
  background: none;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all .15s;
}

.btn-sidebar:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

/* ─── Sidebar user ───────────────────────────────────────────────────────────── */

.sidebar-user {
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--surface-2);
}

.sidebar-user-info {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  overflow: hidden;
}

.sidebar-user-info svg { color: var(--text-light); }

.sidebar-user-info span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.btn-logout {
  flex-shrink: 0;
  background: none;
  border: none;
  color: var(--text-light);
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  position: relative;
  transition: color .15s, background .15s;
}
/* Touch target ≥ 44×44px без коллизии с соседней кнопкой */
.btn-logout::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: var(--radius-sm);
}

.btn-logout:hover {
  color: var(--danger);
  background: var(--danger-light);
}

/* ─── Auth screen ────────────────────────────────────────────────────────────── */

#auth-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #0F172A 0%, #1E3A5F 50%, #0F172A 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.auth-logo {
  width: 56px;
  height: 56px;
  background: var(--primary);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  margin: 0 auto 16px;
  box-shadow: 0 8px 16px rgba(59,130,246,.35);
}

.auth-brand {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -.5px;
  color: var(--text);
}

.auth-brand span {
  color: var(--primary);
}

.auth-subtitle {
  font-size: 12px;
  color: var(--text-light);
  margin-top: 4px;
  margin-bottom: 28px;
}

.auth-setup-notice {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--primary-light);
  color: var(--primary-dark);
  border: 1px solid var(--primary-dim);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px;
  font-weight: 500;
  margin-bottom: 20px;
  text-align: left;
}

/* Унифицированный класс ошибки для всех форм */
.form-error,
.auth-error {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid var(--danger-border); /* токенизировано с #FECACA */
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: var(--text-sm);
  font-weight: 500;
  margin-bottom: 16px;
  text-align: left;
}

.btn-full {
  width: 100%;
  justify-content: center;
  margin-top: 4px;
}

/* ─── Admin panel ────────────────────────────────────────────────────────────── */

.modal-wide {
  max-width: 520px;
}

.admin-create-form {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.admin-users-list {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.admin-user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}

.admin-user-row:last-child { border-bottom: none; }

.admin-user-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.admin-badge {
  font-size: 10px;
  font-weight: 600;
  background: var(--primary-dim);
  color: var(--primary-dark);
  padding: 2px 7px;
  border-radius: 20px;
  letter-spacing: .3px;
  text-transform: uppercase;
}

.admin-user-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-xs {
  padding: 4px 10px;
  font-size: 11px;
  height: 26px;
}

/* ─── Topbar ─────────────────────────────────────────────────────────────────── */

#topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  z-index: 5;
}

#project-title {
  font-size: 15px;
  font-weight: 700;
  flex: 1;
  letter-spacing: -.3px;
  color: var(--text);
}

/* ─── Tabs ───────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 2px;
}

.tab-btn {
  padding: 5px 16px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  transition: all .15s;
  white-space: nowrap;
}

.tab-btn:hover:not(.active) { color: var(--text); background: var(--surface); }

.tab-btn.active {
  background: var(--surface);
  color: var(--primary-dark);
  box-shadow: var(--shadow-xs);
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ─── Content ────────────────────────────────────────────────────────────────── */

#content {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */

.btn {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  transition: all .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  letter-spacing: -.1px;
}

.btn:disabled { opacity: .5; cursor: not-allowed; }

/* Глобальный focus-visible — видимый индикатор фокуса клавиатуры */
:focus-visible {
  outline: 2px solid var(--primary-dark);
  outline-offset: 2px;
  border-radius: 4px;
}
/* Для form-control фокус через box-shadow (outline убран намеренно) */
.form-control:focus-visible { outline: none; }

.btn-primary {
  /* Начинаем с --primary-dark для контраста 4.98:1 вместо 3.40:1 */
  background: linear-gradient(135deg, var(--primary-dark), var(--primary-darker));
  color: #fff;
  box-shadow: 0 1px 3px rgba(59,130,246,.4), 0 1px 2px rgba(59,130,246,.2);
}
.btn-primary:not(:disabled):hover {
  background: linear-gradient(135deg, var(--primary-darker), #1A44C8);
  box-shadow: 0 4px 12px rgba(59,130,246,.45);
  transform: translateY(-1px);
}
.btn-primary:not(:disabled):active { transform: translateY(0); filter: brightness(.95); }

.btn-success {
  /* Начинаем с --success-dark (#059669) для контраста 4.55:1 вместо 2.43:1 */
  background: linear-gradient(135deg, var(--success-dark), var(--success-darker));
  color: #fff;
  box-shadow: 0 1px 3px rgba(16,185,129,.4);
}
.btn-success:not(:disabled):hover {
  background: linear-gradient(135deg, var(--success-darker), #065F46);
  box-shadow: 0 4px 12px rgba(16,185,129,.45);
  transform: translateY(-1px);
}
.btn-success:not(:disabled):active { transform: translateY(0); filter: brightness(.95); }

.btn-danger {
  background: linear-gradient(135deg, var(--danger), var(--danger-dark));
  color: #fff;
  box-shadow: 0 1px 3px rgba(239,68,68,.35);
}
.btn-danger:not(:disabled):hover { filter: brightness(.92); transform: translateY(-1px); }
.btn-danger:not(:disabled):active { transform: translateY(0); filter: brightness(.85); }

.btn-outline {
  background: var(--surface);
  color: var(--text-muted);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-outline:not(:disabled):hover {
  border-color: var(--border-dark);
  color: var(--text);
  background: var(--surface-2);
}
.btn-outline:not(:disabled):active { background: var(--bg); }

.btn-sm { padding: 5px 11px; font-size: 12px; }

/* ─── Actions bar ────────────────────────────────────────────────────────────── */

.actions-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  box-shadow: var(--shadow-xs);
}

/* ─── Empty state ────────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: var(--text-muted);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: .75;
  display: block;
}

.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
  letter-spacing: -.2px;
}

.empty-state p {
  font-size: 13px;
  margin-bottom: 24px;
  max-width: 300px;
  margin-left: auto;
  margin-right: auto;
}

/* ─── Period chips ───────────────────────────────────────────────────────────── */

.period-select-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}

.period-chip {
  padding: 5px 13px;
  border-radius: 100px;
  border: 1.5px solid var(--border);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
  box-shadow: var(--shadow-xs);
}

.period-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.period-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 8px rgba(59,130,246,.35);
}

.period-chip.is-current {
  border-color: var(--warning);
}

.period-chip.is-current:not(.active) {
  color: var(--amber);
  background: var(--warning-light);
}

.period-chip.is-current.active {
  background: linear-gradient(135deg, var(--warning), var(--amber));
  border-color: transparent;
  box-shadow: 0 2px 8px rgba(245,158,11,.35);
}

/* ─── Summary table ──────────────────────────────────────────────────────────── */

.summary-table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-base);
}

.summary-table th, .summary-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.summary-table tbody tr:last-child td { border-bottom: none; }

.summary-table thead th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--border);
}

/* Row types */
.row-week th, .row-month th {
  background: var(--row-period-bg);
  color: var(--row-period-fg);
  font-size: 13px;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  padding: 9px 12px;
}

.row-total td {
  background: var(--row-total-bg);
  color: var(--row-total-fg);
  font-weight: 700;
  border-top: 2px solid var(--warning-dim);
  border-bottom: 2px solid var(--warning-dim);
}

.row-camp-header td {
  background: var(--row-camp-hbg);
  color: var(--row-camp-hfg);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 5px 12px;
}

/* Базовый класс для заголовков секций — DRY-паттерн */
.row-camp-header td,
.row-title-header td,
.row-text-header td,
.row-image-header td {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 5px 12px;
}

.row-camp-header td  { background: var(--row-camp-hbg);  color: var(--row-camp-hfg); box-shadow: inset 3px 0 0 var(--success-dark); }
.row-title-header td { background: var(--row-title-hbg); color: var(--row-title-hfg); box-shadow: inset 3px 0 0 var(--amber); }
.row-text-header td  { background: var(--row-text-hbg);  color: var(--row-text-hfg); box-shadow: inset 3px 0 0 var(--purple); }
.row-image-header td { background: var(--row-img-hbg);   color: var(--row-img-hfg); box-shadow: inset 3px 0 0 var(--teal); }

.row-camp td  { background: var(--surface); }
.row-title td { background: var(--surface); }
.row-text td  { background: var(--surface); }
.row-image td { background: var(--surface); }

.row-camp:hover td  { background: var(--row-camp-hover); }
.row-title:hover td { background: var(--row-title-hover); }
.row-text:hover td  { background: var(--row-text-hover); }
.row-image:hover td { background: var(--row-img-hover); }

.row-type-header td {
  background: var(--surface-2);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 12px 4px 24px;
  border-bottom: 1px solid var(--border);
}

/* Sort header row */
.row-sort-header td {
  background: var(--surface-2);
  color: var(--text-muted); /* исправлено с --text-light (2.44:1) на --text-muted (4.36:1) */
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  padding: 4px 12px;
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid var(--border);
  transition: background .1s, color .1s;
  white-space: nowrap;
}

.row-sort-header td:hover { background: var(--primary-light); color: var(--primary); }
.row-sort-header td.sort-active { color: var(--primary-dark); font-weight: 700; }
.row-sort-header td:first-child { padding-left: 24px; }

/* Стрелка через псевдоэлемент — текст не меняется, ширина стабильна */
.row-sort-header td::after { content: ''; display: inline-block; width: 12px; }
.row-sort-header td[data-sort="desc"]::after { content: ' ↓'; width: auto; }
.row-sort-header td[data-sort="asc"]::after  { content: ' ↑'; width: auto; }

.row-subtotal td {
  background: var(--row-subtotal-bg);
  color: var(--row-subtotal-fg);
  font-weight: 600;
  font-size: var(--text-sm);
  border-top: 1px solid var(--row-subtotal-border);
  border-bottom: 1px solid var(--row-subtotal-border);
}

.row-subtotal td:first-child {
  padding-left: 24px;
}

.row-camp td:first-child,
.row-title td:first-child,
.row-text td:first-child,
.row-image td:first-child {
  padding-left: 24px;
  text-align: left;
  max-width: 460px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Цветовая полоса секции на строках данных */
.row-camp  td:first-child { box-shadow: inset 3px 0 0 rgba(5,150,105,.22); }
.row-title td:first-child  { box-shadow: inset 3px 0 0 rgba(217,119,6,.22); }
.row-text  td:first-child  { box-shadow: inset 3px 0 0 rgba(139,92,246,.22); }
.row-image td:first-child  { box-shadow: inset 3px 0 0 rgba(20,184,166,.22); }

/* zero-val: --text-muted (4.36:1) вместо --border-dark (1.96:1) */
.zero-val { color: var(--text-muted); opacity: .5; }
.neg-trend { color: var(--danger); }
.pos-trend { color: var(--success); }

/* ─── Reports ────────────────────────────────────────────────────────────────── */

.report-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
  transition: box-shadow .15s;
  border-left-width: 4px;
}

.report-card:hover { box-shadow: var(--shadow); }

/* Цвет акцента по типу периода */
.report-card--weekly  { border-left-color: var(--primary-dark); }
.report-card--monthly { border-left-color: var(--success-dark); }

.report-meta {
  font-size: var(--text-sm); /* 12px — исправлено с 11.5px */
  color: var(--text-light);
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

.report-meta-badge {
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 600;
}

.report-text {
  white-space: pre-wrap;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text);
}

/* ─── Modal ──────────────────────────────────────────────────────────────────── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 100;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 500px;
  max-width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modalIn .18s ease;
}

@keyframes modalIn {
  from { transform: translateY(8px) scale(.98); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  margin: 0 0 20px;   /* сброс браузерного margin у h2 */
  padding: 0;
  color: var(--text);
  letter-spacing: -.3px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* ─── Form ───────────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  letter-spacing: .2px;
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  background: var(--surface);
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(59,130,246,.18);
}

/* Состояние ошибки поля ввода */
.form-control--error,
.form-control.error {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}
.form-control--error:focus,
.form-control.error:focus {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px rgba(239,68,68,.2);
}

.counter-list { display: flex; flex-direction: column; gap: 8px; }

.counter-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
}

/* ─── Scope wrap ─────────────────────────────────────────────────────────────── */

.scope-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 12px;
  font-size: 13px;
  box-shadow: var(--shadow-xs);
}

.scope-input {
  width: 46px;
  border: none;
  outline: none;
  font-size: 13px;
  font-family: inherit;
  text-align: center;
  background: transparent;
  color: var(--text);
  -moz-appearance: textfield;
}

.scope-input::-webkit-inner-spin-button,
.scope-input::-webkit-outer-spin-button { -webkit-appearance: none; }

.scope-unit { color: var(--text-muted); }

.scope-preview {
  color: var(--primary);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

/* ─── Period check list ──────────────────────────────────────────────────────── */

.period-check-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.period-check-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  margin-bottom: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.period-check-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background .1s;
  user-select: none;
  color: var(--text);
}

.period-check-item:hover { background: var(--primary-light); }

.period-check-item input[type=checkbox] {
  width: 15px; height: 15px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

/* ─── Upload area ────────────────────────────────────────────────────────────── */

.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  color: var(--text-muted);
  background: var(--surface-2);
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}

.upload-area input { display: none; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */

#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: #fff;
  max-width: 360px;
  box-shadow: var(--shadow-md);
  animation: toastIn .2s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast::before {
  font-size: 15px;
  flex-shrink: 0;
}

.toast.success { background: linear-gradient(135deg, var(--success-dark), var(--success-darker)); }
.toast.success::before { content: '✓'; }
.toast.error { background: linear-gradient(135deg, var(--danger), var(--danger-dark)); }
.toast.error::before { content: '✕'; }
.toast.info { background: linear-gradient(135deg, var(--primary), var(--primary-dark)); }
.toast.info::before { content: 'ℹ'; }

@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

/* ─── Spinner ────────────────────────────────────────────────────────────────── */

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .65s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Progress bar ───────────────────────────────────────────────────────────── */

.progress-wrap { display: none; }
.progress-wrap.visible { display: block; }

.progress-bar {
  height: 3px;
  background: var(--primary-dim);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 6px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), #60A5FA);
  border-radius: 99px;
  animation: indeterminate 1.3s ease-in-out infinite;
  width: 40%;
}

@keyframes indeterminate {
  0%   { transform: translateX(-150%); }
  100% { transform: translateX(400%); }
}

.progress-label { font-size: 11.5px; color: var(--text-muted); }

/* ─── Image thumbnail ────────────────────────────────────────────────────────── */

.img-thumb {
  max-width: 72px;
  max-height: 36px;
  border-radius: 4px;
  vertical-align: middle;
  cursor: pointer;
  border: 1px solid var(--border);
}

/* ─── Hamburger button (скрыт на десктопе) ───────────────────────────────────── */

.btn-hamburger {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: color .15s, background .15s;
}
.btn-hamburger:hover { color: var(--text); background: var(--surface-2); }

/* ─── Sidebar overlay ────────────────────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.45);
  z-index: 40;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.sidebar-overlay.show { display: block; }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  /* Сайдбар — выезжает как drawer */
  #sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform .25s ease, box-shadow .25s ease;
    width: 260px;
    min-width: 260px;
  }
  #sidebar.mobile-open {
    transform: translateX(0);
    box-shadow: var(--shadow-lg);
  }

  /* Кнопка гамбургера видна */
  .btn-hamburger { display: flex; }

  /* Основной контент на всю ширину */
  #main { width: 100%; }
  #content { padding: 12px 14px; }

  /* Топбар: компактнее */
  #topbar { padding: 0 14px; gap: 10px; }
  #project-title { font-size: 14px; }

  /* Табы — скрол по горизонтали */
  #tabs-wrap { overflow-x: auto; flex-shrink: 1; min-width: 0; }
  .tabs { flex-wrap: nowrap; }
  .tab-btn { padding: 5px 12px; font-size: 12px; }

  /* Скрываем текст «Настройки», оставляем только иконку */
  #topbar-actions .btn-outline { padding: 6px 8px; font-size: 12px; }

  /* Actions bar */
  .actions-bar { padding: 8px 10px; gap: 6px; }
  .actions-bar .btn { font-size: 12px; padding: 6px 10px; }

  /* Таблица — горизонтальный скролл */
  .summary-table-wrap { font-size: 12px; }
  .summary-table th, .summary-table td { padding: 6px 8px; }

  /* Period chips компактнее */
  .period-chip { padding: 4px 10px; font-size: 11px; }

  /* Auth card */
  .auth-card { padding: 28px 20px; margin: 16px; }

  /* Toast */
  #toast-container { left: 12px; right: 12px; bottom: 16px; }
  .toast { max-width: 100%; }
}

/* ─── Иконки темы ────────────────────────────────────────────────────────────── */

.icon-sun  { display: none; }
.icon-moon { display: block; }
.dark .icon-moon { display: none; }
.dark .icon-sun  { display: block; }

/* ─── Dark theme ─────────────────────────────────────────────────────────────── */

.dark {
  color-scheme: dark;

  /* Нейтральные */
  --bg:          #0F172A;
  --surface:     #1E293B;
  --surface-2:   #243044;
  --border:      #334155;
  --border-dark: #475569;
  --text:        #F1F5F9;
  --text-muted:  #94A3B8;
  --text-light:  #4E6080;

  /* Тени */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.5);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.6), 0 1px 2px rgba(0,0,0,.4);
  --shadow:    0 4px 6px -1px rgba(0,0,0,.5), 0 2px 4px -2px rgba(0,0,0,.4);
  --shadow-md: 0 10px 15px -3px rgba(0,0,0,.6), 0 4px 6px -4px rgba(0,0,0,.4);
  --shadow-lg: 0 20px 25px -5px rgba(0,0,0,.7), 0 8px 10px -6px rgba(0,0,0,.5);

  /* Светлые оттенки → тёмные */
  --primary-light: #172554;
  --primary-dim:   #1E3A8A;

  --success-light: #052E16;
  --success-dim:   #064E3B;

  --danger-light:  #450A0A;
  --danger-border: #991B1B;

  --warning-light: #431407;
  --warning-dim:   #713F12;
  --amber-light:   #431407;
  --amber-dim:     #713F12;

  --purple-light:  #1E1040;
  --purple-dim:    #3B0764;

  --teal-light:    #042F2E;
  --teal-dim:      #134E4A;

  /* Строки таблицы */
  --row-total-bg:       #292208;
  --row-total-fg:       #FDE68A;

  --row-camp-hbg:       #064E3B;
  --row-camp-hfg:       #6EE7B7;
  --row-title-hbg:      #431407;
  --row-title-hfg:      #FED7AA;
  --row-text-hbg:       #1E1040;
  --row-text-hfg:       #C4B5FD;
  --row-img-hbg:        #042F2E;
  --row-img-hfg:        #99F6E4;

  --row-camp-hover:     #052E16;
  --row-title-hover:    #2C1503;
  --row-text-hover:     #1A0E38;
  --row-img-hover:      #031F20;

  --row-subtotal-bg:    #172554;
  --row-subtotal-fg:    #93C5FD;
  --row-subtotal-border:#1E3A8A;
}

/* Точечные перезаписи хардкод-цветов */
.dark body { background: var(--bg); color: var(--text); }

.dark .form-control {
  background: var(--surface-2);
  color: var(--text);
}
.dark .form-control::placeholder { color: var(--text-light); }

.dark select.form-control option { background: var(--surface-2); }

.dark .upload-area    { background: var(--surface-2); }
.dark .admin-create-form { background: var(--surface-2); }
.dark .scope-wrap     { background: var(--surface-2); }
.dark .counter-item   { background: var(--surface-2); }

/* Период row темнее */
.dark .row-week th, .dark .row-month th { background: #1E3A8A; }

/* Инпут поиска (если появится) */
.dark input { color-scheme: dark; }
