/* ═══════════════════════════════════════════════════════════════════════════
   EM2E - Interface de Gestion Maintenance & Audits
   Design System v6.0 - Modern Glass Morphism
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary: #080d19;
  --bg-secondary: #0c1222;
  --bg-tertiary: #111827;
  --bg-elevated: #151d2e;
  --surface-glass: rgba(17, 24, 39, 0.75);
  --surface-glass-hover: rgba(24, 32, 48, 0.85);
  --surface-card: linear-gradient(135deg, rgba(21, 29, 46, 0.9) 0%, rgba(17, 24, 39, 0.8) 100%);
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-disabled: #475569;
  --accent-primary: #3b82f6;
  --accent-primary-rgb: 59, 130, 246;
  --accent-secondary: #22d3ee;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #22d3ee 100%);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.12);
  --danger-border: rgba(239, 68, 68, 0.3);
  --info: #6366f1;
  --info-bg: rgba(99, 102, 241, 0.12);
  --info-border: rgba(99, 102, 241, 0.3);
  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-default: rgba(148, 163, 184, 0.12);
  --border-strong: rgba(148, 163, 184, 0.2);
  --border-focus: rgba(59, 130, 246, 0.5);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.15);
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;
  --space-3xl: 48px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  --sidebar-width: 240px;
  --topbar-height: 64px;
  --container-max: 1280px;
  --transition-fast: 0.15s ease;
  --transition-base: 0.2s ease;
  --transition-slow: 0.3s ease;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* Legacy */
  --bg: var(--bg-primary);
  --card: var(--bg-tertiary);
  --card2: var(--bg-secondary);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --primary: var(--accent-primary);
  --ok: var(--success);
  --border: var(--border-default);
  --shadow: var(--shadow-md);
  --radius: var(--radius-lg);
}

html[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-secondary: #f1f5f9;
  --bg-tertiary: #e2e8f0;
  --bg-elevated: #ffffff;
  --surface-glass: rgba(255, 255, 255, 0.85);
  --surface-glass-hover: rgba(255, 255, 255, 0.95);
  --surface-card: linear-gradient(135deg, rgba(255, 255, 255, 0.95) 0%, rgba(248, 250, 252, 0.9) 100%);
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-disabled: #94a3b8;
  --border-subtle: rgba(15, 23, 42, 0.04);
  --border-default: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.15);
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 12px 40px rgba(15, 23, 42, 0.12);
  --shadow-glow: 0 0 30px rgba(59, 130, 246, 0.1);
  --bg: var(--bg-primary);
  --card: var(--bg-elevated);
  --card2: var(--bg-secondary);
  --text: var(--text-primary);
  --muted: var(--text-muted);
  --border: var(--border-default);
  --shadow: var(--shadow-md);
}

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

html { font-size: 16px; scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background: 
    radial-gradient(ellipse 80% 50% at 20% -20%, rgba(59, 130, 246, 0.15), transparent),
    radial-gradient(ellipse 60% 40% at 80% 0%, rgba(34, 211, 238, 0.1), transparent),
    radial-gradient(ellipse 50% 50% at 50% 100%, rgba(99, 102, 241, 0.08), transparent);
  pointer-events: none;
  z-index: -1;
}

html[data-theme="light"] body::before {
  background: 
    radial-gradient(ellipse 80% 50% at 20% -20%, rgba(59, 130, 246, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 80% 0%, rgba(16, 185, 129, 0.06), transparent);
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; line-height: 1.3; color: var(--text-primary); }
h1, .h1 { font-size: 1.75rem; letter-spacing: -0.025em; margin: 0 0 var(--space-sm); }
h2, .h2 { font-size: 1.25rem; letter-spacing: -0.02em; margin: 0 0 var(--space-sm); }
h3, .h3 { font-size: 1rem; margin: var(--space-md) 0 var(--space-sm); color: var(--text-muted); }
p { margin: var(--space-sm) 0; }
a { color: var(--accent-primary); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--accent-secondary); }
.muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }

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

.sidebar {
  width: var(--sidebar-width);
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-right: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform var(--transition-slow);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 1rem;
  color: white;
  box-shadow: var(--shadow-md), var(--shadow-glow);
  overflow: hidden;
  flex-shrink: 0;
}

