[hidden] {
  display: none !important;
}

html,
body {
  min-height: 100%;
  overflow-y: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 0%, rgba(37, 99, 235, .10), transparent 28%),
    radial-gradient(circle at 88% 12%, rgba(22, 163, 74, .10), transparent 24%),
    #f8fafc;
}

#sidebar {
  height: 100dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#sidebar::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

html.dark-theme body {
  background: #0f172a;
  color: #e2e8f0;
}

html.dark-theme .topbar,
html.dark-theme .card,
html.dark-theme .bg-white {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html.dark-theme .text-gray-900,
html.dark-theme .text-gray-800,
html.dark-theme .text-gray-700 {
  color: #e2e8f0 !important;
}

html.dark-theme .text-gray-600,
html.dark-theme .text-gray-500 {
  color: #94a3b8 !important;
}

html.dark-theme input,
html.dark-theme select,
html.dark-theme textarea {
  background-color: #0f172a !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}

html.dark-theme thead {
  background-color: #334155 !important;
}

html.dark-theme tbody tr {
  border-color: #334155 !important;
}

html.dark-theme .divide-gray-200 > * {
  border-color: #334155 !important;
}

.sidebar-item,
.nav button {
  transition: all .18s ease;
}

.nav button.active,
.nav button:hover {
  background: rgba(59, 130, 246, .16);
  color: #ffffff;
}

.btn-primary {
  background: linear-gradient(135deg, #2563eb, #0891b2);
  transition: transform .18s ease, box-shadow .18s ease;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(37, 99, 235, .22);
}

.login-panel {
  min-height: calc(100vh - 112px);
  display: grid;
  place-items: center;
}

.login-form {
  width: min(420px, 100%);
}

body[data-mobile="true"] .login-panel {
  min-height: 100dvh;
  place-items: start center;
  padding-top: 12vh;
}

body[data-mobile="true"] .login-form {
  border-color: #dbeafe !important;
  box-shadow: 0 20px 50px rgba(15, 23, 42, .12);
}

.chart-box {
  position: relative;
  width: 100%;
  height: 260px;
  min-height: 260px;
  max-height: 260px;
  overflow: hidden;
}

.chart-box canvas {
  display: block;
  width: 100% !important;
  height: 260px !important;
  max-height: 260px !important;
}

.crm-customer-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: thin;
  scrollbar-color: #94a3b8 #f1f5f9;
}

.crm-customer-scroll::-webkit-scrollbar {
  height: 10px;
}

.crm-customer-scroll::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 999px;
}

.crm-customer-scroll::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 999px;
}

.orders-map {
  position: relative;
  z-index: 0;
  isolation: isolate;
  width: 100%;
  height: min(62vh, 560px);
  min-height: 420px;
  overflow: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #e0f2fe;
}

.orders-map-fallback {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(148, 163, 184, .28) 1px, transparent 1px),
    linear-gradient(0deg, rgba(148, 163, 184, .28) 1px, transparent 1px),
    #e0f2fe;
  background-size: 48px 48px;
}

.map-legend {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 7px 10px;
  border: 1px solid #e5e7eb;
  background: #fff;
}

.map-legend::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.map-green::before,
.map-pin-green {
  background: #16a34a;
}

.map-yellow::before,
.map-pin-yellow {
  background: #f59e0b;
}

.map-red::before,
.map-pin-red {
  background: #dc2626;
}

.map-gray::before,
.map-pin-gray {
  background: #64748b;
}

.map-pin {
  display: block;
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .24);
}

.map-fallback-pin {
  position: absolute;
  transform: translate(-50%, -50%);
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow: 0 8px 20px rgba(15, 23, 42, .24);
}

.map-fallback-pin span {
  position: absolute;
  left: 50%;
  top: 24px;
  transform: translateX(-50%);
  white-space: nowrap;
  border-radius: 6px;
  background: #fff;
  padding: 2px 6px;
  font-size: 11px;
  font-weight: 700;
  color: #111827;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(420px, calc(100vw - 40px));
  background: #111827;
  color: #fff;
  padding: 12px 14px;
  border-radius: 10px;
  box-shadow: 0 18px 40px rgba(15, 23, 42, .22);
  z-index: 3200;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, .42);
}

.modal-card {
  width: min(520px, 100%);
  max-height: calc(100dvh - 40px);
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  background: #ffffff;
  padding: 20px;
  box-shadow: 0 24px 70px rgba(15, 23, 42, .28);
}

.modal-card-wide {
  width: min(1180px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
}

.modal-card-wide .card {
  border-radius: 12px;
}

@media (max-width: 640px) {
  .modal-backdrop {
    padding: 10px;
    place-items: stretch;
  }

  .modal-card-wide {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 14px;
  }
}

.assistant-widget {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2400;
  font-family: inherit;
}

.assistant-fab {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, .72);
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
  box-shadow: 0 18px 38px rgba(15, 23, 42, .28);
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}

