/* ============================================
   uMov.me Design System
   ============================================ */

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

/* ============================================
   Login Screen
   ============================================ */
.login-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--egeu-dark) 0%, var(--primary) 40%, var(--primary-pure) 100%);
  font-family: var(--default-font-family);
}

.login-card {
  width: 100%;
  max-width: 380px;
  padding: 2.5rem 2rem 2rem;
  border-radius: 16px;
  background: rgba(255,255,255,0.08);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.12);
  text-align: center;
}

.login-logo {
  margin-bottom: 0.25rem;
}

.login-logo-img {
  width: 200px;
  height: auto;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.2));
}

.login-subtitle {
  font-size: 22px;
  font-weight: 300;
  color: rgba(255,255,255,0.8);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-bottom: 2rem;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-field {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  padding: 0 14px;
  height: 48px;
  border: 2px solid transparent;
  transition: border-color 0.2s;
}

.login-field:focus-within {
  border-color: rgba(255,255,255,0.5);
  background: #fff;
}

.login-field svg {
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.login-field input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  font-size: var(--text-base);
  font-family: inherit;
  color: var(--card-foreground);
  height: 100%;
}

.login-field input::placeholder {
  color: var(--muted-foreground);
}

.login-error {
  background: color-mix(in oklab, var(--red-pure) 18%, transparent);
  color: var(--red-light);
  border: 1px solid color-mix(in oklab, var(--red-pure) 35%, transparent);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  font-size: 13px;
  text-align: left;
}

.login-steps {
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 0;
}

.login-step {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.3s;
}

.login-step.active {
  color: rgba(255,255,255,0.9);
}

.login-step.done {
  color: var(--neon-medium);
}

.login-step.error {
  color: var(--red-medium);
}

.login-step-icon {
  font-size: 8px;
}

.login-step.active .login-step-icon::after {
  content: '';
  display: inline-block;
  width: 12px;
  height: 12px;
  border: 2px solid rgba(255,255,255,0.7);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}

.login-step.active .login-step-icon {
  font-size: 0;
}

.login-step.done .login-step-icon::after {
  content: '\2714';
  font-size: 11px;
}

.login-step.done .login-step-icon {
  font-size: 0;
}

.login-step.error .login-step-icon::after {
  content: '\2716';
  font-size: 11px;
}

.login-step.error .login-step-icon {
  font-size: 0;
}

.login-btn {
  margin-top: 0.5rem;
  height: 48px;
  border: none;
  border-radius: 8px;
  background: rgba(0,0,0,0.25);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 2px;
  cursor: pointer;
  transition: background 0.2s;
}

.login-btn:hover {
  background: rgba(0,0,0,0.35);
}

.login-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-version {
  margin-top: 1.25rem;
  font-size: 11px;
  color: rgba(255,255,255,0.3);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* :root tokens vêm de design-system.css (Figma DS).
   Aqui mantemos apenas os APELIDOS legados que ainda são consumidos
   por classes deste arquivo, mapeados aos tokens canônicos. */
:root {
  --font: var(--default-font-family);

  /* Aliases legados → DS Figma */
  --primary-dark:    var(--egeu-dark);     /* #05294a */
  --primary-darker:  #03182c;
  --primary-border:  var(--egeu-medium);   /* #96cdff */

  --accent:           var(--emerald-light);
  --accent-foreground: var(--emerald-dark);

  /* Teal accent (mantido p/ ícones) */
  --teal:       var(--emerald-pure);
  --teal-light: var(--emerald-light);

  /* Estados (success/warning/danger) ancorados na paleta brand */
  --success-bg:     var(--neon-light);
  --success-border: var(--neon-medium);
  --warning:        var(--orange-pure);
  --warning-bg:     var(--orange-light);
  --warning-border: var(--orange-medium);
  --danger:         var(--red-pure);
  --danger-bg:      var(--red-light);
  --danger-border:  var(--red-medium);
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  color: var(--foreground);
  background: var(--muted);
  -webkit-font-smoothing: antialiased;
}

/* ============================================
   Layout: Sidebar + Main
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-width);
  background: var(--primary-dark);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
  transition: transform 0.2s ease;
}

.sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 700;
  font-size: 15px;
  color: #ffffff;
}

.sidebar-logo svg {
  color: var(--primary-light);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 11px;
  font-weight: 500;
  color: rgba(255,255,255,0.4);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.5rem 0.75rem 0.25rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.15s;
}

.sidebar-link:hover {
  background: rgba(255,255,255,0.08);
  color: #ffffff;
}

.sidebar-link.active {
  background: rgba(255,255,255,0.12);
  color: #ffffff;
  font-weight: 600;
}

.sidebar-link svg {
  opacity: 0.7;
}

.sidebar-link.active svg,
.sidebar-link:hover svg {
  opacity: 1;
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.sidebar-footer-text {
  font-size: 11px;
  color: rgba(255,255,255,0.35);
}

.sidebar-toggle {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.375rem;
  cursor: pointer;
  color: #ffffff;
}

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ============================================
   Top header
   ============================================ */

.top-header {
  height: 56px;
  background: var(--primary-darker);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-title {
  font-size: 15px;
  font-weight: 600;
  color: #ffffff;
}

.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-header-outline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  font-family: inherit;
  color: rgba(255,255,255,0.85);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}

.btn-header-outline:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}

.btn-header-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  color: rgba(255,255,255,0.7);
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 50%;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn-header-icon:hover {
  background: rgba(255,255,255,0.1);
  color: #fff;
}

.header-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.15);
}