.sidebar-logo img { width: 100%; height: 100%; object-fit: cover; }
.sidebar-meta { min-width: 0; }
.sidebar-title {
  font-weight: 800;
  font-size: 1.1rem;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.sidebar-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

.sidebar-nav {
  flex: 1;
  padding: var(--space-md);
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
  overflow-y: auto;
}

.side-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.875rem;
  font-weight: 500;
  transition: all var(--transition-fast);
  border: 1px solid transparent;
}

.side-link:hover {
  background: rgba(var(--accent-primary-rgb), 0.08);
  color: var(--text-primary);
  border-color: rgba(var(--accent-primary-rgb), 0.15);
  transform: translateX(4px);
}

.side-link.active {
  background: rgba(var(--accent-primary-rgb), 0.12);
  color: var(--accent-primary);
  border-color: rgba(var(--accent-primary-rgb), 0.2);
}

.side-link .ico { width: 20px; height: 20px; display: flex; align-items: center; justify-content: center; opacity: 0.8; flex-shrink: 0; }
.side-link.danger { color: var(--danger); }
.side-link.danger:hover { background: var(--danger-bg); border-color: var(--danger-border); }
.side-sep { height: 1px; background: var(--border-subtle); margin: var(--space-sm) var(--space-lg); }

.sidebar-footer {
  padding: var(--space-md);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-top: auto;
}

.side-user {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  background: rgba(var(--accent-primary-rgb), 0.05);
  border: 1px solid var(--border-subtle);
}

.side-user-name { font-weight: 700; font-size: 0.875rem; }
.side-user-role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; margin-top: 2px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: var(--topbar-height);
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-xl);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-title { font-weight: 700; font-size: 1rem; display: none; }
.topbar-actions { display: flex; align-items: center; gap: var(--space-md); }

.iconbtn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-glass);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
  font-size: 1.25rem;
}

.iconbtn:hover {
  background: var(--surface-glass-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

.container { max-width: var(--container-max); margin: 0 auto; padding: var(--space-xl); width: 100%; }

.card {
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
  box-shadow: var(--shadow-md);
  transition: all var(--transition-base);
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-lg);
  margin: var(--space-xl) 0;
}

@media (min-width: 640px) { .kpi-grid { grid-template-columns: repeat(3, 1fr); } }
@media (min-width: 1024px) { .kpi-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1280px) { .kpi-grid { grid-template-columns: repeat(6, 1fr); } }

.kpi {
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

.kpi::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--accent-gradient);
  opacity: 0;
  transition: opacity var(--transition-base);
}

.kpi:hover {
  border-color: rgba(var(--accent-primary-rgb), 0.3);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
}

.kpi:hover::before { opacity: 1; }
.kpi-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi-value {
  font-size: 1.75rem;
  font-weight: 800;
  margin: var(--space-sm) 0;
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.kpi-hint { font-size: 0.75rem; color: var(--text-muted); }
.kpi-hint a { color: var(--accent-primary); font-weight: 500; }
.kpi .label { font-size: 0.75rem; color: var(--text-muted); margin: 0; }
.kpi .value { font-size: 1.5rem; font-weight: 800; margin: var(--space-sm) 0 0; }
.kpi .hint { color: var(--text-muted); font-size: 0.75rem; margin-top: var(--space-xs); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: var(--surface-glass);
  color: var(--text-primary);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover {
  background: var(--surface-glass-hover);
  border-color: var(--border-strong);
  transform: translateY(-1px);
  color: var(--text-primary);
}

.btn.primary {
  background: var(--accent-gradient);
  border-color: transparent;
  color: white;
  box-shadow: var(--shadow-sm), 0 0 20px rgba(var(--accent-primary-rgb), 0.2);
}

.btn.primary:hover {
  box-shadow: var(--shadow-md), 0 0 30px rgba(var(--accent-primary-rgb), 0.3);
  transform: translateY(-2px);
  color: white;
}

.btn.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.btn.danger:hover { background: rgba(239, 68, 68, 0.2); }
.btn.small { padding: var(--space-sm) var(--space-md); font-size: 0.8125rem; border-radius: var(--radius-sm); }
.btn.disabled, .btn:disabled { opacity: 0.5; pointer-events: none; }

.form { display: flex; flex-direction: column; gap: var(--space-lg); margin-top: var(--space-md); }
label, .label { display: block; font-size: 0.8125rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-sm); }

input, textarea, select, .input {
  width: 100%;
  padding: var(--space-md) var(--space-lg);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-default);
  background: rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
  font-size: 0.9375rem;
  font-family: inherit;
  transition: all var(--transition-fast);
  outline: none;
}

