/* ==========================================================================
   Redesign 2026 — iconografia, topbar, conta, tema claro/escuro.
   Carregado depois de app.css para refinar o design system sem duplicar
   os componentes existentes.
   ========================================================================== */

:root {
  --shadow-pop: 0 16px 40px rgba(20, 30, 40, 0.14);
  --shadow-card: 0 1px 2px rgba(20, 30, 40, 0.04);
}

html[data-theme="dark"] {
  --paper: #0f1317;
  --surface: #161b21;
  --surface-2: #1d242b;
  --ink: #e9eef3;
  --ink-2: #b9c4cf;
  --muted: #8a97a4;
  --line: #29323a;
  --line-strong: #3c4753;
  --accent: #c06a62;
  --accent-strong: #dda096;
  --accent-soft: #2b2223;
  --success: #8fc7a8;
  --success-soft: #1d2c25;
  --warning: #e0b878;
  --warning-soft: #2e2619;
  --danger: #e79a93;
  --danger-soft: #33201f;
  --shadow-pop: 0 18px 44px rgba(0, 0, 0, 0.45);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

html[data-theme="light"] { color-scheme: light; }

/* ------------------------------------------------------------------- Icons */

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn .icon { width: 16px; height: 16px; }

/* ------------------------------------------------------------------ Shell */

.app { grid-template-columns: 256px minmax(0, 1fr); }

.sidebar {
  gap: 22px;
  padding: 20px 14px 18px;
  background: var(--surface);
}

.brand {
  gap: 10px;
  padding: 4px 8px 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 2px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}

.brand-text strong { font-size: 16px; letter-spacing: -0.01em; }
.brand-text small {
  margin-top: 2px;
  font-size: 9.5px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
}

.nav { gap: 2px; }
.nav-label { margin: 16px 10px 6px; font-size: 9.5px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 7px 7px 0;
  font-size: 13.5px;
}

.nav-item .icon { width: 17px; height: 17px; color: var(--muted); }
.nav-item:hover .icon { color: var(--ink-2); }
.nav-item.is-active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
}
.nav-item.is-active .icon { color: var(--accent); }

.env-chip { border-radius: 5px; font-size: 9.5px; }
.sidebar-note { font-size: 11px; }

/* ------------------------------------------------------------------ Topbar */

.topbar {
  display: grid;
  grid-template-columns: auto minmax(220px, 420px) auto;
  align-items: center;
  gap: 24px;
  padding: 12px 28px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-title h1 { font-size: 19px; margin-top: 1px; }
.topbar-eyebrow { font-size: 9.5px; }

.topbar-search {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 0 12px;
  background: var(--surface-2);
  border: 1px solid transparent;
  border-radius: 8px;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.topbar-search:focus-within {
  background: var(--surface);
  border-color: var(--line-strong);
}
.topbar-search .icon { width: 16px; height: 16px; color: var(--muted); }
.topbar-search input {
  width: 100%;
  min-height: 38px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  outline: none;
}
.topbar-search input::placeholder { color: var(--muted); }

.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 8px;
  color: var(--muted);
  font-size: 11.5px;
  white-space: nowrap;
}
.topbar-dot { color: var(--line-strong); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid transparent;
  border-radius: 50%;
  background: transparent;
  color: var(--ink-2);
  cursor: pointer;
  text-decoration: none;
}
.icon-btn:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.icon-btn .icon { width: 17px; height: 17px; }

.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="dark"] .theme-toggle .icon-sun { display: block; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ------------------------------------------------------------------- Conta */

.user-menu { position: relative; margin-left: 4px; }
.avatar-btn {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  padding: 2px 4px 2px 2px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}
.avatar-btn:hover { background: var(--surface-2); }
.avatar {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.avatar .icon { width: 18px; height: 18px; }
.icon-chevron { width: 13px; height: 13px; color: var(--muted); }

.user-pop {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: 224px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-pop);
  z-index: 60;
}
.user-pop[hidden] { display: none; }
.user-pop-head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 8px 10px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 5px;
}
.user-pop-head strong { font-size: 13px; }
.user-pop-head span { color: var(--muted); font-size: 11.5px; }
.user-pop-form { margin: 0; }
.user-pop-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  text-decoration: none;
}
.user-pop-item:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.user-pop-item .icon { width: 15px; height: 15px; color: var(--muted); }

/* ------------------------------------------------------------------ Content */

.content { max-width: 1240px; padding: 28px 32px 36px; gap: 18px; }

.page-intro { display: flex; flex-direction: column; gap: 2px; }
.page-date {
  color: var(--muted);
  font-size: 11.5px;
  letter-spacing: 0.01em;
}
.greeting {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: -0.015em;
}
.page-sub { color: var(--ink-2); font-size: 13px; }

/* --------------------------------------------------------------------- Hero */

.hero-card {
  gap: 22px;
  padding: 24px 26px;
  border-radius: 12px;
  box-shadow: var(--shadow-card);
}
.hero-copy h2 { font-size: 26px; margin: 4px 0 6px; }
.hero-copy p { font-size: 13.5px; line-height: 1.6; }
.hero-eyebrow { font-size: 9.5px; }

