/* ==========================================================================
   MÓDULO REGISTROS — GRAPHITE AURORA DESIGN SYSTEM v3.1.0
   Dark Premium Architecture • Inspired by Linear, Vercel & Surpluss
   ========================================================================== */

/* 1. RESET & NATIVE TWEAKS */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type=number] {
  -moz-appearance: textfield;
}

/* 2. DESIGN TOKENS (GRAPHITE AURORA) */
:root {
  /* CANVAS & BACKGROUNDS */
  --bg-primary: #0B1117;
  --bg-secondary: #0E161D;
  --bg-ambient-teal: rgba(54, 214, 195, 0.06);
  --bg-ambient-violet: rgba(155, 138, 251, 0.05);

  /* SURFACES & ELEVATION */
  --surface-base: #111A22;
  --surface-elevated: #16232D;
  --surface-interactive: #1C2B36;
  --surface-interactive-hover: #223442;
  --surface-overlay: rgba(11, 17, 23, 0.88);

  /* ACCENTS (AURORA SIGNATURE) */
  --accent-teal: #36D6C3;
  --accent-teal-deep: #147D78;
  --accent-teal-glow: rgba(54, 214, 195, 0.16);
  --accent-violet: #9B8AFB;
  --accent-violet-deep: #5A4AB8;
  --accent-violet-glow: rgba(155, 138, 251, 0.16);

  /* TYPOGRAPHY COLORS */
  --text-primary: #F1F5F7;
  --text-secondary: #A5B2BC;
  --text-muted: #94A3B8;
  --text-inverse: #0B1117;

  /* BORDERS & HAIRLINES */
  --border-default: #263640;
  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-strong: #334856;
  --border-glow-teal: rgba(54, 214, 195, 0.4);
  --border-glow-violet: rgba(155, 138, 251, 0.4);

  /* SEMANTIC TOKENS */
  --semantic-success: #45C98A;
  --semantic-success-bg: rgba(69, 201, 138, 0.14);
  --semantic-warning: #E8B65D;
  --semantic-warning-bg: rgba(232, 182, 93, 0.14);
  --semantic-error: #F07882;
  --semantic-error-bg: rgba(240, 120, 130, 0.14);
  --semantic-info: #6BA8F5;
  --semantic-info-bg: rgba(107, 168, 245, 0.14);

  /* TYPOGRAPHY STACKS */
  --font-heading: 'Space Grotesk', -apple-system, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

  /* GEOMETRY & RADIUS */
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 18px;
  --radius-pill: 9999px;

  /* SHADOWS & GLOWS */
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.04);
  --shadow-elevated: 0 12px 36px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --shadow-modal: 0 24px 60px rgba(0, 0, 0, 0.75), 0 0 0 1px var(--border-default);
  --shadow-glow-teal: 0 0 24px rgba(54, 214, 195, 0.25);
  --shadow-glow-violet: 0 0 24px rgba(155, 138, 251, 0.22);

  /* ALIASES FOR COMPATIBILITY & CHARTS */
  --accent-amber: #E8B65D;
  --accent-emerald: #45C98A;
  --accent-cyan: #36D6C3;
  --accent-blue-light: #6BA8F5;
  --text-main: #F1F5F7;
  --bg-surface-elevated: #16232D;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 3. LIGHT THEME (CLEAN SLATE GRAPHITE) */
body.theme-light {
  --bg-primary: #F8FAFC;
  --bg-secondary: #F1F5F9;
  --bg-ambient-teal: rgba(54, 214, 195, 0.08);
  --bg-ambient-violet: rgba(155, 138, 251, 0.06);

  --surface-base: #FFFFFF;
  --surface-elevated: #F8FAFC;
  --surface-interactive: #EDF2F7;
  --surface-interactive-hover: #E2E8F0;
  --surface-overlay: rgba(248, 250, 252, 0.9);

  --accent-teal: #0D9488;
  --accent-teal-deep: #0F766E;
  --accent-teal-glow: rgba(13, 148, 136, 0.12);
  --accent-violet: #7C3AED;
  --accent-violet-deep: #6D28D9;
  --accent-violet-glow: rgba(124, 58, 237, 0.12);

  --text-primary: #0F172A;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --text-inverse: #FFFFFF;

  --border-default: #E2E8F0;
  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-strong: #CBD5E1;
  --border-glow-teal: rgba(13, 148, 136, 0.4);
  --border-glow-violet: rgba(124, 58, 237, 0.4);

  --shadow-card: 0 4px 16px rgba(0, 0, 0, 0.05), 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-elevated: 0 10px 30px rgba(0, 0, 0, 0.08);
  --shadow-modal: 0 20px 50px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--border-default);

  /* ALIASES FOR COMPATIBILITY & CHARTS (LIGHT) */
  --accent-amber: #D97706;
  --accent-emerald: #059669;
  --accent-cyan: #0D9488;
  --accent-blue-light: #2563EB;
  --text-main: #0F172A;
  --bg-surface-elevated: #F8FAFC;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* 4. BASE BODY & SCROLLBAR */
