:root {
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --text: #1B1E24;
  --text-muted: #6B7280;
  --accent: #1B3A5F;
  --accent-soft: #E8EDF3;
  --amber: #E8A93D;
  --danger: #C0392B;
  --green: #2E7D32;
  --border: #E5E7EB;
  --radius: 16px;
  --font: "Inter", "Noto Sans Georgian", sans-serif;
}

[data-theme="dark"] {
  --bg: #14171B;
  --surface: #1D2126;
  --text: #ECEAE4;
  --text-muted: #8E8A82;
  --accent: #6FA3D6;
  --accent-soft: rgba(111, 163, 214, 0.16);
  --amber: #E8A93D;
  --danger: #E2725A;
  --green: #6FBF73;
  --border: #2B2F35;
}

* { box-sizing: border-box; }

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

body { min-height: 100vh; }

#app {
  max-width: 520px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
  padding-bottom: 88px;
}

a { color: inherit; }

button, input, select, textarea {
  font-family: inherit;
  font-size: 1rem;
}

/* ---------- App bar: clean, minimal — back, title, language pill only ---------- */
.app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  color: var(--text);
  padding: 20px 16px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-bar .back {
  background: none;
  border: none;
  color: var(--text);
  font-size: 1.3rem;
  padding: 6px 10px;
  cursor: pointer;
  line-height: 1;
  border-radius: 50%;
  flex-shrink: 0;
}

.app-bar .title-wrap {
  flex: 1;
  min-width: 0;
}

.app-bar h1 {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.3rem;
  margin: 0;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-bar .subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
  font-weight: 500;
}

/* ---------- Overflow menu (Your Garage only): dark mode + log out ---------- */
.overflow-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  font-size: 1.1rem;
  color: var(--text);
  padding: 0;
}

.menu-popover {
  position: absolute;
  top: 66px;
  right: 16px;
  background: var(--surface);
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(20,25,35,0.16);
  padding: 6px;
  width: 200px;
  z-index: 30;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}

.menu-item.danger { color: var(--danger); }

.menu-value {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
}

.menu-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 6px;
}

.toggle-track {
  width: 36px;
  height: 20px;
  border-radius: 10px;
  background: var(--border);
  position: relative;
  display: inline-block;
  flex-shrink: 0;
}

.toggle-track.on { background: var(--accent); }

.toggle-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  position: absolute;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
  transition: left 0.15s ease;
}

.toggle-track.on .toggle-thumb { left: 18px; }

