/* =========================================================================
   Portal do Contador · Efige — Design System PREMIUM
   Inspiração: Stripe · Vercel · Linear · Notion · Supabase · Clerk
   Identidade: azul Efige #0088ff. Verde = status de sucesso (semântico).
   ========================================================================= */

:root {
  /* Marca */
  --primary: #0088ff;
  --primary-strong: #0069c8;
  --primary-deep: #024e94;
  --primary-soft: #e8f3ff;
  --primary-tint: #f3f9ff;
  --primary-rgb: 0, 136, 255;

  /* Superfícies / texto */
  --bg: #f6f8fc;
  --bg-grad-a: #f7f9fd;
  --bg-grad-b: #eef3fa;
  --surface: #ffffff;
  --surface-soft: #f1f5fa;
  --surface-alt: #f8fafd;
  --text: #0d1526;
  --text-soft: #35435b;
  --muted: #6a7890;
  --faint: #93a1b5;
  --line: #e7ecf3;
  --line-soft: #eef2f7;
  --line-strong: #d4dde8;

  /* Estados semânticos */
  --accent: #6366f1;
  --accent-soft: #eef0fe;
  --warning: #b7791f;
  --warning-soft: #fff6e6;
  --danger: #d5322b;
  --danger-soft: #fdecea;
  --success: #12855a;
  --success-soft: #e4f6ee;
  --info: #0a7ea4;
  --info-soft: #e4f5fb;

  /* Navy da sidebar */
  --navy: #0b1220;
  --navy-2: #0e1729;
  --navy-line: rgba(255, 255, 255, 0.09);

  /* Raios */
  --radius-xs: 7px;
  --radius-sm: 9px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;

  /* Sombras em camadas (estilo Stripe/Linear) */
  --shadow-xs: 0 1px 2px rgba(13, 21, 38, 0.06);
  --shadow-sm: 0 1px 2px rgba(13, 21, 38, 0.06), 0 1px 3px rgba(13, 21, 38, 0.05);
  --shadow: 0 2px 4px rgba(13, 21, 38, 0.04), 0 6px 16px rgba(13, 21, 38, 0.07);
  --shadow-md: 0 4px 10px rgba(13, 21, 38, 0.06), 0 12px 28px rgba(13, 21, 38, 0.10);
  --shadow-lg: 0 10px 24px rgba(13, 21, 38, 0.10), 0 30px 60px rgba(13, 21, 38, 0.16);
  --ring: 0 0 0 3px rgba(var(--primary-rgb), 0.18);
  --ring-danger: 0 0 0 3px rgba(213, 50, 43, 0.16);

  /* Movimento */
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --fast: 0.14s;
  --med: 0.24s;

  --sidebar-w: 258px;
}

* { box-sizing: border-box; }
html { font-size: 15.5px; -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(1200px 600px at 100% -5%, rgba(var(--primary-rgb), 0.05), transparent 60%),
    linear-gradient(180deg, var(--bg-grad-a), var(--bg-grad-b));
  background-attachment: fixed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.006em;
}

