/* =============================================================================
   RAVEN - Roadtex Automated Validation & Extraction Network
   Design System based on Echo/Freight/Dock-Operations Applications
   ============================================================================= */

/* ==================== CSS Variables (Echo Design System) ==================== */
:root {
  /* Core Brand Colors */
  --bg: #f6f8fb;
  --panel: #fff;
  --fg: #1d2a3a;
  --muted: #66768a;
  --border: #dde4ed;
  --accent: #e21d2a;
  --primary: #195fcb;
  --primary-hover: #1654b5;
  --primary-dark: #003366;

  /* Status Colors */
  --success: #28a745;
  --success-light: #e7f6e7;
  --success-teal: #20c997;
  --warning: #ffc107;
  --warning-light: #fff7cc;
  --error: #dc3545;
  --error-dark: #c82333;
  --error-light: #ffe5e5;
  --info: #17a2b8;
  --info-light: #e3f2fd;

  /* Extended Palette */
  --color-accent-purple: #667eea;
  --color-bg-slate: #f8f9fa;
  --color-bg-hover: #f1f5f9;
  --color-bg-table-hover: #e6f3ff;
  --color-text-slate: #475569;

  /* Gradients */
  --gradient-primary: linear-gradient(135deg, #003366 0%, #0056b3 100%);
  --gradient-success: linear-gradient(135deg, #28a745 0%, #20c997 100%);
  --gradient-danger: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
  --gradient-warning: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
  --gradient-info: linear-gradient(135deg, #17a2b8 0%, #138496 100%);

  /* Spacing */
  --spacing-xs: 4px;
  --spacing-sm: 8px;
  --spacing-md: 12px;
  --spacing-lg: 16px;
  --spacing-xl: 20px;
  --spacing-2xl: 24px;
  --spacing-3xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 10px;
  --radius-2xl: 12px;
  --radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.15);
  --shadow-primary: 0 4px 12px rgba(25, 95, 203, 0.25);
  --shadow-success: 0 4px 12px rgba(40, 167, 69, 0.3);
  --shadow-danger: 0 4px 12px rgba(220, 53, 69, 0.3);

  /* Typography */
  --font-primary: "Segoe UI", Roboto, Arial, sans-serif;
  --font-mono: ui-monospace, Consolas, Menlo, monospace;
}

/* ==================== Base Styles ==================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.45 var(--font-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: var(--spacing-xl) 0;
}

/* ==================== Header ==================== */
.rv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.rv-header-left {
  display: flex;
  align-items: center;
}

.rv-logo-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
}

.rv-logo {
  height: 36px;
  width: auto;
}

.rv-logo-text {
  display: flex;
  flex-direction: column;
}

.rv-app-name {
  font-size: 18px;
  font-weight: 700;
  color: var(--fg);
  letter-spacing: 0.05em;
}

.rv-app-subtitle {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: -0.01em;
}

.rv-header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Status Pill */
.rv-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--success-light);
  border: 1px solid rgba(40, 167, 69, 0.2);
}

.rv-status-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  background: var(--success);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.rv-status-text {
  font-size: 11px;
  font-weight: 600;
  color: #15803d;
}

/* User Block */
.rv-user-block {
  text-align: right;
}

.rv-user-name {
  font-weight: 600;
  font-size: 14px;
  color: var(--fg);
}

.rv-user-roles {
  margin-top: 2px;
}

.rv-role-pill {
  display: inline-block;
  padding: 2px 8px;
  background: rgba(25, 95, 203, 0.1);
  color: var(--primary);
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-left: 4px;
}

/* ==================== User Dropdown ==================== */
.user-dropdown {
  position: relative;
  display: inline-block;
  margin-left: 16px;
}

.user-avatar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.user-avatar:hover {
  background: var(--color-bg-hover);
  border-color: var(--primary);
}