body {
  background-color: var(--bg-primary);
  background-image:
    radial-gradient(circle at 14% 12%, var(--bg-ambient-teal) 0%, transparent 45%),
    radial-gradient(circle at 86% 65%, var(--bg-ambient-violet) 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-variant-numeric: tabular-nums;
  overflow-x: hidden;
}

::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--surface-interactive);
  border-radius: var(--radius-pill);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

/* 5. APP SHELL ARCHITECTURE */
.app-shell {
  display: grid;
  grid-template-columns: 210px 1fr;
  min-height: 100vh;
}

/* 6. SIDEBAR GRAPHITE AURORA (260px) */
.sidebar {
  background: var(--bg-primary);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 18px 14px 14px;
  user-select: none;
  z-index: 100;
  overflow-y: auto;
}

.brand-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 18px;
}

.brand-badge {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, rgba(54, 214, 195, 0.16), rgba(155, 138, 251, 0.18));
  border: 1px solid rgba(54, 214, 195, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(54, 214, 195, 0.15);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.brand-badge:hover {
  transform: scale(1.05);
  box-shadow: var(--shadow-glow-teal);
}

.brand-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.brand-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text-primary);
  line-height: 1.1;
}

.version-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-teal-glow);
  color: var(--accent-teal);
  border: 1px solid rgba(54, 214, 195, 0.3);
  line-height: 1.3;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  margin-top: 2px;
}

.nav-section-label {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: 0 10px 8px;
}

.nav-menu {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 12px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
  text-align: left;
}

.nav-btn:hover {
  background: var(--surface-interactive);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  transform: translateX(2px);
}

.nav-btn.active {
  background: linear-gradient(90deg, rgba(54, 214, 195, 0.14), rgba(54, 214, 195, 0.04));
  border-color: rgba(54, 214, 195, 0.3);
  color: var(--accent-teal);
  font-weight: 600;
  box-shadow: inset 2px 0 0 var(--accent-teal);
}

.nav-btn-content {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  flex-shrink: 0;
  color: currentColor;
  opacity: 0.9;
}

.nav-pill {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
  transition: all 0.18s ease;
}

.nav-btn.active .nav-pill {
  background: rgba(54, 214, 195, 0.18);
  color: var(--accent-teal);
  border-color: rgba(54, 214, 195, 0.35);
}

/* Sidebar Footer & Utilities */
.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.footer-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.footer-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 7px 4px;
  border-radius: var(--radius-sm);
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-size: 10.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.footer-action-btn:hover {
  background: var(--surface-interactive);
  color: var(--accent-teal);
  border-color: rgba(54, 214, 195, 0.3);
}

.user-profile-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--surface-base);
  border: 1px solid var(--border-default);
}

.avatar-circle {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-pill);
  background: linear-gradient(135deg, var(--accent-teal-deep), var(--accent-violet-deep));
  color: #fff;
  font-family: var(--font-heading);
  font-weight: 700;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.avatar-info {
  min-width: 0;
}

