/* ── Reset & Tokens ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* hidden attribute must win over display:flex/grid rules below */
[hidden] { display: none !important; }

:root {
  --font: 'DM Sans', system-ui, sans-serif;
  --mono: 'DM Mono', monospace;

  --bg:        #f4f3ef;
  --surface:   #ffffff;
  --surface2:  #f9f8f5;
  --border:    #e4e2db;
  --border2:   #d0cec5;

  --text:      #1c1b18;
  --muted:     #6b6960;
  --hint:      #9b9890;

  --accent:    #1c1b18;
  --accent-bg: #1c1b18;
  --accent-fg: #ffffff;

  --green:     #1a6644;
  --green-bg:  #edf7f2;
  --amber:     #92580a;
  --amber-bg:  #fef7eb;
  --red:       #b83232;
  --red-bg:    #fdf0f0;
  --blue:      #1a4f8c;
  --blue-bg:   #eef4fc;

  --sidebar-w: 240px;
  --radius:    8px;
  --radius-lg: 12px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,.06);
  --shadow:    0 4px 16px rgba(0,0,0,.08);
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--bg); color: var(--text); line-height: 1.6; }

/* ── Login ──────────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow);
}
.login-logo { display: flex; align-items: center; gap: 8px; margin-bottom: 32px; }
.logo-icon { font-size: 22px; }
.logo-text { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
.login-title { font-size: 22px; font-weight: 600; letter-spacing: -.4px; margin-bottom: 4px; }
.login-sub { color: var(--muted); font-size: 14px; margin-bottom: 28px; }
.login-switch { margin-top: 20px; font-size: 13px; color: var(--muted); text-align: center; }
.login-switch a { color: var(--text); font-weight: 500; text-decoration: none; }
.login-switch a:hover { text-decoration: underline; }

.account-type-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 24px; }
.type-option { text-align: left; padding: 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); cursor: pointer; transition: border-color .12s, background .12s; display: flex; flex-direction: column; gap: 2px; }
.type-option:hover { border-color: var(--border2); }
.type-option.active { border-color: var(--accent); background: var(--surface2); }
.type-title { font-size: 14px; font-weight: 600; color: var(--text); }
.type-desc { font-size: 12px; color: var(--muted); }

/* ── Forms ──────────────────────────────────────────────────── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], input[type="search"],
select, textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; min-height: 80px; }
.select { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' viewBox='0 0 24 24'%3E%3Cpath stroke='%236b6960' stroke-width='2' d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; appearance: none; padding-right: 32px; }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; background: var(--surface); color: var(--text);
  transition: background .12s, border-color .12s;
  text-decoration: none;
}
.btn:hover { background: var(--surface2); border-color: var(--border2); }
.btn:active { transform: scale(.985); }
.btn-primary { background: var(--accent-bg); color: var(--accent-fg); border-color: var(--accent-bg); }
.btn-primary:hover { opacity: .88; background: var(--accent-bg); }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: #f5c6c6; }
.btn-danger:hover { background: #fad0d0; }
.btn-full { width: 100%; justify-content: center; }
.btn-text { background: none; border: none; padding: 4px 8px; font-size: 12px; color: var(--muted); cursor: pointer; border-radius: 4px; }
.btn-text:hover { background: var(--surface2); color: var(--text); }
.btn-icon { background: none; border: none; cursor: pointer; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 6px; transition: background .12s; }
.btn-icon:hover { background: var(--surface2); color: var(--text); }
.btn-back { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; color: var(--muted); background: none; border: none; cursor: pointer; padding: 4px 0; margin-bottom: 20px; }
.btn-back:hover { color: var(--text); }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-bg); color: var(--red); border: 1px solid #f5c6c6; }
.alert-success { background: var(--green-bg); color: var(--green); }

/* ── App Shell ──────────────────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; height: 100vh;
  z-index: 100;
  transition: transform .22s ease;
}
.sidebar-logo { display: flex; align-items: center; gap: 8px; padding: 20px 20px 16px; border-bottom: 1px solid var(--border); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 8px; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; color: var(--muted);
  text-decoration: none; transition: background .12s, color .12s;
  position: relative;
}
.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--bg); color: var(--text); }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; }
.admin-badge { margin-left: auto; font-size: 10px; font-weight: 600; background: var(--amber-bg); color: var(--amber); padding: 1px 6px; border-radius: 20px; }

.sidebar-footer { padding: 12px 8px; border-top: 1px solid var(--border); }
.notification-btn { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); font-size: 14px; font-weight: 500; color: var(--muted); cursor: pointer; transition: background .12s; margin-bottom: 4px; position: relative; }
.notification-btn:hover { background: var(--surface2); color: var(--text); }
.notif-badge { background: var(--red); color: #fff; font-size: 10px; font-weight: 700; border-radius: 20px; padding: 0 6px; min-width: 18px; text-align: center; }
.user-info { display: flex; align-items: center; gap: 10px; padding: 8px 12px; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--accent-bg); color: var(--accent-fg); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; flex-shrink: 0; }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--muted); text-transform: capitalize; }
.logout-btn { margin-left: auto; }

/* Main content */
.main-content { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-height: 100vh; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 14px 24px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50; }
.topbar-title { font-size: 15px; font-weight: 600; flex: 1; }
.super-banner { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 24px; background: var(--amber-bg); color: var(--amber); font-size: 13px; border-bottom: 1px solid #f0e0c0; }
.super-banner .btn-text { color: var(--amber); }
.topbar-actions { display: flex; gap: 8px; }
.sidebar-toggle { display: none; }
.page-content { padding: 24px; }

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.card-title { font-size: 15px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--muted); }