/* ---------- Content ---------- */
.content {
  padding: 4px 20px 20px;
  flex: 1;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state .glyph {
  font-size: 2rem;
  color: var(--border);
  margin-bottom: 8px;
}

.empty-state p { margin: 4px 0; }

/* ---------- Cards ---------- */
.ticket {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 14px;
  box-shadow: 0 2px 10px rgba(20,25,35,0.06);
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.1s ease;
}

.ticket:active { transform: scale(0.99); }

.ticket-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.ticket h2 {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.15rem;
  margin: 0 0 4px;
  letter-spacing: -0.01em;
}

.ticket .year {
  color: var(--text-muted);
  font-size: 0.86rem;
  font-weight: 500;
}

.chip {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
}

.ticket-meta {
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.78rem;
}

/* ---------- Info rows (label left, value right) ---------- */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.info-row:last-of-type { border-bottom: none; }

.info-row .k {
  font-size: 0.86rem;
  color: var(--text-muted);
  font-weight: 500;
}

.info-row .v {
  font-size: 0.92rem;
  font-weight: 600;
  text-align: right;
}

.stat-block {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.stat-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.9rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

/* ---------- Repair rows ---------- */
.repair-row {
  background: var(--surface);
  border-radius: 14px;
  padding: 15px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(20,25,35,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.repair-row .info { min-width: 0; }

.repair-row .name {
  font-weight: 600;
  font-size: 0.97rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.repair-row .date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.repair-row .cost {
  font-weight: 700;
  font-size: 0.97rem;
  color: var(--accent);
  white-space: nowrap;
}

/* ---------- Detail readout ---------- */
.readout-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 18px 0;
}

.readout {
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  box-shadow: 0 2px 8px rgba(20,25,35,0.05);
}

.readout .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.readout .value {
  font-weight: 700;
  font-size: 1.05rem;
}

.detail-block {
  background: var(--surface);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 2px 8px rgba(20,25,35,0.05);
}

.detail-block .label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.detail-block .value {
  font-size: 0.95rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 18px; }

.field label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.field input, .field textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.field select {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
}

.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.field textarea { resize: vertical; min-height: 80px; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 16px;
  border-radius: 14px;
  border: none;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: center;
}

.btn-primary { background: var(--accent); color: var(--surface); box-shadow: 0 4px 12px rgba(27,58,95,0.2); }
.btn-primary:active { opacity: 0.9; }

.btn-danger { background: var(--danger); color: var(--surface); }

.btn-ghost {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 10px 0;
  font-size: 0.88rem;
  width: 100%;
  text-align: center;
}

.error-msg {
  background: #FBEAE7;
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

.success-msg {
  background: #E8F0E6;
  color: var(--green);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  margin-bottom: 16px;
}

/* ---------- Auth screens ---------- */
.auth-wrap {
  padding: 48px 24px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
}

.auth-brand { text-align: center; margin-bottom: 36px; }

.auth-brand .glyph {
  font-size: 0.78rem;
  letter-spacing: 0.14em;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
}

.auth-brand h1 {
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.6rem;
  margin: 10px 0 4px;
  letter-spacing: -0.01em;
}

.auth-brand p {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0;
  font-weight: 500;
}

.auth-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 24px 20px;
  box-shadow: 0 2px 10px rgba(20,25,35,0.06);
}

/* ---------- FAB (circular) ---------- */
.fab {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(calc(-260px + 22px));
  background: var(--accent);
  color: var(--surface);
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(27,58,95,0.3);
  cursor: pointer;
  z-index: 20;
  padding: 0;
}

@media (max-width: 560px) {
  .fab { transform: none; right: 22px; left: auto; }
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 22px;
}

/* ---------- Toolbar / search ---------- */
.toolbar { display: flex; gap: 10px; margin-bottom: 16px; }

.search-field { flex: 1; min-width: 0; position: relative; }

.search-field input {
  width: 100%;
  min-width: 0;
  padding: 12px 14px 12px 36px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
}

.search-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search-field::before {
  content: "";
  position: absolute;
  left: 14px;
  top: 50%;
  width: 8px;
  height: 8px;
  border: 2px solid var(--text-muted);
  border-radius: 50%;
  transform: translateY(-60%);
}

.search-field::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 63%;
  width: 6px;
  height: 2px;
  background: var(--text-muted);
  transform: rotate(45deg);
}

.select-toggle {
  white-space: nowrap;
  flex-shrink: 0;
  padding: 0 18px;
  height: 46px;
  border-radius: 12px;
  border: 1.5px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.85rem;
  cursor: pointer;
}

.select-toggle.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--surface);
}

.no-results {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* ---------- Selectable repair rows ---------- */
.repair-row.selectable { padding-left: 12px; }

.repair-row .checkbox {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
}

.repair-row.selected { background: var(--accent-soft); }

.repair-row.selected .checkbox {
  background: var(--accent);
  border-color: var(--accent);
}

.repair-row.selected .checkbox::after {
  content: "";
  width: 6px;
  height: 10px;
  border-right: 2px solid var(--surface);
  border-bottom: 2px solid var(--surface);
  transform: rotate(45deg) translate(-1px, -1px);
}

/* ---------- Selection total bar ---------- */
.selection-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 520px;
  background: var(--accent);
  color: #fff;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 25;
  border-radius: 20px 20px 0 0;
  box-shadow: 0 -4px 16px rgba(0,0,0,0.18);
}

.selection-bar .count { font-size: 0.78rem; opacity: 0.8; font-weight: 500; }

.selection-bar .total { font-weight: 700; font-size: 1.15rem; }

.selection-bar button {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.35);
  color: inherit;
  border-radius: 10px;
  padding: 9px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}

.selection-bar button.remove-btn { background: var(--danger); border-color: var(--danger); }

/* ---------- Legacy toggle styling — no longer used directly, kept only in
   case any cached HTML still references it; safe to remove once confirmed
   unused after a deploy. ---------- */
.theme-toggle {
  background: none;
  border: none;
  color: var(--text);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.auth-theme-toggle {
  position: absolute;
  top: 16px;
  right: 16px;
}

/* ---------- Offline banner ---------- */
.offline-banner {
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  margin-bottom: 14px;
  font-weight: 500;
}

/* ---------- Pending-sync chip ---------- */
.pending-chip {
  font-size: 0.62rem;
  background: var(--amber);
  color: #3A2A06;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
  font-weight: 600;
}

/* ---------- Undo toast ---------- */
.undo-toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 12px 18px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 0.85rem;
  z-index: 40;
  box-shadow: 0 3px 8px rgba(0,0,0,0.25);
  max-width: 88%;
  white-space: nowrap;
}

.undo-toast button {
  background: none;
  border: none;
  color: var(--amber);
  font-weight: 700;
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0;
}

/* ---------- Footer ---------- */
.app-footer {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
