:root {
  --bg: #212121;
  --card: #2b2b2b;
  --card-border: #383838;
  --input-bg: #343638;
  --text: #dce4ee;
  --muted: #9ca3af;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --green: #059669;
  --green-soft: rgba(5, 150, 105, 0.22);
  --yellow: #d97706;
  --yellow-soft: rgba(217, 119, 6, 0.18);
  --red: #dc2626;
  --red-soft: rgba(220, 38, 38, 0.18);
  --orange: #ea580c;
  --warn: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --tab-bar-h: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.35;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }

.app, .login-view {
  max-width: 560px;
  margin: 0 auto;
  padding: 10px 12px calc(var(--tab-bar-h) + 20px);
}

/* —— Шапка —— */
.header.card {
  padding: 14px;
  background: linear-gradient(180deg, #2d2d2d 0%, var(--card) 100%);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  margin-bottom: 10px;
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark { font-size: 1.6rem; line-height: 1; }
.header h1 { margin: 0; font-size: 1.25rem; font-weight: 700; }
.tagline { margin: 2px 0 0; font-size: 0.74rem; color: var(--muted); }
.btn-logout { margin-left: auto; }

.stats-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip {
  background: #3f3f3f; color: var(--text);
  padding: 4px 10px; border-radius: 20px; font-size: 0.72rem; font-weight: 600;
}
.chip-free { background: var(--green-soft); color: #6ee7b7; }
.chip-occupied { background: var(--accent); color: #fff; }
.chip-level { background: #343638; color: var(--muted); }

/* —— Кнопки и поля —— */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: none; border-radius: var(--radius-sm); padding: 10px 14px;
  font-size: 0.9rem; font-weight: 600; color: #fff; cursor: pointer;
  background: #4b5563;
}
.btn:active { transform: translateY(1px); }
.btn-accent { background: var(--accent); }
.btn-accent:active { background: var(--accent-hover); }
.btn-green { background: var(--green); }
.btn-red { background: var(--red); }
.btn-yellow { background: var(--yellow); }
.btn-ghost { background: #3f3f3f; color: var(--muted); }
.btn-block { width: 100%; }
.btn-sm { padding: 7px 10px; font-size: 0.8rem; }

.input {
  width: 100%; background: var(--input-bg); border: 1px solid var(--card-border);
  color: var(--text); border-radius: var(--radius-sm); padding: 10px 12px; font-size: 0.95rem;
}
.input:focus { outline: none; border-color: var(--accent); }

.field { display: block; margin-bottom: 10px; }
.field > span { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }

.search-row { margin-bottom: 10px; }

/* —— Карточки/секции —— */
.card { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); }
.section-title { font-size: 0.95rem; font-weight: 700; margin: 4px 0 8px; }

/* —— Вкладки —— */
.tab-bar {
  position: fixed; left: 0; right: 0; bottom: 0; height: var(--tab-bar-h);
  display: flex; background: #1a1a1a; border-top: 1px solid var(--card-border);
  max-width: 560px; margin: 0 auto; z-index: 50;
}
.tab-btn {
  flex: 1; background: none; border: none; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  font-size: 0.68rem; cursor: pointer;
}
.tab-btn .tab-icon { font-size: 1.15rem; }
.tab-btn-active { color: var(--accent); }

.tab-panel { display: none; }
.tab-panel-active { display: block; }

/* —— Сетка мест —— */
.legend { display: flex; flex-wrap: wrap; gap: 8px; font-size: 0.72rem; color: var(--muted); margin-bottom: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 3px; vertical-align: -1px; }

.spots-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px;
}
.spot-card {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 9px 10px; cursor: pointer; min-height: 74px;
}
.spot-card:active { border-color: var(--accent); }
.spot-free { border-left: 3px solid var(--green); }
.spot-occupied { border-left: 3px solid var(--accent); }
.spot-overlap { border-left: 3px solid var(--yellow); }
.spot-special { border-left: 3px solid var(--muted); }

.spot-num { font-weight: 700; font-size: 0.95rem; }
.spot-num .num-empty { color: var(--muted); font-weight: 400; }
.spot-car { font-size: 0.76rem; color: var(--text); margin-top: 3px; word-break: break-word; }
.spot-vin { font-size: 0.7rem; color: var(--muted); font-family: ui-monospace, Consolas, monospace; margin-top: 2px; }
.spot-level { font-size: 0.66rem; color: var(--muted); margin-top: 2px; }

.rent-badge {
  display: inline-block; background: var(--yellow-soft); color: #fcd34d;
  border: 1px solid var(--yellow); border-radius: 6px;
  padding: 1px 6px; font-size: 0.62rem; font-weight: 600; vertical-align: middle;
}

.memory-picker { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 10px; }
.memory-picker .btn { justify-content: flex-start; text-align: left; }

/* —— Списки результатов —— */
.results-list { display: flex; flex-direction: column; gap: 8px; }
.result-item {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius-sm);
  padding: 10px 12px;
}
.result-item .ri-title { font-weight: 600; }
.result-item .ri-sub { font-size: 0.78rem; color: var(--muted); margin-top: 2px; }
.result-item .ri-actions { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
.empty { color: var(--muted); text-align: center; padding: 20px 0; }

.move-banner {
  position: sticky; top: 8px; z-index: 30;
  background: var(--yellow-soft); border: 1px solid var(--yellow);
  border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
}
.move-banner span { flex: 1; font-size: 0.85rem; }

.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-box {
  position: relative; width: 100%; max-width: 560px; padding: 16px;
  border-radius: var(--radius) var(--radius) 0 0; max-height: 85vh; overflow-y: auto;
}
.modal-box h3 { margin: 0 0 10px; font-size: 1.02rem; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.modal-row { margin-bottom: 10px; }
.modal-row label { display: block; font-size: 0.78rem; color: var(--muted); margin-bottom: 4px; }
.modal-close-row { text-align: right; margin-top: 10px; }

.toast {
  position: fixed; bottom: calc(var(--tab-bar-h) + 12px); left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 12px 18px; border-radius: var(--radius-sm);
  font-size: 0.88rem; font-weight: 500; z-index: 200; max-width: 92%; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.45);
}

/* —— Вход —— */
.login-view { padding-top: 20vh; }
.login-card { padding: 20px; }
.login-card .brand-row { margin-bottom: 18px; }
.login-card h1 { font-size: 1.5rem; }
.login-card .btn { width: 100%; margin-top: 4px; }

/* —— Админ —— */
.admin-section { margin-bottom: 16px; }
.admin-card { padding: 12px; }
.admin-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.history-item { border-bottom: 1px solid var(--card-border); padding: 7px 0; font-size: 0.8rem; }
.history-item:last-child { border-bottom: none; }
.history-item .h-ts { color: var(--muted); font-size: 0.7rem; }
.history-item .h-action { font-weight: 600; }
.history-item .h-detail { color: var(--muted); }

.error-banner {
  background: #451a1a; color: #fecaca; border: 1px solid #991b1b;
  border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 8px; font-size: 0.85rem;
}

@media (min-width: 600px) {
  .modal { align-items: center; }
  .modal-box { border-radius: var(--radius); }
}