.header-env-active {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.18);
  color: #ffffff;
  font-weight: 600;
  border-color: rgba(255,255,255,0.3);
  font-size: 12px;
  padding: 0.25rem 0.75rem;
}

/* ============================================
   Content area
   ============================================ */

.content {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  width: 100%;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--foreground);
}

.page-description {
  color: var(--muted-foreground);
  font-size: 13px;
  margin-top: 0.25rem;
}

/* ============================================
   Buttons
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
  text-decoration: none;
}

.btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

.btn-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-pure);
}

.btn-secondary {
  background: var(--secondary);
  color: var(--secondary-foreground);
  border-color: var(--border);
}

.btn-secondary:hover {
  background: var(--accent);
}

.btn-outline {
  background: transparent;
  color: var(--foreground);
  border-color: var(--border);
}

.btn-outline:hover {
  background: var(--accent);
  border-color: var(--border);
}

.btn-ghost {
  background: transparent;
  color: var(--muted-foreground);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--accent);
  color: var(--accent-foreground);
}

.btn-destructive {
  background: transparent;
  color: var(--destructive);
  border-color: var(--border);
}

.btn-destructive:hover {
  background: var(--danger-bg);
  border-color: var(--danger-border);
}

.btn-sm {
  padding: 0.325rem 0.75rem;
  font-size: 12px;
  margin-bottom: 1rem;
}

/* ============================================
   Card — uMov.me style with left border
   ============================================ */

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
}

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

.card-title {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--foreground);
}

.card-description {
  font-size: 13px;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
}

/* ============================================
   Validator card grid
   ============================================ */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 1rem;
}

.validator-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.15s;
}

.validator-card:hover {
  box-shadow: var(--shadow-card-hover);
  border-left-color: var(--teal);
}

.validator-card-name {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 0.375rem;
  color: var(--foreground);
}

.validator-card-meta {
  display: flex;
  gap: 0.375rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  border: 1px solid var(--primary-border);
  background: var(--primary-light);
  color: var(--primary);
}

.badge-primary {
  background: var(--primary);
  color: var(--primary-foreground);
  border-color: var(--primary);
}

.badge-success {
  background: var(--success-bg);
  color: var(--neon-dark);
  border-color: var(--success-border);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--red-dark);
  border-color: var(--danger-border);
}

.validator-card-top {
  cursor: pointer;
}

.validator-card-preview {
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.validator-card-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

/* ============================================
   Forms
   ============================================ */

.form-group {
  margin-bottom: 1.25rem;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 0.375rem;
  color: var(--foreground);
}

.form-input {
  display: block;
  width: 100%;
  padding: 0.5rem 0.75rem;
  font-family: var(--font);
  font-size: 13px;
  border: 1px solid var(--input);
  border-radius: var(--radius);
  background: var(--background);
  color: var(--foreground);
  transition: border-color 0.15s, box-shadow 0.15s;
  outline: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--primary-light) 50%, transparent);
}

.form-input::placeholder {
  color: var(--muted-foreground);
}

textarea.form-input {
  resize: vertical;
  min-height: 60px;
}

.font-mono {
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.form-actions {
  margin-top: 1.5rem;
}

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

/* Dropzone */
.dropzone {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  background: var(--muted);
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.dropzone:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone.drag-over {
  border-color: var(--primary);
  background: var(--primary-light);
}

.dropzone svg {
  color: var(--muted-foreground);
}

.dropzone p {
  font-size: 13px;
  font-weight: 500;
  color: var(--foreground);
}

.dropzone-hint {
  font-size: 11px;
  color: var(--muted-foreground);
}

.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.image-preview-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.75rem;
}

.image-preview-grid img {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

/* Collapsible */
.collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}

.collapsible-trigger {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.75rem 1rem;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--primary);
}

.collapsible-trigger svg {
  transition: transform 0.2s;
  color: var(--primary);
}

.collapsible.open .collapsible-trigger svg {
  transform: rotate(90deg);
}

.collapsible-content {
  display: none;
  padding: 0 1rem 1rem;
}

.collapsible.open .collapsible-content {
  display: block;
}

/* ============================================
   Detail page
   ============================================ */

.detail-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.5rem;
  gap: 1rem;
}

.detail-top h1 {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.025em;
}

.detail-top .badge {
  margin-top: 0.375rem;
}

.detail-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.detail-section {
  margin-bottom: 1.5rem;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.prompt-box {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  white-space: pre-wrap;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.6;
  max-height: 360px;
  overflow-y: auto;
  color: var(--foreground);
}

.sample-images-grid {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.sample-images-grid img {
  max-width: 180px;
  max-height: 180px;
  object-fit: cover;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

.detail-meta {
  font-size: 12px;
  color: var(--muted-foreground);
}

/* ============================================
   Validation result
   ============================================ */

.result-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-top: 1.5rem;
  background: var(--card);
}

.result-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.result-card-header.valid {
  background: var(--success-bg);
  border-bottom-color: var(--success-border);
}

.result-card-header.invalid {
  background: var(--danger-bg);
  border-bottom-color: var(--danger-border);
}

.result-card-header.error {
  background: var(--warning-bg);
  border-bottom-color: var(--warning-border);
}

.result-status-label {
  font-size: 15px;
  font-weight: 700;
}

.result-status-label.valid { color: var(--neon-dark); }
.result-status-label.invalid { color: var(--red-dark); }
.result-status-label.error { color: var(--orange-dark); }

.result-metrics {
  display: flex;
  gap: 0.75rem;
  font-size: 12px;
  color: var(--muted-foreground);
}

.result-body {
  padding: 1.5rem;
}

/* Confidence */
.confidence-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.confidence-bar {
  flex: 1;
  height: 6px;
  background: var(--muted);
  border-radius: 999px;
  overflow: hidden;
}

.confidence-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.5s ease;
}

.confidence-fill.high { background: var(--success); }
.confidence-fill.medium { background: var(--warning); }
.confidence-fill.low { background: var(--danger); }

.confidence-label {
  font-size: 13px;
  font-weight: 600;
  min-width: 48px;
  text-align: right;
}

/* Justification */
.result-section {
  margin-bottom: 1.25rem;
}

.result-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.5rem;
}

