:root {
  --navy: #10184A;
  --accent: #1A2FB5;
  --accent-light: #E7EAFB;
  --accent-light-2: #5B76E0;
  --bg: #F4F6FB;
  --card-bg: #FFFFFF;
  --card-border: #E7E9F3;
  --card-border-light: #EEF0F7;
  --text: #202538;
  --text-muted: #7C8CA0;
  --text-faint: #A6ACC0;
  --success-bg: #E8F5EB;
  --success-text: #1E7A34;
  --danger-text: #B3261E;
  --warning-bg: #FDF3E3;
  --warning-text: #8A6412;
  --field-border: #DCE0EE;
  --shadow-card: 0 1px 2px rgba(16,24,74,0.05);
}

/* Tema escuro — aplicado via <html data-theme="escuro">, definido em Configurações */
[data-theme="escuro"] {
  --bg: #12172B;
  --card-bg: #1B2138;
  --card-border: #2B3350;
  --card-border-light: #262D48;
  --text: #EBEDF5;
  --text-muted: #97A0BE;
  --text-faint: #6B7394;
  --field-border: #343C5C;
  --success-bg: #16321F;
  --success-text: #4ADE80;
  --danger-text: #F87171;
  --warning-bg: #3A2E12;
  --warning-text: #FBBF24;
  --shadow-card: 0 1px 3px rgba(0,0,0,0.35);
}

[data-theme="escuro"] body { background: var(--bg); }
[data-theme="escuro"] .alert-error { background: #3A1616; }
[data-theme="escuro"] .accent-light-tint { background: rgba(26,47,181,0.25); }

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
}

.display {
  font-family: 'Inter', sans-serif; font-weight: 700;
}

a { color: inherit; text-decoration: none; }

/* Layout geral */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: var(--navy);
  color: var(--bg);
  display: flex;
  flex-direction: column;
  padding: 32px 0;
}

.sidebar-logo {
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 22px;
  padding: 0 28px 36px 28px;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.sidebar-section-title {
  padding: 14px 28px 6px 28px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.45;
}

.sidebar-nav > .sidebar-section-title:first-child { padding-top: 0; }

.nav-item {
  padding: 10px 28px;
  font-size: 14px;
  opacity: 0.7;
  display: flex;
  align-items: center;
  gap: 11px;
}

.nav-item.active {
  background: rgba(244,246,251,0.08);
  border-left: 3px solid var(--accent);
  font-weight: 600;
  opacity: 1;
}

.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.sidebar-user {
  padding: 0 28px;
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0.85;
  font-size: 13.5px;
}

.avatar-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
}

.sidebar-brand {
  padding: 14px 28px 0 28px;
  border-top: 1px solid rgba(244,246,251,0.1);
  font-size: 11px;
  letter-spacing: 0.2px;
  opacity: 0.55;
}

.main-content {
  flex: 1;
  padding: 40px 48px;
  overflow-x: hidden;
}

/* Layout: menu de topo (alternativa ao menu lateral) */
.app-shell-topo { flex-direction: column; min-height: 100vh; }

.topbar {
  height: 60px;
  flex-shrink: 0;
  background: var(--navy);
  color: #F4F6FB;
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 28px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: 'Inter', sans-serif; font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.topbar-brand img { width: 24px; height: 24px; object-fit: contain; border-radius: 4px; background: #FFFFFF; }

.topbar-nav {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 2px;
  overflow-x: auto;
}

.topbar-item {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 13px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 500;
  opacity: 0.72;
  white-space: nowrap;
  flex-shrink: 0;
}

.topbar-item.active {
  background: rgba(244,246,251,0.1);
  opacity: 1;
  font-weight: 600;
}

.topbar-user { display: flex; align-items: center; gap: 14px; flex-shrink: 0; }
.topbar-user a { display: flex; }

.ead-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(244,246,251,0.1);
  color: #F4F6FB;
  padding: 7px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
}

.main-content-topo { padding: 32px 40px; }

/* Layout: ícones com submenu (rail + flyout ao passar o mouse) */
.app-shell-icones { flex-direction: column; min-height: 100vh; }

.icones-body { flex: 1; display: flex; min-height: 0; }

.icon-rail {
  width: 64px;
  flex-shrink: 0;
  background: var(--card-bg);
  border-right: 1px solid var(--card-border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 10px;
}

.icon-rail-item { position: relative; width: 100%; }

.icon-rail-link {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 52px;
  font-size: 22px;
  line-height: 1;
}

.icon-rail-item.active .icon-rail-link { background: var(--accent); }
.icon-rail-item:hover .icon-rail-link { background: var(--accent-light); }
.icon-rail-item.active:hover .icon-rail-link { background: var(--accent); }

.icon-flyout {
  position: absolute;
  top: 0;
  left: 64px;
  min-width: 220px;
  background: var(--navy);
  border-radius: 0 10px 10px 0;
  box-shadow: 4px 4px 16px rgba(0,0,0,0.18);
  padding: 14px 0;
  z-index: 40;
  display: none;
  flex-direction: column;
}

.icon-rail-item:hover .icon-flyout { display: flex; }

.icon-flyout-title {
  color: #FFFFFF;
  font-weight: 700;
  font-size: 13px;
  padding: 0 20px 10px 20px;
  border-bottom: 1px solid rgba(244,246,251,0.12);
  margin-bottom: 6px;
}

.icon-flyout a {
  color: rgba(244,246,251,0.85);
  font-size: 13.5px;
  padding: 9px 20px;
}

.icon-flyout a:hover { background: rgba(244,246,251,0.08); color: #FFFFFF; }

.main-content-icones { padding: 32px 40px; flex: 1; overflow-x: hidden; }

/* Cartões */
.card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}

.card-flat {
  background: var(--card-bg);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(16,24,74,0.05);
}

/* Cabeçalho de boas-vindas com relógio */
.welcome-card {
  background: var(--card-bg);
  border-radius: 14px;
  padding: 24px 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-card);
  margin-bottom: 28px;
}

.welcome-clock {
  font-size: 34px;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.5px;
}

/* Botões */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border-radius: 6px;
  padding: 9px 18px;
  font-size: 13.5px;
  font-weight: 600;
  border: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #FFFFFF;
}