.avatar-name {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.avatar-role {
  font-size: 10.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 7. MAIN VIEW & TOP COMMAND BAR */
.main-content {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: hidden;
}

.top-bar {
  background: var(--surface-base);
  border-bottom: 1px solid var(--border-default);
  padding: 12px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 20px;
  position: sticky;
  top: 0;
  z-index: 90;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.header-titles {
  min-width: 240px;
  flex: 0 1 auto;
}

.view-title {
  font-family: var(--font-heading);
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  white-space: nowrap;
}

.view-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.controls-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1 1 auto;
  justify-content: flex-end;
}

/* Visit selector segmented buttons */
.seg-group {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  gap: 2px;
}

.seg-btn {
  padding: 4px 9px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.seg-btn:hover {
  color: var(--text-primary);
  background: var(--surface-interactive);
}

.seg-btn.active {
  background: linear-gradient(135deg, rgba(54, 214, 195, 0.22), rgba(20, 125, 120, 0.35));
  color: var(--accent-teal);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4), 0 0 10px rgba(54, 214, 195, 0.2);
  border: 1px solid rgba(54, 214, 195, 0.3);
}

.seg-btn.v-avg.active {
  background: linear-gradient(135deg, rgba(155, 138, 251, 0.22), rgba(90, 74, 184, 0.35));
  color: var(--accent-violet);
  border: 1px solid rgba(155, 138, 251, 0.3);
}

/* Select Dropdowns */
.select-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.ctrl-select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg-primary);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 26px 5px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s ease;
  outline: none;
  max-width: 215px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  outline: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371818D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.ctrl-select:hover, .ctrl-select:focus {
  border-color: rgba(54, 214, 195, 0.5);
  box-shadow: 0 0 0 1px rgba(54, 214, 195, 0.2);
}

/* 8. VIEWPORT CANVAS & CARDS */
.viewport-canvas {
  padding: 24px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Generic Panel Card */
.panel-card {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.panel-card:hover {
  border-color: var(--border-strong);
}

.panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-title {
  font-family: var(--font-heading);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.panel-sub {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}


/* 9. DASHBOARD METRIC CARDS (KPIs) - GRAPHITE AURORA v3.1.3 */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(185px, 1fr));
  gap: 14px;
}

.kpi-card {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 18px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  transition: all 0.2s ease;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: transparent;
  transition: background 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-elevated);
}

.kpi-card.teal:hover::before { background: var(--accent-teal); }
.kpi-card.violet:hover::before { background: var(--accent-violet); }
.kpi-card.emerald:hover::before { background: var(--semantic-success); }
.kpi-card.amber:hover::before { background: var(--semantic-warning); }
.kpi-card.blue:hover::before { background: var(--semantic-info); }
.kpi-card.purple:hover::before { background: #C084FC; }

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
}

.kpi-label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.kpi-icon-box {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--accent-teal);
  flex-shrink: 0;
}

.kpi-val-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-top: 4px;
  margin-bottom: 8px;
}