.result-section p {
  font-size: 13px;
  line-height: 1.6;
  color: var(--foreground);
}

/* Extracted data table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: left;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--muted);
  width: 40%;
}

.data-table td {
  color: var(--foreground);
  font-weight: 500;
}

/* ============================================
   Token & Cost section (inside result)
   ============================================ */

.cost-divider {
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

.stat-grid {
  display: grid;
  gap: 0.75rem;
}

.stat-grid-3 { grid-template-columns: repeat(3, 1fr); }
.stat-grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  text-align: center;
  background: var(--background);
}

.stat-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
  line-height: 1.2;
}

.stat-value-sm {
  font-size: 15px;
}

.stat-hint {
  font-size: 11px;
  color: var(--muted-foreground);
  margin-top: 0.125rem;
}

/* Highlight card — brand blue */
.stat-card-highlight {
  background: var(--primary);
  border-color: var(--primary);
}

.stat-card-highlight .stat-label {
  color: rgba(255,255,255,0.7);
}

.stat-card-highlight .stat-value {
  color: #ffffff;
}

.stat-card-highlight .stat-hint {
  color: rgba(255,255,255,0.5);
}

/* Projection cards — dark navy */
.stat-card-dark {
  background: var(--primary-dark);
  border-color: rgba(255,255,255,0.08);
}

.stat-card-dark .stat-label {
  color: rgba(255,255,255,0.55);
}

.stat-card-dark .stat-value {
  color: var(--primary-light);
}

.stat-card-dark .stat-hint {
  color: rgba(255,255,255,0.35);
}

/* ============================================
   History
   ============================================ */

.history-table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border-collapse: collapse;
}

.history-table th,
.history-table td {
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.history-table th {
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 12px;
}

.history-table tr {
  cursor: pointer;
  transition: background 0.1s;
}

.history-table tbody tr:hover {
  background: var(--primary-light);
}

.history-table tbody tr:last-child td {
  border-bottom: none;
}

/* ============================================
   Status / Loading / Empty
   ============================================ */

.status-msg {
  margin-top: 1rem;
  font-size: 13px;
}

.status-msg.loading { color: var(--muted-foreground); }
.status-msg.error { color: var(--destructive); }
.status-msg.success { color: var(--success); }

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
  margin-right: 0.5rem;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.skeleton-loader {
  padding: 3rem;
  text-align: center;
  color: var(--muted-foreground);
  font-size: 13px;
}

.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted-foreground);
}

.empty-state p {
  margin-bottom: 1rem;
  font-size: 14px;
}

/* ============================================
   Wizard Stepper
   ============================================ */

.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 2rem;
  padding: 1.25rem 1.5rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.step {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  flex-shrink: 0;
}

.step-number {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  border: 2px solid var(--border);
  color: var(--muted-foreground);
  background: var(--background);
  transition: all 0.2s;
}

.step.active .step-number {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.step.completed .step-number {
  background: var(--success);
  border-color: var(--success);
  color: white;
}

.step.completed {
  cursor: pointer;
}

.step.completed:hover .step-number {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--success) 25%, transparent);
}

.step.completed:hover .step-title {
  color: var(--primary);
}

.step-info {
  display: flex;
  flex-direction: column;
}

.step-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-foreground);
  transition: color 0.2s;
}

.step.active .step-title,
.step.completed .step-title {
  color: var(--foreground);
}

.step-desc {
  font-size: 11px;
  color: var(--muted-foreground);
}

.step-line {
  flex: 1;
  height: 2px;
  background: var(--border);
  margin: 0 0.75rem;
  transition: background 0.2s;
}

.step-line.completed {
  background: var(--success);
}

/* Wizard Tabs (Step 1) */
.wizard-tabs {
  display: flex;
  gap: 0;
  border-bottom: 2px solid var(--border);
  margin-bottom: 1.25rem;
}

.wizard-tab {
  padding: 0.625rem 1.25rem;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: color 0.2s, border-color 0.2s;
}

.wizard-tab:hover {
  color: var(--foreground);
}

.wizard-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}

.wizard-tab-content {
  display: none;
}

.wizard-tab-content.active {
  display: block;
}

/* Step 4 Collapsible Sections */
.step4-collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-top: 1.25rem;
  overflow: hidden;
}

.step4-collapsible-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  padding: 0.875rem 1.25rem;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  background: var(--accent);
  border: none;
  cursor: pointer;
  color: var(--foreground);
  transition: background 0.15s;
}

.step4-collapsible-header:hover {
  background: var(--muted);
}

.step4-collapsible-header svg.chevron {
  transition: transform 0.2s;
  color: var(--muted-foreground);
}

.step4-collapsible.open .step4-collapsible-header svg.chevron {
  transform: rotate(90deg);
}

