:root {
  --bg: #0b0b0f;
  --card: #1a1a20;
  --card-2: #202028;
  --text: #f2f2f4;
  --text-dim: #9a9aa4;
  --border: #2a2a33;
  --blue-bg: rgba(45, 110, 220, 0.18);
  --blue-fg: #5b9dff;
  --green-bg: rgba(40, 160, 100, 0.16);
  --green-fg: #3fdc8a;
  --orange-bg: rgba(190, 110, 20, 0.18);
  --orange-fg: #ffb84d;
  --gold-bg: rgba(200, 150, 30, 0.18);
  --gold-fg: #ffcf4d;
  --purple-bg: rgba(120, 70, 200, 0.2);
  --purple-fg: #b58cff;
  --red-fg: #ff6161;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-sm: 10px;
}

* { box-sizing: border-box; }

/* .tile/.sheet-overlay задают свой display — без этого правила атрибут
   hidden на них перестаёт работать (тот самый "серый экран, который не
   закрывается и блокирует все нажатия"). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

#app {
  max-width: 520px;
  margin: 0 auto;
  padding-bottom: 96px;
  min-height: 100vh;
}

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

/* --- Topbar --- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 12px 8px;
}
.month-nav {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--card);
  font-size: 20px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  justify-content: center;
}
.month-nav:active { background: var(--card-2); }
.month-title { text-align: center; }
.month-label { font-size: 15px; color: var(--text-dim); text-transform: capitalize; }
.app-title { font-size: 20px; font-weight: 700; margin-top: 2px; }

/* --- Content --- */
.content { padding: 8px 14px 0; }

.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 14px;
}
.card-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}
.card-sub { font-size: 13px; font-weight: 400; color: var(--text-dim); }

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
.tile {
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
  width: 100%;
}
.tile-label { font-size: 13px; color: var(--text-dim); }
.tile-value { font-size: 22px; font-weight: 700; }
.tile-wide { flex-direction: row; align-items: center; justify-content: space-between; margin-top: 10px; }
.tile-wide .tile-label { font-size: 14px; color: var(--text); }
.tile-wide .tile-value { font-size: 18px; }

.tile-blue { background: var(--blue-bg); }
.tile-blue .tile-value { color: var(--blue-fg); }
.tile-green { background: var(--green-bg); }
.tile-green .tile-value { color: var(--green-fg); }
.tile-orange { background: var(--orange-bg); }
.tile-orange .tile-value { color: var(--orange-fg); }
.tile-gold { background: var(--gold-bg); }
.tile-gold .tile-value { color: var(--gold-fg); }

/* --- Quick actions --- */
.quick-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.qa {
  border-radius: 999px;
  padding: 12px 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}
.qa-calc { background: var(--blue-bg); color: var(--blue-fg); }
.qa-stats { background: var(--purple-bg); color: var(--purple-fg); }
.qa-plechi { background: var(--gold-bg); color: var(--gold-fg); }
.qa:active { filter: brightness(1.2); }

/* --- Routes --- */
.section-head {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 10px;
}
.badge {
  background: var(--card-2);
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 2px 9px;
}
.routes-list { display: flex; flex-direction: column; gap: 10px; }
.empty-state {
  text-align: center;
  color: var(--text-dim);
  padding: 30px 10px;
  font-size: 14px;
}

.route-card {
  background: var(--card);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  text-align: left;
  width: 100%;
  display: block;
}
.route-card:active { background: var(--card-2); }
.route-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}
.route-title { font-size: 16px; font-weight: 700; }
.holiday-pill {
  background: var(--gold-bg);
  color: var(--gold-fg);
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 3px 8px;
}
.route-number { font-size: 13px; color: var(--text-dim); margin-bottom: 10px; }
.route-meta {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.route-meta-item { display: flex; flex-direction: column; gap: 2px; }
.route-meta-label { font-size: 11px; color: var(--text-dim); }
.route-meta-value { font-size: 13px; font-weight: 600; }
.v-start { color: var(--green-fg); }
.v-end { color: var(--red-fg); }
.v-hours { color: var(--blue-fg); }

/* --- Bottom nav --- */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 30px calc(14px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 60%, transparent);
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--text-dim);
}
.nav-icon { font-size: 20px; }
.nav-add {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--blue-fg);
  color: #05122b;
  font-size: 28px;
  font-weight: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 18px rgba(91, 157, 255, 0.4);
}
.nav-add:active { filter: brightness(1.1); }

/* --- Bottom sheet / modal --- */
.sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}
.sheet {
  background: var(--bg);
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  border-radius: 22px 22px 0 0;
  max-height: 90vh;
  overflow-y: auto;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom));
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 0 auto 14px;
}
.sheet-title {
  font-size: 19px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.sheet-close {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--card);
  color: var(--text-dim);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 6px;
}
.field input, .field textarea, .field select {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 12px;
  font-size: 15px;
  color: var(--text);
}
.field textarea { resize: vertical; min-height: 60px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.preview-box {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.preview-item { display: flex; flex-direction: column; gap: 2px; }
.preview-label { font-size: 11px; color: var(--text-dim); }
.preview-value { font-size: 16px; font-weight: 700; }

.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
  margin-top: 4px;
}
.btn-primary { background: var(--blue-fg); color: #05122b; }
.btn-primary:active { filter: brightness(1.1); }
.btn-danger { background: rgba(255, 97, 97, 0.15); color: var(--red-fg); margin-top: 10px; }
.btn-ghost { background: var(--card); color: var(--text); margin-top: 10px; }

.settings-group { margin-bottom: 20px; }
.settings-group-title { font-size: 13px; font-weight: 700; color: var(--text-dim); margin-bottom: 10px; text-transform: uppercase; letter-spacing: .3px; }

.holiday-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.holiday-row:last-child { border-bottom: none; }
.holiday-date { font-weight: 600; }
.holiday-label { font-size: 12px; color: var(--text-dim); }
.holiday-remove { color: var(--red-fg); font-size: 13px; }

.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}
.stat-tile {
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.stat-tile .tile-label { color: var(--text-dim); font-size: 12px; }
.stat-tile .tile-value { font-size: 20px; font-weight: 700; margin-top: 4px; }

.plechi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--card);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 8px;
}
.plechi-route { font-weight: 600; font-size: 14px; }
.plechi-meta { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.plechi-hours { color: var(--blue-fg); font-weight: 700; }

.salary-row {
  display: flex;
  justify-content: space-between;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
}
.salary-row:last-child { border: none; }
.salary-row.total { font-size: 18px; font-weight: 700; padding-top: 14px; color: var(--green-fg); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 100px;
  transform: translateX(-50%);
  background: var(--card-2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}
