/* ======= DESIGN SYSTEM & TOKENS ======= */
:root {
  /* HSL Colors - Light Theme */
  --bg-primary: hsl(40, 20%, 93%);
  --bg-secondary: hsl(45, 15%, 95%);
  --bg-tertiary: hsl(0, 0%, 100%);
  --border-color: rgba(0, 0, 0, 0.08);
  --divider-color: hsl(40, 10%, 85%);
  
  --text-primary: hsl(210, 40%, 10%);
  --text-muted: hsl(40, 8%, 40%);
  --text-faint: hsl(40, 5%, 70%);
  --text-inverse: hsl(40, 20%, 98%);
  
  /* Brand Corporate Navy */
  --primary: hsl(215, 65%, 15%);
  --primary-hover: hsl(215, 65%, 20%);
  --primary-active: hsl(215, 65%, 10%);
  --primary-highlight: hsl(215, 40%, 90%);
  
  /* Brand Accent Gold */
  --accent: hsl(40, 42%, 54%);
  --accent-hover: hsl(40, 42%, 46%);
  --accent-light: hsl(40, 40%, 90%);
  
  /* Shadow & Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.12);
  
  /* Fonts */
  --font-display: 'Cormorant Garamond', Georgia, serif;
  --font-body: 'Outfit', sans-serif;
  
  --transition: 250ms cubic-bezier(0.16, 1, 0.3, 1);
  
  /* Typography Scale */
  --text-xs: clamp(0.75rem, 0.7rem + 0.2vw, 0.875rem);
  --text-sm: clamp(0.875rem, 0.8rem + 0.3vw, 1rem);
  --text-base: clamp(1rem, 0.95rem + 0.25vw, 1.125rem);
  --text-lg: clamp(1.125rem, 1rem + 0.6vw, 1.35rem);
  --text-xl: clamp(1.35rem, 1.2rem + 1vw, 2rem);
  
  /* Layout Spaces */
  --space-1: 0.25rem; --space-2: 0.5rem; --space-3: 0.75rem;
  --space-4: 1rem; --space-5: 1.25rem; --space-6: 1.5rem;
  --space-8: 2rem; --space-10: 2.5rem; --space-12: 3rem;
  
  /* Specific Transparencies */
  --card-bg: rgba(255, 255, 255, 0.45);
  --sidebar-hover-bg: rgba(13, 31, 60, 0.05);
  --header-welcome-span: hsl(40, 42%, 54%);
  --btn-auth-border: rgba(184, 151, 90, 0.5);
  --chart-kpi-sub: rgba(0, 0, 0, 0.1);
  --chart-kpi-sub-focus: rgba(13, 31, 60, 0.08);
  --notif-danger-bg: hsl(0, 80%, 95%);
  --notif-danger-color: hsl(0, 80%, 50%);
  --notif-success-bg: hsl(100, 70%, 95%);
  --notif-success-color: hsl(100, 70%, 40%);
  --doc-icon-bg: rgba(13, 31, 60, 0.08);
  --calendar-has-event-bg: rgba(184, 151, 90, 0.08);
  --calendar-has-event-border: rgba(184, 151, 90, 0.2);
  --ticket-urgent-low: rgba(0, 0, 0, 0.05);
  --ticket-urgent-medium: rgba(184, 151, 90, 0.15);
  --ticket-urgent-high: rgba(255, 0, 0, 0.1);
}

