:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-400: #94a3b8;
  --gray-600: #475569;
  --gray-800: #1e293b;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--gray-50);
  color: var(--gray-800);
  font-size: 14px;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px 20px 60px;
}

/* ---------- Topbar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.topbar-title h1 { margin: 0 0 4px; font-size: 22px; }
.topbar-title p { margin: 0; color: var(--gray-600); }
.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- User menu ---------- */
.user-menu { position: relative; }
.user-menu-dropdown {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: #fff;
  border-radius: 10px;
  box-shadow: var(--shadow);
  border: 1px solid var(--gray-100);
  min-width: 190px;
  overflow: hidden;
  z-index: 40;
}
.user-menu-dropdown.open { display: block; }
.user-menu-dropdown button,
.user-menu-dropdown a {
  display: block;
  width: 100%;
  text-align: left;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 13px;
  color: var(--gray-800);
  text-decoration: none;
  cursor: pointer;
  box-sizing: border-box;
}
.user-menu-dropdown button:hover,
.user-menu-dropdown a:hover { background: var(--gray-100); }
.user-menu-dropdown a { border-top: 1px solid var(--gray-100); color: var(--red); }

.btn {
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s ease, opacity .15s ease;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-ghost { background: var(--gray-100); color: var(--gray-800); }
.btn-ghost:hover { background: var(--gray-200); }
.btn-danger { background: #fee2e2; color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-small { padding: 6px 10px; font-size: 12px; }

/* ---------- Summary cards ---------- */
.summary-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  border-left: 5px solid var(--gray-200);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.card-total { border-left-color: var(--blue); }
.card-proses { border-left-color: var(--amber); }
.card-selesai { border-left-color: var(--green); }
.card-label { font-size: 12px; color: var(--gray-600); text-transform: uppercase; letter-spacing: .04em; }
.card-value { font-size: 22px; font-weight: 700; }
.card-sub { font-size: 12px; color: var(--gray-400); }

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: #fff;
  padding: 14px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.filters input[type="text"],
.filters select,
.filters input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  background: #fff;
}
.filters input[type="text"] { flex: 1; min-width: 180px; }
.filter-date { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--gray-600); }

/* ---------- Table ---------- */
.table-wrap {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow-x: auto;
  margin-bottom: 16px;
}
table { width: 100%; border-collapse: collapse; min-width: 900px; }
thead th {
  text-align: left;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .03em;
  color: var(--gray-600);
  background: var(--gray-100);
  padding: 12px 14px;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
thead th:hover { color: var(--blue); }
tbody td {
  padding: 12px 14px;
  border-top: 1px solid var(--gray-100);
  vertical-align: middle;
  white-space: nowrap;
}
tbody tr:hover { background: var(--gray-50); }
.empty-row { text-align: center; color: var(--gray-400); padding: 30px !important; white-space: normal; }

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}
.badge-proses { background: #fef3c7; color: #92400e; }
.badge-selesai { background: #dcfce7; color: #166534; }

.link-bukti { color: var(--blue); text-decoration: none; font-size: 13px; }
.link-bukti:hover { text-decoration: underline; }
.no-bukti { color: var(--gray-400); font-size: 12px; }

.row-actions { display: flex; gap: 6px; }

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 30px;
  flex-wrap: wrap;
}
.pagination button {
  border: 1px solid var(--gray-200);
  background: #fff;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}
.pagination button.active { background: var(--blue); color: #fff; border-color: var(--blue); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- Recap per driver ---------- */
.recap-driver h2 { font-size: 16px; margin-bottom: 10px; }

/* ---------- Modal ---------- */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}
.modal-overlay.open { display: flex; }
.modal {
  background: #fff;
  border-radius: 14px;
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--gray-100);
}
.modal-header h2 { margin: 0; font-size: 17px; }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--gray-600); line-height: 1; }
.modal-small { max-width: 460px; }
.modal-body { padding: 20px 22px; }
.modal-body form { padding: 0; margin-top: 10px; }
.admin-add-title { font-size: 14px; margin: 18px 0 4px; }

form { padding: 20px 22px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.form-field-wide { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 5px; }
.form-field label { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.req { color: var(--red); }
.req.cond { color: var(--amber); }
.form-field input,
.form-field select,
.form-field textarea {
  padding: 9px 10px;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  font-size: 13px;
  font-family: inherit;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}
.hint { font-size: 11px; color: var(--gray-400); }
.field-error { font-size: 12px; color: var(--red); min-height: 14px; }
.form-general-error {
  margin-top: 6px;
  padding: 10px 12px;
  background: #fee2e2;
  color: var(--red);
  border-radius: 8px;
  font-size: 13px;
}
.bukti-existing { display: flex; align-items: center; gap: 12px; font-size: 12px; margin-top: 4px; }
.checkbox-inline { display: flex; align-items: center; gap: 5px; color: var(--gray-600); }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--gray-100);
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--gray-800);
  color: #fff;
  padding: 12px 18px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .2s ease, transform .2s ease;
  pointer-events: none;
  z-index: 100;
  max-width: 320px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #166534; }
.toast.error { background: #991b1b; }

@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
  table { min-width: 720px; }
}

/* ---------- Login page ---------- */
.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(160deg, var(--blue) 0%, var(--blue-dark) 100%);
}
.login-wrap { width: 100%; max-width: 380px; padding: 20px; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 32px 28px;
  box-shadow: 0 20px 50px rgba(0,0,0,.25);
}
.login-card h1 { margin: 0 0 4px; font-size: 20px; text-align: center; }
.login-sub { margin: 0 0 20px; text-align: center; color: var(--gray-600); font-size: 13px; }
.login-card form { padding: 0; }
.login-card .form-field { margin-bottom: 14px; }
.login-btn { width: 100%; margin-top: 6px; padding: 11px 16px; }
