@import url('https://fonts.googleapis.com/css2?family=Big+Shoulders+Display:ital,wght@0,700;0,800;1,700;1,800&family=Manrope:wght@400;500;600;700;800&family=JetBrains+Mono:wght@500;700&display=swap');

:root {
  /* --- палитра ГАЙД: тёплый уголь + фирменный красный --- */
  --bg: #0a0a0a;
  --bg-soft: #121212;
  --surface: #171717;
  --surface-2: #1f1f1f;
  --border: #2c2c2c;

  --ember: #e2000b;       /* фирменный красный ГАЙД (было ember-оранжевый) */
  --ember-dim: #a80008;
  --gold: #e8b33d;
  --sage: #8fbf8b;
  --danger: #e1543f;

  --text-hi: #f5eee4;
  --text-lo: #b4a99a;
  --text-faint: #7d7263;

  --font-display: 'Big Shoulders Display', sans-serif;
  --font-body: 'Manrope', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 16px;
  --radius-sm: 10px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text-hi);
  font-family: var(--font-body);
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 84px; /* место под таб-бар */
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  color: var(--text-hi);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 15px;
  width: 100%;
}

input:focus, textarea:focus, button:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 1px;
}

::-webkit-scrollbar { display: none; }

/* ---------------- header ---------------- */
.app-header {
  padding: 18px 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.app-header .brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-style: italic;
  font-size: 17px;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--text-hi);
}

.app-header .brand span {
  color: var(--ember);
}

.app-header .user-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 10px;
}

/* ---------------- ember progress ring (signature element) ---------------- */
.ring-wrap {
  padding: 4px 18px 14px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.ring {
  position: relative;
  width: 64px;
  height: 64px;
  flex-shrink: 0;
}

.ring svg { transform: rotate(-90deg); }

.ring circle {
  fill: none;
  stroke-width: 6;
}

.ring .track { stroke: var(--surface-2); }

.ring .fill {
  stroke: url(#emberGradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.5s cubic-bezier(.4,0,.2,1);
}

.ring.full .fill { animation: flicker 1.4s ease-in-out 2; }

@keyframes flicker {
  0%, 100% { filter: drop-shadow(0 0 0 rgba(226,0,11,0)); }
  50% { filter: drop-shadow(0 0 6px rgba(226,0,11,0.65)); }
}

.ring .pct {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-hi);
}

.ring-meta .category-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--text-hi);
  margin: 0 0 2px;
}

.ring-meta .category-sub {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-lo);
}

@media (prefers-reduced-motion: reduce) {
  .ring .fill, .ring.full .fill { transition: none; animation: none; }
}

/* ---------------- category chips ---------------- */
.chip-row {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 0 18px 14px;
  scroll-snap-type: x proximity;
}

.chip {
  flex-shrink: 0;
  scroll-snap-align: start;
  padding: 9px 14px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-lo);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.chip.active {
  background: linear-gradient(135deg, var(--ember), var(--ember-dim));
  color: #fff;
  border-color: transparent;
}

/* ---------------- main content ---------------- */
main {
  flex: 1;
  padding: 4px 18px 18px;
}

.section-title {
  font-family: var(--font-display);
  font-weight: 700;
  font-style: italic;
  font-size: 14px;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin: 18px 0 10px;
}

/* ---------------- task rows ---------------- */
.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.15s, background 0.15s;
}

.task-row.done {
  border-color: rgba(143, 191, 139, 0.4);
  background: linear-gradient(0deg, rgba(143,191,139,0.07), rgba(143,191,139,0.07)), var(--surface);
}

.task-row.skipped {
  border-color: rgba(180, 169, 154, 0.4);
  background: linear-gradient(0deg, rgba(180,169,154,0.07), rgba(180,169,154,0.07)), var(--surface);
}

.task-row .idx {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  width: 18px;
  flex-shrink: 0;
}

.task-row .mark {
  position: relative;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.task-row.done .mark {
  background: linear-gradient(135deg, var(--sage), #6ea56a);
  border-color: transparent;
}

.task-row.skipped .mark {
  background: var(--surface-2);
  border-color: rgba(180, 169, 154, 0.6);
}

.task-row:active .mark { transform: scale(0.9); }

.task-row .mark svg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  opacity: 0;
  transition: opacity 0.1s;
}

.task-row.done .mark .mark-check { opacity: 1; }
.task-row.skipped .mark .mark-dash { opacity: 1; }

.task-row .text {
  flex: 1;
  min-width: 0;
  text-align: left;
  font-size: 14.5px;
  line-height: 1.35;
  color: var(--text-hi);
}

.task-row.done .text {
  color: var(--text-lo);
  text-decoration: line-through;
  text-decoration-color: rgba(180,169,154,0.5);
}

.task-row.skipped .text {
  color: var(--text-lo);
}

.task-note-row {
  padding: 0 14px 4px 44px;
}

.task-note-row .note-input {
  width: 100%;
  font-size: 13px;
  padding: 8px 10px;
}

/* ---------------- buttons ---------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 14px;
  width: 100%;
}

.btn-primary {
  background: linear-gradient(135deg, var(--ember), var(--ember-dim));
  color: #fff;
}

.btn-secondary {
  background: var(--surface-2);
  color: var(--text-hi);
  border: 1px solid var(--border);
}

.btn-danger {
  background: rgba(225, 84, 63, 0.15);
  color: var(--danger);
  border: 1px solid rgba(225, 84, 63, 0.4);
}

.btn-icon {
  gap: 6px;
}

.btn:disabled { opacity: 0.5; }

/* ---------------- event cards ---------------- */
.event-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 10px;
}