[data-theme="dark"] {
  /* HSL Colors - Dark Theme */
  --bg-primary: hsl(220, 25%, 8%);
  --bg-secondary: hsl(220, 25%, 11%);
  --bg-tertiary: hsl(220, 20%, 14%);
  --border-color: rgba(255, 255, 255, 0.08);
  --divider-color: hsl(220, 15%, 18%);
  
  --text-primary: hsl(40, 20%, 90%);
  --text-muted: hsl(220, 10%, 65%);
  --text-faint: hsl(220, 10%, 40%);
  --text-inverse: hsl(220, 25%, 6%);
  
  --primary: hsl(215, 50%, 45%);
  --primary-hover: hsl(215, 50%, 52%);
  --primary-active: hsl(215, 50%, 38%);
  --primary-highlight: hsl(215, 30%, 15%);
  
  --accent: hsl(40, 50%, 65%);
  --accent-hover: hsl(40, 50%, 72%);
  --accent-light: hsl(40, 30%, 15%);
  
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.5);
  
  /* Specific Transparencies */
  --card-bg: rgba(28, 34, 48, 0.45);
  --sidebar-hover-bg: rgba(212, 170, 110, 0.1);
  --header-welcome-span: hsl(40, 50%, 65%);
  --btn-auth-border: rgba(212, 170, 110, 0.5);
  --chart-kpi-sub: rgba(255, 255, 255, 0.1);
  --chart-kpi-sub-focus: rgba(255, 255, 255, 0.15);
  --notif-danger-bg: hsl(0, 50%, 15%);
  --notif-danger-color: hsl(0, 80%, 60%);
  --notif-success-bg: hsl(100, 50%, 15%);
  --notif-success-color: hsl(100, 70%, 50%);
  --doc-icon-bg: rgba(212, 170, 110, 0.15);
  --calendar-has-event-bg: rgba(212, 170, 110, 0.08);
  --calendar-has-event-border: rgba(212, 170, 110, 0.2);
  --ticket-urgent-low: rgba(255, 255, 255, 0.05);
  --ticket-urgent-medium: rgba(212, 170, 110, 0.15);
  --ticket-urgent-high: rgba(255, 0, 0, 0.15);
}

/* ======= BASE & RESET ======= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: var(--font-body);
  font-size: var(--text-base);
  color: var(--text-primary);
  background-color: var(--bg-primary);
  overflow-x: hidden;
  transition: background-color var(--transition), color var(--transition);
}

h1, h2, h3, h4 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--primary);
  line-height: 1.2;
}
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] h4 {
  color: var(--text-primary);
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition);
}
button {
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  color: inherit;
  transition: all var(--transition);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

input[type="checkbox"], input[type="radio"] {
  accent-color: var(--accent) !important;
}

/* ======= TOAST NOTIFICATIONS ======= */
.toast-container {
  position: fixed;
  top: var(--space-6);
  right: var(--space-6);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  max-width: 340px;
}
.toast {
  background: var(--bg-tertiary);
  border-left: 4px solid var(--primary);
  border-radius: var(--radius-md);
  padding: var(--space-4);
  box-shadow: var(--shadow-md);
  color: var(--text-primary);
  font-size: var(--text-sm);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  animation: slide-toast 300ms ease forwards;
}
.toast.success {
  border-left-color: hsl(100, 70%, 45%);
}
.toast.danger {
  border-left-color: hsl(0, 80%, 60%);
}
.toast.info {
  border-left-color: var(--accent);
}
.toast svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
@keyframes slide-toast {
  from { transform: translateX(120%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ======= AUTHENTICATION SCREEN ======= */
.auth-wrapper {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
  padding: var(--space-4);
}
.auth-bg-glow {
  position: absolute;
  top: 10%;
  left: 10%;
  width: 80%;
  height: 80%;
  background: radial-gradient(circle, rgba(184, 151, 90, 0.08) 0%, transparent 65%);
  pointer-events: none;
}
[data-theme="dark"] .auth-bg-glow {
  background: radial-gradient(circle, rgba(212, 170, 110, 0.08) 0%, transparent 65%);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: var(--space-10) var(--space-8);
  border-top: 4px solid var(--accent);
  position: relative;
  z-index: 5;
}
.auth-header {
  text-align: center;
  margin-bottom: var(--space-8);
}
.logo-badge-pro {
  display: inline-flex;
  padding: var(--space-1) var(--space-3);
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 700;
  font-size: 11px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  border: 1px solid var(--btn-auth-border);
  margin-bottom: var(--space-3);
}
.auth-header h2 {
  font-size: var(--text-2xl);
  font-weight: 700;
  margin-bottom: var(--space-1);
}
.auth-header h2 em {
  font-style: italic;
  color: var(--accent);
}
.auth-header p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.form-group label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-primary);
}
.input-icon-box {
  position: relative;
  display: flex;
  align-items: center;
}
.input-icon-box .input-icon {
  position: absolute;
  left: var(--space-3);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
.input-icon-box input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) 36px;
  background: var(--bg-secondary);
  border: 1px solid var(--divider-color);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}