html[data-theme="light"] input,
html[data-theme="light"] textarea,
html[data-theme="light"] select,
html[data-theme="light"] .input { background: rgba(255, 255, 255, 0.8); }

input:focus, textarea:focus, select:focus, .input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.15);
}

input::placeholder, textarea::placeholder { color: var(--text-disabled); }
textarea { resize: vertical; min-height: 100px; }

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' 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");
  background-repeat: no-repeat;
  background-position: right var(--space-md) center;
  padding-right: calc(var(--space-lg) + 24px);
}

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-lg);
  flex-wrap: wrap;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-lg);
  border-bottom: 1px solid var(--border-subtle);
}

.tool { display: flex; flex-direction: column; gap: var(--space-xs); flex: 1; min-width: 200px; }
.tool-label { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.tool-input { padding: var(--space-sm) var(--space-md); font-size: 0.875rem; }
.tool-actions { display: flex; gap: var(--space-sm); flex-shrink: 0; }
.filters { display: flex; gap: var(--space-md); flex-wrap: wrap; align-items: center; }
.filters .field { min-width: 200px; }
.filters .field.small { min-width: 160px; }

.tablewrap { overflow-x: auto; margin: var(--space-lg) calc(-1 * var(--space-lg)); padding: 0 var(--space-lg); }

.table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.table th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-weight: 600;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}
.table th a { color: var(--text-muted); display: inline-flex; align-items: center; gap: var(--space-xs); }
.table th a:hover { color: var(--accent-primary); }
.table td { padding: var(--space-md) var(--space-lg); border-bottom: 1px solid var(--border-subtle); vertical-align: middle; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: rgba(var(--accent-primary-rgb), 0.04); }
html[data-theme="light"] .table tbody tr:hover { background: rgba(var(--accent-primary-rgb), 0.06); }
.table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 600;
  background: rgba(100, 116, 139, 0.12);
  border: 1px solid rgba(100, 116, 139, 0.2);
  color: var(--text-secondary);
  white-space: nowrap;
}

.badge.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.badge.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.badge.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }
.badge.info { background: var(--info-bg); border-color: var(--info-border); color: var(--info); }

.pagination { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); margin-top: var(--space-xl); flex-wrap: wrap; }
.pagination-controls { display: flex; align-items: center; gap: var(--space-xs); }
.pagination-info, .pager-info { font-size: 0.8125rem; color: var(--text-muted); }
.btn.small.active { background: rgba(var(--accent-primary-rgb), 0.15); border-color: var(--accent-primary); color: var(--accent-primary); }
.btn.small.disabled { opacity: 0.45; pointer-events: none; }
.pager-ellipsis { color: var(--text-muted); padding: 0 var(--space-sm); }
.pager-jump { display: flex; align-items: center; gap: var(--space-sm); margin-left: var(--space-sm); }
.jump-input { width: 80px; padding: var(--space-sm); text-align: center; }
.pager { display: flex; justify-content: space-between; align-items: center; gap: var(--space-md); margin-top: var(--space-md); }
.pager-links { display: flex; align-items: center; gap: var(--space-md); }

.row { display: flex; align-items: center; justify-content: space-between; gap: var(--space-lg); flex-wrap: wrap; }

.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--space-lg); margin-bottom: var(--space-xl); flex-wrap: wrap; }
.page-head .actions, .head-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; justify-content: flex-end; }
.crumbs { font-size: 0.8125rem; color: var(--text-muted); margin-bottom: var(--space-sm); }
.crumbs a { color: var(--text-muted); }
.crumbs a:hover { color: var(--accent-primary); }

