/* =========================================================================
   SmartBox v2 — Modern minimalist (Linear/Notion vibe)
   Design tokens via CSS custom properties + light/dark themes.
   ========================================================================= */

:root {
  /* Brand */
  --brand-primary: #5b6cff;
  --brand-primary-hover: #4a5be0;
  --brand-primary-active: #3d4cc4;

  /* Surfaces */
  --bg: #fafafa;
  --bg-elevated: #ffffff;
  --bg-subtle: #f4f4f5;
  --bg-hover: #f4f4f5;

  /* Borders */
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --border-focus: var(--brand-primary);

  /* Text */
  --text: #18181b;
  --text-muted: #52525b;
  --text-subtle: #a1a1aa;
  --text-inverse: #ffffff;

  /* Accents */
  --success: #16a34a;
  --success-bg: #dcfce7;
  --warning: #ea580c;
  --warning-bg: #ffedd5;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --info: var(--brand-primary);
  --info-bg: #eef2ff;

  /* Radii */
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --fs-xs: 12px;
  --fs-sm: 13px;
  --fs-base: 14px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 20px;
  --fs-2xl: 24px;
  --fs-3xl: 30px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.04);

  /* Layout */
  --container-max: 880px;
  --header-height: 56px;

  /* Motion */
  --t-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
  --t: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
  --bg: #09090b;
  --bg-elevated: #18181b;
  --bg-subtle: #27272a;
  --bg-hover: #27272a;

  --border: #27272a;
  --border-strong: #3f3f46;

  --text: #fafafa;
  --text-muted: #a1a1aa;
  --text-subtle: #71717a;
  --text-inverse: #18181b;

  --brand-primary: #818cf8;
  --brand-primary-hover: #a5b4fc;
  --brand-primary-active: #6366f1;

  --success: #4ade80;
  --success-bg: rgba(74, 222, 128, 0.12);
  --warning: #fb923c;
  --warning-bg: rgba(251, 146, 60, 0.12);
  --danger: #f87171;
  --danger-bg: rgba(248, 113, 113, 0.12);
  --info-bg: rgba(129, 140, 248, 0.12);

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.5), 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* =========================================================================
   Base / reset
   ========================================================================= */

*, *::before, *::after { box-sizing: border-box; }

* { margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
}

body {
  font-family: var(--font-sans);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--brand-primary);
  text-decoration: none;
  transition: color var(--t-fast);
}
a:hover { color: var(--brand-primary-hover); }

img { max-width: 100%; display: block; }

/* Defensive default — qualquer SVG inline sem dimensão explícita usa 1em
   (regras específicas com selector mais forte continuam ganhando) */
svg { width: 1em; height: 1em; flex-shrink: 0; }

::selection { background: var(--brand-primary); color: white; }

/* =========================================================================
   Header
   ========================================================================= */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(8px);
}

.topbar-inner {
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--sp-4);
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-4);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { color: var(--text); }
.brand-mark {
  width: 28px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--brand-primary);
  color: white;
}
.brand-mark svg { width: 18px; height: 18px; }

.nav {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
}

.nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--text-muted);
  transition: background var(--t-fast), color var(--t-fast);
}
.nav-link:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.nav-link.is-active {
  color: var(--text);
  background: var(--bg-subtle);
}
.nav-link svg { width: 16px; height: 16px; }

.nav-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 var(--sp-2);
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 0 var(--sp-2) 0 var(--sp-2);
  height: 36px;
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  color: var(--text-muted);
}
.user-avatar {
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 11px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast);
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }

.theme-toggle .sun { display: none; }
.theme-toggle .moon { display: inline-flex; }
[data-theme="dark"] .theme-toggle .sun { display: inline-flex; }
[data-theme="dark"] .theme-toggle .moon { display: none; }

/* Mobile nav */
.nav-toggle { display: none; }

@media (max-width: 720px) {
  .topbar-inner { padding: 0 var(--sp-3); gap: var(--sp-2); }
  .nav { display: none; }
  .nav.is-open {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-2);
    box-shadow: var(--shadow);
    gap: 0;
  }
  .nav.is-open .nav-divider { display: none; }
  .nav.is-open .user-chip { padding-left: var(--sp-3); }
  .nav.is-open .nav-link,
  .nav.is-open .user-chip { width: 100%; justify-content: flex-start; }
  .nav-toggle { display: inline-flex; }
}

/* =========================================================================
   Layout
   ========================================================================= */