/* ── Stats ──────────────────────────────────────────────────── */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.stat-label { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: .2px; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; letter-spacing: -.5px; }
.stat-value.red { color: var(--red); }
.stat-value.amber { color: var(--amber); }
.stat-value.green { color: var(--green); }

/* ── Dual col ───────────────────────────────────────────────── */
.dual-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Record list ────────────────────────────────────────────── */
.record-list { display: flex; flex-direction: column; gap: 1px; }
.record-item { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.record-item:last-child { border-bottom: none; padding-bottom: 0; }
.record-item-main { min-width: 0; }
.record-item-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.record-item-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.record-item-right { flex-shrink: 0; text-align: right; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 20px; }
.badge-red    { background: var(--red-bg);   color: var(--red);   }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-blue   { background: var(--blue-bg);  color: var(--blue);  }
.badge-gray   { background: var(--surface2); color: var(--muted); }

/* ── Vehicle grid ───────────────────────────────────────────── */
.vehicle-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; margin-top: 16px; }
.vehicle-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 18px 20px; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
.vehicle-card:hover { border-color: var(--border2); box-shadow: var(--shadow-sm); }
.vehicle-card-reg { font-size: 17px; font-weight: 700; font-family: var(--mono); letter-spacing: .5px; margin-bottom: 4px; }
.vehicle-card-desc { font-size: 14px; font-weight: 500; margin-bottom: 2px; }
.vehicle-card-meta { font-size: 12px; color: var(--muted); }
.vehicle-card-footer { margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* ── Vehicle detail ─────────────────────────────────────────── */
.vehicle-detail-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.vehicle-detail-reg { font-size: 28px; font-weight: 700; font-family: var(--mono); letter-spacing: 1px; }
.vehicle-detail-desc { font-size: 15px; color: var(--muted); margin-top: 2px; }
.meta-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; margin-bottom: 20px; }
.meta-item { background: var(--surface2); border-radius: var(--radius); padding: 12px; }
.meta-item-label { font-size: 11px; font-weight: 500; color: var(--muted); letter-spacing: .3px; margin-bottom: 4px; }
.meta-item-value { font-size: 15px; font-weight: 600; }

/* ── Data table ─────────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius-lg); overflow: hidden; border: 1px solid var(--border); }
.data-table th { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--muted); text-align: left; border-bottom: 1px solid var(--border); background: var(--surface2); letter-spacing: .2px; }
.data-table td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--surface2); }

/* ── Search / filter bar ────────────────────────────────────── */
.search-bar { margin-bottom: 0; }
.search-input { max-width: 360px; }
.filter-bar { display: flex; gap: 10px; margin-bottom: 16px; }
.filter-bar select { max-width: 260px; }

/* ── Customer grid ──────────────────────────────────────────── */
.customer-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; }
.customer-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 20px; }
.customer-card-name { font-size: 15px; font-weight: 600; margin-bottom: 2px; }
.customer-card-email { font-size: 13px; color: var(--muted); margin-bottom: 12px; }
.customer-card-footer { padding-top: 12px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 200; padding: 20px; }
.modal { background: var(--surface); border-radius: var(--radius-lg); width: 100%; max-width: 520px; max-height: 90vh; overflow-y: auto; box-shadow: var(--shadow); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 20px 24px 0; margin-bottom: 20px; }
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-body { padding: 0 24px 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── Notification panel ─────────────────────────────────────── */
.notif-panel { position: fixed; top: 0; right: 0; height: 100vh; width: 320px; background: var(--surface); border-left: 1px solid var(--border); z-index: 300; display: flex; flex-direction: column; box-shadow: -4px 0 24px rgba(0,0,0,.08); }
.notif-panel-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 14px; }
.notif-backdrop { position: fixed; inset: 0; z-index: 299; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; line-height: 1.5; }
.notif-item.unread { background: var(--blue-bg); }
.notif-item-time { font-size: 11px; color: var(--muted); margin-top: 3px; }

/* ── Empty states ───────────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--muted); font-size: 14px; }
.empty-state p { margin-bottom: 12px; }

/* ── Spinner ────────────────────────────────────────────────── */
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin .6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .dual-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page-content { padding: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
}