.input-icon-box input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 151, 90, 0.15);
}
[data-theme="dark"] .input-icon-box input:focus {
  box-shadow: 0 0 0 3px rgba(212, 170, 110, 0.15);
}

.auth-actions-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.remember-me {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}
.forgot-pass:hover {
  color: var(--accent);
}

.btn-auth-submit {
  width: 100%;
  padding: var(--space-4);
  background: var(--primary);
  color: var(--text-inverse);
  font-weight: 700;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  margin-top: var(--space-2);
}
.btn-auth-submit:hover {
  background: var(--primary-hover);
  box-shadow: var(--shadow-md);
}
.btn-auth-submit svg {
  width: 16px;
  height: 16px;
  color: var(--accent);
}

.auth-footer {
  text-align: center;
  margin-top: var(--space-8);
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.auth-footer a {
  color: var(--accent);
  font-weight: 600;
}
.auth-footer a:hover {
  text-decoration: underline;
}

/* Glassmorphism Cards */
.glass-card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  backdrop-filter: blur(20px);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  transition: border-color var(--transition);
}

/* ======= MAIN PORTAL APPLICATION ======= */
.app-wrapper {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

/* Sidebar Navigation */
.app-sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: var(--space-6);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-8);
  padding-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-color);
}
.brand-info {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}
.brand-name {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--primary);
}
[data-theme="dark"] .brand-name {
  color: var(--text-primary);
}
.brand-user-role {
  font-size: 10px;
  color: var(--accent);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  flex: 1;
}
.nav-tab {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-muted);
  width: 100%;
  text-align: left;
}
.nav-tab:hover {
  background: var(--sidebar-hover-bg);
  color: var(--primary);
}
[data-theme="dark"] .nav-tab:hover {
  color: var(--accent);
}
.nav-tab.active {
  background: var(--primary);
  color: var(--text-inverse);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .nav-tab.active {
  background: var(--accent);
  color: var(--primary);
}
.nav-tab svg {
  width: 16px;
  height: 16px;
}

.sidebar-footer {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  border-top: 1px solid var(--border-color);
  padding-top: var(--space-6);
}
.user-widget {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  color: var(--primary);
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
}
[data-theme="dark"] .user-avatar {
  color: var(--accent);
}
.user-avatar svg {
  width: 16px;
  height: 16px;
}
.user-details {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  max-width: 140px;
}
.user-company {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.user-email {
  font-size: 10px;
  color: var(--text-muted);
}

.btn-logout {
  width: 100%;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
}
.btn-logout:hover {
  background: hsl(0, 80%, 95%);
  color: hsl(0, 80%, 50%);
  border-color: hsl(0, 80%, 90%);
}
[data-theme="dark"] .btn-logout:hover {
  background: hsl(0, 50%, 15%);
  color: hsl(0, 80%, 60%);
  border-color: hsl(0, 50%, 25%);
}
.btn-logout svg {
  width: 14px;
  height: 14px;
}

/* Main Content Area */
.app-main {
  display: flex;
  flex-direction: column;
  padding: var(--space-8);
  overflow-y: auto;
  height: 100vh;
}

.portal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
}
.header-welcome h2 {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-1);
}
[data-theme="dark"] .header-welcome h2 {
  color: var(--text-primary);
}
.header-welcome h2 span {
  font-style: italic;
  color: var(--header-welcome-span);
}
.header-welcome p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.portal-header .header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
}
.theme-toggle:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}

