/* AI Change Detection — Gradient theme (#2e33c5 → #cf2040) */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --gradient: linear-gradient(135deg, #2e33c5, #cf2040);
  --gradient-h: linear-gradient(90deg, #2e33c5, #cf2040);
  --grad-start: #2e33c5;
  --grad-end: #cf2040;
  --grad-mid: #7a2a82;

  --bg-deep: #ffffff;
  --bg-surface: #f8f9fb;
  --bg-elevated: #f1f3f7;
  --bg-card: #ffffff;
  --bg-hover: #edf0f5;
  --border: rgba(0, 0, 0, 0.08);
  --border-hover: rgba(0, 0, 0, 0.16);
  --border-focus: rgba(46, 51, 197, 0.45);
  --text: #1a1a2e;
  --text-muted: #555770;
  --text-dim: #8890a4;
  --accent: #7a6aed;
  --accent-dim: #6358d4;
  --accent-glow: rgba(122, 106, 237, 0.2);
  --danger: #dc2626;
  --danger-dim: #b91c1c;
  --danger-glow: rgba(220, 38, 38, 0.1);
  --success: #16a34a;
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 6px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --transition: 0.2s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-deep);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(46, 51, 197, 0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(207, 32, 64, 0.03) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem;
  min-height: 100vh;
}

/* Views */
.view { display: none; animation: fadeSlideIn 0.35s ease; }
.view.active { display: block; }

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---- Auth pages ---- */
.auth-container { max-width: 420px; margin: 3rem auto; }

.auth-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  margin-bottom: 2rem;
  font-size: 1.3rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  color: var(--text);
}
.auth-logo-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--gradient);
  color: #fff;
}

.auth-container .card { padding: 2rem; }
.auth-container h2 {
  font-size: 1.3rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}
.auth-container .sub {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
}
.auth-container .form-group:last-of-type { margin-bottom: 1.75rem; }

.auth-actions { margin-top: 1.75rem; }

.forgot-link {
  text-align: center;
  margin-top: 1rem;
  margin-bottom: 0;
}
.forgot-link a {
  color: var(--text-dim);
  font-size: 0.84rem;
  text-decoration: none;
  transition: color var(--transition);
}
.forgot-link a:hover { color: var(--grad-start); }

.toggle-auth {
  text-align: center;
  margin-top: 1.25rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.toggle-auth a {
  color: var(--grad-start);
  text-decoration: none;
  font-weight: 500;
}
.toggle-auth a:hover { text-decoration: underline; }

/* Forgot password page */
.forgot-header-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: var(--gradient);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: #fff;
}
.back-to-login {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--text-dim);
  font-size: 0.84rem;
  text-decoration: none;
  margin-top: 1.75rem;
  transition: color var(--transition);
}
.back-to-login:hover { color: var(--grad-start); }

/* ---- Password input with eye toggle ---- */
.input-password-wrap {
  position: relative;
}
.input-password-wrap input {
  width: 100%;
  padding-right: 2.75rem;
}
.password-toggle {
  position: absolute;
  right: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  color: #8890a4;
  padding: 0.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color var(--transition);
  line-height: 0;
}
.password-toggle:hover { color: #555770; }
.password-toggle.active { color: #555770; }

/* ---- Cards ---- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 1.25rem; }

.card-header {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}
.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* ---- Forms ---- */
.form-group { margin-bottom: 1.25rem; }
.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

input[type="email"],
input[type="password"],
input[type="text"],
select,
textarea {
  width: 100%;
  padding: 0.7rem 0.9rem;
  font-family: var(--font-sans);
  font-size: 0.95rem;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(46, 51, 197, 0.18);
}

.checkbox-group label {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}
.checkbox-group input[type="checkbox"] {
  accent-color: var(--grad-start);
  width: 16px;
  height: 16px;
}

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

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.65rem 1.3rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 500;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gradient);
  color: #fff;
  font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.15); box-shadow: 0 4px 24px rgba(46, 51, 197, 0.35), 0 4px 16px rgba(207, 32, 64, 0.2); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 0.5rem 0.75rem;
}
.btn-ghost:hover { color: var(--text); background: rgba(0,0,0,0.04); }

.btn-danger {
  background: var(--danger);
  color: #fff;
  font-weight: 600;
}
.btn-danger:hover { background: var(--danger-dim); box-shadow: 0 4px 16px var(--danger-glow); }