button, input, select, textarea { font: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
h1, h2, h3, h4 { letter-spacing: -0.02em; }

svg.lucide { width: 18px; height: 18px; stroke-width: 2; }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-thumb { background: #cfd9e6; border-radius: 999px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9c6d6; background-clip: content-box; }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ---------- utilitários ---------- */
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.flex { display: flex; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.center { display: flex; align-items: center; gap: 10px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; }
.gap-sm { gap: 8px; }
.mt { margin-top: 16px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.hidden { display: none !important; }

@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

/* =========================================================================
   Botões
   ========================================================================= */
.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text-soft);
  --btn-bd: var(--line-strong);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 15px;
  border: 1px solid var(--btn-bd); border-radius: var(--radius-sm);
  background: var(--btn-bg); color: var(--btn-fg); font-weight: 600; font-size: .9rem;
  cursor: pointer; white-space: nowrap; position: relative; isolation: isolate;
  box-shadow: var(--shadow-xs);
  transition: transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease),
              background var(--fast) var(--ease), border-color var(--fast) var(--ease), filter var(--fast) var(--ease);
}
.btn:hover { background: var(--surface-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.btn:active { transform: translateY(0) scale(.985); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn.primary {
  --btn-fg: #fff; --btn-bd: transparent; color: #fff;
  background: linear-gradient(180deg, #1a93ff, var(--primary));
  box-shadow: 0 1px 2px rgba(var(--primary-rgb), .35), 0 6px 16px rgba(var(--primary-rgb), .28);
}
.btn.primary:hover { background: linear-gradient(180deg, var(--primary), var(--primary-strong)); box-shadow: 0 2px 6px rgba(var(--primary-rgb), .4), 0 10px 22px rgba(var(--primary-rgb), .32); }
.btn.accent { --btn-fg: #fff; --btn-bd: transparent; color: #fff; background: linear-gradient(180deg, #7577f5, var(--accent)); box-shadow: 0 6px 16px rgba(99,102,241,.28); }
.btn.ghost { --btn-bd: transparent; --btn-bg: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--surface-soft); }
.btn.danger { --btn-fg: var(--danger); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.sm { min-height: 33px; padding: 0 11px; font-size: .84rem; gap: 6px; border-radius: var(--radius-xs); }
.btn.block { width: 100%; }
.btn svg.lucide { width: 16px; height: 16px; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex: 0 0 40px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text-soft); cursor: pointer;
  position: relative; box-shadow: var(--shadow-xs);
  transition: background var(--fast) var(--ease), transform var(--fast) var(--ease), box-shadow var(--fast) var(--ease), color var(--fast);
}
.icon-btn:hover { background: var(--surface-soft); transform: translateY(-1px); box-shadow: var(--shadow-sm); }
.icon-btn:active { transform: translateY(0); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn.ghost { border-color: transparent; background: transparent; box-shadow: none; }
.icon-btn.ghost:hover { background: var(--surface-soft); }
.icon-btn .dot { position: absolute; top: 7px; right: 8px; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); border: 2px solid var(--surface); animation: pulse-dot 2s infinite; }
@keyframes pulse-dot { 0%, 100% { box-shadow: 0 0 0 0 rgba(213,50,43,.4); } 50% { box-shadow: 0 0 0 4px rgba(213,50,43,0); } }

.link-btn { border: 0; background: none; padding: 0; color: var(--primary); font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }

/* =========================================================================
   Badges / status
   ========================================================================= */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  min-height: 22px; padding: 2px 9px; border-radius: 999px;
  font-size: .74rem; font-weight: 650; line-height: 1; white-space: nowrap;
  border: 1px solid transparent;
}
.badge .dot-i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0); }
.badge.success { background: var(--success-soft); color: var(--success); border-color: rgba(18,133,90,.14); }
.badge.danger  { background: var(--danger-soft);  color: var(--danger);  border-color: rgba(213,50,43,.14); }
.badge.warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(183,121,31,.16); }
.badge.info    { background: var(--info-soft);    color: var(--info);    border-color: rgba(10,126,164,.14); }
.badge.muted   { background: var(--surface-soft); color: var(--muted);   border-color: var(--line); }
.badge.primary { background: var(--primary-soft); color: var(--primary-strong); border-color: rgba(var(--primary-rgb),.16); }
.badge.outline { background: transparent; border-color: var(--line-strong); color: var(--text-soft); }

/* =========================================================================
   Login
   ========================================================================= */
.auth { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; }
.auth-brand {
  position: relative; overflow: hidden; padding: 60px 64px;
  color: #eaf2ff; display: flex; flex-direction: column; justify-content: space-between;
  background:
    radial-gradient(60% 46% at 14% 6%, rgba(0, 136, 255, .32), transparent 62%),
    radial-gradient(46% 38% at 96% 14%, rgba(0, 136, 255, .14), transparent 65%),
    radial-gradient(50% 42% at 88% 92%, rgba(0, 136, 255, .16), transparent 62%),
    linear-gradient(165deg, #060a14 0%, #0a1730 36%, #0d2547 70%, #0a3a70 100%);
}
/* textura discreta de pontos + linhas técnicas */
.auth-brand::after {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: .55; z-index: 0;
  background-image:
    radial-gradient(rgba(255,255,255,.09) 1px, transparent 1px),
    linear-gradient(rgba(0,136,255,.05) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,136,255,.05) 1px, transparent 1px);
  background-size: 22px 22px, 88px 88px, 88px 88px;
  mask-image: radial-gradient(650px 560px at 22% 26%, #000, transparent 78%);
}
.auth-brand > * { position: relative; z-index: 1; }

/* brilho radial suave atrás do título */
.auth-glow {
  position: absolute; z-index: 0; pointer-events: none; left: -6%; top: 4%;
  width: 560px; height: 560px; max-width: 80%;
  background: radial-gradient(circle, rgba(0,136,255,.32) 0%, rgba(0,136,255,.10) 42%, transparent 72%);
  filter: blur(6px);
}

/* elementos decorativos: círculos, curvas e pontos luminosos */
.auth-decor { position: absolute; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.auth-decor .decor-curve { position: absolute; inset: 0; width: 100%; height: 100%; opacity: .55; }
.auth-decor .decor-circle { position: absolute; border-radius: 50%; border: 1px solid rgba(0,136,255,.18); }
.auth-decor .c1 { width: 300px; height: 300px; right: -110px; top: -90px; border-color: rgba(0,136,255,.22); }
.auth-decor .c2 { width: 190px; height: 190px; left: -70px; bottom: 64px; }
.auth-decor .decor-dot { position: absolute; width: 5px; height: 5px; border-radius: 50%; background: #4db4ff; box-shadow: 0 0 12px 3px rgba(0,136,255,.65); opacity: .8; }
.auth-decor .d1 { top: 20%; right: 16%; }
.auth-decor .d2 { top: 58%; right: 9%; width: 4px; height: 4px; }
.auth-decor .d3 { bottom: 22%; left: 13%; }

.auth-logo { position: relative; margin-bottom: 28px; }
.auth-logo::before {
  content: ""; position: absolute; inset: -18px -18px 30px -18px; z-index: 0; pointer-events: none;
  background: radial-gradient(60% 70% at 30% 40%, rgba(0, 136, 255, .22), transparent 72%);
  filter: blur(14px);
}
.auth-logo-img { position: relative; z-index: 1; display: block; width: 224px; height: auto; max-width: 100%; }
.auth-logo-sub { position: relative; z-index: 1; display: block; margin-top: 8px; font-size: .8rem; letter-spacing: .02em; color: var(--muted); }

.auth-headline { max-width: 500px; }
.auth-headline h1 { font-size: 2.4rem; font-weight: 750; line-height: 1.16; letter-spacing: -0.025em; margin: 0 0 18px; color: #f4f9ff; }
.auth-headline h1 .hl { color: #4db4ff; }
.auth-headline p { max-width: 430px; color: rgba(255,255,255,.66); line-height: 1.65; margin: 0; }

.auth-points { display: grid; gap: 12px; margin-top: 34px; max-width: 460px; }
.auth-point {
  display: flex; gap: 13px; align-items: flex-start; padding: 15px 16px;
  border-radius: var(--radius-lg);
  background: linear-gradient(180deg, rgba(255,255,255,.055), rgba(255,255,255,.025));
  border: 1px solid rgba(0,136,255,.18);
  box-shadow: 0 1px 2px rgba(2,8,20,.3), 0 10px 24px rgba(2,8,20,.22);
  backdrop-filter: blur(8px);
  transition: background var(--med) var(--ease), border-color var(--med) var(--ease), transform var(--med) var(--ease);
}
.auth-point:hover { background: linear-gradient(180deg, rgba(255,255,255,.09), rgba(255,255,255,.04)); border-color: rgba(0,136,255,.36); transform: translateY(-2px); }
.auth-point .ic { flex: 0 0 38px; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 11px; background: rgba(0,136,255,.16); border: 1px solid rgba(0,136,255,.24); color: #7cc4ff; }
.auth-point b { display: block; font-size: .95rem; color: #f2f7ff; }
.auth-point span { color: rgba(255,255,255,.56); font-size: .85rem; line-height: 1.4; }
.auth-foot { color: rgba(255,255,255,.55); font-size: .8rem; }

.auth-form-wrap { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 404px; animation: rise var(--med) var(--ease-out); }
.auth-card h2 { margin: 0 0 5px; font-size: 1.55rem; }
.auth-card .sub { margin: 0 0 26px; color: var(--muted); }

/* =========================================================================
   Formulários
   ========================================================================= */
.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > label { font-size: .82rem; font-weight: 600; color: var(--text-soft); }
.field .hint { font-size: .78rem; color: var(--muted); }
.control {
  width: 100%; min-height: 42px; padding: 0 13px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); box-shadow: var(--shadow-xs);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease), background var(--fast);
}
.control::placeholder { color: var(--faint); }
.control:hover { border-color: #c0ccdb; }
textarea.control { padding: 10px 13px; min-height: 92px; resize: vertical; }
.control:focus { outline: none; border-color: var(--primary); box-shadow: var(--ring); }
.control.invalid { border-color: var(--danger); box-shadow: var(--ring-danger); }
select.control { cursor: pointer; }
input[type="date"].control { cursor: pointer; }
.input-icon { position: relative; }
.input-icon .control { padding-left: 40px; }
.input-icon > svg.lucide, .input-icon > .lucide { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.input-icon .toggle-pass { position: absolute; right: 5px; top: 50%; transform: translateY(-50%); }
.form-error { color: var(--danger); font-size: .82rem; margin-top: 4px; display: flex; gap: 6px; align-items: center; }

.alert { display: flex; gap: 10px; padding: 12px 14px; border-radius: var(--radius-sm); font-size: .88rem; align-items: flex-start; border: 1px solid transparent; animation: rise var(--fast) var(--ease-out); }
.alert.error { background: var(--danger-soft); color: #8a201a; border-color: rgba(213,50,43,.16); }
.alert.info { background: var(--primary-soft); color: #0a4c86; border-color: rgba(var(--primary-rgb),.16); }
.alert.warning { background: var(--warning-soft); color: var(--warning); border-color: rgba(183,121,31,.16); }
.alert svg.lucide { flex: 0 0 18px; margin-top: 1px; }

.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 42px; height: 24px; border-radius: 999px; background: var(--line-strong); transition: background var(--med) var(--ease); position: relative; flex: 0 0 42px; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left var(--med) var(--ease-out); box-shadow: var(--shadow-sm); }
.switch input:checked + .track { background: linear-gradient(180deg, #1a93ff, var(--primary)); }
.switch input:checked + .track::after { left: 21px; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* =========================================================================
   App shell
   ========================================================================= */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: 100vh; }

.sidebar {
  position: sticky; top: 0; align-self: start; height: 100vh;
  display: flex; flex-direction: column; gap: 3px; padding: 18px 13px;
  color: #b7c4da;
  background:
    radial-gradient(120% 60% at 100% -12%, rgba(0, 136, 255, .26), transparent 52%),
    radial-gradient(90% 55% at -18% 108%, rgba(0, 136, 255, .12), transparent 60%),
    linear-gradient(165deg, #0e2e5c 0%, #0a1f42 20%, #071531 46%, #050e22 70%, #030710 100%);
  border-right: 1px solid rgba(0, 136, 255, .14);
  overflow-y: auto; overflow-x: hidden;
}
/* textura muito discreta, só perto do topo — não compete com o menu */
.sidebar::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; z-index: 0; opacity: .4;
  background-image: radial-gradient(rgba(255,255,255,.08) 1px, transparent 1px);
  background-size: 20px 20px;
  mask-image: linear-gradient(180deg, #000 0%, transparent 46%);
}
.sidebar > * { position: relative; z-index: 1; }
.sidebar::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); background-clip: content-box; border: none; }

.sidebar .brand { position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 7px; padding: 16px 8px 22px; margin-bottom: 6px; border-bottom: 1px solid rgba(0, 136, 255, .12); }
.sidebar .brand::before {
  content: ""; position: absolute; inset: -12px -12px 26px -12px; z-index: 0; pointer-events: none;
  background: radial-gradient(60% 75% at 26% 40%, rgba(0, 136, 255, .32), transparent 72%);
  filter: blur(11px);
}
.sidebar .brand .brand-logo { position: relative; z-index: 1; display: block; width: 172px; height: auto; max-width: 100%; }
.sidebar .brand .brand-sub { position: relative; z-index: 1; padding-left: 2px; font-size: .72rem; letter-spacing: .03em; color: #83a0c4; }

.nav-group-label { padding: 18px 12px 8px; font-size: .66rem; letter-spacing: .12em; text-transform: uppercase; color: #6f88ab; font-weight: 700; }

.nav-item {
  display: flex; align-items: center; gap: 11px; min-height: 40px; padding: 0 11px;
  border-radius: var(--radius-sm); color: #93a5c0; font-weight: 550; font-size: .9rem;
  cursor: pointer; position: relative; transition: background var(--fast) var(--ease), color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.nav-item svg.lucide { width: 17px; height: 17px; color: #7387a6; opacity: .9; transition: transform var(--fast) var(--ease), color var(--fast) var(--ease), opacity var(--fast) var(--ease); }
.nav-item:hover { background: rgba(0, 136, 255, .10); color: #eef5ff; }
.nav-item:hover svg.lucide { color: #bcdcff; opacity: 1; transform: translateX(1px); }
.nav-item:focus-visible { outline: none; box-shadow: var(--ring); background: rgba(0, 136, 255, .12); color: #fff; }
.nav-item.active { background: linear-gradient(90deg, rgba(0, 136, 255, .32), rgba(0, 136, 255, .07)); color: #fff; box-shadow: inset 0 0 0 1px rgba(0, 136, 255, .22), 0 4px 14px rgba(0, 136, 255, .16); }
.nav-item.active svg.lucide { opacity: 1; color: #fff; }
.nav-item.active::before { content: ""; position: absolute; left: -13px; top: 50%; transform: translateY(-50%); width: 3px; height: 20px; border-radius: 0 3px 3px 0; background: var(--primary); box-shadow: 0 0 10px rgba(0, 136, 255, .65); }
.nav-item .badge { margin-left: auto; }

.sidebar-foot {
  margin-top: auto; padding: 10px; border: 1px solid rgba(0, 136, 255, .10); border-radius: var(--radius);
  background: rgba(255,255,255,.035); display: flex; gap: 10px; align-items: center;
  transition: background var(--med) var(--ease), border-color var(--med) var(--ease);
}
.sidebar-foot:hover { background: rgba(255,255,255,.06); border-color: rgba(0, 136, 255, .2); }
.sidebar-foot .avatar { flex: 0 0 36px; box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 0 0 1px rgba(0, 136, 255, .22), 0 2px 8px rgba(0, 136, 255, .25); }
.sidebar-foot b { display: block; font-size: .85rem; color: #fff; }
.sidebar-foot span { font-size: .74rem; color: #8296b5; }

.avatar { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; font-weight: 700; font-size: .82rem; color: #fff; background: linear-gradient(160deg, #2a9bff, var(--primary-strong)); box-shadow: inset 0 1px 0 rgba(255,255,255,.25), 0 2px 6px rgba(var(--primary-rgb),.3); }
.avatar.lg { width: 46px; height: 46px; font-size: 1rem; border-radius: 13px; }

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

.topbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px;
  padding: 11px 22px; background: rgba(250, 251, 253, 0.8);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--line);
}
.topbar .menu-toggle { display: none; }
.topbar .crumbs { font-size: .82rem; color: var(--muted); }
.topbar .crumbs b { color: var(--text); font-weight: 600; }
.topbar .search { flex: 1; max-width: 430px; }
.topbar .spacer { flex: 1; }
.userchip { display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 5px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); cursor: pointer; box-shadow: var(--shadow-xs); transition: background var(--fast) var(--ease), box-shadow var(--fast) var(--ease), border-color var(--fast); }
.userchip:hover { background: var(--surface-soft); box-shadow: var(--shadow-sm); border-color: var(--line-strong); }
.userchip b { font-size: .84rem; }
.userchip span { font-size: .74rem; color: var(--muted); }
.userchip .chev { color: var(--faint); transition: transform var(--fast) var(--ease); }
.userchip[aria-expanded="true"] .chev { transform: rotate(180deg); }

/* Menu de perfil */
.menu {
  position: absolute; top: 58px; right: 22px; z-index: 40; width: 250px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 6px; animation: pop-in var(--fast) var(--ease-out); transform-origin: top right;
}
/* Painel de notificações: mesmo componente do menu de perfil, ancorado sob o
   sino em vez do chip de usuário — mais largo pra caber "N documentos — Cliente". */
.notif-menu { right: 245px; width: 300px; max-height: 70vh; overflow-y: auto; }
.menu-head { display: flex; gap: 10px; align-items: center; padding: 10px; border-bottom: 1px solid var(--line-soft); margin-bottom: 6px; }
.menu-head b { display: block; font-size: .88rem; }
.menu-head span { font-size: .76rem; color: var(--muted); word-break: break-all; }
.menu-item { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border: 0; background: none; border-radius: var(--radius-xs); color: var(--text-soft); font-size: .88rem; font-weight: 550; cursor: pointer; text-align: left; transition: background var(--fast) var(--ease); }
.menu-item:hover { background: var(--surface-soft); }
.menu-item.danger { color: var(--danger); }
.menu-item.danger:hover { background: var(--danger-soft); }
.menu-item svg.lucide { width: 16px; height: 16px; color: var(--faint); }
.menu-item.danger svg.lucide { color: var(--danger); }

.page { padding: 26px; max-width: 1460px; width: 100%; margin: 0 auto; animation: fadein var(--med) var(--ease); }
.page-head { margin-bottom: 22px; }
.page-head .eyebrow { color: var(--primary); font-size: .72rem; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; margin: 0 0 7px; }
.page-head h1 { margin: 0; font-size: 1.72rem; }
.page-head p { margin: 7px 0 0; color: var(--muted); max-width: 720px; line-height: 1.55; }

/* =========================================================================
   Cards / painéis
   ========================================================================= */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); transition: box-shadow var(--med) var(--ease), transform var(--med) var(--ease), border-color var(--med) var(--ease); }
.card:hover { box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--line-soft); flex-wrap: wrap; row-gap: 10px; }
.card-head .input-icon.search-field { flex: 1 1 280px; max-width: 620px; min-width: 220px; }
.card-head select.control.filter-inline { flex: 0 1 220px; min-width: 170px; }
.card-head h3 { margin: 0; font-size: 1rem; }
.card-head .kicker { margin: 0 0 2px; font-size: .72rem; color: var(--muted); font-weight: 600; letter-spacing: .02em; text-transform: uppercase; }
.card-body { padding: 18px; }
.card-body.flush { padding: 0; }

/* Métricas / KPIs */
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 16px; margin-bottom: 22px; }
.metric { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 17px 18px; box-shadow: var(--shadow-sm); transition: box-shadow var(--med) var(--ease), transform var(--med) var(--ease); animation: rise var(--med) var(--ease-out) backwards; }
.metric:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.metric:nth-child(2) { animation-delay: .04s; }
.metric:nth-child(3) { animation-delay: .08s; }
.metric:nth-child(4) { animation-delay: .12s; }
.metric::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: linear-gradient(90deg, var(--primary), transparent 70%); opacity: .0; transition: opacity var(--med) var(--ease); }
.metric:hover::after { opacity: .9; }
.metric .top { display: flex; align-items: center; justify-content: space-between; }
.metric .ic { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); box-shadow: inset 0 0 0 1px rgba(var(--primary-rgb),.1); }
.metric.a .ic { background: var(--accent-soft); color: var(--accent); box-shadow: inset 0 0 0 1px rgba(99,102,241,.12); }
.metric.w .ic { background: var(--warning-soft); color: var(--warning); box-shadow: inset 0 0 0 1px rgba(183,121,31,.14); }
.metric.d .ic { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(213,50,43,.12); }
.metric .label { margin: 15px 0 0; color: var(--muted); font-size: .84rem; font-weight: 600; }
.metric .value { margin: 3px 0 0; font-size: 1.9rem; font-weight: 750; letter-spacing: -.03em; line-height: 1.1; }
.metric .delta { margin: 8px 0 0; font-size: .78rem; display: inline-flex; align-items: center; gap: 4px; font-weight: 600; padding: 2px 7px; border-radius: 999px; background: var(--surface-soft); color: var(--muted); }
.metric .delta.up { color: var(--success); background: var(--success-soft); }
.metric .delta.down { color: var(--danger); background: var(--danger-soft); }
.metric .delta svg.lucide { width: 13px; height: 13px; }
.metric .spark { position: absolute; right: 14px; bottom: 12px; width: 92px; height: 34px; opacity: .9; pointer-events: none; }

.grid-2 { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(320px,0.75fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; }
.stack { display: grid; gap: 20px; align-content: start; }

/* =========================================================================
   Gráficos (SVG)
   ========================================================================= */
.chart { width: 100%; display: block; overflow: visible; }
.chart .bar { transition: opacity var(--fast) var(--ease); cursor: default; }
.chart .bar:hover { opacity: .82; }
.chart-empty { color: var(--faint); text-align: center; padding: 30px; font-size: .85rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 10px 16px; margin-top: 14px; }
.legend-item { display: flex; align-items: center; gap: 7px; font-size: .82rem; color: var(--text-soft); }
.legend-item .sw { width: 10px; height: 10px; border-radius: 3px; }
.legend-item b { font-variant-numeric: tabular-nums; }
.donut-wrap { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.donut-center { font-weight: 750; }

/* =========================================================================
   Filtros
   ========================================================================= */
.filters { display: flex; flex-wrap: wrap; gap: 14px 16px; align-items: end; }
.filters .field { flex: 1 1 200px; min-width: 190px; margin: 0; }
.filters .field.field-wide { flex: 1.6 1 260px; min-width: 230px; max-width: 420px; }
.filters .field.field-date { flex: 1 1 165px; min-width: 150px; }
.filters .actions { display: flex; gap: 8px; align-items: end; flex: 0 0 auto; }
.filter-bar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--surface-soft); color: var(--text-soft); font-size: .8rem; font-weight: 600; border: 1px solid var(--line); }
.chip svg.lucide { width: 14px; height: 14px; }
.chip button { border: 0; background: none; cursor: pointer; color: inherit; display: inline-flex; opacity: .7; }
.chip button:hover { opacity: 1; }
.chip b { font-weight: 700; }
/* Divisória entre os valores por tipo e as contagens de documentos no resumo. */
.resumo-sep { width: 1px; align-self: stretch; margin: 2px 3px; background: var(--line-strong); }
@media (max-width: 620px) { .resumo-sep { display: none; } }

/* presets de período */
.presets { display: inline-flex; gap: 4px; padding: 3px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 999px; }
.preset { border: 0; background: none; padding: 6px 12px; border-radius: 999px; font-size: .82rem; font-weight: 600; color: var(--muted); cursor: pointer; transition: background var(--fast) var(--ease), color var(--fast) var(--ease); }
.preset:hover { color: var(--text); }
.preset.active { background: var(--surface); color: var(--primary-strong); box-shadow: var(--shadow-xs); }

/* =========================================================================
   Tabelas
   ========================================================================= */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .89rem; }
.table th, .table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.table thead th { position: sticky; top: 0; background: var(--surface-alt); color: var(--muted); font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; z-index: 1; border-bottom: 1px solid var(--line); }
.table thead th:first-child { border-top-left-radius: var(--radius); }
.table thead th:last-child { border-top-right-radius: var(--radius); }
/* Cabeçalho ordenável: a seta só fica sólida na coluna ativa; nas demais fica
   apagada (indica que dá pra clicar, sem competir com a coluna ordenada). */
.table thead th.sortable { cursor: pointer; user-select: none; transition: color var(--fast) var(--ease), background var(--fast) var(--ease); }
.table thead th.sortable:hover { color: var(--text-soft); background: var(--surface-soft); }
.table thead th.sortable:focus-visible { outline: none; box-shadow: inset var(--ring); }
.table thead th.sortable.sorted { color: var(--primary-strong); }
.table thead th .th-sort { display: inline-flex; align-items: center; gap: 5px; }
.table thead th.right .th-sort { flex-direction: row-reverse; }
.table thead th .th-sort svg.lucide { width: 13px; height: 13px; opacity: .35; }
.table thead th.sortable:hover .th-sort svg.lucide { opacity: .7; }
.table thead th.sorted .th-sort svg.lucide { opacity: 1; }
.table tbody tr { transition: background var(--fast) var(--ease); }
.table tbody tr:hover { background: var(--primary-tint); }
.table tbody tr.selected { background: var(--primary-soft); box-shadow: inset 3px 0 0 var(--primary); }
.table tbody tr:last-child td { border-bottom: 0; }
.table td .sub { color: var(--muted); font-size: .8rem; }
.table td.actions { text-align: right; white-space: nowrap; }
.table .check { width: 42px; }
.table td b { font-weight: 600; }
.table-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line-soft); flex-wrap: wrap; }
.chkbox { width: 17px; height: 17px; accent-color: var(--primary); cursor: pointer; }

.pagination { display: flex; align-items: center; gap: 4px; }
.pagination button { min-width: 34px; height: 34px; padding: 0 8px; border: 1px solid var(--line-strong); background: var(--surface); border-radius: var(--radius-xs); cursor: pointer; font-weight: 600; font-size: .85rem; color: var(--text-soft); box-shadow: var(--shadow-xs); transition: background var(--fast) var(--ease), transform var(--fast) var(--ease); }
.pagination button:hover:not(:disabled) { background: var(--surface-soft); transform: translateY(-1px); }
.pagination button.active { background: linear-gradient(180deg, #1a93ff, var(--primary)); border-color: transparent; color: #fff; box-shadow: 0 4px 12px rgba(var(--primary-rgb),.3); }
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

.bulkbar { display: flex; align-items: center; gap: 12px; padding: 11px 16px; color: #e7eefb; border-radius: var(--radius); margin-bottom: 14px; background: linear-gradient(180deg, var(--navy-2), var(--navy)); box-shadow: var(--shadow-md); animation: rise var(--fast) var(--ease-out); }
.bulkbar b { color: #fff; }
.bulkbar .btn { min-height: 33px; }

/* =========================================================================
   Listas
   ========================================================================= */
.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 13px 18px; border-bottom: 1px solid var(--line-soft); transition: background var(--fast) var(--ease); }
.list-item:last-child { border-bottom: 0; }
.list-item:hover { background: var(--surface-alt); }
.list-item .ic { flex: 0 0 38px; width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary); }
.list-item .grow b { display: block; font-size: .9rem; }
.list-item .grow span { font-size: .8rem; color: var(--muted); }

.timeline { display: grid; gap: 2px; padding: 6px 0; }
.tl-item { display: flex; gap: 13px; padding: 9px 18px; }
.tl-item .rail { display: flex; flex-direction: column; align-items: center; }
.tl-item .rail .node { width: 11px; height: 11px; border-radius: 50%; background: var(--primary); margin-top: 4px; box-shadow: 0 0 0 4px rgba(var(--primary-rgb),.12); }
.tl-item .rail .line { flex: 1; width: 2px; background: var(--line); margin-top: 4px; }
.tl-item:last-child .rail .line { display: none; }
.tl-item .body b { font-size: .87rem; }
.tl-item .body p { margin: 2px 0 0; color: var(--muted); font-size: .81rem; }

.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 2px 18px; }
.kv-item { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.kv-item .k { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; }
.kv-item .v { margin-top: 4px; font-size: .93rem; word-break: break-word; }
.kv-item .v.mono { font-family: ui-monospace, "Cascadia Code", monospace; font-size: .84rem; }

/* =========================================================================
   Tabs
   ========================================================================= */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tab { border: 0; background: none; padding: 11px 15px; font-weight: 600; font-size: .9rem; color: var(--muted); cursor: pointer; border-bottom: 2px solid transparent; white-space: nowrap; transition: color var(--fast) var(--ease); position: relative; top: 1px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary-strong); border-bottom-color: var(--primary); }

/* =========================================================================
   Estados: vazio, erro, loading
   ========================================================================= */
.empty { text-align: center; padding: 48px 24px; animation: fadein var(--med) var(--ease); }
.empty .ic { width: 60px; height: 60px; margin: 0 auto 15px; border-radius: 16px; display: grid; place-items: center; background: linear-gradient(160deg, var(--surface-soft), var(--surface-alt)); color: var(--faint); box-shadow: inset 0 0 0 1px var(--line); }
.empty .ic svg.lucide { width: 27px; height: 27px; }
.empty h4 { margin: 0 0 6px; font-size: 1.06rem; }
.empty p { margin: 0 auto; color: var(--muted); max-width: 390px; line-height: 1.55; }
.empty .btn { margin-top: 18px; }
.empty.danger .ic { background: var(--danger-soft); color: var(--danger); box-shadow: inset 0 0 0 1px rgba(213,50,43,.12); }

.skel { position: relative; overflow: hidden; background: var(--surface-soft); border-radius: 7px; }
.skel::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg, transparent, rgba(255,255,255,.7), transparent); animation: shimmer 1.4s infinite; }
@keyframes shimmer { 100% { transform: translateX(100%); } }
.skel-line { height: 11px; margin: 8px 0; }
.skel-row td { padding: 15px 16px; }

.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.35); border-top-color: #fff; border-radius: 50%; animation: spin .65s linear infinite; }
.spinner.dark { border-color: rgba(var(--primary-rgb),.2); border-top-color: var(--primary); }
.page-loading { display: flex; align-items: center; justify-content: center; gap: 10px; padding: 64px; color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Toast
   ========================================================================= */
.toast-root { position: fixed; bottom: 22px; right: 22px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; max-width: 390px; }
.toast { display: flex; gap: 11px; padding: 13px 15px; border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-lg); border: 1px solid var(--line); border-left: 4px solid var(--muted); animation: toast-in var(--med) var(--ease-out); }
@keyframes toast-in { from { transform: translateX(24px) scale(.98); opacity: 0; } }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }
.toast.warning { border-left-color: var(--warning); }
.toast .ic { margin-top: 1px; }
.toast.success .ic { color: var(--success); }
.toast.error .ic { color: var(--danger); }
.toast.info .ic { color: var(--primary); }
.toast.warning .ic { color: var(--warning); }
.toast b { font-size: .9rem; }
.toast p { margin: 2px 0 0; font-size: .84rem; color: var(--muted); }
.toast .x { margin-left: auto; border: 0; background: none; cursor: pointer; color: var(--faint); border-radius: 6px; display: inline-flex; padding: 2px; }
.toast .x:hover { background: var(--surface-soft); color: var(--text); }

/* =========================================================================
   Modal
   ========================================================================= */
.modal-overlay { position: fixed; inset: 0; z-index: 900; background: rgba(11,18,32,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 24px; animation: fadein var(--fast) ease; }
.modal { width: 100%; max-width: 528px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 90vh; display: flex; flex-direction: column; animation: pop-in var(--med) var(--ease-out); border: 1px solid var(--line); }
.modal.lg { max-width: 800px; }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px 22px 15px; border-bottom: 1px solid var(--line-soft); }
.modal-head h3 { margin: 0; font-size: 1.16rem; }
.modal-head p { margin: 4px 0 0; color: var(--muted); font-size: .86rem; }
.modal-body { padding: 20px 22px; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 22px; border-top: 1px solid var(--line-soft); background: var(--surface-alt); border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.xml-pre { background: #0b1220; color: #cfe3ff; padding: 16px; border-radius: var(--radius-sm); font-family: ui-monospace, "Cascadia Code", monospace; font-size: .78rem; line-height: 1.55; overflow: auto; max-height: 344px; white-space: pre-wrap; word-break: break-all; border: 1px solid #1b2740; }

/* =========================================================================
   Responsivo
   ========================================================================= */
.backdrop { display: none; }

@media (max-width: 1180px) {
  .metrics { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .grid-2 { grid-template-columns: 1fr; }
  /* notebook: composição mais compacta, sem cortes */
  .auth-brand { padding: 48px 44px; }
  .auth-headline h1 { font-size: 2.05rem; }
  .auth-glow { width: 440px; height: 440px; }
}
@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; width: 276px; transform: translateX(-100%); transition: transform var(--med) var(--ease-out); box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: translateX(0); }
  .shell.nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 55; background: rgba(11,18,32,.5); backdrop-filter: blur(2px); animation: fadein var(--fast); }
  .topbar .menu-toggle { display: inline-flex; }
  .topbar .search { display: none; }
  .menu { right: 14px; top: 56px; }
  .notif-menu { right: 14px; width: calc(100vw - 28px); max-width: 300px; }

  /* tablet: institucional passa a topo, condensada, mas ainda visível */
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 34px 34px 26px; min-height: 0; }
  .auth-headline { max-width: 640px; }
  .auth-headline h1 { font-size: 1.72rem; margin-bottom: 12px; }
  .auth-headline p { max-width: 560px; }
  .auth-points { grid-template-columns: repeat(3, 1fr); max-width: none; margin-top: 22px; }
  .auth-point { flex-direction: column; gap: 8px; }
  .auth-foot { margin-top: 18px; }
}
@media (max-width: 620px) {
  /* mobile: área institucional recolhida para priorizar o login */
  .auth-brand { display: none; }
  .metrics { grid-template-columns: 1fr; }
  .page { padding: 16px; }
  .topbar { padding: 10px 14px; }
  .userchip .who { display: none; }
  .modal-foot { flex-direction: column-reverse; }
  .modal-foot .btn { width: 100%; }

  .filters .field,
  .filters .field.field-wide,
  .filters .field.field-date { flex: 1 1 100%; min-width: 0; }
  .filters .actions { flex: 1 1 100%; }
  .filters .actions .btn { flex: 1; }

  .card-head .input-icon.search-field,
  .card-head select.control.filter-inline { flex: 1 1 100%; max-width: none; }
}
