:root {
  --bg: #f4f6f9;
  --surface: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #16a34a;
  --primary-dark: #15803d;
  --primary-soft: #dcfce7;
  --amber: #d97706;
  --amber-soft: #fef3c7;
  --blue: #2563eb;
  --blue-soft: #dbeafe;
  --red: #dc2626;
  --red-soft: #fee2e2;
  --dark: #1f2937;
  --radius: 12px;
  --shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1220px;
  margin: 0 auto;
  padding: 0 16px;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 900;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  padding-bottom: 12px;
  flex-wrap: wrap;
}

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

.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 700;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.badge-branch {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
}

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

.status-pill {
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 999px;
}

.status-local {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-cloud {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.user-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #f9fafb;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--blue-soft);
  color: var(--blue);
}

.main-wrap {
  padding-top: 20px;
  padding-bottom: 40px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.card-header-flex {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 0.82rem;
}

.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

/* BUTTONS */
.btn {
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: 0.15s ease;
}

.btn-sm {
  padding: 6px 10px;
  font-size: 0.8rem;
}

.btn-lg {
  padding: 12px 18px;
  font-size: 0.96rem;
}

.btn-block {
  width: 100%;
}

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

.btn-primary:hover {
  background: var(--primary-dark);
}

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

.btn-outline {
  background: #fff;
  border-color: var(--border);
  color: var(--text);
}

.btn-outline:hover {
  background: #f9fafb;
}

.btn-danger-outline {
  background: #fff;
  border-color: #fecaca;
  color: var(--red);
}

.btn-wa {
  background: #16a34a;
  color: #fff;
}

.btn-link {
  background: none;
  border: none;
  color: var(--primary-dark);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
}

/* FORMS */
.form-group {
  margin-bottom: 12px;
}

.form-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 5px;
  color: #374151;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="datetime-local"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.input-sm {
  padding: 6px 10px;
  font-size: 0.82rem;
  width: auto;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.grid-form-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* AUTH */
.auth-wrapper {
  max-width: 440px;
  margin: 30px auto;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #f3f4f6;
  padding: 4px;
  border-radius: 10px;
  margin-bottom: 18px;
}

.auth-tab {
  border: none;
  background: transparent;
  padding: 8px;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  color: var(--muted);
}

.auth-tab.active {
  background: #fff;
  color: var(--text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.auth-form h2 {
  font-size: 1.25rem;
  margin-bottom: 4px;
}

.auth-form p {
  margin-bottom: 16px;
  font-size: 0.86rem;
}

/* NAVIGATION */
.nav-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.nav-tab {
  background: #fff;
  border: 1px solid var(--border);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.nav-tab.active {
  background: var(--dark);
  color: #fff;
  border-color: var(--dark);
}

.count-pill {
  background: var(--primary);
  color: #fff;
  font-size: 0.74rem;
  padding: 1px 7px;
  border-radius: 999px;
}

/* SERVICE SELECTOR */
.service-selector {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 18px;
}

.service-card {
  background: #fff;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  text-align: left;
  cursor: pointer;
  transition: 0.15s ease;
}

.service-card.active {
  border-color: var(--primary);
  background: #f0fdf4;
}

.service-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.service-title {
  font-size: 1.1rem;
  font-weight: 700;
}

.tariff-tag {
  background: var(--primary-soft);
  color: var(--primary-dark);
  font-size: 0.78rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
}

.tariff-amber {
  background: var(--amber-soft);
  color: var(--amber);
}

.service-desc {
  font-size: 0.84rem;
  color: var(--muted);
}

/* GRID LAYOUT */
.grid-2 {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 18px;
  align-items: start;
}

.preset-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.preset-label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.preset-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.preset-chip {
  background: #f3f4f6;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 0.76rem;
  cursor: pointer;
}

.preset-chip:hover {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.map-container {
  height: 360px;
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--border);
  z-index: 1;
}

/* FARE BANNER */
.fare-banner {
  border-radius: var(--radius);
  padding: 18px 20px;
  color: #fff;
  box-shadow: var(--shadow);
}

.fare-ride {
  background: linear-gradient(135deg, #16a34a, #15803d);
}

.fare-send {
  background: linear-gradient(135deg, #d97706, #b45309);
}

.fare-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.fare-badge {
  background: rgba(255, 255, 255, 0.2);
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
}

.fare-rate {
  font-size: 0.85rem;
  font-weight: 600;
}

.fare-main {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}

.fare-caption {
  font-size: 0.8rem;
  opacity: 0.9;
}

.fare-amount {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
}

.fare-dist-box {
  text-align: right;
}

.fare-dist {
  font-size: 1.35rem;
  font-weight: 700;
}

.fare-split {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.25);
  display: flex;
  justify-content: space-between;
  font-size: 0.84rem;
}

.admin-override {
  background: #fefce8;
  border: 1px solid #fde047;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

/* ORDERS LIST */
.filter-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.orders-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.order-item {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  background: #fff;
}

.order-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid #f3f4f6;
  margin-bottom: 12px;
}

.order-code {
  font-weight: 800;
  font-size: 1rem;
  margin-right: 8px;
}

.svc-pill {
  font-size: 0.74rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
}

.svc-ride {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.svc-send {
  background: var(--amber-soft);
  color: var(--amber);
}

.status-badge {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 999px;
}

.st-new { background: #e0f2fe; color: #0369a1; }
.st-process { background: #fef3c7; color: #b45309; }
.st-reschedule { background: #f3e8ff; color: #7e22ce; }
.st-ontrip { background: #dbeafe; color: #1d4ed8; }
.st-completed { background: #ffedd5; color: #c2410c; }
.st-pending { background: #fee2e2; color: #b91c1c; }
.st-success { background: #dcfce7; color: #15803d; }
.st-cancel { background: #f3f4f6; color: #4b5563; }

.order-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
  font-size: 0.86rem;
}

.order-field-label {
  font-size: 0.74rem;
  color: var(--muted);
  text-transform: uppercase;
  font-weight: 600;
}

.order-actions {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.courier-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 8px;
}

/* STATS & TABLE */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
}

.stat-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 800;
  margin-top: 4px;
}

.table-responsive {
  overflow-x: auto;
}

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

.data-table th,
.data-table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.data-table th {
  background: #f9fafb;
  font-weight: 700;
}

/* MODAL */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
}

.modal-content {
  position: relative;
  background: #fff;
  border-radius: var(--radius);
  width: 100%;
  max-width: 480px;
  padding: 20px;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.2);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-lg {
  max-width: 720px;
}

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

.btn-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: var(--muted);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

.upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.proof-preview {
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  text-align: center;
}

.proof-preview img {
  max-width: 100%;
  max-height: 260px;
  border-radius: 6px;
}

.code-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.78rem;
  background: #111827;
  color: #e5e7eb;
}

/* TOAST */
.toast {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--dark);
  color: #fff;
  padding: 11px 16px;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  z-index: 1500;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

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

@media (max-width: 600px) {
  .service-selector,
  .grid-form-2 {
    grid-template-columns: 1fr;
  }
}