.event-card .title {
  font-weight: 700;
  font-size: 15px;
  margin: 0 0 6px;
}

.event-card .meta {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-lo);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.event-card .actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.event-card .actions .btn { width: auto; padding: 8px 12px; font-size: 12.5px; }

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

/* ---------------- time tracking tab ---------------- */
.table-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 4px;
}

.table-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 14px;
  color: var(--text-hi);
  transition: transform 0.1s, border-color 0.15s;
}

.table-cell:active { transform: scale(0.94); }
.table-cell.busy { border-color: var(--gold); color: var(--gold); }

.order-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 8px;
}

.order-card .info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.order-card .order-title {
  font-weight: 700;
  font-size: 14px;
}

.order-card .timer {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-lo);
}

.order-card.running .timer { color: var(--gold); }
.order-card .actions .btn { width: auto; padding: 8px 14px; font-size: 13px; }

/* ---------------- admin forms ---------------- */
.form-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}

.form-grid label {
  font-size: 12px;
  color: var(--text-lo);
  font-weight: 600;
  margin-bottom: -4px;
}

.form-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.form-inline {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.form-inline input { flex: 1; }

.zones-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.zones-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--border);
}

.zones-table td:first-child {
  font-family: var(--font-mono);
  color: var(--text-lo);
  white-space: nowrap;
}

.zones-table .zone-status {
  color: var(--text-faint);
  text-align: right;
  white-space: nowrap;
}

.zones-table .zone-status.done {
  color: var(--sage);
}

/* ---------------- управление категориями чек-листа ---------------- */
.category-manage-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 10px;
  overflow: hidden;
}

.category-manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  cursor: pointer;
  user-select: none;
}

.category-manage-header .name {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-hi);
}

.category-manage-header .name .chevron {
  color: var(--text-faint);
  transition: transform 0.15s;
  flex-shrink: 0;
}

.category-manage-header.open .name .chevron { transform: rotate(90deg); }

.category-manage-header .count {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
}

.category-manage-body {
  display: none;
  padding: 0 14px 14px;
}

.category-manage-body.open { display: block; padding-top: 2px; }

.task-manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
}

.task-manage-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.task-manage-row .text-input {
  flex: 1;
  font-size: 13.5px;
}

.task-manage-row .text-input:focus {
  outline: 2px solid var(--ember);
}

.task-manage-row button {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-faint);
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
}

.task-manage-row button:hover { color: var(--danger); background: rgba(225,84,63,0.1); }

.category-manage-footer {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.category-manage-footer input { flex: 1; font-size: 13px; }
.category-manage-footer .btn { width: auto; padding: 8px 12px; font-size: 12.5px; }

.category-danger-row {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.category-danger-row .btn { width: 100%; }

/* ---------------- tab bar ---------------- */
.tab-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  background: var(--bg-soft);
  border-top: 1px solid var(--border);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  gap: 4px;
  z-index: 10;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  color: var(--text-faint);
  font-size: 10.5px;
  font-weight: 600;
}

.tab-btn.active { color: var(--ember); }

.tab-btn svg { width: 20px; height: 20px; }

/* ---------------- toast ---------------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 96px;
  transform: translateX(-50%) translateY(8px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-hi);
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 20;
  white-space: nowrap;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error { border-color: rgba(225,84,63,0.5); color: #ffb4a6; }

/* ---------------- modal ---------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 30;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-hi);
  text-align: center;
  margin: 0;
}

.star-row {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.star-btn {
  font-size: 32px;
  line-height: 1;
  color: var(--border);
  transition: color 0.1s, transform 0.1s;
}

.star-btn.filled { color: var(--gold); }

.star-btn:active { transform: scale(0.9); }

.modal-card textarea { resize: none; }

.modal-actions {
  display: flex;
  gap: 10px;
}

.modal-actions .btn { width: auto; flex: 1; }

/* ---------------- loading ---------------- */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: var(--text-faint);
  font-size: 13px;
  gap: 10px;
}

.spinner {
  width: 16px; height: 16px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--ember);
  animation: spin 0.7s linear infinite;
}

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

.gate {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 80vh;
  padding: 32px;
  text-align: center;
  gap: 10px;
}

.gate h1 {
  font-family: var(--font-display);
  font-style: italic;
  font-size: 18px;
}

.gate p { color: var(--text-lo); font-size: 13.5px; line-height: 1.5; }