:root {
  --ui-bg-1: #0b1026;
  --ui-bg-2: #1a1f46;
  --ui-bg-3: #2a2360;
  --ui-primary: #7b74ff;
  --ui-primary-strong: #9e86ff;
  --ui-cyan: #4dd8ff;
  --ui-success: #4cd787;
  --ui-warning: #ffb84d;
  --ui-danger: #ff7a8a;

  --color-bg: transparent;
  --color-surface: rgba(34, 43, 92, 0.5);
  --color-surface-sub: rgba(255, 255, 255, 0.05);
  --color-hover: rgba(255, 255, 255, 0.08);
  --color-text: #eef2ff;
  --color-text-sub: #c6d0ff;
  --color-text-muted: #97a3d7;
  --color-border: rgba(169, 180, 255, 0.24);
  --color-primary: var(--ui-primary);
  --color-primary-light: rgba(123, 116, 255, 0.2);
  --color-primary-dark: #6a63ef;
  --grad-brand: linear-gradient(120deg, #2f2f86 0%, #5141b0 40%, #3c63d4 100%);
}

body {
  background:
    radial-gradient(circle at 10% 10%, rgba(123, 116, 255, 0.24), transparent 30%),
    radial-gradient(circle at 90% 20%, rgba(77, 216, 255, 0.2), transparent 32%),
    radial-gradient(circle at 30% 90%, rgba(162, 99, 255, 0.18), transparent 35%),
    linear-gradient(135deg, var(--ui-bg-1) 0%, var(--ui-bg-2) 45%, var(--ui-bg-3) 100%);
  color: var(--color-text);
}

/* Unified typography baseline (global readability) */
body,
input,
select,
textarea,
button {
  font-family: "Inter", "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  font-size: 15px;
  line-height: 1.58;
  letter-spacing: 0.01em;
  text-rendering: optimizeLegibility;
}

h1, h2, h3 {
  letter-spacing: 0.012em;
}

.topbar,
.sidebar-left,
.sidebar-right,
.card,
.page-card,
.widget,
.modal,
.smart-result-popup {
  backdrop-filter: blur(12px);
}

.topbar {
  background: var(--grad-brand);
  border-bottom: 1px solid var(--color-border);
}

.sidebar-left,
.sidebar-right {
  background: rgba(18, 24, 58, 0.72);
  border-color: var(--color-border);
}

.sidebar-right .widget,
.card,
.page-card {
  background: rgba(45, 55, 110, 0.45);
  border: 1px solid var(--color-border);
  box-shadow: 0 8px 28px rgba(7, 10, 30, 0.35);
}

.menu-item,
.menu-group-toggle,
.menu-section-title,
.card-title,
.widget-title,
.stat-label,
label {
  color: var(--color-text-sub);
}

.sidebar-right [style*="background:#fff"],
.sidebar-right [style*="background: #fff"] {
  background: rgba(37, 47, 96, 0.82) !important;
  color: var(--color-text) !important;
}

.sidebar-right [style*="background:#f8fafc"],
.sidebar-right [style*="background: #f8fafc"],
.sidebar-right [style*="background:#f9fafb"],
.sidebar-right [style*="background: #f9fafb"] {
  background: rgba(33, 43, 90, 0.8) !important;
  color: var(--color-text-sub) !important;
}

.sidebar-right [style*="border:1px solid #e2e8f0"],
.sidebar-right [style*="border: 1px solid #e2e8f0"] {
  border-color: var(--color-border) !important;
}

.sidebar-right [style*="color:#374151"],
.sidebar-right [style*="color: #374151"],
.sidebar-right [style*="color:#475569"],
.sidebar-right [style*="color: #475569"],
.sidebar-right [style*="color:#6b7280"],
.sidebar-right [style*="color: #6b7280"] {
  color: var(--color-text-sub) !important;
}

.topbar [style*="background:#fff"],
.topbar [style*="background: #fff"] {
  background: rgba(29, 39, 87, 0.95) !important;
}

.menu-item:hover,
.menu-group-toggle:hover,
.menu-item.active,
.menu-group-toggle.active {
  color: #ffffff;
}

/* Legacy inline style normalization (all active pages) */
.main-content [style*="background:white"],
.main-content [style*="background: white"],
.main-content [style*="background:#fff"],
.main-content [style*="background: #fff"] {
  background: rgba(39, 50, 105, 0.56) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
}

.main-content [style*="background:#f8f9fa"],
.main-content [style*="background: #f8f9fa"],
.main-content [style*="background:#f9fafb"],
.main-content [style*="background: #f9fafb"],
.main-content [style*="background:#fafafa"],
.main-content [style*="background: #fafafa"] {
  background: rgba(255, 255, 255, 0.06) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text-sub) !important;
}