.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: var(--sp-6) var(--sp-4) var(--sp-12);
  flex: 1;
}

.container-narrow {
  max-width: 420px;
  margin: 0 auto;
  padding: var(--sp-12) var(--sp-4);
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.page-header h1 { margin: 0; }

.page-title {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
}
.page-subtitle {
  color: var(--text-muted);
  font-size: var(--fs-sm);
  margin-top: var(--sp-1);
}

.section { margin-bottom: var(--sp-8); }
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
  margin-bottom: var(--sp-3);
}
.section-title {
  font-size: var(--fs-md);
  font-weight: 600;
  color: var(--text);
}
.section-meta {
  font-size: var(--fs-xs);
  color: var(--text-muted);
}

/* =========================================================================
   Cards
   ========================================================================= */

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-5);
}
.card-pad-sm { padding: var(--sp-4); }
.card-pad-lg { padding: var(--sp-8); }
.card-flat { box-shadow: none; }
.card-elevated { box-shadow: var(--shadow); }
.card-empty {
  text-align: center;
  color: var(--text-muted);
  padding: var(--sp-10) var(--sp-4);
}
.card-empty svg {
  width: 40px;
  height: 40px;
  color: var(--text-subtle);
  margin-bottom: var(--sp-3);
}

.card-hero {
  text-align: center;
}
.card-hero .hero-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-lg);
  background: var(--info-bg);
  color: var(--brand-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--sp-4);
}
.card-hero .hero-icon svg { width: 28px; height: 28px; }

/* =========================================================================
   Forms
   ========================================================================= */

.form-grid {
  display: grid;
  gap: var(--sp-4);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
@media (max-width: 540px) { .form-row { grid-template-columns: 1fr; } }

.field { display: block; }
.field-label {
  display: block;
  font-size: var(--fs-sm);
  color: var(--text-muted);
  font-weight: 500;
  margin-bottom: var(--sp-2);
}
.field-hint {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  margin-top: var(--sp-1);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="datetime-local"],
input[type="search"],
input:not([type]),
select,
textarea {
  width: 100%;
  height: 40px;
  padding: 0 var(--sp-3);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: inherit;
  font-size: var(--fs-base);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
textarea {
  height: auto;
  min-height: 80px;
  padding: var(--sp-3);
  resize: vertical;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--info-bg);
}
input::placeholder, textarea::placeholder { color: var(--text-subtle); }

input[type="file"] {
  padding: 6px;
  font-size: var(--fs-sm);
}
input[type="file"]::file-selector-button {
  height: 28px;
  padding: 0 var(--sp-3);
  margin-right: var(--sp-3);
  background: var(--bg-subtle);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: var(--fs-xs);
  font-weight: 500;
  cursor: pointer;
}

/* =========================================================================
   Buttons
   ========================================================================= */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 40px;
  padding: 0 var(--sp-4);
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: var(--fs-sm);
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast), box-shadow var(--t-fast);
}
.btn:hover { background: var(--bg-hover); }
.btn:active { background: var(--bg-subtle); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--info-bg); border-color: var(--brand-primary); }
.btn[disabled], .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}
.btn svg { width: 16px; height: 16px; }

.btn-primary {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}
.btn-primary:hover { background: var(--brand-primary-hover); border-color: var(--brand-primary-hover); }
.btn-primary:active { background: var(--brand-primary-active); border-color: var(--brand-primary-active); }

.btn-danger {
  background: transparent;
  border-color: var(--border);
  color: var(--danger);
}
.btn-danger:hover { background: var(--danger-bg); border-color: var(--danger); }

.btn-ghost { border-color: transparent; }
.btn-ghost:hover { background: var(--bg-hover); }

.btn-lg {
  height: 48px;
  padding: 0 var(--sp-5);
  font-size: var(--fs-md);
}

.btn-sm {
  height: 32px;
  padding: 0 var(--sp-3);
  font-size: var(--fs-xs);
  border-radius: var(--radius-sm);
}

.btn-icon-only {
  width: 36px;
  padding: 0;
}

.btn-block { width: 100%; }

.btn-group {
  display: flex;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

/* =========================================================================
   Bike list (resident dashboard)
   ========================================================================= */

.bike-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--sp-3);
}

.bike-card {
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
  cursor: pointer;
  position: relative;
}
.bike-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.bike-card.is-selected {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px var(--info-bg);
}
.bike-card input[type="checkbox"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  z-index: 1;
}

