* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: var(--font-sans);
  background: var(--surface-100);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* Mobile top bar (hidden on desktop) */
.mobile-topbar {
  display: none;
  position: sticky;
  top: 0;
  z-index: 30;
  height: 60px;
  padding: 0 16px;
  background: var(--brand-deep);
  color: #ffffff;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.menu-toggle,
.drawer-close {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #ffffff;
  font-size: 20px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.drawer-close {
  display: none;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(7, 54, 49, 0.45);
}

.drawer-backdrop.hidden {
  display: none;
}

/* Fixed sidebar on desktop */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 256px;
  z-index: 40;
  background: var(--brand-deep);
  color: #ffffff;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px;
}

.brand-logo {
  flex: 0 0 auto;
  border-radius: 10px;
  display: block;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  line-height: 22px;
}

.brand-role {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.72);
}

.nav-list {
  flex: 1 1 auto;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: rgba(255, 255, 255, 0.86);
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
}

.nav-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 12px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.sidebar-footer {
  flex: 0 0 auto;
  padding: 6px;
}

.sidebar-note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 17px;
  color: rgba(255, 255, 255, 0.74);
}

/* Fluid full-width workspace */
.main {
  margin-left: 256px;
  width: calc(100% - 256px);
  min-height: 100vh;
  padding: 24px clamp(16px, 2.5vw, 36px) 48px;
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.page-title {
  margin: 0 0 4px;
  font-size: clamp(22px, 2.2vw, 28px);
  line-height: 1.25;
  font-weight: 700;
}

.page-sub {
  margin: 0;
  font-size: 14px;
  color: var(--ink-muted);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.chip-btn {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-200);
  color: var(--ink);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.chip-btn.active {
  background: var(--brand);
  border-color: var(--brand);
  color: var(--on-brand);
}

.select-input,
.text-input {
  min-height: 38px;
  padding: 6px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--line-strong);
  background: var(--surface-200);
  color: var(--ink);
  font-family: inherit;
  font-size: 14px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.card {
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 16px 18px;
}

.card-flush {
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
}

.kpi-label {
  font-size: 13px;
  color: var(--ink-muted);
  margin-bottom: 6px;
}

.kpi-val {
  font-size: 26px;
  line-height: 32px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
}

.kpi-sub {
  font-size: 13px;
  color: var(--ink-muted);
}

.data-table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  background: var(--surface-300);
  color: var(--ink-muted);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table th.sortable {
  cursor: pointer;
  user-select: none;
}

.data-table th.sortable:hover {
  color: var(--ink);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr.selected-row {
  background: var(--brand-tint);
}

.numeral {
  font-variant-numeric: tabular-nums;
}

.text-right {
  text-align: right;
}

.two-col-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
  margin-top: 20px;
}

.section-heading {
  margin: 0 0 4px;
  font-size: 18px;
  font-weight: 700;
}

.bar-row {
  display: grid;
  grid-template-columns: 150px 1fr 32px;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  font-size: 14px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--surface-300);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--brand);
}

.attention-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  cursor: pointer;
  background: transparent;
  border-left: none;
  border-right: none;
  border-top: none;
  width: 100%;
  text-align: left;
  color: var(--ink);
  font-family: inherit;
}

.attention-row:last-child {
  border-bottom: none;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.pill-accent {
  background: var(--accent);
  color: var(--on-accent);
}

.pill-warning {
  background: var(--accent-tint);
  color: var(--ink);
}

.pill-success {
  background: var(--brand-tint);
  color: var(--brand);
}

.pill-danger {
  background: #fde8e7;
  color: var(--danger);
}

.btn {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: 1.5px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
}

.btn-primary {
  background: var(--brand);
  color: var(--on-brand);
}

.btn-outline {
  background: var(--surface-200);
  border-color: var(--brand);
  color: var(--brand);
}

.btn-neutral {
  background: var(--surface-200);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn-danger {
  background: #fde8e7;
  border-color: var(--danger);
  color: var(--danger);
}

.split-requests {
  display: grid;
  grid-template-columns: minmax(260px, 340px) 1fr;
  gap: 16px;
  align-items: start;
}

.req-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.req-card {
  width: 100%;
  text-align: left;
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
}

.req-card.selected {
  background: var(--brand-tint);
  border-color: var(--brand);
}

.req-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin: 16px 0;
}

.banner-warning {
  background: var(--accent-tint);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
  font-size: 14px;
}

.banner-info {
  background: var(--brand-tint);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 14px 0;
  font-size: 14px;
}

.import-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.import-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
  margin-bottom: 4px;
}

.danger-zone {
  margin-top: 24px;
  border-color: var(--danger);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(7, 54, 49, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.hidden {
  display: none;
}

.modal-card {
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px 24px;
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
}

.form-section-title {
  margin: 16px 0 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--brand);
}

.req-photos-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  background: var(--brand-deep);
  color: #ffffff;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  z-index: 100;
}

.toast.hidden {
  display: none;
}

.sidebar-signout {
  margin-top: 12px;
  width: 100%;
  min-height: 36px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: transparent;
  color: #ffffff;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.login-gate {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: var(--surface-100);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-gate.hidden {
  display: none;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface-200);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 12px 32px rgba(7, 54, 49, 0.08);
}

.banner-danger {
  background: var(--danger-tint);
  color: var(--danger);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 600;
}

.banner-danger.hidden {
  display: none;
}

.live-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.live-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  margin-right: 6px;
}

.team-map-box {
  background: #edf4f2;
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 18px;
}

.live-map-canvas {
  width: 100%;
  height: 440px;
  z-index: 1;
}

.map-legend-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 16px;
  padding: 10px 14px;
  background: var(--surface-200);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

.routiva-salesman-pin {
  background: #d97706;
  color: #ffffff;
  border: 2.5px solid #ffffff;
  border-radius: 999px;
  padding: 3px 9px;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.team-map-svg {
  width: 100%;
  height: auto;
  max-height: 360px;
  display: block;
}

.req-photo {
  margin-top: 12px;
  max-width: 240px;
  max-height: 160px;
  border-radius: 12px;
  border: 1px solid var(--line);
  object-fit: cover;
  display: block;
}

@media (max-width: 960px) {
  .mobile-topbar {
    display: flex;
  }

  .drawer-close {
    display: inline-flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 180ms ease;
    width: 272px;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 16px 16px 40px;
  }

  .split-requests {
    grid-template-columns: 1fr;
  }
}