.assistant-fab:hover {
  transform: translateY(-2px);
  background: #0f172a;
  box-shadow: 0 22px 44px rgba(15, 23, 42, .34);
}

.assistant-fab i {
  font-size: 22px;
}

.assistant-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  display: grid;
  grid-template-rows: auto minmax(180px, 1fr) auto;
  width: min(380px, calc(100vw - 32px));
  max-height: min(620px, calc(100dvh - 116px));
  overflow: hidden;
  border: 1px solid #dbe3ef;
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 28px 76px rgba(15, 23, 42, .3);
  opacity: 0;
  pointer-events: none;
  transform: translateY(14px) scale(.96);
  transform-origin: bottom right;
  visibility: hidden;
  transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
  will-change: opacity, transform;
}

.assistant-panel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition-delay: 0s;
}

@media (prefers-reduced-motion: reduce) {
  .assistant-panel {
    transition: none;
    transform: none;
  }
}

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}

.assistant-header p {
  margin: 0;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: #2563eb;
}

.assistant-header strong {
  display: block;
  margin-top: 2px;
  color: #111827;
  font-size: 15px;
}

.assistant-header button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  color: #475569;
  background: #ffffff;
}

.assistant-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  padding: 14px;
  background: #ffffff;
}

.assistant-message {
  max-width: 88%;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.assistant-message p {
  display: grid;
  gap: 3px;
  margin: 0;
}

.assistant-message strong {
  font-weight: 800;
}

.assistant-line {
  display: block;
}

.assistant-heading {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .02em;
  text-transform: uppercase;
  color: #1d4ed8;
}

.assistant-line-gap {
  min-height: 6px;
}

.assistant-message.assistant {
  align-self: flex-start;
  border: 1px solid #e5e7eb;
  background: #f8fafc;
  color: #111827;
}

.assistant-message.user {
  align-self: flex-end;
  background: #1d4ed8;
  color: #ffffff;
}

.assistant-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.assistant-actions button {
  min-height: 34px;
  border: 1px solid #cbd5e1;
  border-radius: 999px;
  background: #ffffff;
  padding: 6px 10px;
  color: #1f2937;
  font-size: 12px;
  font-weight: 700;
}

.assistant-actions button:hover {
  border-color: #2563eb;
  color: #1d4ed8;
}

.assistant-input {
  display: grid;
  grid-template-columns: 1fr 40px;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #e5e7eb;
  background: #f8fafc;
}

.assistant-input input {
  min-width: 0;
  min-height: 40px;
  border: 1px solid #d1d5db;
  border-radius: 999px;
  padding: 0 13px;
  font-size: 13px;
  outline: none;
}

.assistant-input input:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .14);
}

.assistant-input button {
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  background: #111827;
  color: #ffffff;
}

body.driver-mode {
  background: #f8fafc;
}

body[data-mobile="true"] #sidebar,
body[data-mobile="true"] .topbar,
body.driver-mode #sidebar {
  display: none;
}

body[data-mobile="true"] .lg\:ml-64,
body.driver-mode .lg\:ml-64 {
  margin-left: 0 !important;
}

body[data-mobile="true"] main,
body.driver-mode main {
  min-height: 100dvh;
  padding: 16px;
}

body.driver-mode .topbar {
  display: none;
}

body.driver-mode #sidebar-toggle,
body.driver-mode #globalSearch,
body.driver-mode #theme-toggle {
  display: none;
}

body.driver-mode #syncBtn {
  min-width: 44px;
}

body.driver-mode #syncBtn i {
  margin-right: 0;
}

.driver-mobile-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
}

@media (max-width: 420px) {
  .driver-mobile-header {
    grid-template-columns: 1fr;
  }
}

.driver-menu-item {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  border-radius: 10px;
  color: #475569;
  font-size: 14px;
  font-weight: 700;
  transition: background .16s ease, color .16s ease, box-shadow .16s ease;
}

.driver-menu-item.active {
  background: #111827;
  color: #ffffff;
  box-shadow: 0 10px 24px rgba(15, 23, 42, .16);
}

.driver-menu-item:not(.active):hover {
  background: #f1f5f9;
  color: #111827;
}

.stats-menu {
  margin-bottom: 18px;
}

.driver-page input,
.driver-page select {
  min-height: 44px;
}

.driver-page button {
  min-height: 44px;
}

.driver-page button:disabled {
  cursor: not-allowed;
  opacity: .45;
}

@media (max-width: 640px) {
  .assistant-widget {
    right: 14px;
    bottom: 14px;
  }

  .assistant-fab {
    width: 54px;
    height: 54px;
  }

  .assistant-panel {
    right: -2px;
    bottom: 66px;
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 94px);
    border-radius: 12px;
  }

  .assistant-message {
    max-width: 94%;
  }
}