.main-content [style*="color:#1e293b"],
.main-content [style*="color: #1e293b"],
.main-content [style*="color:#2c3e50"],
.main-content [style*="color: #2c3e50"],
.main-content [style*="color:#334155"],
.main-content [style*="color: #334155"],
.main-content [style*="color:#374151"],
.main-content [style*="color: #374151"] {
  color: var(--color-text) !important;
}

.main-content [style*="color:#64748b"],
.main-content [style*="color: #64748b"],
.main-content [style*="color:#6c757d"],
.main-content [style*="color: #6c757d"],
.main-content [style*="color:#94a3b8"],
.main-content [style*="color: #94a3b8"],
.main-content [style*="color:#9ca3af"],
.main-content [style*="color: #9ca3af"],
.main-content [style*="color:#8a9bb0"],
.main-content [style*="color: #8a9bb0"] {
  color: var(--color-text-sub) !important;
}

.data-table th {
  background: rgba(255, 255, 255, 0.05);
  color: var(--color-text-sub);
  border-bottom: 1px solid var(--color-border);
}

.data-table td {
  color: #f0f4ff;
  border-bottom: 1px solid rgba(169, 180, 255, 0.16);
}

.data-table tbody tr:hover {
  background: rgba(122, 116, 255, 0.12);
}

input,
select,
textarea {
  background: rgba(9, 14, 42, 0.45);
  color: var(--color-text);
  border-color: var(--color-border);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-text-muted);
}

.btn-light {
  background: rgba(255, 255, 255, 0.07);
  color: var(--color-text-sub);
  border-color: var(--color-border);
}

.btn-light:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