.header-notification {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  position: relative;
  cursor: pointer;
}
.header-notification:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.header-notification svg {
  width: 16px;
  height: 16px;
}
.badge-dot {
  position: absolute;
  top: 8px; right: 8px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: hsl(0, 80%, 60%);
}

.portal-marquee-box {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: var(--space-2) var(--space-4);
  overflow: hidden;
  margin-bottom: var(--space-8);
}
.portal-marquee-box .indicators-track {
  display: flex;
  justify-content: space-around;
  width: 100%;
  flex-wrap: wrap;
  gap: var(--space-4);
}
.portal-marquee-box .indicator-item {
  margin-right: 0;
}

.portal-content-viewport {
  flex: 1;
}

/* SPA tab switching classes */
.portal-tab-content {
  display: none;
  animation: fade-tab 300ms ease forwards;
}
.portal-tab-content.active {
  display: block;
}
@keyframes fade-tab {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.tab-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-8);
}
.tab-header-row h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-1);
}
[data-theme="dark"] .tab-header-row h3 {
  color: var(--text-primary);
}
.tab-header-row p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.btn-primary-sm {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  background: var(--primary);
  color: var(--text-inverse);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 700;
}
[data-theme="dark"] .btn-primary-sm {
  background: var(--accent);
  color: var(--primary);
}
.btn-primary-sm:hover {
  transform: translateY(-1px);
}
.btn-primary-sm svg {
  width: 14px;
  height: 14px;
}

/* ======= MODULE 1: DASHBOARD ======= */
.dashboard-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-6);
  margin-bottom: var(--space-8);
}
.kpi-card {
  padding: var(--space-6);
}
.kpi-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-block: var(--space-3);
}
.kpi-value {
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text-primary);
}
.kpi-value.text-accent {
  color: var(--accent);
}
.stat-trend {
  font-size: 11px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.stat-trend.positive { color: hsl(100, 70%, 45%); }
.stat-trend svg { width: 12px; height: 12px; }
.stat-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
}
.stat-badge.warning {
  background: var(--chart-kpi-sub);
  color: var(--accent);
}
.stat-badge.info {
  background: var(--chart-kpi-sub-focus);
  color: var(--primary);
}
[data-theme="dark"] .stat-badge.info {
  color: var(--text-primary);
}
.kpi-subtext {
  font-size: 11px;
  color: var(--text-muted);
}

.dashboard-charts-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: var(--space-6);
}
.chart-card-large {
  padding: var(--space-6);
}
.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-4);
}
.chart-header h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}
.chart-legend {
  display: flex;
  gap: var(--space-4);
}
.legend-item {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.legend-color {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-color.primary { background: var(--primary); }
.legend-color.accent { background: var(--accent); }

.svg-chart-container {
  width: 100%;
  height: 200px;
}
.svg-chart {
  width: 100%;
  height: 100%;
}

.feed-card {
  padding: var(--space-6);
}
.feed-card h3 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-4);
}
.notification-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.notif-item {
  border-left: 3px solid var(--border-color);
  padding-left: var(--space-3);
}
.notif-badge {
  font-size: 9px;
  font-weight: 700;
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  display: inline-block;
  margin-bottom: var(--space-1);
  text-transform: uppercase;
}
.notif-badge.danger {
  background: var(--notif-danger-bg);
  color: var(--notif-danger-color);
}
.notif-badge.success {
  background: var(--notif-success-bg);
  color: var(--notif-success-color);
}
.notif-item p {
  font-size: var(--text-xs);
  line-height: 1.4;
  margin-bottom: var(--space-1);
}
.notif-time {
  font-size: 10px;
  color: var(--text-faint);
}

/* ======= MODULE 2: DOCUMENTOS ======= */
.doc-categories-tabs {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding-bottom: var(--space-2);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
}
.doc-tab {
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}
.doc-tab:hover {
  background: var(--bg-secondary);
}
.doc-tab.active {
  background: var(--primary-highlight);
  color: var(--primary);
}
[data-theme="dark"] .doc-tab.active {
  color: var(--accent);
}