.btn-icon {
  background: transparent;
  color: var(--text-dim);
  padding: 0.4rem;
  border-radius: var(--radius-xs);
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  transition: all var(--transition);
}
.btn-icon:hover { color: var(--danger); background: var(--danger-glow); }

.btn-block { width: 100%; }
.btn-sm { font-size: 0.8rem; padding: 0.45rem 0.8rem; }
.btn-lg { padding: 0.8rem 1.6rem; font-size: 0.95rem; }

/* ---- Topbar (user avatar) ---- */
.topbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 1rem;
}
.nav-user {
  position: relative;
}
.nav-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
}
.nav-avatar:hover {
  border-color: var(--grad-start);
  color: var(--grad-start);
  background: var(--bg-hover);
}

/* Dropdown */
.nav-dropdown {
  position: absolute;
  top: calc(100% + 0.5rem);
  right: 0;
  min-width: 210px;
  background: linear-gradient(135deg, #4a4ed4, #d94060);
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.5rem 0;
  animation: dropIn 0.15s ease;
  z-index: 200;
  box-shadow: 0 8px 28px rgba(46, 51, 197, 0.3), 0 4px 12px rgba(207, 32, 64, 0.15);
}
@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}
.nav-dropdown-email {
  padding: 0.6rem 1rem;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  word-break: break-all;
}
.nav-dropdown-divider {
  height: 1px;
  background: rgba(255,255,255,0.12);
  margin: 0.25rem 0;
}
.nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 1rem;
  border: none;
  background: none;
  color: rgba(255,255,255,0.9);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background var(--transition);
}
.nav-dropdown-item:hover {
  background: rgba(255,255,255,0.1);
}
.nav-dropdown-item svg { color: rgba(255,255,255,0.6); }

/* ---- Location row ---- */
.location-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.location-row label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.location-row label svg {
  color: var(--grad-start);
  flex-shrink: 0;
}
.location-row select {
  width: 100%;
}
@media (max-width: 640px) {
  .location-row { grid-template-columns: 1fr; }
}

/* ---- Notify row ---- */
.notify-row {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}
.notify-email-group {
  flex: 1;
  min-width: 200px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.notify-email-group.visible {
  opacity: 1;
  transform: translateY(0);
}
.notify-email-group label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}
.notify-email-group label svg {
  color: var(--grad-start);
  flex-shrink: 0;
}
.notify-email-group input {
  width: 100%;
}
.notify-email-actions {
  display: flex;
  gap: 0.6rem;
  align-items: stretch;
}
.notify-email-actions .btn {
  flex-shrink: 0;
}
.notify-help {
  margin-top: 0.35rem;
  font-size: 0.78rem;
  color: var(--text-dim);
}
@media (max-width: 640px) {
  .notify-row { flex-direction: column; align-items: stretch; }
  .notify-email-group { min-width: 100%; }
  .notify-email-actions { flex-direction: column; }
}

/* ---- Upload zones ---- */
.upload-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 640px) {
  .upload-grid { grid-template-columns: 1fr; }
}

.upload-zone {
  position: relative;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem;
  text-align: center;
  background: var(--bg-elevated);
  transition: all var(--transition);
  cursor: pointer;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--grad-start);
  background: rgba(46, 51, 197, 0.04);
  box-shadow: 0 0 0 4px rgba(46, 51, 197, 0.15);
}
.upload-zone input[type="file"] {
  position: absolute;
  width: 0;
  height: 0;
  opacity: 0;
}
.upload-icon {
  color: var(--text-dim);
  margin-bottom: 0.5rem;
  transition: color var(--transition);
}
.upload-zone:hover .upload-icon { color: var(--grad-start); }
.upload-zone label {
  cursor: pointer;
  display: block;
  color: var(--text-muted);
  font-size: 0.85rem;
}
.upload-zone .filename {
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--grad-start);
  font-family: var(--font-mono);
}
.upload-preview {
  margin-top: 0.75rem;
  max-height: 100px;
  max-width: 100%;
  border-radius: var(--radius-xs);
  object-fit: cover;
  border: 1px solid var(--border);
}

.options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: flex-end;
}
.options-row .form-group {
  margin-bottom: 0;
  min-width: 160px;
  flex: 1;
}

