:root {
  --km-green: #135D36;
  --km-green-dark: #0a3d24;
  --km-gold: #F2C94C;
  --km-bg: #eef5f0;
  --km-card: #ffffff;
  --km-text: #12231a;
  --km-muted: #5b6b63;
  --km-border: #d7e5dc;
  --km-danger: #e11d48;
  --km-success: #059669;
  --km-blue: #2563eb;
  --km-purple: #7c3aed;
  --km-orange: #ea580c;
  --km-teal: #0d9488;
  --km-pink: #db2777;
  --km-cyan: #0891b2;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background:
    radial-gradient(1200px 500px at 10% -10%, #d1fae5 0%, transparent 55%),
    radial-gradient(900px 400px at 100% 0%, #fef3c7 0%, transparent 50%),
    radial-gradient(800px 400px at 80% 100%, #dbeafe 0%, transparent 45%),
    var(--km-bg);
  color: var(--km-text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.admin-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0f766e 0%, #135D36 45%, #0a3d24 100%);
  color: #fff;
  padding: 1.25rem 0;
  flex-shrink: 0;
  box-shadow: 8px 0 28px rgba(19, 93, 54, .18);
  display: flex;
  flex-direction: column;
}
.sidebar nav { flex: 1; overflow-y: auto; }
.sidebar-logout {
  margin: .75rem .7rem 0;
  padding-top: .75rem;
  border-top: 1px solid rgba(255,255,255,.18);
}
.sidebar-logout button {
  width: 100%;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.08);
  color: #fff;
  border-radius: 10px;
  padding: .7rem 1rem;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.sidebar-logout button:hover {
  background: rgba(225, 29, 72, .85);
  border-color: transparent;
}
.topbar-actions { display: flex; align-items: center; gap: .65rem; flex-shrink: 0; }
.btn-logout {
  border: none;
  border-radius: 999px;
  padding: .45rem .95rem;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(135deg, #e11d48, #fb7185);
}
.btn-logout:hover { filter: brightness(1.05); }
.sidebar .brand {
  padding: 0 1.25rem 1.35rem;
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: .2px;
  border-bottom: 1px solid rgba(255,255,255,.18);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.sidebar .brand::before {
  content: "";
  width: 28px; height: 28px; border-radius: 8px;
  background: linear-gradient(135deg, var(--km-gold), #f59e0b);
  box-shadow: 0 0 0 3px rgba(242,201,76,.25);
}
.sidebar nav a {
  display: block;
  margin: .15rem .7rem;
  padding: .7rem 1rem;
  color: rgba(255,255,255,.9);
  font-size: .92rem;
  border-radius: 10px;
  transition: .15s ease;
}
.sidebar nav a:hover {
  background: rgba(255,255,255,.12);
  color: #fff;
  transform: translateX(2px);
}
.sidebar nav a.active {
  background: linear-gradient(90deg, rgba(242,201,76,.95), #fbbf24);
  color: #14301f;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(0,0,0,.18);
}

.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  background: linear-gradient(90deg, #ffffff, #f0fdf4 60%, #fff7ed);
  border-bottom: 1px solid var(--km-border);
  padding: .9rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  backdrop-filter: blur(8px);
}
.topbar input {
  border: 1px solid #bbf7d0;
  border-radius: 999px;
  padding: .55rem 1rem;
  width: min(380px, 100%);
  background: #fff;
  outline: none;
}
.topbar input:focus { border-color: #34d399; box-shadow: 0 0 0 3px rgba(52,211,153,.2); }
.topbar-user {
  background: linear-gradient(135deg, #135D36, #0d9488);
  color: #fff;
  padding: .45rem .9rem;
  border-radius: 999px;
  font-size: .85rem;
  font-weight: 600;
}
.content { padding: 1.5rem; }

.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.kpi {
  position: relative;
  overflow: hidden;
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  border: 1px solid transparent;
  color: #fff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .08);
  min-height: 98px;
}
.kpi::after {
  content: "";
  position: absolute;
  right: -18px; bottom: -22px;
  width: 90px; height: 90px;
  border-radius: 50%;
  background: rgba(255,255,255,.16);
}
.kpi .label { font-size: .8rem; opacity: .92; margin-bottom: .4rem; font-weight: 600; letter-spacing: .2px; }
.kpi .value { font-size: 1.55rem; font-weight: 800; position: relative; z-index: 1; }

.kpi-emerald { background: linear-gradient(135deg, #059669, #34d399); }
.kpi-blue { background: linear-gradient(135deg, #2563eb, #60a5fa); }
.kpi-violet { background: linear-gradient(135deg, #7c3aed, #a78bfa); }
.kpi-amber { background: linear-gradient(135deg, #d97706, #fbbf24); color: #1f1300; }
.kpi-amber .label { color: rgba(31,19,0,.8); }
.kpi-cyan { background: linear-gradient(135deg, #0891b2, #22d3ee); color: #06262c; }
.kpi-cyan .label { color: rgba(6,38,44,.8); }
.kpi-rose { background: linear-gradient(135deg, #e11d48, #fb7185); }
.kpi-orange { background: linear-gradient(135deg, #ea580c, #fb923c); }
.kpi-teal { background: linear-gradient(135deg, #0f766e, #2dd4bf); }

.card {
  background: rgba(255,255,255,.92);
  border: 1px solid rgba(215,229,220,.9);
  border-radius: 16px;
  padding: 1.1rem 1.2rem;
  margin-bottom: 1rem;
  box-shadow: 0 8px 24px rgba(19, 93, 54, .06);
}
.card h2, .card h3 {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--km-green-dark);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.card h2::before, .card h3::before {
  content: "";
  width: 8px; height: 18px; border-radius: 4px;
  background: linear-gradient(180deg, #34d399, #135D36);
}

table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
th, td { text-align: left; padding: .75rem .6rem; border-bottom: 1px solid #e8f0eb; }
th {
  color: #065f46;
  font-weight: 700;
  font-size: .75rem;
  text-transform: uppercase;
  background: linear-gradient(90deg, #ecfdf5, #eff6ff);
}
tbody tr:hover { background: #f0fdf4; }
tbody tr:nth-child(even) { background: #f8fffb; }
tbody tr:nth-child(even):hover { background: #ecfdf5; }

.badge {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 700;
  background: #eef2ff;
  color: #3730a3;
}
.badge.green, .badge-status-completed, .badge-status-customer_confirmed, .badge-status-approved, .badge-status-published { background: #d1fae5; color: #065f46; }
.badge.red, .badge-status-cancelled, .badge-status-rejected, .badge-status-failed, .badge-status-suspended, .badge-status-blacklisted { background: #ffe4e6; color: #9f1239; }
.badge.yellow, .badge-status-searching_provider, .badge-status-payment_pending, .badge-status-pending, .badge-status-under_verification, .badge-status-submitted, .badge-status-draft { background: #fef3c7; color: #92400e; }
h1 { color: #0f3d28; letter-spacing: -.2px; }

.badge.blue, .badge-status-provider_assigned, .badge-status-in_progress, .badge-status-journey_started { background: #dbeafe; color: #1e40af; }
.badge.purple, .badge-status-quotation_pending, .badge-status-disputed { background: #ede9fe; color: #5b21b6; }
.badge.teal, .badge-status-arrived, .badge-status-work_started { background: #ccfbf1; color: #115e59; }

.btn {
  display: inline-block; border: none; border-radius: 10px; padding: .5rem .9rem; cursor: pointer; font-size: .85rem; font-weight: 700;
  transition: .15s ease;
}
.btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.btn-primary { background: linear-gradient(135deg, #135D36, #0d9488); color: #fff; }
.btn-gold { background: linear-gradient(135deg, #F2C94C, #f59e0b); color: #1a1a1a; }
.btn-danger { background: linear-gradient(135deg, #e11d48, #fb7185); color: #fff; }
.btn-ghost { background: #fff; border: 1px solid #86efac; color: #166534; }

.tabs { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a {
  padding: .45rem .9rem; border-radius: 999px; background: #fff; border: 1px solid #bbf7d0; font-size: .85rem; font-weight: 600; color: #166534;
}
.tabs a.active { background: linear-gradient(135deg, #135D36, #0d9488); color: #fff; border-color: transparent; }

.alert {
  padding: .85rem 1rem; border-radius: 12px;
  background: linear-gradient(90deg, #d1fae5, #ecfccb);
  color: #166534; margin-bottom: 1rem; border: 1px solid #86efac; font-weight: 600;
}

.dist-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: .55rem .65rem; margin-bottom: .4rem; border-radius: 10px;
  background: linear-gradient(90deg, #ecfdf5, #eff6ff);
  border: 1px solid #d1fae5;
}
.dist-row strong {
  background: #135D36; color: #fff; min-width: 28px; text-align: center;
  border-radius: 999px; padding: .15rem .55rem; font-size: .8rem;
}

.map-placeholder {
  height: 420px; border-radius: 16px;
  background: linear-gradient(135deg, #d1fae5, #dbeafe 50%, #fef3c7);
  display: flex; align-items: center; justify-content: center; color: var(--km-green); font-weight: 700;
  border: 1px solid #86efac;
}

.kpi-hint {
  position: relative; z-index: 1;
  margin-top: .35rem; font-size: .72rem; font-weight: 600; opacity: .88;
}
.dash-alerts {
  display: grid; gap: .55rem; margin-bottom: 1.15rem;
}
.dash-alert {
  display: block; padding: .75rem 1rem; border-radius: 12px;
  font-size: .88rem; font-weight: 600; text-decoration: none;
  border: 1px solid transparent;
}
.dash-alert-warn { background: linear-gradient(90deg,#fef3c7,#ffedd5); color:#92400e; border-color:#fcd34d; }
.dash-alert-info { background: linear-gradient(90deg,#dbeafe,#e0e7ff); color:#1e3a8a; border-color:#93c5fd; }
.dash-alert-money { background: linear-gradient(90deg,#ecfccb,#d1fae5); color:#166534; border-color:#86efac; }
.card-title-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  margin-bottom: 1rem;
}
.card-title-row h2::before { content: none; }
.link-more { color: #135D36; font-weight: 700; font-size: .88rem; }
.ops-list { display: grid; gap: .45rem; }
.ops-row {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  padding: .55rem .65rem; border-radius: 10px;
  background: linear-gradient(90deg, #ecfdf5, #eff6ff);
  border: 1px solid #d1fae5; font-size: .85rem; color: #334155;
}
.ops-row b { color: #135D36; font-weight: 800; }
.reports-head {
  display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem;
  margin-bottom: 1.25rem; flex-wrap: wrap;
}
.reports-sub { margin: 0; color: #5a6b62; font-size: .9rem; }
.chart-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem;
}
.chart-grid-3 { grid-template-columns: repeat(3, 1fr); }
.chart-card { min-height: 0; }
.chart-wrap { position: relative; height: 280px; }
.chart-wrap-sm { height: 240px; }
.status-chips {
  display: flex; flex-wrap: wrap; gap: .55rem; margin-bottom: 1rem;
}
.status-chip {
  display: inline-flex; align-items: center; gap: .55rem;
  background: linear-gradient(90deg, #ecfdf5, #eff6ff);
  border: 1px solid #d1fae5; border-radius: 999px;
  padding: .4rem .75rem; font-size: .82rem; font-weight: 600; color: #166534;
}
.status-chip strong {
  background: #135D36; color: #fff; border-radius: 999px;
  min-width: 1.5rem; text-align: center; padding: .1rem .45rem; font-size: .75rem;
}
.reports-meta {
  display: flex; flex-wrap: wrap; gap: 1rem; font-size: .85rem; color: #5a6b62;
  border-top: 1px dashed #d1e7db; padding-top: .85rem;
}
.reports-meta b { color: #135D36; }
input, select, textarea {
  font: inherit;
}

.sidebar-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .5rem;
}
.sidebar-top .brand {
  border-bottom: 0;
  margin-bottom: 0;
  padding-bottom: .35rem;
  flex: 1;
}
.sidebar-close {
  display: none;
  border: 0;
  background: rgba(255,255,255,.12);
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  margin: 0 .85rem 0 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: .65rem;
  flex: 1;
  min-width: 0;
}
.menu-toggle {
  display: none;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  border: 1px solid #bbf7d0;
  background: #fff;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.menu-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  border-radius: 2px;
  background: #135D36;
}
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(10, 30, 20, .45);
  z-index: 40;
  border: 0;
}
body.no-scroll { overflow: hidden; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.card { overflow-x: auto; }

@media (max-width: 1100px) {
  .chart-grid, .chart-grid-3 { grid-template-columns: 1fr; }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 900px) {
  .menu-toggle { display: inline-flex; }
  .sidebar-close { display: inline-flex; align-items: center; justify-content: center; }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    z-index: 50;
    transform: translateX(-105%);
    transition: transform .22s ease;
    box-shadow: 16px 0 40px rgba(0,0,0,.28);
  }
  .admin-shell.sidebar-open .sidebar { transform: translateX(0); }

  .main { width: 100%; }
  .topbar {
    padding: .7rem .85rem;
    position: sticky;
    top: 0;
    z-index: 30;
    flex-wrap: nowrap;
  }
  .topbar-left input {
    width: 100%;
    min-width: 0;
    font-size: .85rem;
  }
  .topbar-user {
    max-width: 42vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: .72rem;
    padding: .4rem .65rem;
  }
  .topbar-logout-form { display: none; }
  .content { padding: 1rem .85rem 1.5rem; }
  .sidebar .brand { font-size: 1.05rem; padding-left: 1rem; }
  .sidebar-top {
    border-bottom: 1px solid rgba(255,255,255,.18);
    margin-bottom: .75rem;
    padding-bottom: .75rem;
  }
}

@media (max-width: 700px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .reports-head { align-items: stretch; }
  .reports-head .tabs { width: 100%; }
  .card-title-row { flex-wrap: wrap; }
  h1 { font-size: 1.35rem; }
  .kpi .value { font-size: 1.35rem; }
  .chart-wrap { height: 220px; }
  .chart-wrap-sm { height: 200px; }
  table { font-size: .82rem; }
  th, td { padding: .55rem .4rem; }
  .map-placeholder { height: 280px; }
}

@media (max-width: 420px) {
  .topbar-user { display: none; }
  .btn-logout { display: none; }
}