.portal-search-row {
  margin-bottom: var(--space-6);
}
.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.search-input-wrapper .search-icon {
  position: absolute;
  left: var(--space-4);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}
.search-input-wrapper input {
  width: 100%;
  padding: var(--space-3) var(--space-4) var(--space-3) 42px;
  background: var(--bg-tertiary);
  border: 1px solid var(--divider-color);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: var(--text-sm);
}
.search-input-wrapper input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 151, 90, 0.15);
}
[data-theme="dark"] .search-input-wrapper input:focus {
  box-shadow: 0 0 0 3px rgba(212, 170, 110, 0.15);
}

.documents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(260px, 100%), 1fr));
  gap: var(--space-4);
}
.doc-card {
  padding: var(--space-5);
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}
.doc-icon-box {
  width: 42px;
  height: 42px;
  background: var(--doc-icon-bg);
  color: var(--primary);
  border-radius: var(--radius-md);
  display: grid;
  place-items: center;
  flex-shrink: 0;
}
[data-theme="dark"] .doc-icon-box {
  color: var(--accent);
}
.doc-icon-box svg {
  width: 20px;
  height: 20px;
}
.doc-card-details {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.doc-card-details h4 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.doc-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: var(--space-4);
}
.doc-card-actions {
  display: flex;
  gap: var(--space-3);
  margin-top: auto;
}
.btn-doc-action {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}
.btn-doc-action svg {
  width: 12px;
  height: 12px;
}
.btn-doc-action:hover {
  text-shadow: 0 0 8px rgba(184, 151, 90, 0.3);
}
[data-theme="dark"] .btn-doc-action:hover {
  text-shadow: 0 0 8px rgba(212, 170, 110, 0.3);
}

/* ======= MODULE 3: CALENDARIO ======= */
.calendar-layout-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-6);
}
.calendar-card {
  padding: var(--space-6);
}
.calendar-month-selector {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-4);
}
.calendar-month-selector h4 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
}
.calendar-month-selector button {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  display: grid;
  place-items: center;
}
.calendar-month-selector button:hover {
  color: var(--text-primary);
  background: var(--bg-secondary);
}
.calendar-month-selector button svg {
  width: 14px;
  height: 14px;
}

.calendar-days-header {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: var(--space-3);
  text-transform: uppercase;
}
.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.calendar-day-cell {
  aspect-ratio: 1.2;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 4px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}
.calendar-day-cell.other-month {
  opacity: 0.3;
}
.calendar-day-cell.has-event {
  background: var(--calendar-has-event-bg);
  border-color: var(--calendar-has-event-border);
}
.calendar-day-cell.active-selected {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
[data-theme="dark"] .calendar-day-cell.active-selected {
  background: var(--accent);
  color: var(--primary);
  border-color: var(--accent);
}
.calendar-event-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
  align-self: center;
}
.calendar-day-cell.active-selected .calendar-event-dot {
  background: var(--text-inverse);
}
[data-theme="dark"] .calendar-day-cell.active-selected .calendar-event-dot {
  background: var(--primary);
}

.events-card {
  padding: var(--space-6);
  max-height: 420px;
  overflow-y: auto;
}
.events-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.event-item-card {
  padding: var(--space-4);
  background: var(--bg-secondary);
  opacity: 0.9;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.event-item-card.no-border {
  border-left-color: var(--border-color);
}
.event-item-card h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.event-item-card p {
  font-size: 11px;
  line-height: 1.4;
}
.event-date-badge {
  font-size: 9px;
  font-weight: 700;
  color: var(--accent);
  text-transform: uppercase;
  margin-top: var(--space-2);
  display: block;
}

/* ======= MODULE 4: CALCULADORAS ======= */
.calculators-selector-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}
.calc-selector-card {
  padding: var(--space-6);
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}
.calc-selector-card svg {
  width: 24px;
  height: 24px;
  color: var(--accent);
  margin-bottom: var(--space-3);
}
.calc-selector-card h4 {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}
.calc-selector-card p {
  font-size: var(--text-xs);
  color: var(--text-muted);
}
.calc-selector-card.active {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(184, 151, 90, 0.15);
  background: rgba(184, 151, 90, 0.05);
}
[data-theme="dark"] .calc-selector-card.active {
  box-shadow: 0 0 12px rgba(212, 170, 110, 0.15);
  background: rgba(212, 170, 110, 0.05);
}