.grid { display: grid; grid-template-columns: 1fr; gap: var(--space-xl); }
@media (min-width: 1024px) {
  .grid { grid-template-columns: repeat(12, 1fr); }
  .grid > .card { grid-column: span 12; }
  .grid > .card.span-8, .grid > .span-8 { grid-column: span 8; }
  .grid > .card.span-6, .grid > .span-6 { grid-column: span 6; }
  .grid > .card.span-4, .grid > .span-4 { grid-column: span 4; }
  .grid > .card.span-3, .grid > .span-3 { grid-column: span 3; }
}
.grid2 { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 768px) { .grid2 { grid-template-columns: repeat(2, 1fr); } }
.cards-grid { display: grid; grid-template-columns: 1fr; gap: var(--space-lg); }
@media (min-width: 768px) { .cards-grid { grid-template-columns: repeat(2, 1fr); } }
.kpis { display: grid; grid-template-columns: repeat(12, 1fr); gap: var(--space-lg); margin-bottom: var(--space-lg); }
@media (min-width: 900px) { .kpis .kpi { grid-column: span 3; } }

.timeline { display: flex; flex-direction: column; gap: var(--space-sm); margin-top: var(--space-lg); position: relative; }
.timeline::before { content: ''; position: absolute; left: 14px; top: 0; bottom: 0; width: 2px; background: var(--border-default); }
.timeline-item {
  display: flex;
  gap: var(--space-md);
  padding: var(--space-md);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.1);
  color: inherit;
  transition: all var(--transition-fast);
  position: relative;
  margin-left: 24px;
}
html[data-theme="light"] .timeline-item { background: rgba(255, 255, 255, 0.5); }
.timeline-item:hover { border-color: rgba(var(--accent-primary-rgb), 0.3); background: rgba(var(--accent-primary-rgb), 0.05); transform: translateX(4px); }
.timeline-dot { width: 10px; height: 10px; border-radius: var(--radius-full); background: var(--accent-gradient); margin-top: 6px; flex-shrink: 0; box-shadow: 0 0 10px rgba(var(--accent-primary-rgb), 0.4); position: absolute; left: -19px; }
.timeline-content, .timeline-body { flex: 1; min-width: 0; }

.t-item { position: relative; display: grid; grid-template-columns: 90px 1fr; gap: var(--space-md); padding: var(--space-md) 0 var(--space-md) 38px; }
.t-dot { position: absolute; left: 7px; top: 18px; width: 16px; height: 16px; border-radius: var(--radius-full); border: 2px solid var(--border-default); background: var(--bg-secondary); }
.t-date { color: var(--text-muted); font-size: 0.75rem; padding-top: 6px; }
.t-card { border: 1px solid var(--border-default); background: var(--surface-glass); border-radius: var(--radius-lg); padding: var(--space-md); }
.t-head { display: flex; justify-content: space-between; gap: var(--space-md); align-items: flex-start; }
.t-title { font-weight: 700; }
.t-meta { margin-top: var(--space-xs); display: flex; gap: var(--space-sm); flex-wrap: wrap; }
.t-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; justify-content: flex-end; }
.t-notes { margin-top: var(--space-md); color: var(--text-muted); font-size: 0.8125rem; line-height: 1.4; }
@media (max-width: 720px) { .t-item { grid-template-columns: 1fr; padding-left: 38px; } .t-date { display: none; } }

.alert { padding: var(--space-lg); border-radius: var(--radius-md); border: 1px solid var(--border-default); background: var(--surface-glass); margin-bottom: var(--space-lg); }
.alert.success { background: var(--success-bg); border-color: var(--success-border); color: var(--success); }
.alert.warning { background: var(--warning-bg); border-color: var(--warning-border); color: var(--warning); }
.alert.danger { background: var(--danger-bg); border-color: var(--danger-border); color: var(--danger); }

.toast {
  position: fixed;
  bottom: var(--space-xl);
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface-glass);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  padding: var(--space-md) var(--space-xl);
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  animation: toastIn 0.3s ease;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.hidden { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
  z-index: 200;
  animation: modalBgIn 0.2s ease;
}

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