.step4-collapsible-content {
  display: none;
  padding: 1.25rem;
  border-top: 1px solid var(--border);
}

.step4-collapsible.open .step4-collapsible-content {
  display: block;
}

.optional-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--muted);
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
  margin-left: 0.25rem;
  vertical-align: middle;
}

/* Form hint */
.form-hint {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

/* Cost highlight in validation result */
.cost-highlight {
  font-weight: 600;
  color: var(--primary);
}

/* Installer steps */
.installer-steps {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin: 1rem 0;
}

.installer-step {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--muted-foreground);
  transition: all 0.2s;
}

.installer-step.active {
  background: var(--primary-light);
  border-color: var(--primary-border);
  color: var(--primary);
  font-weight: 500;
}

.installer-step.completed {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success);
}

.installer-step.error {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--destructive);
}

.installer-step-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  background: var(--border);
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.installer-step.active .installer-step-icon {
  background: var(--primary);
  color: #fff;
}

.installer-step.completed .installer-step-icon {
  background: var(--success);
  color: #fff;
}

.installer-step.error .installer-step-icon {
  background: var(--destructive);
  color: #fff;
}

/* Progress bar (analyzer) */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 999px;
  transition: width 0.3s ease;
}

/* Wizard steps content */
.wizard-step {
  display: none;
}

.wizard-step.active {
  display: block;
}

.wizard-step-header {
  margin-bottom: 1.25rem;
}

.wizard-step-header h2 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

.wizard-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.5rem;
}

.step2-info-row {
  display: flex;
  gap: 1rem;
}

/* ============================================
   Economic Analysis (Step 4)
   ============================================ */

.econ-banner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem 1.5rem;
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-darker) 100%);
  border-radius: var(--radius-lg);
  margin-bottom: 1.5rem;
  color: #fff;
}

.econ-banner-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.econ-banner-icon svg {
  color: var(--primary-light);
}

.econ-banner-title {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.econ-banner-desc {
  font-size: 13px;
  color: rgba(255,255,255,0.55);
  margin-top: 0.125rem;
}

.econ-section {
  margin-bottom: 2rem;
}

.econ-section-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid var(--primary-light);
}

.econ-section-title svg {
  color: var(--primary);
}

.econ-explanation {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.6;
}

/* Versus comparison grid */
.versus-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0;
  align-items: stretch;
}

.versus-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card);
}

.versus-header {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.875rem 1.25rem;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--border);
}

.versus-manual .versus-header {
  background: var(--orange-light);
  color: var(--orange-dark);
  border-left: 4px solid var(--orange-pure);
}

.versus-manual .versus-header svg {
  color: var(--orange-pure);
}

.versus-ai .versus-header {
  background: var(--primary-light);
  color: var(--primary);
  border-left: 4px solid var(--primary);
}

.versus-ai .versus-header svg {
  color: var(--primary);
}

.versus-body {
  padding: 0.5rem 0;
}

.versus-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.625rem 1.25rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.versus-row:last-child {
  border-bottom: none;
}

.versus-label {
  color: var(--muted-foreground);
}

.versus-value {
  font-weight: 600;
  color: var(--foreground);
}

.versus-value-good {
  color: var(--success);
}

.versus-value-bad {
  color: var(--danger);
}

.versus-divider {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1rem;
}

.versus-divider span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary-dark);
  color: #ffffff;
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.05em;
}

/* Pricing cards */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 1rem;
}

.pricing-card {
  position: relative;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  text-align: center;
  background: var(--background);
  transition: all 0.15s;
}

.pricing-card-featured {
  border-color: var(--primary);
  border-width: 2px;
  box-shadow: var(--shadow-card-hover);
}

.pricing-badge {
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.75rem;
  background: var(--primary);
  color: var(--primary-foreground);
  font-size: 11px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.pricing-tier {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted-foreground);
  margin-bottom: 0.5rem;
}

.pricing-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.pricing-per {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-bottom: 1rem;
}

.pricing-details {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.pricing-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  padding: 0.375rem 0;
  color: var(--muted-foreground);
}

.pricing-row span:last-child {
  font-weight: 600;
  color: var(--foreground);
}

/* Value proposition */
.value-prop-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 2rem;
}

.value-prop-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.value-prop-item {
  text-align: center;
}

.value-prop-number {
  font-size: 28px;
  font-weight: 700;
  color: var(--foreground);
  letter-spacing: -0.02em;
}

.value-prop-desc {
  font-size: 12px;
  color: var(--muted-foreground);
  margin-top: 0.25rem;
}

.value-prop-arrow {
  flex-shrink: 0;
}

.value-prop-summary {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.7;
  text-align: center;
  border-top: 1px solid var(--border);
  padding-top: 1rem;
}

.value-prop-summary strong {
  color: var(--primary);
}

/* Assumptions */
.econ-assumptions {
  background: var(--muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-top: 1rem;
}

.econ-assumptions-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted-foreground);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.5rem;
}

.econ-assumptions ul {
  list-style: none;
  padding: 0;
}

.econ-assumptions li {
  font-size: 12px;
  color: var(--muted-foreground);
  padding: 0.2rem 0;
  padding-left: 1rem;
  position: relative;
}

.econ-assumptions li::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0.6em;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--primary);
  opacity: 0.4;
}

/* ============================================
   Dashboard
   ============================================ */

.dashboard-health-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  font-size: 13px;
  border: 1px solid var(--border);
}