/* Worksheet panel control */
.calculator-panel {
  display: none;
  animation: fade-tab 300ms ease forwards;
}
.calculator-panel.active {
  display: block;
}

.calc-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: var(--space-8);
  align-items: start;
}
.calc-inputs-column {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-sm);
}
.calc-inputs-column h3 {
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary);
  margin-bottom: var(--space-2);
}
[data-theme="dark"] .calc-inputs-column h3 {
  color: var(--text-primary);
}

.radio-group-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--divider-color);
}
.radio-tab {
  flex: 1;
  text-align: center;
  padding: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  cursor: pointer;
  user-select: none;
  transition: all var(--transition);
}
.radio-tab.active {
  background: var(--bg-tertiary);
  color: var(--primary);
  box-shadow: var(--shadow-sm);
}
[data-theme="dark"] .radio-tab.active {
  color: var(--accent);
}

.calc-results-column .results-box {
  background: var(--primary);
  color: var(--text-inverse);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-xl);
  padding: var(--space-8);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.results-box h4 {
  font-family: var(--font-display);
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--accent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: var(--space-3);
  margin-bottom: var(--space-2);
}
.result-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: var(--text-sm);
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed rgba(255, 255, 255, 0.1);
}
.result-row strong {
  font-family: var(--font-body);
  font-size: var(--text-base);
}
.result-row.warning-border {
  border-bottom-color: rgba(184, 151, 90, 0.3);
}
[data-theme="dark"] .result-row.warning-border {
  border-bottom-color: rgba(212, 170, 110, 0.3);
}
.result-row.highlight-border {
  border-bottom: none;
  padding-top: var(--space-3);
}
.result-row.highlight-border strong {
  font-size: var(--text-lg);
  color: var(--accent);
}
.result-row strong.text-accent {
  color: var(--accent);
}

/* ======= MODULE 5: SOPORTE ======= */
.tickets-history-container {
  margin-top: var(--space-4);
}
.history-header {
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-secondary);
  opacity: 0.8;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}
.history-header h4 {
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.tickets-list {
  display: flex;
  flex-direction: column;
}
.ticket-row-item {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1.2fr;
  gap: var(--space-4);
  align-items: center;
  padding: var(--space-4) var(--space-6);
  border-bottom: 1px solid var(--border-color);
  font-size: var(--text-xs);
}
.ticket-row-item:last-child {
  border-bottom: none;
}
.ticket-subj-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ticket-subj-col strong {
  font-size: var(--text-xs);
  color: var(--text-primary);
}
.ticket-subj-col span {
  font-size: 10px;
  color: var(--text-muted);
}
.t-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  display: inline-block;
}
.t-badge.open {
  background: var(--ticket-urgent-medium);
  color: var(--accent);
}
.t-badge.process {
  background: var(--primary-highlight);
  color: var(--primary);
}
.t-badge.resolved {
  background: hsl(100, 70%, 93%);
  color: hsl(100, 70%, 35%);
}
[data-theme="dark"] .t-badge.resolved {
  background: hsl(100, 50%, 15%);
  color: hsl(100, 70%, 50%);
}

.t-badge.p-low { background: var(--ticket-urgent-low); color: var(--text-muted); }
.t-badge.p-medium { background: var(--ticket-urgent-medium); color: var(--accent); }
.t-badge.p-high { background: var(--ticket-urgent-high); color: hsl(0, 80%, 50%); }
[data-theme="dark"] .t-badge.p-high { color: hsl(0, 80%, 60%); }

