/* ── Reset & Base ─────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --c-bg:       #f4f5f7;
  --c-surface:  #ffffff;
  --c-border:   #dde1e7;
  --c-text:     #1a1d23;
  --c-muted:    #6b7280;
  --c-primary:  #2563eb;
  --c-primary-d:#1d4ed8;
  --c-danger:   #dc2626;
  --c-success:  #16a34a;
  --c-warn:     #d97706;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(0,0,0,.08), 0 2px 12px rgba(0,0,0,.05);
}

body { font-family: system-ui, -apple-system, sans-serif; background: var(--c-bg); color: var(--c-text); font-size: 14px; line-height: 1.5; }
a { color: var(--c-primary); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea { font: inherit; }

/* ── Buttons ─────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius);
  border: 1px solid var(--c-border); background: var(--c-surface);
  cursor: pointer; font-size: 14px; font-weight: 500; white-space: nowrap;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--c-bg); }
.btn--primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn--primary:hover { background: var(--c-primary-d); border-color: var(--c-primary-d); }
.btn--danger { background: var(--c-danger); color: #fff; border-color: var(--c-danger); }
.btn--sm { padding: 4px 10px; font-size: 13px; }
.btn--today { font-size: 12px; }

/* ── Badges ──────────────────────────────────────────────────────────── */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 11px; font-weight: 600; line-height: 1.6;
}
.badge--paid      { background: #dcfce7; color: #15803d; }
.badge--unpaid    { background: #fef9c3; color: #854d0e; }
.badge--loc       { background: #e0e7ff; color: #3730a3; font-size: 10px; }
.badge--booked    { background: #dbeafe; color: #1e40af; }
.badge--in_progress { background: #fef3c7; color: #92400e; }
.badge--done      { background: #dcfce7; color: #166534; }
.badge--no_show   { background: #f3f4f6; color: #6b7280; }
.badge--cancelled { background: #fee2e2; color: #991b1b; }

/* ── Nav ─────────────────────────────────────────────────────────────── */
.nav {
  display: flex; align-items: center; gap: 16px;
  padding: 10px 20px; background: var(--c-surface);
  border-bottom: 1px solid var(--c-border); position: sticky; top: 0; z-index: 100;
}
.nav__brand { font-weight: 700; font-size: 16px; color: var(--c-text); }
.nav__links { display: flex; gap: 4px; flex: 1; }
.nav__link { padding: 5px 10px; border-radius: 6px; color: var(--c-muted); font-size: 14px; }
.nav__link:hover { background: var(--c-bg); color: var(--c-text); text-decoration: none; }
.nav__link--active { background: #eff6ff; color: var(--c-primary); font-weight: 600; }
.nav__user { display: flex; align-items: center; gap: 10px; color: var(--c-muted); font-size: 13px; }
.nav__logout { font-size: 13px; }

/* ── Board ───────────────────────────────────────────────────────────── */
.board-wrap { max-width: 1200px; margin: 0 auto; padding: 16px; }

.board-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-bottom: 12px;
}
.board-controls__left, .board-controls__center, .board-controls__right {
  display: flex; align-items: center; gap: 8px;
}
.board-controls__center { flex: 1; }
.input--date, .select--loc {
  padding: 6px 10px; border: 1px solid var(--c-border);
  border-radius: var(--radius); background: var(--c-surface);
  font-size: 14px;
}

.totals-bar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px;
  padding: 8px 12px; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  margin-bottom: 12px; font-size: 13px; min-height: 38px;
}
.totals__label { color: var(--c-muted); }
.totals__item { display: flex; gap: 4px; }
.totals__grand { margin-left: auto; font-weight: 600; }

.board-list { display: flex; flex-direction: column; gap: 6px; }
.board-loading, .board-empty { text-align: center; padding: 48px; color: var(--c-muted); }

/* ── Card ────────────────────────────────────────────────────────────── */
.board-card {
  display: flex; align-items: stretch;
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); cursor: pointer;
  transition: box-shadow .15s;
  border-left: 4px solid var(--c-border);
}
.board-card:hover { box-shadow: var(--shadow); }
.board-card.dragging { opacity: .4; }
.board-card--in_progress { border-left-color: var(--c-warn); }
.board-card--done        { border-left-color: var(--c-success); }
.board-card--cancelled   { border-left-color: var(--c-danger); opacity: .6; }
.board-card--no_show     { opacity: .5; }

.card__drag-handle {
  display: flex; align-items: center; padding: 0 10px;
  color: var(--c-muted); cursor: grab; font-size: 18px; user-select: none;
}
.card__body { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.card__top  { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card__mid  { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--c-muted); font-size: 13px; }
.card__bot  { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; }
.card__time { font-weight: 700; font-size: 15px; min-width: 38px; }
.card__plate { font-weight: 600; font-size: 13px; letter-spacing: .5px; }
.card__car  { color: var(--c-muted); }
.card__total { font-weight: 700; font-size: 14px; }
.card__phone { color: var(--c-muted); font-size: 12px; }
.card__masters { font-size: 12px; }
.drag-placeholder { height: 52px; background: #eff6ff; border: 2px dashed var(--c-primary); border-radius: var(--radius); }

/* ── Modal ───────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; z-index: 1000; padding: 40px 16px;
}
.modal {
  background: var(--c-surface); border-radius: 12px;
  width: 100%; max-width: 680px; box-shadow: 0 8px 40px rgba(0,0,0,.18);
}
.modal--sm { max-width: 440px; }
.modal__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--c-border);
}
.modal__title { font-size: 16px; font-weight: 700; }
.modal__close { background: none; border: none; cursor: pointer; font-size: 18px; color: var(--c-muted); padding: 4px 8px; border-radius: 6px; }
.modal__close:hover { background: var(--c-bg); }
.modal__body { padding: 20px; }

/* ── Booking Form ────────────────────────────────────────────────────── */
.bform { display: flex; flex-direction: column; gap: 14px; }
.bform__row { display: grid; gap: 12px; }
.bform__row--2 { grid-template-columns: 1fr 1fr; }
.bform__row--3 { grid-template-columns: 1fr 1fr 1fr; }
.bform__field { display: flex; flex-direction: column; gap: 4px; }
.bform__field label { font-size: 12px; font-weight: 600; color: var(--c-muted); text-transform: uppercase; letter-spacing: .5px; }
.bform__field input, .bform__field select, .bform__field textarea {
  padding: 8px 10px; border: 1px solid var(--c-border); border-radius: 6px;
  background: var(--c-surface); font-size: 14px;
}
.bform__field input:focus, .bform__field select:focus, .bform__field textarea:focus {
  outline: 2px solid var(--c-primary); border-color: var(--c-primary);
}
.bform__section-title { font-size: 13px; font-weight: 700; color: var(--c-muted); text-transform: uppercase; letter-spacing: .5px; margin-bottom: -4px; }
.bform__insurance { padding: 12px; background: #eff6ff; border-radius: var(--radius); display: flex; flex-direction: column; gap: 10px; }
.bform__actions { display: flex; gap: 10px; margin-top: 4px; }
.bform__hint { font-size: 13px; color: var(--c-muted); }
.check-label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 0; cursor: pointer; }

/* ── Autocomplete ────────────────────────────────────────────────────── */
.autocomplete-list {
  background: var(--c-surface); border: 1px solid var(--c-border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  max-height: 200px; overflow-y: auto;
}
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 13px; }
.autocomplete-item:hover { background: var(--c-bg); }

/* ── Search ──────────────────────────────────────────────────────────── */
.search-wrap { max-width: 1100px; margin: 0 auto; padding: 20px 16px; }
.search-bar { margin-bottom: 16px; }
.search-bar__input {
  width: 100%; padding: 10px 14px; border: 1px solid var(--c-border);
  border-radius: var(--radius); font-size: 16px; background: var(--c-surface);
}
.search-bar__input:focus { outline: 2px solid var(--c-primary); border-color: var(--c-primary); }
.search-results { display: flex; flex-direction: column; gap: 4px; }
.search-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--c-surface);
  border: 1px solid var(--c-border); border-radius: var(--radius); cursor: pointer;
}
.search-row:hover { box-shadow: var(--shadow); }
.search-row__date { font-weight: 600; min-width: 90px; }
.search-row__plate { font-weight: 600; }
.search-row__car, .search-row__phone, .search-row__loc { color: var(--c-muted); font-size: 13px; }
.search-row__total { font-weight: 700; margin-left: auto; }
.search-empty { text-align: center; padding: 40px; color: var(--c-muted); }

/* ── Admin ───────────────────────────────────────────────────────────── */
.admin-wrap { max-width: 1000px; margin: 0 auto; padding: 24px 16px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--c-border); }
.admin-header__title { font-weight: 700; font-size: 16px; }
.admin-title { font-size: 22px; font-weight: 700; margin-bottom: 16px; }
.users-table-wrap { margin-top: 16px; overflow-x: auto; }
.users-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.users-table th { background: var(--c-bg); padding: 10px 12px; text-align: left; border-bottom: 2px solid var(--c-border); font-weight: 600; white-space: nowrap; }
.users-table td { padding: 10px 12px; border-bottom: 1px solid var(--c-border); vertical-align: middle; }
.users-table tr:hover td { background: #f8faff; }

/* Toggle switch */
.toggle { position: relative; display: inline-block; width: 36px; height: 20px; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle__slider { position: absolute; inset: 0; background: var(--c-border); border-radius: 999px; cursor: pointer; transition: background .2s; }
.toggle__slider::before { content:''; position: absolute; height: 14px; width: 14px; left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: transform .2s; }
.toggle input:checked + .toggle__slider { background: var(--c-primary); }
.toggle input:checked + .toggle__slider::before { transform: translateX(16px); }

/* ── Admin tabs ──────────────────────────────────────────────────────── */
.admin-tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 2px solid var(--c-border); }
.admin-tab {
  padding: 8px 18px; background: none; border: none; border-bottom: 2px solid transparent;
  margin-bottom: -2px; cursor: pointer; font-size: 14px; font-weight: 500; color: var(--c-muted);
}
.admin-tab:hover { color: var(--c-text); }
.admin-tab--active { color: var(--c-primary); border-bottom-color: var(--c-primary); }
.admin-panel__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.admin-panel__title { font-size: 18px; font-weight: 700; }
.admin-panel__hint { font-size: 13px; color: var(--c-muted); margin-bottom: 16px; line-height: 1.6; }
.users-table__actions { white-space: nowrap; }

.smtp-table { width: 100%; max-width: 560px; border-collapse: collapse; margin-bottom: 24px; font-size: 14px; }
.smtp-table th { width: 140px; text-align: left; padding: 8px 12px; color: var(--c-muted); font-weight: 600; border-bottom: 1px solid var(--c-border); }
.smtp-table td { padding: 8px 12px; border-bottom: 1px solid var(--c-border); }
.smtp-table code { background: var(--c-bg); padding: 2px 6px; border-radius: 4px; font-size: 13px; }

.smtp-test__title { font-size: 15px; font-weight: 600; margin-bottom: 10px; }
.smtp-test__row { display: flex; gap: 10px; }
.smtp-test__input { flex: 1; padding: 8px 10px; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: 14px; }
.smtp-test__result { margin-top: 10px; font-size: 13px; color: var(--c-muted); min-height: 20px; }

/* ── Auth ────────────────────────────────────────────────────────────── */
.auth-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--c-bg); }
.auth-box { background: var(--c-surface); border-radius: 12px; padding: 40px; width: 100%; max-width: 400px; box-shadow: var(--shadow); text-align: center; }
.auth-box__title { font-size: 28px; font-weight: 800; margin-bottom: 8px; }
.auth-box__sub { color: var(--c-muted); margin-bottom: 24px; font-size: 15px; }
.auth-form { display: flex; flex-direction: column; gap: 12px; }
.auth-form__input { padding: 10px 14px; border: 1px solid var(--c-border); border-radius: var(--radius); font-size: 15px; }
.auth-box__msg { margin-top: 14px; font-size: 14px; color: var(--c-success); min-height: 20px; }
.auth-box__error { color: var(--c-danger); font-size: 14px; }
.auth-box__dev { margin-top: 16px; padding: 10px; background: #fef9c3; border-radius: 6px; font-size: 13px; }

/* ── Mobile ──────────────────────────────────────────────────────────── */
@media (max-width: 600px) {
  .board-controls { gap: 8px; }
  .bform__row--3 { grid-template-columns: 1fr 1fr; }
  .bform__row--2 { grid-template-columns: 1fr; }
  .modal { border-radius: 0; min-height: 100vh; }
  .modal-overlay { padding: 0; align-items: flex-end; }
  .nav__links .nav__link span { display: none; }
  .card__loc { display: none; }
  .totals-bar { font-size: 12px; gap: 8px; }
}