.dashboard-health-bar.health-ok {
  background: var(--success-bg);
  border-color: var(--success-border);
}

.dashboard-health-bar.health-degraded {
  background: var(--warning-bg);
  border-color: var(--warning-border);
}

.health-indicators {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.health-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.health-dot.ok { background: var(--success); }
.health-dot.error { background: var(--danger); }

.health-label {
  color: var(--muted-foreground);
  font-size: 12px;
  margin-right: 0.75rem;
}

.health-status-text {
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
}

.dashboard-filter {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.dashboard-filter-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

/* CSS Bar Chart (vertical bars) */
.css-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  height: 180px;
  padding: 1rem 0.5rem 0;
}

.css-bar-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
  min-width: 0;
}

.css-bar-track {
  flex: 1;
  width: 100%;
  max-width: 32px;
  display: flex;
  align-items: flex-end;
  border-radius: 3px 3px 0 0;
  overflow: hidden;
}

.css-bar-fill {
  width: 100%;
  background: var(--primary);
  border-radius: 3px 3px 0 0;
  transition: height 0.3s ease;
  min-height: 2px;
}

.css-bar-fill-teal {
  background: var(--teal);
}

.css-bar-label {
  font-size: 10px;
  color: var(--muted-foreground);
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
  text-align: center;
}

/* CSS Stacked Bar (horizontal) */
.css-stacked-bar {
  display: flex;
  height: 28px;
  border-radius: var(--radius);
  overflow: hidden;
  margin: 1rem 0 0.75rem;
}

.css-stacked-segment {
  transition: width 0.3s ease;
  min-width: 2px;
}

.css-stacked-segment.approved { background: var(--success); }
.css-stacked-segment.rejected { background: var(--danger); }
.css-stacked-segment.errors { background: var(--warning); }

.css-stacked-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted-foreground);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.legend-dot.approved { background: var(--success); }
.legend-dot.rejected { background: var(--danger); }
.legend-dot.errors { background: var(--warning); }

/* ============================================
   Agent Management
   ============================================ */

.agent-choice-buttons {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
}

.agent-table {
  width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  border-collapse: collapse;
}

.agent-table th,
.agent-table td {
  text-align: left;
  padding: 0.625rem 1rem;
  font-size: 13px;
  border-bottom: 1px solid var(--border);
}

.agent-table th {
  font-weight: 500;
  color: var(--muted-foreground);
  background: var(--muted);
  font-size: 12px;
}

.agent-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}

.agent-table tbody tr:hover {
  background: var(--primary-light);
}

.agent-table tbody tr:last-child td {
  border-bottom: none;
}

.agent-form .section-label {
  margin-bottom: 1rem;
}

.agent-result .section-label {
  margin-bottom: 0.75rem;
}

/* ============================================
   Responsive
   ============================================ */

/* ============================================
   Sidebar Overlay (mobile)
   ============================================ */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 45;
}

.app-layout.sidebar-open .sidebar-overlay {
  display: block;
}

/* ============================================
   Responsive — Tablet & Mobile (<=768px)
   ============================================ */

@media (max-width: 768px) {
  /* Sidebar */
  .sidebar {
    transform: translateX(-100%);
  }

  .app-layout.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .sidebar-toggle {
    display: flex;
  }

  .main-wrapper {
    margin-left: 0;
  }

  /* Content */
  .content {
    padding: 1rem;
  }

  /* Page header */
  .page-header {
    flex-direction: column;
    gap: 1rem;
  }

  /* Header right: hide Gemini badge, compact layout */
  .header-right {
    gap: 0.5rem;
  }

  .header-badge:not(.header-env-active) {
    display: none;
  }

  .header-env-active {
    font-size: 11px;
    padding: 0.2rem 0.5rem;
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* Cards */
  .card-grid {
    grid-template-columns: 1fr;
  }

  .detail-top {
    flex-direction: column;
  }

  /* Forms */
  .form-grid {
    grid-template-columns: 1fr;
  }

  /* Stat grids */
  .stat-grid-3,
  .stat-grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  /* Result card */
  .result-card-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .result-metrics {
    flex-wrap: wrap;
    gap: 0.375rem;
  }

  .result-body {
    padding: 1rem;
  }

  /* Stepper */
  .stepper {
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 1rem;
  }

  .step-line {
    display: none;
  }

  .step-info {
    display: none;
  }

  /* Wizard actions */
  .wizard-actions {
    flex-direction: column;
    gap: 0.75rem;
  }

  .wizard-actions > div {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
  }

  .wizard-actions .btn {
    width: 100%;
    justify-content: center;
  }

  /* Wizard tabs */
  .wizard-tab {
    padding: 0.5rem 0.75rem;
    font-size: 12px;
  }

  .wizard-tab svg {
    display: none;
  }

  /* Versus / Economic analysis */
  .versus-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .versus-divider {
    padding: 0;
  }

  .versus-divider span {
    width: 32px;
    height: 32px;
    font-size: 11px;
  }

  .econ-banner {
    flex-direction: column;
    text-align: center;
  }

  /* Dashboard */
  .dashboard-charts-grid {
    grid-template-columns: 1fr;
  }

  .dashboard-health-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .dashboard-filter {
    flex-wrap: wrap;
  }

  /* Pricing */
  .pricing-grid {
    grid-template-columns: 1fr;
  }

  /* Value prop */
  .value-prop-row {
    flex-direction: column;
    gap: 1rem;
  }

  .value-prop-arrow {
    transform: rotate(90deg);
  }

  .value-prop-number {
    font-size: 22px;
  }

  /* History table: horizontal scroll */
  #history-list {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .history-table {
    min-width: 640px;
  }

  /* Data table (extraction results) */
  .data-table th {
    width: auto;
    min-width: 120px;
  }

  /* Login card */
  .login-card {
    margin: 0 1rem;
    padding: 2rem 1.5rem 1.5rem;
  }

  .login-subtitle {
    font-size: 18px;
    letter-spacing: 4px;
    margin-bottom: 1.5rem;
  }

  .login-logo-img {
    width: 160px;
  }

  /* Step 2 info row */
  .step2-info-row {
    flex-direction: column;
  }

  /* Sample images */
  .sample-images-grid img {
    max-width: 120px;
    max-height: 120px;
  }

  /* Collapsible step4 sections */
  .step4-collapsible-header {
    font-size: 13px;
    padding: 0.75rem 1rem;
  }

  .step4-collapsible-content {
    padding: 1rem;
  }
}