/* ======= MODULE 6: PERFIL ======= */
.profile-layout-grid {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: var(--space-6);
}
.profile-card {
  padding: var(--space-8);
}
.status-card {
  padding: var(--space-8);
}
.status-card h3 {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-4);
}
.service-status-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.status-item {
  display: flex;
  justify-content: space-between;
  font-size: var(--text-xs);
  padding-bottom: var(--space-3);
  border-bottom: 1px dashed var(--border-color);
}
.status-item strong.text-green {
  color: hsl(100, 70%, 45%);
}

/* ======= MODALS OVERLAY ======= */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(13, 31, 60, 0.45);
  backdrop-filter: blur(12px);
  place-items: center;
  padding: var(--space-4);
  animation: fade-tab 200ms ease;
}
.modal-overlay.open {
  display: grid;
}
.modal-content {
  width: 100%;
  max-width: 500px;
  padding: var(--space-8);
  background: var(--bg-tertiary);
  border-top: 5px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  border-left: 1px solid var(--border-color);
  border-right: 1px solid var(--border-color);
  border-bottom: 1px solid var(--border-color);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-6);
  border-bottom: 1.5px solid var(--divider-color);
  padding-bottom: var(--space-4);
}
.modal-header h3 {
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--primary);
}
.modal-close {
  color: var(--text-muted);
  font-size: var(--text-lg);
  transition: color var(--transition);
}
.modal-close:hover {
  color: var(--primary);
}

/* Modal form elements sizing & typography */
.modal-content .form-group label {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--primary);
  margin-bottom: var(--space-1);
}
.modal-content .form-group input,
.modal-content .form-group select,
.modal-content .form-group textarea {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-family: var(--font-body);
  border: 1.5px solid var(--divider-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  transition: all var(--transition);
}
.modal-content .form-group input:focus,
.modal-content .form-group select:focus,
.modal-content .form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(184, 151, 90, 0.15);
  background: var(--bg-tertiary);
}

/* Premium Main Button (Missing class) */
.btn-primary {
  width: 100%;
  padding: var(--space-4);
  background: var(--primary);
  color: var(--text-inverse);
  font-family: var(--font-body);
  font-size: var(--text-sm);
  font-weight: 700;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition);
  border: 1px solid transparent;
}
.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1.5px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active {
  background: var(--primary-active);
  transform: translateY(0);
}
.btn-primary svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
}

/* ======= PORTAL RESPONSIVE ======= */
@media (max-width: 1024px) {
  .app-wrapper {
    grid-template-columns: 1fr;
  }
  .app-sidebar {
    display: none;
  }
  .app-main {
    padding: var(--space-4);
  }
  .dashboard-kpi-grid, .dashboard-charts-grid, .calendar-layout-grid, .calc-grid, .profile-layout-grid {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 768px) {
  .calculators-selector-grid {
    grid-template-columns: 1fr;
  }
  .ticket-row-item {
    grid-template-columns: 1.5fr 1fr;
    gap: var(--space-2);
  }
  .ticket-row-item > *:nth-child(3), .ticket-row-item > *:nth-child(4) {
    display: none;
  }
}

/* ======= NEW PREMIUM MODULES STYLING ======= */

/* 1. Notification Dropdown */
.notif-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 320px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-top: 4px solid var(--accent);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 400;
  cursor: default;
  animation: fade-tab 200ms ease;
  overflow: hidden;
}
.header-notification.open .notif-dropdown {
  display: block;
}
.notif-dropdown-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--divider-color);
  background: var(--bg-secondary);
}
.notif-dropdown-header h4 {
  font-family: var(--font-body);
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--primary);
}
.notif-dropdown-header button {
  font-size: 10px;
  color: var(--accent);
  font-weight: 600;
}
.notif-dropdown-header button:hover {
  text-decoration: underline;
}
.notif-dropdown-list {
  max-height: 250px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.notif-item-row {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border-color);
  font-size: 11px;
  line-height: 1.4;
  color: var(--text-primary);
  transition: background var(--transition);
  cursor: pointer;
  text-align: left;
}
.notif-item-row:hover {
  background: var(--bg-secondary);
}
.notif-item-row:last-child {
  border-bottom: none;
}
.notif-item-row .notif-title {
  font-weight: 700;
  display: block;
  margin-bottom: 2px;
}
.notif-item-row .notif-time {
  font-size: 9px;
  color: var(--text-muted);
  display: block;
  margin-top: 4px;
}