.bike-photo {
  aspect-ratio: 16 / 10;
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
  overflow: hidden;
}
.bike-photo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.bike-photo svg { width: 48px; height: 48px; opacity: 0.4; }

.bike-info-row {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-2);
}
.bike-info-row strong {
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--text);
}
.bike-info-row small {
  display: block;
  color: var(--text-muted);
  font-size: var(--fs-xs);
  margin-top: 2px;
}

.bike-check-mark {
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  border: 2px solid var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-fast);
}
.bike-card.is-selected .bike-check-mark {
  background: var(--brand-primary);
  border-color: var(--brand-primary);
  color: white;
}
.bike-check-mark svg { width: 14px; height: 14px; opacity: 0; transition: opacity var(--t-fast); }
.bike-card.is-selected .bike-check-mark svg { opacity: 1; }

/* In-use list (mais simples) */
.loan-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}
.loan-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.loan-row .loan-thumb {
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}
.loan-row .loan-thumb img { width: 100%; height: 100%; object-fit: cover; }
.loan-row .loan-thumb svg { width: 22px; height: 22px; opacity: 0.4; }
.loan-row strong { font-weight: 600; }
.loan-row small { color: var(--text-muted); font-size: var(--fs-xs); }
.loan-row .loan-meta { flex: 1; min-width: 0; }

/* =========================================================================
   Tables
   ========================================================================= */

.table-wrap {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-sm);
}
th, td {
  padding: var(--sp-3) var(--sp-4);
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
th {
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  position: sticky;
  top: 0;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg-hover); }

td.actions { white-space: nowrap; text-align: right; }
td.actions form { display: inline-block; margin-left: var(--sp-1); }
td.actions .btn { vertical-align: middle; }

/* Modal dialog — escapa overflow via top layer do browser e centraliza
   mesmo com o reset * { margin: 0 } sobrescrevendo o margin: auto default. */
dialog.modal {
  position: fixed;
  inset: 0;                                 /* top/right/bottom/left = 0 */
  margin: auto;                             /* centraliza vertical + horizontal */
  width: calc(100vw - 2rem);
  max-width: 480px;
  height: fit-content;
  max-height: calc(100vh - 4rem);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-elevated);
  color: var(--text);
  padding: var(--sp-6);
  box-shadow: var(--shadow-lg);
  overflow: auto;
  animation: dialog-pop 180ms cubic-bezier(0.16, 1, 0.3, 1);
}
dialog.modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(4px);
  animation: backdrop-fade 180ms ease-out;
}
@keyframes dialog-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: none; }
}
@keyframes backdrop-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}
dialog.modal h3 {
  font-size: var(--fs-lg);
  font-weight: 600;
  margin-bottom: var(--sp-5);
  letter-spacing: -0.01em;
  color: var(--text);
}
dialog.modal .form-grid { gap: var(--sp-4); }
dialog.modal .form-row { gap: var(--sp-3); }
dialog.modal .modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  margin-top: var(--sp-6);
  padding-top: var(--sp-4);
  border-top: 1px solid var(--border);
}

/* Lista de próximas reservas dentro do modal */
.upcoming {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-3);
}
.upcoming-title {
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}
.upcoming-empty {
  font-size: var(--fs-sm);
  color: var(--text-muted);
  padding: var(--sp-1) 0;
}
.upcoming-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
  font-size: var(--fs-sm);
  border-bottom: 1px solid var(--border);
}
.upcoming-item:last-child { border-bottom: none; }
.upcoming-item.is-mine { color: var(--brand-primary); }
.upcoming-when strong { font-weight: 500; }
.upcoming-who {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
}
.upcoming-item.is-mine .upcoming-who {
  background: var(--info-bg);
  color: var(--brand-primary);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 500;
}

@media (max-width: 540px) {
  dialog.modal {
    padding: var(--sp-4);
    width: calc(100vw - 1rem);
  }
  dialog.modal h3 { margin-bottom: var(--sp-4); }
  dialog.modal .modal-actions {
    margin-top: var(--sp-5);
    flex-direction: column-reverse;
  }
  dialog.modal .modal-actions .btn { width: 100%; }
}

/* =========================================================================
   Badges
   ========================================================================= */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
  padding: 2px var(--sp-2);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge svg { width: 12px; height: 12px; }