.modal-card {
  width: min(500px, 95vw);
  background: var(--surface-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  box-shadow: var(--shadow-lg);
  animation: modalCardIn 0.3s ease;
}

@keyframes modalCardIn {
  from { opacity: 0; transform: scale(0.95) translateY(-10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-top { display: flex; align-items: center; gap: var(--space-md); }
.modal-lottie { width: 48px; height: 48px; flex-shrink: 0; border-radius: var(--radius-md); background: rgba(var(--accent-primary-rgb), 0.1); display: flex; align-items: center; justify-content: center; overflow: hidden; }
.modal-lottie > svg { width: 100%; height: 100%; }
.modal-title { font-weight: 700; font-size: 1.125rem; margin-bottom: var(--space-xs); }
.modal-body { color: var(--text-secondary); margin-top: var(--space-md); line-height: 1.6; }
.modal-actions { display: flex; justify-content: flex-end; gap: var(--space-sm); margin-top: var(--space-xl); }

.sig-box { display: flex; flex-direction: column; gap: var(--space-md); }
#sig_canvas { width: 100%; max-width: 420px; border: 2px dashed var(--border-strong); border-radius: var(--radius-lg); background: rgba(0, 0, 0, 0.2); cursor: crosshair; }
.signature-img { width: 100%; max-width: 420px; border-radius: var(--radius-lg); border: 1px solid var(--border-default); }

.auth { max-width: 420px; margin: var(--space-3xl) auto; }

.sep { border: 0; border-top: 1px solid var(--border-subtle); margin: var(--space-lg) 0; }
.big { font-size: 2rem; font-weight: 800; margin: var(--space-md) 0; }
.stack { display: flex; flex-direction: column; gap: var(--space-md); }
.section-title { font-weight: 700; margin: 0 0 var(--space-md); }
.block { border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-lg); background: rgba(0, 0, 0, 0.1); }
html[data-theme="light"] .block { background: rgba(255, 255, 255, 0.5); }
.actions-grid { display: flex; gap: var(--space-md); flex-wrap: wrap; margin-top: var(--space-md); }
.kpi-row { display: flex; gap: var(--space-md); flex-wrap: wrap; }
.kpi .k { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.kpi .v { font-weight: 700; margin-top: 2px; }

.mini-card { border: 1px solid var(--border-default); background: var(--surface-card); border-radius: var(--radius-lg); padding: var(--space-lg); transition: all var(--transition-base); box-shadow: var(--shadow-sm); }
.mini-card:hover { border-color: var(--border-strong); }
.mini-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-md); }
.mini-title { font-weight: 700; font-size: 0.9375rem; }
.mini-meta { display: grid; gap: var(--space-xs); margin-top: var(--space-md); font-size: 0.8125rem; color: var(--text-muted); }
.mini-actions { display: flex; gap: var(--space-sm); margin-top: var(--space-md); flex-wrap: wrap; }

button.navlink { color: inherit; font: inherit; cursor: pointer; border: none; background: none; }
.navlink { transition: all var(--transition-fast); }

@media (max-width: 1023px) {
  .sidebar { position: fixed; left: 0; top: 0; transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.5); z-index: 35; animation: fadeIn 0.2s ease; }
  @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
  .topbar-title { display: block; }
  .container { padding: var(--space-lg); }
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .toolbar { flex-direction: column; align-items: stretch; }
  .tool { min-width: 100%; }
  .tool-actions { justify-content: flex-end; }
  .page-head { flex-direction: column; align-items: stretch; }
  .page-head .actions { justify-content: flex-start; }
  .pagination { flex-direction: column; align-items: center; }
  .pager-jump { width: 100%; justify-content: center; margin-left: 0; }
}

@media (max-width: 640px) {
  h1, .h1 { font-size: 1.5rem; }
  .card { padding: var(--space-lg); }
  .table { font-size: 0.8125rem; }
  .table th, .table td { padding: var(--space-sm) var(--space-md); }
  .row { flex-direction: column; align-items: stretch; }
  .kpi-grid { grid-template-columns: 1fr; }
  .pagination { justify-content: center; }
}

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--text-disabled); }