.run-btn-wrap {
  margin-top: 1.25rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

/* ---- Result stats ---- */
.result-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}
.stat-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.85rem 0.75rem;
  text-align: center;
  transition: border-color var(--transition);
}
.stat-box:hover { border-color: var(--border-hover); }
.stat-box .value {
  font-size: clamp(0.85rem, 3.5vw, 1.35rem);
  font-weight: 700;
  background: var(--gradient-h);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: break-all;
}
.stat-box .label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 0.2rem;
}
.stat-box-wide {
  grid-column: span 2;
}
.stat-box .value-sm {
  font-size: clamp(0.75rem, 3vw, 1.05rem);
}
.result-warning {
  grid-column: 1 / -1;
  padding: 0.65rem 0.85rem;
  margin-bottom: 0.5rem;
  border-radius: 6px;
  background: #fef3c7;
  color: #92400e;
  font-size: 0.85rem;
  line-height: 1.4;
}
@media (max-width: 640px) {
  .stat-box-wide { grid-column: span 1; }
}

/* ---- Zoom + compare slider ---- */
.zoom-slider-section { margin-bottom: 1rem; }
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}
.btn-zoom {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text);
  transition: all var(--transition);
}
.btn-zoom:hover {
  border-color: var(--grad-start);
  color: var(--grad-start);
  background: var(--bg-hover);
}
.zoom-level {
  font-size: 0.8rem;
  color: var(--text-muted);
  min-width: 3.5rem;
  text-align: center;
}
.zoom-wrapper {
  overflow: auto;
  max-height: 70vh;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  margin-top: 0.75rem;
}
.zoom-wrapper .compare-slider { min-height: 280px; margin-top: 0; }
.region-highlight-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  z-index: 5;
}
.region-highlight-overlay .highlight-box {
  position: absolute;
  border: 3px solid rgba(255,255,0,0.9);
  background: rgba(255,255,0,0.15);
  box-shadow: 0 0 12px rgba(255,255,0,0.5);
  border-radius: 2px;
  transition: opacity 0.15s ease;
}

/* ---- Compare slider ---- */
.compare-slider {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  margin-top: 0.75rem;
  cursor: col-resize;
  user-select: none;
  -webkit-user-select: none;
  background: var(--bg-elevated);
  line-height: 0;
}
.compare-slider img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}
.compare-before {
  position: relative;
  width: 100%;
}
.compare-after {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  overflow: hidden;
  clip-path: inset(0 0 0 50%);
}
.compare-after img {
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.compare-handle {
  position: absolute;
  top: 0; bottom: 0;
  left: 50%;
  width: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transform: translateX(-50%);
  z-index: 10;
  pointer-events: none;
}
.compare-handle-line {
  flex: 1;
  width: 2px;
  background: var(--gradient);
  box-shadow: 0 0 10px rgba(46, 51, 197, 0.3);
}
.compare-handle-knob {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--gradient);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 16px rgba(0,0,0,0.5), 0 0 20px rgba(46, 51, 197, 0.3);
  flex-shrink: 0;
}
.compare-label {
  position: absolute;
  top: 10px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  pointer-events: none;
  line-height: 1.4;
}
.compare-label-left {
  left: 10px;
  background: rgba(255, 255, 255, 0.85);
  color: var(--text);
  backdrop-filter: blur(6px);
  border: 1px solid var(--border);
}
.compare-label-right {
  right: 10px;
  background: rgba(207, 32, 64, 0.85);
  color: #fff;
  backdrop-filter: blur(6px);
}

