/* ============================================================
   assets/css/main.css  –  KM Corporate Design System
   Aesthetic: Refined Corporate / Dark Luxury
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,300;0,9..144,400;0,9..144,600;0,9..144,700;1,9..144,300&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ---------- tokens ---------- */
:root {
  --bg-base:      #0d0f14;
  --bg-card:      #13161e;
  --bg-card2:     #1a1d28;
  --bg-input:     #1e2130;
  --border:       #2a2f45;
  --border-light: #343a54;

  --gold:         #c9a84c;
  --gold-light:   #e5c97a;
  --gold-dim:     rgba(201,168,76,.15);
  --accent:       #4f7cff;
  --accent-dim:   rgba(79,124,255,.15);
  --danger:       #e05c5c;
  --success:      #3dba7c;

  --text-primary:   #eef0f8;
  --text-secondary: #8890b0;
  --text-muted:     #555e7e;

  --font-display: 'Fraunces', Georgia, serif;
  --font-body:    'DM Sans', system-ui, sans-serif;

  --radius:   12px;
  --radius-sm: 8px;
  --shadow:   0 4px 24px rgba(0,0,0,.45);
  --shadow-lg:0 12px 48px rgba(0,0,0,.6);

  --sidebar-w: 260px;
  --topbar-h:  64px;
}

/* ---------- reset ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--bg-base);
  color: var(--text-primary);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ---------- layout shell ---------- */
.shell { display: flex; min-height: 100vh; }

/* sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .3s ease;
}

.sidebar-brand {
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--border);
}

.sidebar-brand .logo-mark {
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-brand .logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 18px;
}

.sidebar-brand .logo-text {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 1.15rem;
  letter-spacing: -.01em;
  color: var(--text-primary);
}

.sidebar-brand .logo-sub {
  font-size: .68rem;
  color: var(--gold);
  letter-spacing: .12em;
  text-transform: uppercase;
  margin-top: 2px;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 16px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: .65rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0 12px 8px;
  margin-top: 16px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  transition: all .18s ease;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-card2);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--gold-dim);
  color: var(--gold-light);
  border: 1px solid rgba(201,168,76,.25);
}

.nav-item .nav-icon { font-size: 1.1rem; width: 20px; text-align: center; }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-card2);
}

.user-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #7b5fff);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: .85rem;
  color: #fff;
  flex-shrink: 0;
}

.user-info .user-name { font-size: .85rem; font-weight: 500; }
.user-info .user-role {
  font-size: .7rem;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: .08em;
}

/* main content */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  height: var(--topbar-h);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 32px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.page-body {
  padding: 32px;
  flex: 1;
}

/* ---------- cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 600;
}

/* stat cards */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--gold), transparent);
}

.stat-card.accent::before { background: linear-gradient(90deg, var(--accent), transparent); }
.stat-card.success::before { background: linear-gradient(90deg, var(--success), transparent); }

.stat-label {
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 2.2rem;
  font-weight: 700;
  line-height: 1;
  color: var(--gold-light);
}

.stat-card.accent .stat-value  { color: #7b9fff; }
.stat-card.success .stat-value { color: var(--success); }

.stat-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

thead tr {
  border-bottom: 1px solid var(--border);
}

thead th {
  text-align: left;
  padding: 10px 16px;
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

tbody tr {
  border-bottom: 1px solid rgba(42,47,69,.5);
  transition: background .15s;
}

tbody tr:hover { background: var(--bg-card2); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 14px 16px;
  color: var(--text-secondary);
}

tbody td strong, tbody td .text-primary { color: var(--text-primary); }

/* ---------- badges ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .05em;
}

.badge-gold    { background: var(--gold-dim);     color: var(--gold-light);  border: 1px solid rgba(201,168,76,.3);  }
.badge-accent  { background: var(--accent-dim);   color: #7b9fff;            border: 1px solid rgba(79,124,255,.3); }
.badge-success { background: rgba(61,186,124,.12); color: var(--success);    border: 1px solid rgba(61,186,124,.3); }
.badge-danger  { background: rgba(224,92,92,.12); color: var(--danger);      border: 1px solid rgba(224,92,92,.3);  }
.badge-muted   { background: rgba(85,94,126,.15); color: var(--text-muted);  border: 1px solid rgba(85,94,126,.3);  }

/* ---------- forms ---------- */
.form-group { margin-bottom: 20px; }

label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

input, select, textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 11px 14px;
  font-family: var(--font-body);
  font-size: .9rem;
  transition: border-color .18s, box-shadow .18s;
  outline: none;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px var(--gold-dim);
}

input::placeholder, textarea::placeholder { color: var(--text-muted); }

select option { background: var(--bg-card2); }

textarea { resize: vertical; min-height: 100px; }

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all .18s ease;
  white-space: nowrap;
}