.hero-range {
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-self: stretch;
  justify-content: center;
  padding: 18px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.range-caption {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.range-flow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.range-arrow { width: 17px; height: 17px; color: var(--muted); }
.range-hint { color: var(--muted); font-size: 11px; line-height: 1.45; }
.range-meta {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.range-meta dt { color: var(--muted); font-size: 9.5px; text-transform: uppercase; letter-spacing: 0.08em; }
.range-meta dd { font-size: 13px; font-weight: 600; font-variant-numeric: tabular-nums; }

/* ---------------------------------------------------------------------- KPI */

.kpi { position: relative; padding: 18px; border-radius: 10px; box-shadow: var(--shadow-card); }
.kpi-icon {
  position: absolute;
  top: 16px;
  right: 16px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  color: var(--muted);
}
.kpi-icon .icon { width: 15px; height: 15px; }
.kpi-value { font-size: 28px; }

.panel { border-radius: 12px; box-shadow: var(--shadow-card); }
.panel-head h2 { font-size: 17px; }

/* -------------------------------------------------------------------- Login */

.auth-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 48px 24px;
  background: var(--paper);
}
.auth-panel {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
  padding: 0;
}
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.auth-seal {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  margin-bottom: 4px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  color: var(--accent);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.08em;
}
.auth-brand h1 {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  line-height: 1.25;
}
.auth-brand p {
  color: var(--muted);
  font-size: 9.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.auth-card {
  width: 100%;
  padding: 30px 28px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 12px 34px rgba(31, 27, 22, 0.08);
}
.auth-eyebrow { font-size: 9.5px; }
.auth-card h2 { margin: 4px 0 5px; font-size: 27px; font-family: var(--font-display); }
.auth-hint { margin-bottom: 20px; font-size: 12.5px; }
.auth-card .alert { margin-bottom: 16px; }
.auth-foot { margin-top: 18px; font-size: 11.5px; }
.auth-meta { color: var(--muted); font-size: 10.5px; letter-spacing: 0.04em; }

.input-wrap { position: relative; }
.input-wrap .input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}
.input-wrap input { min-height: 42px; padding-left: 38px; }
.input-wrap input[type="password"] { padding-right: 44px; }
.password-toggle {
  position: absolute;
  right: 5px;
  top: 50%;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  transform: translateY(-50%);
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.password-toggle:hover { background: var(--surface-2); color: var(--ink-2); }
.password-toggle .icon { width: 17px; height: 17px; }
.password-toggle .icon-hide { display: none; }
.password-toggle.is-visible .icon-show { display: none; }
.password-toggle.is-visible .icon-hide { display: block; }

/* ------------------------------------------------------------- Dark details */

[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--surface-2);
  color: var(--ink);
}
[data-theme="dark"] select option {
  background: var(--surface-2);
  color: var(--ink);
}

[data-theme="dark"] .chip-success { border-color: #315a46; }
[data-theme="dark"] .chip-warning { border-color: #5c482a; }
[data-theme="dark"] .chip-danger { border-color: #5c3230; }

[data-theme="dark"] .alert-success { border-color: #315a46; color: #c9e6d5; }
[data-theme="dark"] .alert-warning { border-color: #5c482a; color: #ecd3a8; }
[data-theme="dark"] .alert-danger { border-color: #5c3230; color: #efb9b4; }

[data-theme="dark"] .preview-note { border-color: #4a302c; }
[data-theme="dark"] .auth-card { box-shadow: 0 18px 44px rgba(0, 0, 0, 0.4); }
[data-theme="dark"] .btn-primary,
[data-theme="dark"] .btn-danger { color: #16110f; }

/* Coluna do número um pouco mais larga, como no modelo impresso. */
.doc-block { grid-template-columns: 7% 49% 44%; }
.doc-number { padding: 0.3em 0.4em; }

/* --------------------------------------------------------------- Responsivo */

@media (max-width: 1200px) {
  .topbar-meta { display: none; }
}

@media (max-width: 960px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    height: auto;
    padding: 12px 16px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .brand { padding: 0; border-bottom: 0; margin-bottom: 0; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav-item { border-left: 0; border-radius: 7px; }
  .nav-label, .sidebar-foot { display: none; }
  .topbar { grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; padding: 12px 20px; }
  .content { padding: 22px 20px 30px; }
}

@media (max-width: 760px) {
  .topbar { grid-template-columns: minmax(0, 1fr) auto; }
  .topbar-title { display: none; }
  .topbar-search { grid-column: 1 / -1; grid-row: 2; }
  .topbar-actions { grid-column: 2; grid-row: 1; }
  .greeting { font-size: 26px; }
  .hero-card { padding: 20px; }
  .range-flow { font-size: 22px; }
  .auth-shell { padding: 32px 18px; }
  .auth-card { padding: 24px 20px; }
}

.choice-grid { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 12px; }
@media (max-width: 640px) { .choice-grid { grid-template-columns: 1fr; } }