.avatar-initials {
  width: 32px;
  height: 32px;
  background: var(--gradient-primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}

.avatar-chevron {
  transition: transform 0.2s;
  color: var(--muted);
}

.user-dropdown.active .avatar-chevron {
  transform: rotate(180deg);
}

.user-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  min-width: 260px;
  z-index: 1000;
  animation: dropdownFadeIn 0.15s ease;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.user-menu[hidden] {
  display: none;
}

.user-menu-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--color-bg-slate);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.user-menu-name {
  font-weight: 700;
  font-size: 15px;
  color: var(--fg);
  margin: 0 0 4px 0;
}

.user-menu-email {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 8px 0;
}

.user-menu-roles {
  margin-top: 8px;
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--fg);
  text-decoration: none;
  font-size: 14px;
  transition: background 0.15s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.user-menu-item:hover {
  background: var(--color-bg-hover);
  text-decoration: none;
}

.user-menu-item svg {
  color: var(--muted);
  flex-shrink: 0;
}

.user-menu-item:hover svg {
  color: var(--primary);
}

.user-menu-logout:hover {
  background: var(--error-light);
}

.user-menu-logout:hover svg {
  color: var(--error);
}

.user-menu-logout:hover span {
  color: var(--error);
}

.user-menu-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* ==================== Main Shell Layout ==================== */
.rv-shell {
  display: flex;
  min-height: calc(100vh - 65px);
  flex: 1;
}

/* ==================== Sidebar ==================== */
.rv-sidebar {
  width: 220px;
  background: linear-gradient(180deg, #1d2a3a 0%, #0f172a 100%);
  color: #e5e7eb;
  padding: 16px 8px;
  flex-shrink: 0;
}

.rv-main-nav ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.rv-main-nav li {
  margin: 2px 0;
}

.rv-main-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  font-weight: 500;
  color: #94a3b8;
  transition: all 0.2s;
}

.rv-main-nav li.active > a {
  background: rgba(25, 95, 203, 0.2);
  color: #fff;
  border-left: 3px solid var(--primary);
}

.rv-main-nav a:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  text-decoration: none;
}

/* ==================== Main Column ==================== */
.rv-main-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* ==================== Subnav Tabs ==================== */
.rv-subnav {
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  padding: 0 20px;
}

.rv-subnav ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  gap: 4px;
}

.rv-subnav li {
  margin: 0;
}

.rv-subnav a,
.rv-subnav span {
  display: block;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
}

.rv-subnav li.active a,
.rv-subnav li.active span {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.rv-subnav a:hover {
  text-decoration: none;
  color: var(--fg);
  border-bottom-color: var(--border);
}

/* ==================== Main Content ==================== */
.rv-main {
  padding: var(--spacing-2xl);
  background: var(--bg);
  flex: 1;
}

.rv-main h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: -0.02em;
}

.rv-main > p {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--muted);
}

/* ==================== Cards & Panels ==================== */
.raven-section {
  margin-bottom: var(--spacing-2xl);
}

.raven-section h1 {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 600;
  color: var(--fg);
}

.raven-section > p {
  margin: 0 0 20px;
  color: var(--muted);
}

.raven-panel,
.rv-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
}

.raven-panel h2,
.rv-panel h2 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
}

.raven-panel p,
.rv-panel p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

/* Grid Layout */
.rv-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: var(--spacing-lg);
  margin-top: var(--spacing-lg);
}

.rv-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.rv-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c9d4e3;
  transform: translateY(-2px);
}

.rv-card h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--fg);
}

.rv-card p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 14px;
}

.rv-card-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 500;
  font-size: 14px;
}

.rv-card-link:hover {
  text-decoration: underline;
}

/* ==================== Forms & Inputs ==================== */
.form-row {
  display: flex;
  gap: var(--spacing-md);
  margin-bottom: var(--spacing-lg);
  align-items: stretch;
}

.form-row label {
  flex: 0 0 120px;
  font-weight: 600;
  color: var(--fg);
  display: flex;
  align-items: center;
  font-size: 14px;
}