@media print {
  .sidebar, .topbar, .btn, .pagination { display: none !important; }
  .main { width: 100%; }
  .card { box-shadow: none; border: 1px solid #ddd; }
}

.stat-card { background: var(--surface-card); border: 1px solid var(--border-default); border-radius: var(--radius-lg); padding: var(--space-xl); text-align: center; }
.stat-value { font-size: 2.5rem; font-weight: 800; background: var(--accent-gradient); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.stat-label { color: var(--text-muted); font-size: 0.875rem; margin-top: var(--space-sm); }

.empty-state { text-align: center; padding: var(--space-3xl) var(--space-xl); color: var(--text-muted); }
.empty-state-icon { font-size: 3rem; margin-bottom: var(--space-lg); opacity: 0.5; }
.empty-state-title { font-size: 1.25rem; font-weight: 600; color: var(--text-secondary); margin-bottom: var(--space-sm); }
.empty-state-text { max-width: 400px; margin: 0 auto var(--space-xl); }

.spinner { width: 40px; height: 40px; border: 3px solid var(--border-default); border-top-color: var(--accent-primary); border-radius: 50%; animation: spin 0.8s linear infinite; }

/* ==========================
   Auth / Login (branding)
   ========================== */

body.auth-page{ 
  min-height: 100vh;
  background: #f6f7fb;
  display:flex;
  align-items:stretch;
  position:relative;
  overflow-x:hidden;
}

/* Large circles like the mockup (tinted by primary color) */
body.auth-page::before,
body.auth-page::after{
  content:"";
  position:absolute;
  width: 520px;
  height: 520px;
  border-radius: 999px;
  background: rgba(var(--accent-primary-rgb),0.92);
  filter: saturate(1.02);
  z-index: 0;
}
body.auth-page::before{ left:-200px; top:-220px; }
body.auth-page::after{ right:-230px; bottom:-240px; opacity: .92; }

.auth-container{
  width:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: clamp(16px, 3vw, 32px);
  position:relative;
  z-index: 1;
}

/* New Login UI (Infinity-like) */
.auth-hero{ width:100%; max-width: 1020px; }

.auth-card{
  background: #fff;
  border-radius: 18px;
  overflow:hidden;
  box-shadow: 0 18px 55px rgba(25,25,25,0.18);
  display:grid;
  grid-template-columns: 1fr 1fr;
  min-height: 560px;
}

.auth-left{ padding: 46px 46px 34px; display:flex; flex-direction:column; }

.auth-kicker{ font-size: 0.78rem; letter-spacing: .18em; color: #8b8f98; font-weight: 700; }

.auth-brand{ margin-top: 10px; display:flex; align-items:center; gap: 12px; }
.auth-logo{ height: 26px; width:auto; display:block; }
.auth-logo-fallback{ height: 26px; width: 26px; border-radius: 7px; background: var(--accent-gradient); display:flex; align-items:center; justify-content:center; color:#fff; font-weight:900; }
.auth-brand-name{ font-size: 1.6rem; font-weight: 900; letter-spacing: .02em; color: rgba(var(--accent-primary-rgb),0.95); }

.auth-sub{ margin-top: 10px; color: #8b8f98; font-size: .92rem; line-height: 1.45; max-width: 420px; }

.auth-alert{
  margin-top: 16px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.22);
  color: #b91c1c;
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 600;
}

.auth-form{ margin-top: 22px; }

.auth-field{
  position:relative;
  display:flex;
  align-items:center;
  border: 1px solid #e7e9ee;
  border-radius: 999px;
  padding: 10px 12px;
  margin-top: 12px;
  background: #fff;
  box-shadow: 0 2px 10px rgba(20,20,20,0.04);
  transition: box-shadow var(--transition-fast), border-color var(--transition-fast);
}
.auth-field:focus-within{
  border-color: rgba(var(--accent-primary-rgb),0.45);
  box-shadow: 0 0 0 4px rgba(var(--accent-primary-rgb),0.12), 0 10px 20px rgba(20,20,20,0.06);
}

.auth-ico{ width: 36px; height: 36px; display:flex; align-items:center; justify-content:center; color: #a3a7b0; flex: 0 0 auto; }
.auth-ico svg{ width: 18px; height: 18px; }

.auth-field input{
  border: 0;
  outline: 0;
  background: transparent;
  width: 100%;
  padding: 8px 10px 8px 2px;
  font-size: 0.98rem;
}

.auth-eye{
  border: 0;
  background: transparent;
  width: 38px;
  height: 38px;
  display:flex;
  align-items:center;
  justify-content:center;
  color: #a3a7b0;
  cursor:pointer;
}
.auth-eye svg{ width: 18px; height: 18px; }

.auth-submit{
  margin-top: 18px;
  width: 100%;
  border: 0;
  color: #fff;
  font-weight: 800;
  letter-spacing: .08em;
  padding: 14px 16px;
  border-radius: 999px;
  background: var(--accent-gradient);
  box-shadow: 0 16px 30px rgba(var(--accent-primary-rgb),0.30);
  cursor:pointer;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.auth-submit:hover{ transform: translateY(-1px); box-shadow: 0 18px 40px rgba(var(--accent-primary-rgb),0.38); }

.auth-links{ margin-top: 12px; text-align:center; font-size: .9rem; color:#8b8f98; }
.auth-links a{ color: var(--accent-primary); font-weight: 700; }

.auth-divider{ margin: 20px 0 14px; position:relative; text-align:center; }
.auth-divider::before{ content:""; position:absolute; left:0; right:0; top:50%; height:1px; background:#eceef3; }
.auth-divider span{ position:relative; padding: 0 12px; background:#fff; color:#a3a7b0; font-size: .85rem; }

.auth-social-label{ text-align:center; color:#a3a7b0; font-size: .85rem; margin-bottom: 10px; }
.auth-social-buttons{ display:flex; align-items:center; justify-content:center; gap: 14px; }
.auth-social-btn{
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid #eceef3;
  background: #fff;
  box-shadow: 0 10px 18px rgba(20,20,20,0.06);
  cursor:pointer;
  font-weight: 800;
  color:#6b7280;
}

.auth-foot{ margin-top:auto; padding-top: 22px; text-align:center; color:#a3a7b0; font-size: .82rem; }

.auth-right{
  position:relative;
  background:
    linear-gradient(0deg, rgba(var(--accent-primary-rgb),0.86), rgba(var(--accent-primary-rgb),0.86)),
    url('/assets/img/auth-city.jpg');
  background-size: cover;
  background-position: center;
}

.auth-right::after{
  content:"";
  position:absolute;
  inset:0;
  background: linear-gradient(135deg, rgba(255,255,255,0.10), rgba(0,0,0,0.18));
  mix-blend-mode: overlay;
}

.auth-right-inner{
  position:relative;
  z-index: 1;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  flex-direction:column;
  text-align:center;
  padding: 42px;
  color:#fff;
}

.auth-right-logo{ width: 84px; height:84px; border-radius: 22px; display:flex; align-items:center; justify-content:center; background: rgba(255,255,255,0.18); backdrop-filter: blur(6px); margin-bottom: 14px; overflow:hidden; }
.auth-right-logo img{ width: 44px; height: 44px; object-fit:contain; filter: brightness(1.05); }
.auth-right-title{ font-size: 2.4rem; font-weight: 900; letter-spacing: .03em; }
.auth-right-text{ margin-top: 14px; max-width: 420px; opacity: .95; line-height: 1.55; font-size: .95rem; }

@media (max-width: 900px){
  body.auth-page::before{ width: 420px; height: 420px; left:-220px; top:-260px; }
  body.auth-page::after{ width: 420px; height: 420px; right:-240px; bottom:-260px; }
  .auth-card{ grid-template-columns: 1fr; min-height: unset; }
  .auth-right{ display:none; }
  .auth-left{ padding: 38px 28px 28px; }
}
@keyframes spin { to { transform: rotate(360deg); } }

.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; margin-right: var(--space-sm); }
.status-dot.success { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 8px var(--warning); }
.status-dot.danger { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.status-dot.info { background: var(--info); box-shadow: 0 0 8px var(--info); }