.page-hero {
  background: linear-gradient(120deg, rgba(83, 74, 196, 0.88) 0%, rgba(64, 112, 220, 0.86) 60%, rgba(72, 170, 224, 0.82) 100%);
  border: 1px solid rgba(198, 208, 255, 0.3);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 12px 32px rgba(9, 14, 44, 0.35);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.page-hero-title {
  margin: 0;
  color: #fff;
  font-size: 32px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.page-hero-subtitle {
  margin-top: 8px;
  color: rgba(255, 255, 255, 0.9);
}

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

.kpi-card {
  border-radius: 14px;
  border: 1px solid rgba(198, 208, 255, 0.24);
  background: linear-gradient(145deg, rgba(77, 88, 159, 0.62), rgba(52, 63, 128, 0.46));
  box-shadow: 0 10px 26px rgba(9, 13, 40, 0.32);
  padding: 18px;
}

.kpi-card.is-success {
  background: linear-gradient(145deg, rgba(57, 130, 108, 0.58), rgba(42, 96, 88, 0.5));
}

.kpi-card.is-warning {
  background: linear-gradient(145deg, rgba(158, 109, 44, 0.62), rgba(117, 80, 41, 0.5));
}

.kpi-card.is-info {
  background: linear-gradient(145deg, rgba(58, 97, 163, 0.64), rgba(50, 75, 133, 0.52));
}

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

.kpi-value {
  margin-top: 6px;
  font-size: 34px;
  line-height: 1;
  font-weight: 700;
  color: #fff;
}

.kpi-meta {
  margin-top: 6px;
  color: var(--color-text-muted);
  font-size: 12px;
}

.glass-panel {
  background: rgba(39, 50, 105, 0.48);
  border: 1px solid var(--color-border);
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(8, 12, 38, 0.32);
  overflow: hidden;
}

.panel-body {
  padding: 16px 18px;
}

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

.section-gap {
  margin-bottom: 20px;
}

.two-col-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.section-actions {
  margin-top: 20px;
  display: flex;
  justify-content: center;
}

.status-amount {
  font-size: 20px;
  font-weight: 700;
}

.status-amount.is-paid {
  color: #87f5b3;
}

.status-amount.is-unpaid {
  color: #ff9aaa;
}

.detail-trigger-btn {
  background: var(--grad-brand);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.detail-trigger-btn:hover {
  filter: brightness(1.08);
}

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--color-text-muted);
}

.empty-state i {
  display: block;
  margin-bottom: 12px;
  font-size: 44px;
}

.auth-shell {
  width: 100%;
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 0;
}

body.auth-page .main-content {
  margin-left: 0 !important;
  margin-right: 0 !important;
  width: 100%;
  padding-left: 16px;
  padding-right: 16px;
}

body.auth-page .sidebar-left,
body.auth-page .sidebar-right {
  display: none !important;
}

.auth-card {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  background: linear-gradient(165deg, rgba(36, 47, 106, 0.78), rgba(24, 32, 78, 0.78));
  border: 1px solid var(--color-border);
  border-radius: 20px;
  padding: 28px;
  box-shadow: 0 20px 40px rgba(6, 10, 32, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.auth-title {
  text-align: center;
  margin-bottom: 22px;
  color: #fff;
}

.auth-card .form-group label {
  display: inline-block;
  margin-bottom: 6px;
  color: #dbe4ff;
  font-weight: 600;
}

.auth-card .form-group input {
  width: 100%;
  min-height: 46px;
  border-radius: 12px;
  border: 1px solid rgba(167, 180, 255, 0.3);
  background: rgba(13, 18, 46, 0.45);
  color: #eef2ff;
  padding: 10px 12px;
}

.auth-card .form-group input:focus {
  outline: none;
  border-color: rgba(129, 140, 248, 0.85);
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.auth-card .btn.btn-primary {
  min-height: 46px;
  border-radius: 12px;
  font-weight: 700;
}

.helper-note {
  text-align: center;
  font-size: 12px;
  color: var(--color-text-muted);
  margin-top: 14px;
}

@media (max-width: 768px) {
  .two-col-grid {
    grid-template-columns: 1fr;
  }

  .page-hero-title {
    font-size: 24px;
  }

  .auth-shell {
    min-height: calc(100dvh - var(--topbar-h));
    padding: 14px 0 18px;
  }

  .auth-card {
    max-width: 520px;
    padding: 20px 18px;
    border-radius: 16px;
  }
}

@media (max-width: 480px) {
  .auth-shell {
    min-height: calc(100dvh - var(--topbar-h));
    align-items: flex-start;
    padding-top: 10px;
  }

  .auth-card {
    max-width: 100%;
    border-radius: 14px;
    padding: 16px 14px;
  }

  .auth-title {
    font-size: 1.32rem;
    margin-bottom: 16px;
  }
}

/* Legacy template harmonizer */
.unified-legacy-page [style*="background: white"],
.unified-legacy-page [style*="background:white"],
.unified-legacy-page [style*="background: #fff"],
.unified-legacy-page [style*="background:#fff"] {
  background: rgba(37, 47, 96, 0.56) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
}

.unified-legacy-page [style*="background:#f8f9fa"],
.unified-legacy-page [style*="background: #f8f9fa"],
.unified-legacy-page [style*="background:#f5f7fa"],
.unified-legacy-page [style*="background: #f5f7fa"],
.unified-legacy-page [style*="background:#fafbff"],
.unified-legacy-page [style*="background: #fafbff"] {
  background: rgba(52, 62, 121, 0.46) !important;
  color: var(--color-text-sub) !important;
}

.unified-legacy-page [style*="color: #2c3e50"],
.unified-legacy-page [style*="color:#2c3e50"],
.unified-legacy-page [style*="color: #1e293b"],
.unified-legacy-page [style*="color:#1e293b"],
.unified-legacy-page [style*="color: #0f172a"],
.unified-legacy-page [style*="color:#0f172a"] {
  color: var(--color-text) !important;
}

.unified-legacy-page [style*="color: #6c757d"],
.unified-legacy-page [style*="color:#6c757d"],
.unified-legacy-page [style*="color: #7f8c8d"],
.unified-legacy-page [style*="color:#7f8c8d"],
.unified-legacy-page [style*="color: #95a5a6"],
.unified-legacy-page [style*="color:#95a5a6"],
.unified-legacy-page [style*="color: #9094a0"],
.unified-legacy-page [style*="color:#9094a0"] {
  color: var(--color-text-muted) !important;
}

.unified-legacy-page [style*="border: 2px solid #e9ecef"],
.unified-legacy-page [style*="border:2px solid #e9ecef"],
.unified-legacy-page [style*="border: 1px solid #e9ecef"],
.unified-legacy-page [style*="border:1px solid #e9ecef"] {
  border-color: var(--color-border) !important;
}

.unified-legacy-page .tabs-container,
.unified-legacy-page .cd-header,
.unified-legacy-page .vd-header {
  background: linear-gradient(120deg, rgba(72, 68, 179, 0.92) 0%, rgba(61, 93, 198, 0.9) 55%, rgba(70, 143, 215, 0.88) 100%) !important;
  border: 1px solid rgba(198, 208, 255, 0.32) !important;
  box-shadow: 0 16px 34px rgba(7, 11, 34, 0.36) !important;
}

.unified-legacy-page .tab-content-wrapper,
.unified-legacy-page .od-card,
.unified-legacy-page .res-card,
.unified-legacy-page .prob-card,
.unified-legacy-page .hist-card {
  background: rgba(38, 48, 103, 0.56) !important;
  border: 1px solid var(--color-border) !important;
  box-shadow: 0 8px 26px rgba(8, 12, 37, 0.34) !important;
}

.unified-legacy-page .vehicle-card {
  background: rgba(38, 48, 103, 0.62) !important;
  border-color: var(--color-border) !important;
}

.unified-legacy-page .vehicle-card-name,
.unified-legacy-page .prob-title,
.unified-legacy-page .res-title,
.unified-legacy-page .tab-toolbar h2,
.unified-legacy-page .od-card-title,
.unified-legacy-page .od-value {
  color: var(--color-text) !important;
}

.unified-legacy-page .vehicle-card-row,
.unified-legacy-page .res-desc,
.unified-legacy-page .prob-list li,
.unified-legacy-page .hist-block,
.unified-legacy-page .od-label {
  color: var(--color-text-sub) !important;
}

.unified-legacy-page .orders-table th,
.unified-legacy-page .od-table th {
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--color-text-sub) !important;
  border-bottom: 1px solid var(--color-border) !important;
}

.unified-legacy-page .orders-table td,
.unified-legacy-page .od-table td {
  color: var(--color-text) !important;
  border-bottom-color: rgba(177, 189, 255, 0.16) !important;
}

.unified-legacy-page .orders-table tr:hover td,
.unified-legacy-page .od-table tbody tr:hover {
  background: rgba(122, 116, 255, 0.12) !important;
}

.unified-legacy-page .empty-state,
.unified-legacy-page .loading-container,
.unified-legacy-page .error-container {
  background: rgba(34, 45, 96, 0.5) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text-sub) !important;
}

.unified-legacy-page .kanban-column {
  background: rgba(30, 40, 90, 0.62) !important;
  border-color: var(--color-border) !important;
}

.unified-legacy-page .kanban-card {
  background: rgba(47, 57, 114, 0.74) !important;
  box-shadow: 0 8px 22px rgba(8, 12, 35, 0.34) !important;
  border: 1px solid rgba(182, 193, 255, 0.24) !important;
}

/* Stage 2: extracted page-specific classes */
.search-shell {
  max-width: 1400px;
  margin: 0 auto;
}

.search-panel {
  background: rgba(39, 50, 105, 0.52);
  padding: 25px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(8, 12, 35, 0.3);
  border: 1px solid var(--color-border);
  margin-bottom: 30px;
}

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

.search-label {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--color-text-sub);
}

.search-control {
  width: 100%;
}

.search-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.search-loading,
.search-error {
  text-align: center;
  padding: 50px 20px;
  border-radius: 12px;
  background: rgba(39, 50, 105, 0.5);
  border: 1px solid var(--color-border);
}

.search-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(225, 230, 255, 0.2);
  border-top-color: var(--ui-primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

.search-results-title {
  color: var(--color-text);
  margin-bottom: 20px;
  font-size: 18px;
}

.search-results-count {
  color: var(--color-text-muted);
  font-size: 15px;
  font-weight: normal;
}

.order-edit-form {
  background: rgba(39, 50, 105, 0.54);
  padding: 28px 30px;
  border-radius: 14px;
  box-shadow: 0 8px 24px rgba(8, 12, 35, 0.3);
  border: 1px solid var(--color-border);
}

.order-edit-section {
  margin-bottom: 24px;
  padding: 18px 20px;
  border-radius: 12px;
  border: 1px solid var(--color-border);
  background: rgba(46, 56, 113, 0.52);
}

.order-edit-title {
  margin: 0 0 18px;
  color: var(--color-text);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
}

.kanban-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  padding-bottom: 20px;
  width: 100%;
}

.queue-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
}

.kanban-column {
  padding: 15px;
  border-radius: 12px;
  min-height: 400px;
}

.kanban-column-head {
  margin: 0 0 15px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
}

.kanban-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.kanban-items {
  min-height: 50px;
}