.btn-outline {
  border: 1px solid var(--field-border);
  background: var(--card-bg);
  color: var(--text);
}

/* Badges de status */
.badge {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 20px;
  font-weight: 600;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }

/* Login — split screen */
.login-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 73% 27%;
}

.login-hero {
  position: relative;
  overflow: hidden;
  background: linear-gradient(135deg, var(--navy) 0%, var(--accent) 130%);
  display: flex;
  align-items: center;
  padding: 0 64px;
}

.login-hero-blob {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}

.login-hero-blob-1 { width: 340px; height: 340px; top: -120px; right: -100px; }
.login-hero-blob-2 { width: 220px; height: 220px; bottom: -80px; left: -60px; background: rgba(255,255,255,0.06); }

.login-hero-content { position: relative; z-index: 1; color: #FFFFFF; max-width: 420px; }

.login-hero-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
  opacity: 0.85;
  margin-bottom: 28px;
}

.login-hero-brand img { width: 20px; height: 20px; object-fit: contain; border-radius: 4px; background: #FFFFFF; }

.login-hero-content h1 {
  font-family: 'Inter', sans-serif;
  font-size: 34px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 14px 0;
}

.login-hero-content p { font-size: 15px; opacity: 0.85; margin: 0; }

.login-panel {
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-panel-inner { width: 100%; max-width: 380px; padding: 0 32px; }

.login-panel-inner h2 {
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 26px;
  margin: 0 0 6px 0;
}

.login-sub {
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.field-group { margin-bottom: 16px; }

.field-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.field-group input {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 11px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
}

.field-group input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.btn-block { width: 100%; justify-content: center; padding: 12px; font-size: 14px; margin-top: 6px; }

.alert-error {
  background: #FBEAEA;
  color: var(--danger-text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 13px;
  margin-bottom: 16px;
}

/* Páginas de listagem (cadastros) */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.page-header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 400;
}

.search-box {
  margin-bottom: 18px;
}

.search-box input {
  width: 320px;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table th {
  text-align: left;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 20px;
  border-bottom: 1px solid var(--card-border);
}

.data-table td {
  padding: 14px 20px;
  border-bottom: 1px solid var(--card-border-light);
  vertical-align: middle;
}

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

.data-table .row-muted { opacity: 0.5; }

.link-action {
  color: var(--accent);
  font-weight: 600;
  font-size: 13px;
}

.link-action-danger {
  color: var(--danger-text);
  font-weight: 600;
  font-size: 13px;
}

.status-pill {
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
}

.status-pill.on { background: var(--success-bg); color: var(--success-text); }
.status-pill.off { background: #F1F2F8; color: var(--text-muted); }

.empty-state {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* Formulários (cadastros) */
.form-card {
  background: var(--card-bg);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  padding: 28px;
  max-width: 720px;
}

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

.form-group { margin-bottom: 4px; }
.form-group.span-2 { grid-column: span 2; }

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  border: 1px solid var(--field-border);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--card-bg);
  color: var(--text);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.form-error {
  color: var(--danger-text);
  font-size: 12px;
  margin-top: 4px;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 24px;
}