.btn-primary {
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  color: #0d0f14;
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(201,168,76,.35);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: #fff;
}

.btn-accent:hover {
  background: #6b8fff;
  box-shadow: 0 4px 20px rgba(79,124,255,.35);
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-ghost:hover {
  border-color: var(--border-light);
  color: var(--text-primary);
  background: var(--bg-card2);
}

.btn-danger {
  background: transparent;
  border: 1px solid rgba(224,92,92,.4);
  color: var(--danger);
}

.btn-danger:hover { background: rgba(224,92,92,.12); }

.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-icon { padding: 9px; }

/* ---------- alerts ---------- */
.alert {
  padding: 14px 18px;
  border-radius: var(--radius-sm);
  margin-bottom: 20px;
  font-size: .875rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.alert-success { background: rgba(61,186,124,.12); border: 1px solid rgba(61,186,124,.3); color: var(--success); }
.alert-error   { background: rgba(224,92,92,.12);  border: 1px solid rgba(224,92,92,.3);  color: var(--danger);  }
.alert-info    { background: var(--accent-dim);    border: 1px solid rgba(79,124,255,.3); color: #7b9fff;        }

/* ---------- login page ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-base);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(201,168,76,.06) 0%, transparent 70%);
  top: -200px; right: -200px;
}

.login-page::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(79,124,255,.05) 0%, transparent 70%);
  bottom: -100px; left: -100px;
}

.login-box {
  width: 100%;
  max-width: 420px;
  z-index: 1;
  padding: 20px;
}

.login-brand {
  text-align: center;
  margin-bottom: 36px;
}

.login-brand .logo-icon-lg {
  width: 60px; height: 60px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
  margin: 0 auto 16px;
  box-shadow: 0 8px 32px rgba(201,168,76,.3);
}

.login-brand h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  letter-spacing: -.02em;
}

.login-brand p {
  color: var(--text-muted);
  font-size: .85rem;
  margin-top: 4px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-lg);
}

/* ---------- page header ---------- */
.page-header {
  margin-bottom: 28px;
}

.page-header h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -.02em;
  margin-bottom: 4px;
}

.page-header p { color: var(--text-muted); font-size: .9rem; }

/* ---------- km progress bar ---------- */
.km-bar-wrap {
  background: var(--bg-input);
  border-radius: 20px;
  height: 8px;
  overflow: hidden;
  margin-top: 8px;
}

.km-bar-fill {
  height: 100%;
  border-radius: 20px;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  transition: width .8s ease;
}

/* ---------- pagination ---------- */
.pagination {
  display: flex;
  gap: 6px;
  align-items: center;
  justify-content: center;
  margin-top: 20px;
}

.pagination a, .pagination span {
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: .825rem;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  transition: all .15s;
}

.pagination a:hover { border-color: var(--gold); color: var(--gold); }
.pagination .current { background: var(--gold-dim); border-color: rgba(201,168,76,.4); color: var(--gold-light); }
.pagination .disabled { opacity: .4; pointer-events: none; }

/* ---------- modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  z-index: 200;
  display: none;
  place-items: center;
}

.modal-overlay.open { display: grid; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn .25s ease;
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 600;
}

/* ---------- utilities ---------- */
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.gap-4        { gap: 16px; }
.ml-auto      { margin-left: auto; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }
.mb-4         { margin-bottom: 16px; }
.mb-6         { margin-bottom: 24px; }
.text-right   { text-align: right; }
.text-center  { text-align: center; }
.text-muted   { color: var(--text-muted); font-size: .85rem; }
.text-gold    { color: var(--gold-light); }
.text-success { color: var(--success); }
.text-danger  { color: var(--danger); }
.w-full       { width: 100%; }
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ---------- responsive ---------- */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .page-body { padding: 20px 16px; }
}

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

/* ---------- scrollbar ---------- */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

/* ---------- logo image ---------- */
.logo-img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  flex-shrink: 0;
  filter: drop-shadow(0 2px 6px rgba(201,168,76,.3));
}

.login-brand .logo-img-lg {
  width: 90px;
  height: 90px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
  filter: drop-shadow(0 4px 16px rgba(201,168,76,.4));
}