.form-row input[type="text"],
.form-row input[type="email"],
.form-row input[type="password"],
.form-row input[type="number"],
.form-row input[type="date"],
.form-row select,
.form-row textarea,
.input {
  flex: 1;
  padding: 10px 12px;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: all 0.2s ease;
}

.form-row input:focus,
.form-row select:focus,
.form-row textarea:focus,
.input:focus {
  border-color: var(--color-accent-purple);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-row input::placeholder,
.form-row textarea::placeholder,
.input::placeholder {
  color: #999;
  font-weight: 400;
}

.form-row input[readonly],
.form-row textarea[readonly] {
  background: #f5f5f5;
  color: #666;
  cursor: not-allowed;
}

.form-row textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* Form Grid Layouts */
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--spacing-lg);
}

.form-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: var(--spacing-md);
}

/* Form Group (vertical stacking) */
.form-group {
  margin-bottom: var(--spacing-xl);
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 13px;
  color: var(--fg);
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
}

/* Informational note box */
.form-note {
  background: #e7f3ff;
  border: 2px solid #b3d9ff;
  border-radius: var(--radius-md);
  padding: var(--spacing-md) var(--spacing-lg);
  font-size: 14px;
  color: #0066cc;
  margin: var(--spacing-xl) 0;
}

/* ==================== Buttons ==================== */
.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: var(--radius-md);
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  border: none;
  text-decoration: none;
  background: var(--panel);
  border: 2px solid var(--border);
  color: var(--fg);
}

.btn:hover {
  border-color: #adb5bd;
  background: var(--color-bg-slate);
  text-decoration: none;
}

.btn.primary,
.btn-primary {
  background: var(--gradient-primary);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-primary);
}

.btn.primary:hover,
.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(0, 86, 179, 0.4);
}

.btn.success,
.btn-success {
  background: var(--gradient-success);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-success);
}

.btn.success:hover,
.btn-success:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.btn.danger,
.btn-danger {
  background: var(--gradient-danger);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-danger);
}

.btn.danger:hover,
.btn-danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(220, 53, 69, 0.4);
}

.btn.warning,
.btn-warning {
  background: var(--gradient-warning);
  border-color: transparent;
  color: #333;
}

.btn.warning:hover,
.btn-warning:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(255, 193, 7, 0.4);
}

.btn.info,
.btn-info {
  background: var(--gradient-info);
  border-color: transparent;
  color: #fff;
}

.btn.info:hover,
.btn-info:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(23, 162, 184, 0.4);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
}

.btn:active {
  transform: translateY(0);
}

/* Small button */
.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

/* Button row (for form footers) */
.form-row.buttons {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  margin-top: var(--spacing-xl);
  padding-top: var(--spacing-xl);
  border-top: 2px solid var(--border);
  gap: 12px;
}

/* ==================== Tables ==================== */
.grid,
.raven-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  overflow: hidden;
  font-family: var(--font-primary);
}

.grid th,
.grid td,
.raven-table th,
.raven-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
  font-family: var(--font-primary);
}

.grid th,
.raven-table th {
  background: #f3f6fb;
  color: var(--primary-dark);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  position: sticky;
  top: 0;
  z-index: 10;
  white-space: nowrap;
  user-select: none;
}

.grid th:hover,
.raven-table th:hover {
  background: #e9eef5;
}

.grid tbody tr,
.raven-table tbody tr {
  transition: background-color 0.15s ease;
}

.grid tbody tr:hover,
.raven-table tbody tr:hover {
  background: var(--color-bg-table-hover);
  cursor: pointer;
}

.grid tbody tr:hover td,
.raven-table tbody tr:hover td {
  background: var(--color-bg-table-hover);
}

.grid tbody tr:last-child td,
.raven-table tbody tr:last-child td {
  border-bottom: none;
}

