/* ============================================================
   X3 Fleet Safety — App Stylesheet
   Brand: Navy #1B3A6B · Gold #F5A623
   Tagline: eXpert · eXperienced · eXceptional
   ============================================================ */

:root {
  --navy: #1B3A6B;
  --navy-dark: #13284D;
  --navy-light: #2A4F8A;
  --gold: #F5A623;
  --gold-dark: #D48806;
  --gold-light: #FFD77A;
  --ink: #0F1E38;
  --slate: #4A5568;
  --slate-light: #718096;
  --bg: #F4F6FB;
  --bg-alt: #EFF3FA;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --green: #16A34A;
  --red: #DC2626;
  --amber: #D97706;
  --radius: 12px;
  --shadow: 0 10px 30px rgba(15, 30, 56, 0.08);
  --shadow-lg: 0 20px 60px rgba(15, 30, 56, 0.15);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
  color: var(--ink);
  line-height: 1.6;
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; display: block; }
a { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold-dark); }
button { font-family: inherit; cursor: pointer; }

/* ---------- Auth screens layout ---------- */
.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-dark) 70%, #0B1A36 100%);
  position: relative;
  overflow: hidden;
}
.auth-wrap::before {
  content: "";
  position: absolute;
  top: -100px; right: -100px;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,.2), transparent 70%);
}
.auth-wrap::after {
  content: "";
  position: absolute;
  bottom: -150px; left: -100px;
  width: 450px; height: 450px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(245,166,35,.1), transparent 70%);
}
.auth-card {
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: 460px;
  background: #fff;
  border-radius: 18px;
  padding: 40px;
  box-shadow: var(--shadow-lg);
}
.brand-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 28px;
}
.brand-mark {
  width: 56px; height: 56px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  display: flex; align-items: center; justify-content: center;
  color: var(--gold);
  font-weight: 900; font-size: 26px;
  letter-spacing: -1.5px;
  box-shadow: 0 4px 14px rgba(27, 58, 107, 0.25);
}
.brand-text .name {
  font-weight: 800;
  color: var(--navy);
  font-size: 20px;
  line-height: 1.1;
}
.brand-text .tag {
  font-size: 11px;
  color: var(--gold-dark);
  letter-spacing: 1.5px;
  font-weight: 700;
  text-transform: uppercase;
  margin-top: 3px;
}

h1.auth-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 6px;
}
p.auth-sub {
  color: var(--slate);
  font-size: 14px;
  margin-bottom: 26px;
}

.auth-tabs {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 4px;
  margin-bottom: 24px;
}
.auth-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--slate);
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.auth-tab.active { background: #fff; color: var(--navy); box-shadow: 0 1px 3px rgba(0,0,0,.06); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 6px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.12);
}
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
@media (max-width: 500px) {
  .form-row { grid-template-columns: 1fr; }
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 22px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  border: none;
  transition: transform .05s, box-shadow .15s, background .15s;
  width: 100%;
  font-family: inherit;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--navy-dark);
}
.btn-primary:hover { box-shadow: 0 8px 20px rgba(245, 166, 35, 0.4); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-ghost {
  background: transparent;
  color: var(--navy);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--navy); background: var(--bg); }

.auth-footer {
  margin-top: 22px;
  text-align: center;
  font-size: 13px;
  color: var(--slate);
}
.auth-footer a { color: var(--navy); font-weight: 700; cursor: pointer; }
.auth-link-btn {
  background: none; border: none; color: var(--navy); font-weight: 700;
  font-size: 13px; padding: 0; text-decoration: underline; cursor: pointer; font-family: inherit;
}

.alert {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 18px;
  display: none;
}
.alert.show { display: block; }
.alert-error { background: #FEE2E2; color: #991B1B; border-left: 3px solid var(--red); }
.alert-success { background: #DCFCE7; color: #166534; border-left: 3px solid var(--green); }
.alert-info { background: #DBEAFE; color: #1E40AF; border-left: 3px solid var(--navy); }

/* ---------- App shell (post-login) ---------- */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px;
  background: linear-gradient(180deg, var(--navy), var(--navy-dark));
  color: #fff;
  padding: 24px 16px;
  flex-shrink: 0;
}
.sidebar .brand-mark { width: 44px; height: 44px; font-size: 20px; margin-bottom: 18px; }
.sidebar .brand-text .name { color: #fff; font-size: 16px; }
.sidebar .brand-text .tag { color: var(--gold); font-size: 10px; }
.sidebar .section-label {
  font-size: 11px; font-weight: 700; color: rgba(255,255,255,.5);
  letter-spacing: 1.5px; text-transform: uppercase;
  margin: 24px 0 8px 10px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; color: rgba(255,255,255,.85);
  border-radius: 8px; font-size: 14px; font-weight: 500;
  cursor: pointer; border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: rgba(245, 166, 35, .15); color: #fff; border-left: 3px solid var(--gold); padding-left: 9px; }

.main-panel { flex: 1; background: var(--bg); }
.topbar {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 2px 8px rgba(15, 30, 56, .04);
}
.topbar h1 { font-size: 20px; color: var(--navy); font-weight: 800; }
.topbar .sub { font-size: 13px; color: var(--slate); margin-top: 2px; }
.user-chip {
  display: flex; align-items: center; gap: 10px;
}
.user-chip .avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--gold-dark));
  color: var(--navy-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 13px;
}
.user-chip .who { font-size: 13px; font-weight: 700; color: var(--navy); line-height: 1.2; }
.user-chip .role { font-size: 11px; color: var(--slate); }

.content { padding: 32px 28px; }
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 28px;
}
.kpi-card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 22px;
  position: relative;
}
.kpi-card::before {
  content: "";
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gold);
  border-radius: var(--radius) var(--radius) 0 0;
}
.kpi-card .label { font-size: 11px; font-weight: 700; color: var(--slate-light); letter-spacing: 1px; text-transform: uppercase; }
.kpi-card .value { font-size: 32px; font-weight: 900; color: var(--navy); margin: 6px 0 4px; }
.kpi-card .sub { font-size: 12px; color: var(--slate); }

.card {
  background: #fff;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 { font-size: 18px; color: var(--navy); font-weight: 800; margin-bottom: 4px; }
.card .lead { color: var(--slate); font-size: 14px; margin-bottom: 18px; }

.btn-sm { padding: 7px 14px; font-size: 12px; width: auto; }
.btn-inline { width: auto; }

.spinner {
  border: 2.5px solid rgba(255,255,255,.3);
  border-top: 2.5px solid var(--navy-dark);
  border-radius: 50%;
  width: 16px; height: 16px;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.muted { color: var(--slate); font-size: 13px; }
.center { text-align: center; }
.mt-3 { margin-top: 14px; }
.mt-5 { margin-top: 24px; }
.hidden { display: none !important; }
