:root {
  --bg: #070b13;
  --bg-2: #0b1421;
  --panel: rgba(15, 23, 42, .96);
  --panel-2: rgba(30, 41, 59, .96);
  --panel-3: rgba(2, 6, 23, .74);
  --border: rgba(226, 232, 240, .16);
  --border-strong: rgba(226, 232, 240, .28);
  --text: #f8fafc;
  --muted: #a7b4c5;
  --soft: #dbeafe;
  --gold: #ffc107;
  --green: #2e9f43;
  --danger: #dc3545;
  --radius: 22px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% 6%, rgba(255, 193, 7, .16), transparent 30%),
    radial-gradient(circle at 88% 0%, rgba(46, 159, 67, .16), transparent 30%),
    linear-gradient(135deg, #030712 0%, var(--bg-2) 50%, #020617 100%);
  color: var(--text);
  font-size: 16px;
}

a { color: #93c5fd; }
a:hover { color: #bfdbfe; }
.text-muted { color: var(--muted) !important; }
.small-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; }

.app-shell {
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
  min-height: 100vh;
}

.app-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px 18px;
  background: rgba(2, 6, 23, .88);
  border-right: 1px solid var(--border);
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.app-main {
  min-width: 0;
  padding: 22px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 15px;
  background: linear-gradient(180deg, var(--gold), #d89500);
  color: #111827;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 950;
  box-shadow: 0 14px 34px rgba(255,193,7,.22);
}
.brand-title { font-size: 1.05rem; font-weight: 950; line-height: 1.1; }
.brand-subtitle, .eyebrow {
  color: var(--muted);
  font-size: .76rem;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-weight: 800;
}

.side-nav {
  display: grid;
  gap: 8px;
}
.side-nav a {
  color: #e5eef8;
  text-decoration: none;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid transparent;
  font-weight: 850;
}
.side-nav a:hover,
.side-nav a.active {
  background: rgba(255,255,255,.09);
  border-color: var(--border);
  color: #fff;
}
.sidebar-note {
  margin-top: auto;
  color: var(--muted);
  font-size: .88rem;
  background: rgba(255,255,255,.055);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 14px;
}

.page-hero {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(360px, 760px);
  gap: 18px;
  align-items: end;
  margin-bottom: 16px;
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: linear-gradient(135deg, rgba(255,255,255,.085), rgba(255,255,255,.035));
  box-shadow: 0 22px 58px rgba(0,0,0,.25);
}
.page-hero h1 {
  margin: 0;
  font-size: clamp(1.9rem, 3vw, 2.8rem);
  font-weight: 950;
  letter-spacing: -.045em;
}
.page-hero p { margin: .25rem 0 0; color: var(--muted); max-width: 760px; }

.dispatch-toolbar {
  display: grid !important;
  grid-template-columns: minmax(220px, 1fr) auto auto;
  gap: 10px !important;
  align-items: center;
  width: 100%;
}
.dispatch-toolbar .form-control { max-width: none; width: 100%; }

.form-control, .form-select {
  border-radius: 15px;
  border: 1px solid rgba(255,255,255,.20);
  background: rgba(255,255,255,.96);
  color: #111827;
  min-height: 46px;
}
.form-control:focus, .form-select:focus {
  border-color: rgba(255,193,7,.75);
  box-shadow: 0 0 0 .25rem rgba(255,193,7,.18);
}

.btn {
  border-radius: 999px;
  font-weight: 850;
  min-height: 38px;
}
.btn-primary { background: linear-gradient(180deg, #39a844, #238434); border: 0; }
.btn-warning { background: linear-gradient(180deg, var(--gold), #e0a800); border: 0; color: #111; }
.btn-outline-secondary, .btn-outline-primary, .btn-outline-warning {
  color: var(--text);
  border-color: rgba(255,255,255,.34);
}
.btn-outline-secondary:hover, .btn-outline-primary:hover { color: #111827; background: #e2e8f0; border-color: #e2e8f0; }
.btn-outline-warning:hover { color: #111827; }

.nav-tabs {
  border-bottom: 0;
  gap: .45rem;
  margin-bottom: 10px;
  overflow-x: auto;
  flex-wrap: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.nav-tabs::-webkit-scrollbar { display: none; }
.nav-tabs .nav-item { flex: 0 0 auto; }
.nav-tabs .nav-link {
  color: #d5deea;
  background: rgba(255,255,255,.06);
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  font-weight: 900;
  white-space: nowrap;
}
.nav-tabs .nav-link.active { color: #111827; background: var(--gold); border-color: var(--gold); }

.card, .card-dispatch, .modal-content, .search-card, .metric-card {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 18px 48px rgba(0,0,0,.28);
}
.search-card { padding: 18px; }
.card-body { padding: 16px; }

/* Make Bootstrap status row colors readable in this dark UI */
.table-success, .table-warning, .table-info, .table-primary, .table-light,
.table-secondary, .table-danger, .table-dark {
  --bs-table-bg: rgba(255,255,255,.035) !important;
  --bs-table-striped-bg: rgba(255,255,255,.045) !important;
  --bs-table-hover-bg: rgba(255,255,255,.08) !important;
  --bs-table-color: var(--text) !important;
  color: var(--text) !important;
}
.card-dispatch.table-success { border-left: 5px solid #22c55e; }
.card-dispatch.table-warning { border-left: 5px solid var(--gold); }
.card-dispatch.table-info { border-left: 5px solid #38bdf8; }
.card-dispatch.table-primary { border-left: 5px solid #60a5fa; }
.card-dispatch.table-danger { border-left: 5px solid #ef4444; }
.card-dispatch.table-secondary, .card-dispatch.table-light, .card-dispatch.table-dark { border-left: 5px solid #94a3b8; }

.table-card { overflow: hidden; }
.table-responsive { border-radius: 16px; }
.table {
  color: var(--text);
  margin-bottom: 0;
  min-width: 1060px;
}
.table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(15, 23, 42, .98);
  color: #dbe4ef;
  border-bottom-color: var(--border-strong);
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .055em;
  padding: 12px 10px;
}
.table td {
  border-color: rgba(255,255,255,.09);
  padding: 14px 10px;
  vertical-align: middle;
}
.table-hover tbody tr:hover { color: #fff; background: rgba(255,255,255,.06); }
.table td:nth-child(1) { min-width: 180px; }
.table td:nth-child(2) { min-width: 170px; }
.table td:nth-child(3) { min-width: 360px; }
.table td:nth-child(4) { min-width: 210px; }
.table td:nth-child(6) { min-width: 150px; }

.dispatch-status, .tm-pill, .editable { cursor: pointer; }
.badge { font-weight: 900; }
.tm-pill { width: fit-content; }
.btn-sms-tiny { --bs-btn-padding-y:.1rem; --bs-btn-padding-x:.45rem; --bs-btn-font-size:.74rem; min-height: 0; }
.edit-notes.bg-light, .bg-light {
  background: rgba(255,255,255,.075) !important;
  color: var(--text) !important;
  border-color: rgba(255,255,255,.16) !important;
}
.notes-editor { min-height: 120px; white-space: pre-wrap; }
.modal-header, .modal-footer { border-color: var(--border); }
.dispatch-modal-card { background: var(--panel); }
.estimate-box {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: rgba(0,0,0,.18);
  display: grid;
  gap: 6px;
}
.pagination .page-link { background: rgba(255,255,255,.08); border-color: rgba(255,255,255,.18); color: #fff; }
.pagination .disabled .page-link { background: rgba(255,255,255,.04); color: var(--muted); }
.metric-card { background: var(--panel-2); padding: 18px; min-height: 110px; }
.metric-card span { display: block; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .05em; }
.metric-card strong { display: block; margin-top: 8px; font-size: 1.45rem; }
.activity-item { border-top: 1px solid var(--border); padding: 12px 0; }
.activity-item:first-of-type { border-top: 0; }
.pac-container { z-index: 20000 !important; }
.refresh-spin { animation: spin 1s linear infinite; }
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

/* Tablet */
@media (max-width: 1199px) {
  .app-shell { grid-template-columns: 1fr; }
  .app-sidebar {
    position: sticky;
    top: 0;
    height: auto;
    z-index: 1020;
    padding: 12px 14px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  .app-sidebar > .d-flex { width: 100%; }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; }
  .brand-title { font-size: 1rem; }
  .side-nav {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 2px;
    margin-top: 2px !important;
    scrollbar-width: none;
  }
  .side-nav::-webkit-scrollbar { display: none; }
  .side-nav a {
    flex: 0 0 auto;
    padding: 9px 12px;
    border-radius: 999px;
    background: rgba(255,255,255,.055);
  }
  .sidebar-note { display: none; }
  .app-main { padding: 14px; }
  .page-hero {
    grid-template-columns: 1fr;
    padding: 18px;
    border-radius: 22px;
  }
  .dispatch-toolbar { grid-template-columns: 1fr auto auto; }
}

/* Phone */
@media (max-width: 575px) {
  body { font-size: 15px; }
  .app-main { padding: 10px; }
  .app-sidebar { padding: 10px; }
  .brand-subtitle { display: none; }
  .side-nav a { padding: 8px 11px; font-size: .9rem; }
  .page-hero { padding: 14px; margin-bottom: 12px; }
  .page-hero h1 { font-size: 2rem; }
  .page-hero p { font-size: .93rem; }
  .dispatch-toolbar { grid-template-columns: 1fr; }
  .dispatch-toolbar .btn { width: 100%; }
  .nav-tabs { padding-bottom: 2px; }
  .nav-tabs .nav-link { padding: 9px 14px; }
  .card-body { padding: 14px; }
  .card-dispatch { border-radius: 18px; }
  .modal-dialog { margin: .5rem; }
  .modal-body { padding: 14px; }
  .pagination { justify-content: center; }
}