/* ============================================
   Responsive — Small phones (<=480px)
   ============================================ */

@media (max-width: 480px) {
  .content {
    padding: 0.75rem;
  }

  .top-header {
    padding: 0 0.75rem;
    gap: 0.5rem;
  }

  .header-title {
    font-size: 13px;
  }

  .header-env-active {
    max-width: 100px;
  }

  .page-header h1 {
    font-size: 20px;
  }

  .wizard-step-header h2 {
    font-size: 18px;
  }

  /* Stat grids: single column */
  .stat-grid-3,
  .stat-grid-4 {
    grid-template-columns: 1fr;
  }

  .card {
    padding: 1rem;
  }

  .stepper {
    padding: 0.75rem;
  }

  .step-number {
    width: 28px;
    height: 28px;
    font-size: 12px;
  }

  /* Login */
  .login-card {
    margin: 0 0.75rem;
    padding: 1.5rem 1.25rem 1.25rem;
  }

  .login-subtitle {
    font-size: 16px;
    letter-spacing: 3px;
  }

  .login-logo-img {
    width: 140px;
  }

  /* Buttons */
  .btn {
    padding: 0.5rem 0.75rem;
    font-size: 12px;
  }

  /* Dropzone */
  .dropzone {
    padding: 1.5rem 1rem;
  }

  .dropzone svg {
    width: 32px;
    height: 32px;
  }

  .dropzone p {
    font-size: 12px;
  }

  /* Cost sections */
  .stat-value {
    font-size: 16px;
  }

  .stat-value-sm {
    font-size: 13px;
  }

  /* Prompt box */
  .prompt-box {
    max-height: 240px;
    font-size: 11px;
  }

  /* Validator card */
  .validator-card {
    padding: 1rem;
  }
}

/* ============================================
   Sidebar Collapsible Sections
   ============================================ */
.nav-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1.25rem;
  color: rgba(255,255,255,0.5);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
  user-select: none;
  margin-top: 0.75rem;
}

.nav-section-toggle:first-child { margin-top: 0; }

.nav-section-toggle:hover { color: rgba(255,255,255,0.7); }

.nav-section-toggle .toggle-icon {
  transition: transform 0.2s ease;
  font-size: 10px;
}

.nav-section-toggle.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

.nav-section-items {
  overflow: hidden;
  transition: max-height 0.25s ease;
  max-height: 500px;
}

.nav-section-items.collapsed {
  max-height: 0;
}

/* ============================================
   Dark Theme
   ============================================ */
[data-theme="dark"] {
  /* Tokens semânticos: alinhados com Figma DS dark mode (design-system.css).
     Aqui apenas refinamos os APELIDOS legados consumidos por classes deste arquivo. */
  --background: #16171c;
  --foreground: #ebebeb;
  --card: #1e1f26;
  --card-foreground: #ebebeb;
  --muted: #373944;
  --muted-foreground: #8c8e9b;
  --accent: #23252e;
  --accent-foreground: #ebebeb;
  --border: #373944;
  --input: #373944;
  --ring: var(--primary-light);

  --primary: #60a5fa;
  --primary-foreground: #0f0f14;
  --primary-dark: #0c1629;
  --primary-darker: #080e1a;
  --primary-light: #1a2744;     /* bg tint navy — uso em surfaces, não confundir com Figma DS dark --primary-light */
  --primary-border: var(--egeu-pure);

  --secondary: #23252e;
  --secondary-foreground: #ebebeb;
  --destructive: var(--red-pure);
  --destructive-foreground: #ffffff;

  --teal: var(--emerald-medium);
  --teal-light: var(--emerald-dark);

  --success: var(--neon-pure);
  --success-bg: color-mix(in oklab, var(--neon-dark) 30%, #16171c);
  --success-border: var(--neon-dark);
  --warning: var(--orange-medium);
  --warning-bg: color-mix(in oklab, var(--orange-dark) 30%, #16171c);
  --warning-border: var(--orange-dark);
  --danger: var(--red-medium);
  --danger-bg: color-mix(in oklab, var(--red-dark) 30%, #16171c);
  --danger-border: var(--red-dark);
}

[data-theme="dark"] .sidebar {
  background: #0c0e14;
  border-color: var(--border);
}

[data-theme="dark"] .sidebar-link:hover,
[data-theme="dark"] .sidebar-link.active {
  background: var(--card);
}

[data-theme="dark"] .login-field {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.1);
}

[data-theme="dark"] .login-field input {
  color: var(--foreground);
}

[data-theme="dark"] .login-field svg {
  color: var(--muted-foreground);
}

[data-theme="dark"] .form-input,
[data-theme="dark"] .form-select {
  background: var(--card);
  border-color: var(--border);
  color: var(--foreground);
}

[data-theme="dark"] .form-input:focus,
[data-theme="dark"] .form-select:focus {
  border-color: var(--primary);
}

[data-theme="dark"] .btn-outline {
  color: var(--foreground);
  border-color: var(--border);
}

[data-theme="dark"] .btn-outline:hover {
  background: var(--accent);
  border-color: var(--muted);
}

[data-theme="dark"] .header-badge {
  background: rgba(255,255,255,0.08);
}

[data-theme="dark"] .skeleton-loader {
  background: var(--card);
  color: var(--muted-foreground);
}

[data-theme="dark"] .status-msg.success {
  background: var(--success-bg);
  color: var(--success);
  border-color: var(--success-border);
}

[data-theme="dark"] .status-msg.error {
  background: var(--danger-bg);
  color: var(--danger);
  border-color: var(--danger-border);
}

[data-theme="dark"] .nav-section-toggle {
  color: var(--muted-foreground);
}

[data-theme="dark"] .nav-section-toggle:hover {
  color: var(--foreground);
}

/* ========== Activity Creator ========== */

.ac-editor-layout {
  display: grid;
  grid-template-columns: 1fr 400px;
  gap: 1rem;
  min-height: 500px;
}
@media (max-width: 900px) {
  .ac-editor-layout {
    grid-template-columns: 1fr;
  }
}

.ac-form-preview {
  max-height: 600px;
  overflow-y: auto;
  padding-right: 0.5rem;
}

.ac-activity-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--primary);
}