/* Table container for scrolling */
.table-container {
  max-height: 500px;
  overflow-y: auto;
  position: relative;
}

/* Row status colors */
tr.late { background: var(--error-light) !important; }
tr.today { background: var(--warning-light) !important; }
tr.tomorrow { background: var(--success-light) !important; }
tr.early { background: #f0e5ff !important; }

/* ==================== Badges & Chips ==================== */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  background: #eef3f9;
  color: #3a506b;
  border: 1px solid var(--border);
}

.badge.success { background: var(--success-light); color: #15803d; border-color: #a5d6a7; }
.badge.warning { background: var(--warning-light); color: #92400e; border-color: #fcd34d; }
.badge.error { background: var(--error-light); color: #b91c1c; border-color: #fca5a5; }
.badge.info { background: var(--info-light); color: #0369a1; border-color: #7dd3fc; }

.chip {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-xl);
  font-size: 11px;
  font-weight: 600;
  line-height: 16px;
  border: 1px solid #d8dce2;
  background: #fff;
  color: #444;
}

.chip.shipper { border-color: #007bff; background: rgba(0, 123, 255, 0.1); color: #007bff; }
.chip.consignee { border-color: #28a745; background: rgba(40, 167, 69, 0.1); color: #28a745; }
.chip.billto { border-color: #6f42c1; background: rgba(111, 66, 193, 0.1); color: #6f42c1; }

/* Tags (for pending locations) */
.tag {
  display: inline-block;
  padding: 4px 10px;
  border-radius: var(--radius-md);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #fff;
}

.tag-shipper { background: var(--primary); }
.tag-consignee { background: var(--success); }
.tag-billto { background: #6f42c1; }

/* ==================== Location Cards (Pending Locations) ==================== */
.loc-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--spacing-xl);
  margin-bottom: var(--spacing-lg);
  box-shadow: var(--shadow-sm);
  transition: all 0.2s;
}

.loc-card:hover {
  box-shadow: var(--shadow-md);
  border-color: #c9d4e3;
}

.loc-header {
  font-weight: 600;
  font-size: 16px;
  color: var(--fg);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.suggest-box {
  background: var(--color-bg-slate);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  margin-bottom: 10px;
  transition: all 0.2s;
}

.suggest-box:hover {
  border-color: var(--primary);
  background: #f0f7ff;
}

.suggest-box b {
  color: var(--primary);
  font-size: 14px;
}

.btn-row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.btn-row button {
  flex: 1;
}

.resolved {
  opacity: 0.5;
  pointer-events: none;
  background: var(--success-light);
  border-color: var(--success);
}

/* Customer Data Section */
.customer-data-section {
  margin-bottom: var(--spacing-xl);
  padding: var(--spacing-lg);
  background: var(--color-bg-slate);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

.section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: var(--spacing-md);
}

.customer-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--spacing-md);
}

.data-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.data-field label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.data-value {
  font-size: 14px;
  color: var(--fg);
  font-weight: 500;
}

.data-value em {
  color: var(--muted);
  font-style: italic;
  font-weight: 400;
}

/* Search Section */
.search-section {
  margin-bottom: var(--spacing-xl);
}

.search-row {
  display: flex;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-md);
}

.search-row .search-input {
  flex: 1;
}

.search-results {
  min-height: 60px;
}

.no-results,
.loading-text,
.error-text {
  padding: var(--spacing-lg);
  text-align: center;
  border-radius: var(--radius-lg);
  font-size: 14px;
}

.no-results {
  background: var(--color-bg-slate);
  color: var(--muted);
  border: 1px dashed var(--border);
}

.loading-text {
  background: var(--info-light);
  color: var(--info);
  border: 1px solid var(--info);
}

.error-text {
  background: var(--error-light);
  color: var(--error-dark);
  border: 1px solid var(--error);
}

/* Suggestion Info Row */
.suggest-info {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

.suggest-code {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--primary-dark);
}

/* Help Text */
.help-text {
  font-size: 12px;
  color: var(--muted);
  margin-top: var(--spacing-sm);
  padding: var(--spacing-sm) var(--spacing-md);
  background: var(--info-light);
  border-radius: var(--radius-md);
  border-left: 3px solid var(--info);
}

/* ==================== Page Header ==================== */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: var(--spacing-xl);
  gap: var(--spacing-xl);
}

.page-header-content h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 700;
  color: var(--fg);
}

.page-header-content p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.page-header-stats {
  display: flex;
  gap: var(--spacing-md);
}

.stat-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 12px 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  min-width: 80px;
}