/* 2. Chat UI bubbles */
.chat-msg-row {
  display: flex;
  width: 100%;
  margin-bottom: 4px;
}
.chat-msg-row.me {
  justify-content: flex-end;
}
.chat-bubble {
  max-width: 70%;
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: var(--text-xs);
  line-height: 1.5;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.chat-msg-row.me .chat-bubble {
  background: var(--primary);
  color: var(--text-inverse);
  border-bottom-right-radius: 2px;
}
.chat-msg-row.other .chat-bubble {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-bottom-left-radius: 2px;
  border: 1px solid var(--border-color);
}
.chat-bubble-time {
  font-size: 9px;
  opacity: 0.7;
  display: block;
  text-align: right;
  margin-top: 4px;
}

/* 3. Invoices row item styling */
.invoice-row-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-4);
  border-bottom: 1px solid var(--border-color);
  transition: background var(--transition);
}
.invoice-row-item:hover {
  background: var(--bg-secondary);
}
.invoice-row-item:last-child {
  border-bottom: none;
}
.invoice-info-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.invoice-info-col strong {
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.invoice-info-col span {
  font-size: 11px;
  color: var(--text-muted);
}
.invoice-status-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}
.invoice-status-badge.paid {
  background: var(--notif-success-bg);
  color: var(--notif-success-color);
}

/* 4. Worker Row Item in Nomina */
.worker-row-item {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  background: var(--bg-tertiary);
  cursor: pointer;
  transition: all var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.worker-row-item:hover, .worker-row-item.active {
  border-color: var(--accent);
  background: var(--accent-light);
  box-shadow: var(--shadow-sm);
}
.worker-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.worker-info strong {
  font-size: var(--text-sm);
  color: var(--text-primary);
}
.worker-info span {
  font-size: 11px;
  color: var(--text-muted);
}

.theme-toggle {
  display: none !important;
}

/* ======= PREMIUM FORM TYPOGRAPHY OVERHAUL ======= */
input, select, textarea, button {
  font-family: var(--font-body) !important;
}

/* Custom form elements formatting */
input[type="text"], 
input[type="email"], 
input[type="password"], 
input[type="number"], 
input[type="date"], 
input[type="datetime-local"], 
select, 
textarea {
  font-family: var(--font-body) !important;
  font-size: var(--text-sm) !important;
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-color) !important;
  background: var(--bg-tertiary) !important;
  padding: 10px 14px !important;
  color: var(--text-primary) !important;
  transition: all var(--transition) !important;
  outline: none !important;
  box-sizing: border-box;
}

input[type="text"]:focus, 
input[type="email"]:focus, 
input[type="password"]:focus, 
input[type="number"]:focus, 
input[type="date"]:focus, 
input[type="datetime-local"]:focus, 
select:focus, 
textarea:focus {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 3px rgba(184, 151, 90, 0.15) !important;
  background: var(--bg-tertiary) !important;
}

/* Select overrides styling */
select {
  cursor: pointer;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23b8975a' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e") !important;
  background-repeat: no-repeat !important;
  background-position: right 12px center !important;
  background-size: 14px !important;
  padding-right: 36px !important;
  appearance: none !important;
}

/* Fix text overlay/overlap with absolute icons in input boxes */
.input-icon-box input {
  padding-left: 40px !important;
}
.search-input-wrapper input {
  padding-left: 44px !important;
}

/* Superadmin Subtabs Full-Width Layout */
.superadmin-subtabs {
  display: flex !important;
  width: 100% !important;
  gap: 8px !important;
  overflow: hidden !important;
}
.sa-subtab {
  flex: 1 !important;
  width: 100% !important;
  justify-content: center !important;
  text-align: center !important;
  transition: all var(--transition) !important;
}