.ac-section {
  margin-bottom: 1.25rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  background: var(--card);
}

.ac-section-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  flex-wrap: wrap;
}

.ac-section-title {
  font-weight: 600;
  font-size: 15px;
}

.ac-section-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--muted-foreground);
}

.ac-section-actions {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
}

.ac-field {
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  background: var(--background);
  border: 1px solid var(--border);
}

.ac-field-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.375rem;
  gap: 0.5rem;
}

.ac-field-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}

.ac-field-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 2px 6px;
  font-size: 12px;
  color: var(--muted-foreground);
  line-height: 1;
}
.ac-field-btn:hover {
  background: var(--accent);
  color: var(--foreground);
}

.ac-field-type-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--primary);
  color: white;
  font-weight: 500;
  white-space: nowrap;
}

.ac-formula-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  background: var(--orange-pure);
  color: white;
  font-weight: 600;
}

.ac-media-placeholder {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 1rem;
  background: var(--accent);
  border-radius: 6px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.ac-label-field {
  padding: 0.5rem;
  color: var(--muted-foreground);
  font-style: italic;
  font-size: 13px;
}

.ac-rating {
  display: flex;
  gap: 0.25rem;
}
.ac-star {
  font-size: 20px;
  color: var(--border);
  cursor: pointer;
}
.ac-star:hover,
.ac-star.active {
  color: var(--orange-pure);
}

.ac-checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 14px;
  cursor: pointer;
}

/* Structure tree */
.ac-tree { font-size: 13px; }
.ac-tree-node { padding: 0.375rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.ac-tree-root { font-size: 15px; border-bottom: 1px solid var(--border); padding-bottom: 0.5rem; margin-bottom: 0.5rem; }
.ac-tree-section { margin-left: 1rem; border-left: 2px solid var(--primary); padding-left: 0.75rem; margin-bottom: 0.5rem; }
.ac-tree-field { margin-left: 1.5rem; padding: 0.25rem 0; display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }

/* Chat */
.ac-chat-messages {
  flex: 1;
  overflow-y: auto;
  min-height: 200px;
  max-height: 400px;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 0.75rem;
  background: var(--background);
}

.ac-chat-msg {
  margin-bottom: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
  max-width: 90%;
  word-wrap: break-word;
}

.ac-chat-user {
  background: var(--primary);
  color: white;
  margin-left: auto;
  border-bottom-right-radius: 2px;
}

.ac-chat-assistant {
  background: var(--accent);
  color: var(--foreground);
  border-bottom-left-radius: 2px;
}

.ac-changes-list {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  font-size: 12px;
}
.ac-changes-list li {
  margin-bottom: 0.25rem;
}

.ac-chat-input-area {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}
.ac-chat-input-area textarea {
  flex: 1;
  resize: none;
}

/* Modal */
.ac-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.ac-modal {
  background: var(--card);
  border-radius: 12px;
  padding: 1.5rem;
  max-width: 500px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}
.ac-modal-lg {
  max-width: 650px;
}

.ac-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.ac-modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.ac-field-type-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

.ac-field-type-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
  padding: 0.75rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--background);
  cursor: pointer;
  font-size: 12px;
  color: var(--foreground);
  transition: all 0.15s;
}
.ac-field-type-btn:hover {
  border-color: var(--primary);
  background: var(--accent);
}

.ac-field-type-icon {
  font-size: 18px;
}

.ac-formula-item {
  position: relative;
  padding: 0.5rem;
  background: var(--accent);
  border-radius: 6px;
}
.ac-formula-item .ac-field-btn {
  position: absolute;
  top: 0.375rem;
  right: 0.375rem;
}

/* Report */
.ac-report-content {
  min-height: 200px;
}

/* Structure view */
.ac-structure-view {
  max-height: 600px;
  overflow-y: auto;
}