.badge-success { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-warning { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-danger { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-info { background: var(--info-bg); color: var(--brand-primary); border-color: transparent; }

.badge-active { background: var(--success-bg); color: var(--success); border-color: transparent; }
.badge-returned { background: var(--bg-subtle); color: var(--text-muted); }
.badge-pending_pickup, .badge-pending_return { background: var(--warning-bg); color: var(--warning); border-color: transparent; }
.badge-cancelled, .badge-expired { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge-scheduled { background: var(--info-bg); color: var(--brand-primary); border-color: transparent; }
.badge-fulfilled { background: var(--success-bg); color: var(--success); border-color: transparent; }

/* =========================================================================
   Alerts / Banners
   ========================================================================= */

.alert {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-4);
  display: flex;
  align-items: flex-start;
  gap: var(--sp-3);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-title { font-weight: 600; margin-bottom: 2px; }
.alert-info { background: var(--info-bg); border-color: transparent; color: var(--brand-primary); }
.alert-success { background: var(--success-bg); border-color: transparent; color: var(--success); }
.alert-warning { background: var(--warning-bg); border-color: transparent; color: var(--warning); }
.alert-danger { background: var(--danger-bg); border-color: transparent; color: var(--danger); }

.alert code {
  display: inline-block;
  padding: 2px 8px;
  background: var(--bg-elevated);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: var(--fs-sm);
  font-weight: 600;
  margin: 4px 0;
}

/* =========================================================================
   Stats cards (admin)
   ========================================================================= */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: var(--sp-3);
  margin-bottom: var(--sp-6);
}
.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
}
.stat-label {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 500;
  margin-bottom: var(--sp-2);
}
.stat-value {
  font-size: var(--fs-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}
.stat-meta {
  font-size: var(--fs-xs);
  color: var(--text-subtle);
  margin-top: var(--sp-1);
}

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: var(--sp-2); }
.bar-row {
  display: grid;
  grid-template-columns: minmax(80px, 140px) 1fr 40px;
  align-items: center;
  gap: var(--sp-3);
  font-size: var(--fs-sm);
}
.bar-label { color: var(--text); font-weight: 500; }
.bar-track { height: 24px; background: var(--bg-subtle); border-radius: var(--radius-sm); overflow: hidden; }
.bar-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: var(--radius-sm);
  transition: width var(--t);
}
.bar-value { color: var(--text-muted); text-align: right; font-variant-numeric: tabular-nums; }

/* =========================================================================
   Misc utilities
   ========================================================================= */

.flex { display: flex; }
.flex-col { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--sp-1); }
.gap-2 { gap: var(--sp-2); }
.gap-3 { gap: var(--sp-3); }
.gap-4 { gap: var(--sp-4); }

.text-muted { color: var(--text-muted); }
.text-subtle { color: var(--text-subtle); }
.text-sm { font-size: var(--fs-sm); }
.text-xs { font-size: var(--fs-xs); }
.text-center { text-align: center; }

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
.mb-2 { margin-bottom: var(--sp-2); }
.mb-3 { margin-bottom: var(--sp-3); }
.mb-4 { margin-bottom: var(--sp-4); }

.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--sp-5) 0;
}

.kbd {
  display: inline-block;
  padding: 1px 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: ui-monospace, SFMono-Regular, monospace;
  font-size: 11px;
  color: var(--text-muted);
}

/* =========================================================================
   Loading states
   ========================================================================= */

.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

.fade-in { animation: fadeIn 200ms ease-out; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: none; }
}

/* =========================================================================
   Feedback (rating) screen
   ========================================================================= */

.rating-row {
  display: flex;
  gap: var(--sp-3);
  margin: var(--sp-4) 0;
}
.rating-btn {
  flex: 1;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  height: 80px;
  background: var(--bg-elevated);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 28px;
  cursor: pointer;
  transition: border-color var(--t-fast), background var(--t-fast);
}
.rating-btn:hover { border-color: var(--border-strong); }
.rating-btn.is-on { border-color: var(--brand-primary); background: var(--info-bg); }
.rating-btn span { font-size: var(--fs-xs); color: var(--text-muted); font-weight: 500; }

/* =========================================================================
   Mobile tweaks
   ========================================================================= */

@media (max-width: 540px) {
  .container { padding: var(--sp-4) var(--sp-3) var(--sp-12); }
  .container-narrow { padding: var(--sp-8) var(--sp-3); }
  .page-title { font-size: var(--fs-xl); }
  .card { padding: var(--sp-4); }
  .bike-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-2); }
  th, td { padding: var(--sp-2) var(--sp-3); }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 380px) {
  .bike-grid { grid-template-columns: 1fr; }
}