/* ---- Regions table ---- */
.regions-table-wrap { overflow-x: auto; margin-top: 1.25rem; }
.regions-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.regions-table th, .regions-table td {
  padding: 0.6rem 0.75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.regions-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-elevated);
  position: sticky;
  top: 0;
}
.regions-table td { color: var(--text-muted); }
.regions-table tr:hover td { background: rgba(46, 51, 197, 0.04); }
.regions-table tr.region-hover td { background: rgba(255, 255, 0, 0.12); }
.regions-table td:nth-child(2) { color: var(--text); font-weight: 500; }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.75rem 0 0.25rem;
  flex-wrap: wrap;
}
.pagination button {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s;
}
.pagination button:hover:not(:disabled) {
  background: rgba(46, 51, 197, 0.08);
  border-color: rgba(46, 51, 197, 0.3);
  color: var(--text);
}
.pagination button.active {
  background: linear-gradient(135deg, #2e33c5, #cf2040);
  color: #fff;
  border-color: transparent;
  font-weight: 600;
}
.pagination button:disabled {
  opacity: 0.4;
  cursor: default;
}
.pagination .page-info {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin: 0 0.5rem;
}

.severity-badge {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: capitalize;
}
.severity-badge.minor { background: rgba(0, 200, 0, 0.2); color: #0a6b0a; }
.severity-badge.moderate { background: rgba(255, 200, 0, 0.25); color: #8b6914; }
.severity-badge.major { background: rgba(255, 0, 0, 0.2); color: #b91c1c; }

/* ---- History table ---- */
.history-table-wrap { overflow-x: auto; margin-top: 0.5rem; }
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
.history-table th, .history-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.history-table th {
  color: var(--text-dim);
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: var(--bg-elevated);
  text-align: left;
}
.history-table tbody tr {
  cursor: pointer;
  transition: background var(--transition);
}
.history-table tbody tr:hover {
  background: var(--bg-hover);
}
.history-table .thumb-cell {
  width: 64px;
  padding: 0.35rem;
}
.history-table .thumb-cell img {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border-radius: var(--radius-xs);
  border: 1px solid var(--border);
  display: block;
}
.history-table .stats-cell { white-space: nowrap; color: var(--text-muted); font-size: 0.8rem; }
.history-table .actions-cell { white-space: nowrap; }
.history-table .actions-cell button { margin-left: 0.25rem; }
.history-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 2rem 1rem;
  font-size: 0.9rem;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  transition: all var(--transition);
}
.history-item:hover { border-color: var(--border-hover); background: var(--bg-hover); }

.history-info { flex: 1; min-width: 0; }
.history-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
  margin-top: 0.15rem;
}
.history-meta .tag {
  display: inline-block;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.1rem 0.45rem;
  border-radius: var(--radius-xs);
  font-size: 0.7rem;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-right: 0.3rem;
}
.history-meta .tag-loc {
  background: linear-gradient(135deg, var(--grad-start), var(--grad-end));
  color: #fff;
  border-color: transparent;
  font-family: var(--font);
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

/* ---- Modal ---- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 16px 48px rgba(0,0,0,0.12);
}
.modal h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.modal p {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ---- Result Modal (full-screen overlay) ---- */
.result-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  animation: fadeIn 0.18s ease;
}
.result-modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  width: 94%;
  max-width: 1100px;
  margin: 2rem auto;
  padding: 1.5rem 1.5rem 2rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  position: relative;
}
.result-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.result-modal-header h3 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}
.btn-close-modal {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 6px;
  transition: background 0.15s, color 0.15s;
}
.btn-close-modal:hover {
  background: rgba(0,0,0,0.07);
  color: var(--text-primary);
}

@media (max-width: 600px) {
  .result-modal {
    width: 100%;
    margin: 0;
    border-radius: 0;
    min-height: 100vh;
    padding: 1rem;
  }
}

/* ---- Alerts ---- */
.alert {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: var(--danger);
}
.alert-success {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: var(--success);
}

/* ---- Loading ---- */
.loading {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-muted);
  font-size: 0.875rem;
}
.spinner {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--grad-start);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Footer ---- */
/* ---- Utility ---- */
.hidden { display: none !important; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1.25rem; }
.mb-2 { margin-bottom: 1rem; }

/* ---- Mobile responsive ---- */
@media (max-width: 768px) {
  .app { padding: 1rem; }

  .auth-container { margin: 2rem auto; }
  .auth-container .card { padding: 1.5rem; }

  .options-row { flex-direction: column; }
  .options-row .form-group { min-width: 100%; }

  .result-stats { grid-template-columns: repeat(2, 1fr); }

  .history-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
  .history-actions { align-self: flex-end; }

  .card { padding: 1.15rem; }
  .card-header { margin-bottom: 1rem; }

  .regions-table { font-size: 0.78rem; }
  .regions-table th, .regions-table td { padding: 0.45rem 0.5rem; }

  .nav-dropdown { right: -0.5rem; min-width: 200px; }
}