/* Spinner (reuse if not already defined) */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  vertical-align: middle;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* View toggle active */
.ac-view-toggle.active,
.ac-report-tab.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ============================================
   Photo Book
   ============================================ */

.pb-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.pb-toolbar-left,
.pb-toolbar-right {
  display: flex;
  gap: 0.25rem;
}

.pb-filter-btn,
.pb-size-btn {
  padding: 0.375rem 0.75rem;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: all 0.15s;
}

.pb-filter-btn:hover,
.pb-size-btn:hover {
  background: var(--accent);
}

.pb-filter-btn.active,
.pb-size-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.pb-selection-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent);
  border-radius: 8px;
}

.pb-selection-bar .btn {
  font-size: 12px;
}

.pb-counter {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted-foreground);
}

.pb-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 0.75rem;
}

.pb-card {
  position: relative;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: box-shadow 0.15s, border-color 0.15s;
}

.pb-card:hover {
  box-shadow: var(--shadow-card);
}

.pb-card-selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px color-mix(in oklab, var(--primary-pure) 25%, transparent);
}

.pb-card-check {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 2;
}

.pb-card-check input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: var(--primary);
}

.pb-card-img {
  width: 100%;
  aspect-ratio: 4/3;
  overflow: hidden;
  background: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
}

.pb-card-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pb-card-body {
  padding: 0.5rem 0.75rem 0.75rem;
}

.pb-card-rating {
  display: flex;
  gap: 2px;
  margin-bottom: 0.25rem;
}

.pb-star {
  font-size: 18px;
  color: var(--border);
  cursor: pointer;
  transition: color 0.1s;
  line-height: 1;
}

.pb-star:hover,
.pb-star.active {
  color: var(--orange-pure);
}

.pb-card-actions-row {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0.375rem;
}

.pb-btn-approve,
.pb-btn-reject {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.pb-btn-approve:hover,
.pb-btn-approve.active {
  background: var(--neon-dark);
  color: white;
  border-color: var(--neon-dark);
}

.pb-btn-reject:hover,
.pb-btn-reject.active {
  background: var(--red-pure);
  color: white;
  border-color: var(--red-pure);
}

.pb-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
}

.pb-badge-approved {
  background: color-mix(in oklab, var(--neon-dark) 12%, transparent);
  color: var(--neon-dark);
}

.pb-badge-rejected {
  background: color-mix(in oklab, var(--red-pure) 12%, transparent);
  color: var(--red-pure);
}

.pb-card-meta {
  font-size: 11px;
  color: var(--muted-foreground);
  line-height: 1.5;
}

.pb-card-meta div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pb-card-link {
  display: inline-block;
  margin-top: 0.25rem;
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
}

.pb-card-link:hover {
  text-decoration: underline;
}

.pb-disabled-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  font-size: 12px;
  color: var(--muted-foreground);
  border: 1px dashed var(--border);
  border-radius: 6px;
  opacity: 0.6;
}

.badge-muted {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 8px;
  background: var(--muted);
  color: var(--muted-foreground);
  font-weight: 600;
}

.pb-check-label {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 13px;
  cursor: pointer;
}

.pb-check-label input[type="checkbox"] {
  accent-color: var(--primary);
}

/* ============================================
   Route Analyzer
   ============================================ */

#ra-map {
  z-index: 1;
}

.ra-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  font-size: 13px;
  cursor: pointer;
  padding: 0.25rem 0;
}

.ra-legend-item input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

.ra-legend-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

.ra-legend-name {
  font-weight: 500;
}

.ra-legend-count {
  color: var(--muted-foreground);
  font-size: 12px;
}

/* Timeline */
.ra-timeline-list {
  position: relative;
  padding-left: 1rem;
}

.ra-timeline-date {
  font-weight: 600;
  font-size: 14px;
  padding: 0.5rem 0 0.25rem;
  color: var(--primary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 0.5rem;
}

.ra-timeline-item {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
}

.ra-timeline-item:last-child {
  border-bottom: none;
}

.ra-timeline-time {
  font-family: monospace;
  font-size: 13px;
  font-weight: 600;
  min-width: 48px;
  color: var(--foreground);
}

.ra-timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.ra-timeline-dot.success { background: var(--neon-dark); }
.ra-timeline-dot.warning { background: var(--orange-pure); }
.ra-timeline-dot.error { background: var(--red-pure); }

.ra-timeline-content {
  flex: 1;
  min-width: 0;
}

.ra-timeline-local {
  font-weight: 500;
  font-size: 13px;
}

.ra-timeline-addr {
  font-size: 12px;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ra-timeline-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  flex-wrap: wrap;
}

.ra-timeline-dist {
  font-size: 11px;
  color: var(--primary);
  font-weight: 500;
}

.ra-timeline-exec {
  font-size: 11px;
  color: var(--muted-foreground);
  font-family: monospace;
}

.badge-success {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--neon-dark) 12%, transparent);
  color: var(--neon-dark);
  font-weight: 600;
}

.badge-warning {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--orange-pure) 12%, transparent);
  color: var(--orange-dark);
  font-weight: 600;
}

.badge-error {
  display: inline-block;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 10px;
  background: color-mix(in oklab, var(--red-pure) 12%, transparent);
  color: var(--red-pure);
  font-weight: 600;
}

@media (max-width: 768px) {
  #ra-map {
    height: 350px !important;
  }

  .ra-timeline-item {
    flex-wrap: wrap;
  }
}
