/* TaxiOps — base stylesheet. Intentionally framework-free and easy to extend. */
:root {
  --bg: #f4f6fb;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1f2937;
  --muted: #6b7280;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-soft: #e0e9ff;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 1px 2px rgba(15, 23, 42, .04);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  line-height: 1.5;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.2rem; }

/* --- Top bar --- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 1.5rem;
  height: 56px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand { font-weight: 700; font-size: 1.1rem; color: var(--text); }
.brand:hover { text-decoration: none; }
.mainnav { display: flex; gap: .25rem; flex: 1; }
.mainnav a {
  padding: .5rem .85rem;
  border-radius: var(--radius);
  color: var(--muted);
  font-weight: 500;
  font-size: .95rem;
}
.mainnav a:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.usernav { display: flex; align-items: center; gap: .75rem; }
.user-chip { color: var(--text); font-size: .9rem; font-weight: 500; }
.logout-form { margin: 0; }

/* --- Layout --- */
.content { flex: 1; width: 100%; max-width: 1200px; margin: 0 auto; padding: 1.5rem; }
.content--centered { display: flex; align-items: center; justify-content: center; }
.footer { text-align: center; color: var(--muted); font-size: .8rem; padding: 1rem; }
.page-header { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 1.25rem; gap: 1rem; flex-wrap: wrap; }
.page-header .subtitle { color: var(--muted); margin: 0; }

/* --- Cards --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}
.card--narrow { max-width: 640px; }
.card--auth { width: 100%; max-width: 400px; }

/* --- Stat grid --- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.25rem; box-shadow: var(--shadow); }
.stat .value { font-size: 2rem; font-weight: 700; }
.stat .label { color: var(--muted); font-size: .85rem; }

/* --- Tables --- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.data th, table.data td { text-align: left; padding: .65rem .75rem; border-bottom: 1px solid var(--border); }
table.data th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
table.data tbody tr:hover { background: var(--bg); }
.empty { color: var(--muted); padding: 1.5rem; text-align: center; }

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: .5rem .9rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  background: var(--bg);
  color: var(--text);
  line-height: 1.2;
}
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; border-color: var(--border); color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: .3rem .6rem; font-size: .8rem; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.toolbar { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }

/* --- Forms --- */
form .form-actions { display: flex; gap: .5rem; margin-top: 1.25rem; }
form > div, form p { margin-bottom: 1rem; }
label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; }
.form-control, .form-select, input, textarea, select {
  width: 100%;
  padding: .55rem .7rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font: inherit;
  background: #fff;
}
.form-control:focus, .form-select:focus, input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-check-input { width: auto; margin-right: .4rem; }
.helptext { color: var(--muted); font-size: .8rem; display: block; margin-top: .25rem; }
ul.errorlist { color: var(--danger); list-style: none; padding: 0; margin: .25rem 0; font-size: .85rem; }
.search-form { display: flex; gap: .5rem; }
.search-form input { max-width: 260px; }

/* --- Badges / status --- */
.badge { display: inline-block; padding: .2rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge--available, .badge--completed, .badge--paid, .badge--sent { background: #dcfce7; color: #166534; }
.badge--in_use, .badge--en_route, .badge--assigned { background: #dbeafe; color: #1e40af; }
.badge--maintenance, .badge--requested, .badge--draft { background: #fef3c7; color: #92400e; }
.badge--inactive, .badge--cancelled { background: #fee2e2; color: #991b1b; }

/* --- Alerts --- */
.messages { margin-bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; }
.alert { padding: .7rem 1rem; border-radius: var(--radius); border: 1px solid transparent; font-size: .9rem; }
.alert-info { background: #e0f2fe; border-color: #bae6fd; color: #075985; }
.alert-success { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.alert-warning { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.alert-danger { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

/* --- Dispatch board --- */
.board { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start; }
.board-col { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.board-col h2 { font-size: .95rem; padding: .75rem 1rem; margin: 0; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.board-col .count { color: var(--muted); font-weight: 600; }
.board-body { padding: .75rem; display: flex; flex-direction: column; gap: .65rem; min-height: 60px; }
.ride-card { border: 1px solid var(--border); border-radius: var(--radius); padding: .7rem .8rem; background: #fff; }
.ride-card .ref { font-size: .75rem; color: var(--muted); font-weight: 600; }
.ride-card .route { font-weight: 600; margin: .2rem 0; }
.ride-card .meta { font-size: .8rem; color: var(--muted); }
.ride-card .card-actions { display: flex; gap: .35rem; margin-top: .55rem; flex-wrap: wrap; }

/* --- Pagination --- */
.pagination { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1.25rem; }
.pagination-info { color: var(--muted); font-size: .85rem; }

/* --- Auth pages --- */
.auth-title { text-align: center; margin-bottom: 1.25rem; }
.auth-links { margin-top: 1rem; text-align: center; font-size: .85rem; }
.dl-grid { display: grid; grid-template-columns: 180px 1fr; gap: .5rem 1rem; margin: 0; }
.dl-grid dt { color: var(--muted); font-weight: 600; }
.dl-grid dd { margin: 0; }

@media (max-width: 800px) {
  .board { grid-template-columns: 1fr; }
  .mainnav { display: none; }
}

/* --- Clickable stat cards & table rows --- */
a.stat { display: block; color: inherit; text-decoration: none; transition: box-shadow .15s, transform .05s; }
a.stat:hover { text-decoration: none; box-shadow: 0 4px 12px rgba(15, 23, 42, .12); transform: translateY(-1px); }
tr.row-link { cursor: pointer; }

/* --- Order status badges --- */
.badge--open { background: #fef3c7; color: #92400e; }
.badge--in_progress { background: #dbeafe; color: #1e40af; }
.badge--done { background: #dcfce7; color: #166534; }

/* --- Action icons in tables --- */
.actions-col { white-space: nowrap; text-align: right; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px; color: var(--muted); border: 1px solid transparent; }
.icon-btn:hover { background: var(--bg); color: var(--text); text-decoration: none; }
.icon-btn--danger:hover { background: #fee2e2; color: var(--danger); }

/* --- Inline formset rows --- */
.formset-table .dl-delete { display: none; }
.row-remove-cell { width: 48px; text-align: center; }
.row-remove { color: var(--muted); font-size: 1.1rem; line-height: 1; }

/* --- Time tracking --- */
.timer-card { text-align: center; }
.work-status { display: flex; flex-direction: column; align-items: center; gap: 1rem; padding: 1rem 0; }
.work-state { font-size: 1.05rem; margin: 0; }
.work-state--on { color: var(--success); font-weight: 600; }
.work-state--off { color: var(--muted); }
.btn-timer { font-size: 1.2rem; padding: 1rem 2.5rem; border-radius: 999px; min-width: 200px; justify-content: center; }
.btn-start { background: var(--success); color: #fff; }
.btn-stop { background: var(--danger); color: #fff; }
.btn-timer:hover { filter: brightness(.95); }