.stat-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--muted);
  margin-top: 4px;
  letter-spacing: 0.5px;
}

/* ==================== Empty State ==================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.empty-state-icon {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  background: var(--color-bg-slate);
  color: var(--muted);
}

.empty-state-icon.success {
  background: var(--success-light);
  color: var(--success);
}

.empty-state h3 {
  margin: 0 0 8px;
  font-size: 20px;
  font-weight: 600;
  color: var(--fg);
}

.empty-state p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

/* ==================== Loading State ==================== */
.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--muted);
}

/* ==================== Results Header ==================== */
.results-header {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: var(--spacing-lg);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border);
}

/* ==================== Location Card Enhancements ==================== */
.loc-address {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 16px;
  line-height: 1.5;
}

.suggestions-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.no-suggestions {
  padding: 16px;
  background: var(--color-bg-slate);
  border-radius: var(--radius-lg);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
  border: 1px dashed var(--border);
}

.suggest-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.suggest-actions {
  display: flex;
  gap: 8px;
}

.suggest-name {
  font-weight: 600;
  font-size: 15px;
  color: var(--fg);
  margin-bottom: 4px;
}

.suggest-address {
  font-size: 13px;
  color: var(--muted);
}

/* Score Badges */
.score-badge {
  display: inline-flex;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.score-badge.score-high {
  background: var(--success);
}

.score-badge.score-medium {
  background: var(--warning);
  color: #333;
}

.score-badge.score-low {
  background: var(--muted);
}

/* ==================== Alert Boxes ==================== */
.alert {
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  margin-bottom: var(--spacing-lg);
  font-size: 14px;
}

.alert-error {
  background: var(--error-light);
  border: 1px solid var(--error);
  color: var(--error-dark);
}

.alert-success {
  background: var(--success-light);
  border: 1px solid var(--success);
  color: #15803d;
}

.alert-warning {
  background: var(--warning-light);
  border: 1px solid var(--warning);
  color: #92400e;
}

.alert-info {
  background: var(--info-light);
  border: 1px solid var(--info);
  color: #0369a1;
}

/* ==================== Modals ==================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease;
}

.modal[style*="display: block"] {
  display: flex !important;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
  margin: auto;
  padding: 0;
  border: none;
  width: 650px;
  max-width: 90%;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.3s ease;
  overflow: hidden;
  position: relative;
  z-index: 1;
}

.modal-content.modal-wide {
  width: 1200px;
  max-width: 95%;
}

.modal-content.modal-small {
  width: 400px;
}

@keyframes slideDown {
  from {
    transform: translateY(-50px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Modal header */
.modal-content h2,
.modal-header {
  background: var(--gradient-primary);
  color: white;
  margin: 0;
  padding: var(--spacing-xl) var(--spacing-2xl);
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);
  text-align: center;
}

.modal-header {
  justify-content: space-between;
}