.kpi-val {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.kpi-badge-avg {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
  background: var(--surface-interactive);
  border: 1px solid var(--border-default);
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

.kpi-pills-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.kpi-sub-pill {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.kpi-sub-pill strong {
  color: var(--text-primary);
}


/* 10. SPLINE CHARTS & CIRCULAR ACTIVITY RING */
.charts-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 1200px) {
  .charts-grid-2 {
    grid-template-columns: 1fr;
  }
}

.chart-container {
  padding: 16px 20px 20px;
  position: relative;
}

/* Spline SVG aesthetics */
.spline-path-teal {
  fill: none;
  stroke: var(--accent-teal);
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 8px rgba(54, 214, 195, 0.35));
}

.spline-area-teal {
  fill: url(#aurora-teal-gradient);
}

.spline-path-violet {
  fill: none;
  stroke: var(--accent-violet);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 8px rgba(155, 138, 251, 0.3));
}

.spline-area-violet {
  fill: url(#aurora-violet-gradient);
}

.chart-grid-line {
  stroke: var(--border-subtle);
  stroke-dasharray: 4 4;
}

.chart-axis-label {
  fill: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 10px;
}

.chart-tooltip-badge {
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-card);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Activity Score Ring Card */
.activity-ring-box {
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 14px 20px;
  gap: 20px;
}

.ring-stat-block {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.ring-stat-item {
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 150px;
}

.ring-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.ring-stat-val {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 2px;
}

/* Latest Metrics List */
.metric-row-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  transition: background 0.15s ease;
}

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

.metric-row-item:hover {
  background: var(--surface-interactive);
}

.metric-row-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.metric-avatar-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.metric-title {
  font-family: var(--font-heading);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.metric-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-val-big {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

/* 11. HIGH-DENSITY DATA GRID & TABLES */
.table-wrap {
  overflow-x: auto;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

table.data-grid {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

table.data-grid th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 8px 4px;
  border-bottom: 1px solid var(--border-default);
  border-right: 1px solid var(--border-subtle);
  text-align: center;
  white-space: nowrap;
}

table.data-grid td {
  padding: 5px 3px;
  border-bottom: 1px solid var(--border-subtle);
  border-right: 1px solid var(--border-subtle);
  text-align: center;
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: nowrap;
  background: var(--surface-base);
}

table.data-grid tr:hover td {
  background: var(--surface-elevated);
}

table.data-grid td.col-sticky,
table.data-grid th.col-sticky {
  position: sticky;
  left: 0;
  background: var(--surface-base);
  z-index: 2;
  text-align: left;
  font-family: var(--font-body);
  min-width: 195px;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 10px;
  padding-right: 8px;
  border-right: 2px solid var(--border-default);
}

table.data-grid tr:hover td.col-sticky {
  background: var(--surface-elevated);
}

/* Cell Inputs */
.cell-input {
  width: 100%;
  max-width: 48px;
  min-width: 28px;
  height: 26px;
  padding: 0 4px;
  text-align: center;
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12.5px;
  font-weight: 600;
  outline: none;
  transition: all 0.15s ease;
}

.cell-input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 1px var(--accent-teal);
  background: var(--surface-interactive);
}

.cell-input-pop {
  width: 130px !important;
  max-width: 150px !important;
  height: 28px !important;
  padding: 2px 8px !important;
  text-align: right !important;
  font-size: 13px !important;
}

.cell-input-territorio {
  width: 85px !important;
  max-width: 105px !important;
  height: 28px !important;
  padding: 2px 6px !important;
  text-align: center !important;
  font-size: 13px !important;
}

.cell-input-assist {
  width: 68px !important;
  max-width: 85px !important;
  height: 28px !important;
  padding: 2px 6px !important;
  text-align: center !important;
  font-size: 13px !important;
}

/* Dashboard Metric Toolbar Strip */
.dashboard-metric-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 8px 14px;
  margin-bottom: 16px;
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
}

.metric-strip-label {
  font-family: var(--font-heading);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.cell-total {
  font-weight: 800;
  color: var(--accent-teal);
  background: rgba(54, 214, 195, 0.06) !important;
}

/* Compact Badges (A, B, C) */
.parte-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  flex-shrink: 0;
  text-align: center;
}

.parte-A {
  background: rgba(54, 214, 195, 0.18);
  color: #36D6C3;
  border: 1px solid rgba(54, 214, 195, 0.35);
}
.parte-B {
  background: rgba(69, 201, 138, 0.18);
  color: #45C98A;
  border: 1px solid rgba(69, 201, 138, 0.35);
}
.parte-C {
  background: rgba(232, 182, 93, 0.18);
  color: #E8B65D;
  border: 1px solid rgba(232, 182, 93, 0.35);
}
.parte-D, .parte-E {
  background: rgba(155, 138, 251, 0.18);
  color: #9B8AFB;
  border: 1px solid rgba(155, 138, 251, 0.35);
}

/* Row Chart Button */
.btn-icon-chart {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: var(--radius-xs);
  border: 1px solid rgba(54, 214, 195, 0.3);
  background: rgba(54, 214, 195, 0.12);
  color: var(--accent-teal);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.btn-icon-chart:hover {
  background: rgba(54, 214, 195, 0.28);
  border-color: var(--accent-teal);
  color: #E6FFFA;
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(54, 214, 195, 0.35);
}

.cong-name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.zoom-tag {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: rgba(232, 182, 93, 0.18);
  color: #E8B65D;
  border: 1px solid rgba(232, 182, 93, 0.3);
  font-weight: 700;
  white-space: nowrap;
  flex-shrink: 0;
}

/* 12. MODAL EXECUTIVO (GRAPHITE AURORA) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fadeInModal 0.2s ease-out;
}

@keyframes fadeInModal {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-dialog {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-modal);
  width: 100%;
  max-width: 1160px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUpModal 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideUpModal {
  from { transform: translateY(20px) scale(0.97); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-default);
  background: var(--surface-elevated);
  flex-shrink: 0;
}

.modal-body {
  padding: 20px 24px 28px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1;
}

.btn-close-modal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--surface-base);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-close-modal:hover {
  background: var(--semantic-error-bg);
  color: var(--semantic-error);
  border-color: rgba(240, 120, 130, 0.4);
}

/* Mini Indicators Grid inside Modal & Single Cong Panel */
.mini-indicators-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.mini-indicator-card {
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow-card);
}

.mini-indicator-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mini-indicator-val {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 700;
  margin: 4px 0 2px;
}

.mini-indicator-sub {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
}

/* 13. DEMOGRAFIA, CALCULADORA & GESTÃO */
.cong-stats-bar {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.cong-stat-card {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  box-shadow: var(--shadow-card);
}

.cong-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
}

.cong-stat-val {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-top: 3px;
}

.cong-add-card {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  box-shadow: var(--shadow-card);
  margin-bottom: 18px;
}

.form-row-grid {
  display: grid;
  grid-template-columns: 2fr 0.8fr 1fr 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: center;
}

/* FORM CONTROLS & INPUTS (GRAPHITE AURORA) */
input, select, textarea, button {
  font-family: inherit;
  color-scheme: dark;
}

input:not([type="checkbox"]):not([type="radio"]),
select,
textarea,
.form-control,
.form-input {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12.5px;
  padding: 6px 12px;
  outline: none;
  transition: all 0.15s ease;
  height: 32px;
  box-sizing: border-box;
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus,
.form-control:focus,
.form-input:focus {
  border-color: var(--accent-teal);
  box-shadow: 0 0 0 1px var(--accent-teal);
  background: var(--surface-interactive);
}

input::placeholder,
select::placeholder,
textarea::placeholder,
.form-control::placeholder,
.form-input::placeholder {
  color: var(--text-muted);
}

select.form-control {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2371818D' stroke-width='2' stroke-linecap='round' stroke-linejoin='round' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

/* BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 14px;
  height: 32px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: var(--surface-elevated);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-interactive);
  border-color: var(--accent-teal);
  color: var(--text-primary);
}

.btn-primary,
.btn-primary-aurora {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  height: 32px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent-teal), var(--accent-teal-deep));
  color: #0B1117;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(54, 214, 195, 0.25);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary:hover,
.btn-primary-aurora:hover {
  filter: brightness(1.1);
  box-shadow: var(--shadow-glow-teal);
}

.btn-emerald {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 16px;
  height: 32px;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--semantic-success), #1b6343);
  color: #0B1117;
  font-family: var(--font-heading);
  font-size: 12.5px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(69, 201, 138, 0.25);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-emerald:hover {
  filter: brightness(1.1);
}

/* SMART INSIGHTS GRID & CARDS */
.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
  padding: 16px 20px;
}

.insight-box {
  background: var(--surface-base);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s ease;
}

.insight-box:hover {
  border-color: var(--border-strong);
}

.insight-title {
  font-family: var(--font-heading);
  font-size: 13px;
  font-weight: 700;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 10px;
}

.insight-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.insight-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: var(--surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xs);
  font-size: 12px;
}

.insight-item strong {
  color: var(--text-primary);
  font-family: var(--font-body);
}

.chip-sur {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(155, 138, 251, 0.15);
  color: #9B8AFB;
  border: 1px solid rgba(155, 138, 251, 0.35);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.chip-ouv {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(54, 214, 195, 0.15);
  color: var(--accent-teal);
  border: 1px solid rgba(54, 214, 195, 0.35);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.chip-warn {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  background: rgba(232, 182, 93, 0.15);
  color: var(--semantic-warning);
  border: 1px solid rgba(232, 182, 93, 0.35);
  border-radius: var(--radius-xs);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
}

.btn-danger-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-danger-icon:hover {
  background: var(--semantic-error-bg);
  color: var(--semantic-error);
  border-color: rgba(240, 120, 130, 0.4);
}

/* 14. TOAST NOTIFICATION */
#app-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface-elevated);
  border: 1px solid rgba(54, 214, 195, 0.4);
  color: var(--text-primary);
  padding: 10px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-elevated), var(--shadow-glow-teal);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

#app-toast.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}