.modal-header.success { background: var(--gradient-success); }
.modal-header.error { background: var(--gradient-danger); }
.modal-header.warning { background: var(--gradient-warning); color: #333; }
.modal-header.info { background: var(--gradient-info); }

.modal-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Modal close button - hidden by default, modals should use Cancel button */
.modal-close {
  display: none;
}

/* Modal body */
.modal-body {
  padding: var(--spacing-3xl);
  overflow-y: auto;
  max-height: 60vh;
}

/* Modal footer */
.modal-footer {
  padding: var(--spacing-lg) var(--spacing-2xl);
  border-top: 2px solid var(--border);
  background: var(--color-bg-slate);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Modal tabs */
.modal-tabs {
  background-color: #f2f5f9;
  padding: var(--spacing-sm);
  display: flex;
  justify-content: space-around;
  gap: var(--spacing-xs);
  flex-wrap: wrap;
}

.modal-tabs .tab-button {
  flex: 1;
  padding: var(--spacing-sm) var(--spacing-md);
  border: none;
  background: var(--panel);
  color: var(--primary-dark);
  cursor: pointer;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: all 0.2s ease;
  min-width: 120px;
}

.modal-tabs .tab-button:hover {
  background: #e6f0ff;
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.15);
}

.modal-tabs .tab-button.active {
  background: var(--gradient-primary);
  color: var(--panel);
  box-shadow: var(--shadow-primary);
}

.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* ==================== Notification Manager (Toast) ==================== */
.nm-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.nm-overlay.nm-active {
  opacity: 1;
  visibility: visible;
}

.nm-modal {
  background: white;
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  max-width: 90%;
  max-height: 90vh;
  overflow: hidden;
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.nm-overlay.nm-active .nm-modal {
  transform: scale(1);
}

.nm-modal.nm-small { width: 400px; }
.nm-modal.nm-medium { width: 550px; min-width: 500px; }
.nm-modal.nm-large { width: 700px; }

.nm-header {
  background: var(--gradient-primary);
  color: white;
  padding: 20px 24px;
  text-align: center;
}

.nm-header.nm-success { background: var(--gradient-success); }
.nm-header.nm-error { background: var(--gradient-danger); }
.nm-header.nm-warning { background: var(--gradient-warning); }
.nm-header.nm-info { background: var(--gradient-info); }

.nm-header-title {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.nm-body {
  padding: 32px 28px;
  overflow-y: auto;
  max-height: 60vh;
}

.nm-body .nm-message {
  font-size: 15px;
  line-height: 1.6;
  color: #555;
  text-align: center;
  font-weight: normal;
}

.nm-footer {
  padding: 0 28px 28px 28px;
  display: flex;
  gap: 12px;
  justify-content: center;
}

.nm-btn {
  flex: 1;
  max-width: 200px;
  padding: 12px 24px;
  font-size: 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  font-family: inherit;
}

.nm-btn-primary {
  background: var(--gradient-success);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-success);
}

.nm-btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4);
}

.nm-btn-secondary {
  background: white;
  color: #666;
  border: 2px solid #ddd;
}

.nm-btn-secondary:hover {
  background: var(--color-bg-slate);
  border-color: #adb5bd;
}

.nm-btn-danger {
  background: var(--gradient-danger);
  color: white;
  font-weight: 600;
  box-shadow: var(--shadow-danger);
}

/* Toast Container */
.nm-toast-container {
  position: fixed;
  z-index: 100000;
  pointer-events: none;
}

.nm-toast-container.nm-top-right { top: 20px; right: 20px; }
.nm-toast-container.nm-top-left { top: 20px; left: 20px; }
.nm-toast-container.nm-bottom-right { bottom: 20px; right: 20px; }
.nm-toast-container.nm-bottom-left { bottom: 20px; left: 20px; }

.nm-toast {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 16px 20px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 400px;
  pointer-events: auto;
  transform: translateX(400px);
  opacity: 0;
  transition: all 0.3s ease;
  border-left: 4px solid var(--primary);
}

.nm-toast.nm-toast-visible {
  transform: translateX(0);
  opacity: 1;
}

.nm-toast.nm-success { border-left-color: var(--success); }
.nm-toast.nm-error { border-left-color: var(--error); }
.nm-toast.nm-warning { border-left-color: var(--warning); }
.nm-toast.nm-info { border-left-color: var(--info); }

.nm-toast-icon { font-size: 24px; flex-shrink: 0; }
.nm-toast-content { flex: 1; }

.nm-toast-title {
  font-weight: 600;
  margin: 0 0 4px 0;
  font-size: 14px;
  color: #333;
}

.nm-toast-message {
  margin: 0;
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.nm-toast-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: 20px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  flex-shrink: 0;
}

.nm-toast-close:hover {
  background: #f0f0f0;
  color: #666;
}

/* Loading Spinner */
.nm-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  padding: 40px;
}

.nm-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid var(--primary);
  border-radius: 50%;
  animation: nm-spin 1s linear infinite;
}

@keyframes nm-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==================== Loading Overlay ==================== */
.loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(246, 248, 251, 0.9);
  backdrop-filter: blur(2px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-xl);
}

.loading-overlay[hidden] { display: none; }

.spinner {
  width: 48px;
  height: 48px;
  border: 4px solid #e9eef3;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==================== Dropzone ==================== */
.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  background: var(--panel);
  border: 2px dashed var(--border);
  border-radius: var(--radius-xl);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}

.dropzone:hover,
.dropzone.dragover {
  border-color: var(--primary);
  background: #f0f7ff;
  box-shadow: 0 0 0 4px rgba(25, 95, 203, 0.1);
}

.dropzone.error {
  border-color: var(--error);
  background: var(--error-light);
}

.dropzone input { display: none; }

.dropzone-icon {
  font-size: 48px;
  color: var(--muted);
  margin-bottom: 12px;
}

.dropzone-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 4px;
}

.dropzone-subtitle {
  font-size: 13px;
  color: var(--muted);
}

/* ==================== Toggle Switch ==================== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 26px;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #cbd5e1;
  transition: 0.3s;
  border-radius: 34px;
}

.toggle-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background-color: var(--primary);
}

.toggle-switch input:checked + .toggle-slider:before {
  transform: translateX(22px);
}

.toggle-switch input:disabled + .toggle-slider {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ==================== Footer ==================== */
.rv-footer {
  padding: 12px 24px;
  font-size: 12px;
  color: var(--muted);
  text-align: center;
  background: var(--panel);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.rv-version {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  opacity: 0.6;
}

/* ==================== Login Page ==================== */
.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  padding: 32px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
  text-align: center;
}

.login-card .logo {
  height: 48px;
  margin-bottom: 16px;
}

.login-card h2 {
  margin-top: 0;
  margin-bottom: 24px;
  color: var(--fg);
}

.login-card .form-group {
  text-align: left;
}

/* ==================== Utilities ==================== */
.text-muted { color: var(--muted); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-error, .text-danger { color: var(--error); }

.font-mono { font-family: var(--font-mono); }
.font-bold { font-weight: 600; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.text-center { text-align: center; }

.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: 4px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.w-full { width: 100%; }
.hidden { display: none !important; }

/* ==================== Responsive ==================== */
@media (max-width: 900px) {
  .rv-shell {
    flex-direction: column;
  }

  .rv-sidebar {
    width: 100%;
    padding: 8px;
  }

  .rv-main-nav ul {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .rv-main-nav a {
    padding: 8px 12px;
    white-space: nowrap;
  }

  .rv-main {
    padding: 16px;
  }

  .rv-grid {
    grid-template-columns: 1fr;
  }

  .form-grid-2,
  .form-grid-3 {
    grid-template-columns: 1fr;
  }

  .form-row {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .form-row label {
    flex: none;
  }

  .modal-content {
    width: 95%;
    margin: var(--spacing-sm) auto;
  }
}

@media (max-width: 640px) {
  .rv-header {
    flex-direction: column;
    gap: 12px;
    text-align: center;
  }

  .rv-header-right {
    width: 100%;
    justify-content: center;
  }

  .btn-row {
    flex-direction: column;
  }

  .btn-row button {
    width: 100%;
  }
}
