/* ============================================================
   Portal RI Bairru — Design System
   Tokens únicos (tema escuro default + tema claro), Manrope,
   gradiente de marca #c1288c → #8740e0.
   ============================================================ */

:root {
  /* Marca */
  --brand-a: #c1288c;
  --brand-b: #8740e0;
  --brand-grad: linear-gradient(135deg, var(--brand-a), var(--brand-b));

  /* Tema escuro (default) */
  --bg: #0b0b11;
  --bg-elev: #101018;
  --surface: #15151d;
  --surface-2: #1b1b25;
  --border: #26262f;
  --fg: #f4f4f7;
  --muted: #9a9aa8;
  --eyebrow: #9aa0e8;

  /* Semânticas (dados) */
  --pos: #10d48e;
  --neg: #f05a5a;
  --warn: #f5b942;
  --info: #4f8ef7;

  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --radius-sm: 10px;

  --font: 'Manrope', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

[data-theme="light"] {
  --bg: #fafafb;
  --bg-elev: #f3f3f6;
  --surface: #ffffff;
  --surface-2: #f6f6f9;
  --border: #ececf0;
  --fg: #0c0c11;
  --muted: #71717f;
  --eyebrow: #585eaa;
  --shadow: 0 10px 30px rgba(20, 20, 40, .08);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--fg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

/* ---------- Tipografia institucional ---------- */

.eyebrow {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--eyebrow);
}

h1 { font-weight: 800; letter-spacing: -.02em; font-size: clamp(1.6rem, 3.4vw, 2.4rem); }
h2 { font-weight: 800; letter-spacing: -.015em; font-size: 1.25rem; }
h3 { font-weight: 700; font-size: 1rem; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }

.brand-text {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* ---------- Header / Nav ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: .8rem clamp(1rem, 4vw, 2.5rem);
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: baseline;
  gap: .5rem;
  font-weight: 800;
  letter-spacing: -.01em;
  white-space: nowrap;
}

.brand .ri-tag {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .14em;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .1rem .5rem;
}

.nav {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.nav::-webkit-scrollbar { display: none; }

.nav a {
  padding: .42rem .66rem;
  border-radius: 999px;
  font-size: .83rem;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  transition: color .15s, background .15s;
}

.nav a:hover { color: var(--fg); background: var(--surface-2); }

.nav a.active {
  color: var(--fg);
  background: var(--surface-2);
  box-shadow: inset 0 -2px 0 0 var(--brand-a);
}

.topbar-actions { display: flex; align-items: center; gap: .5rem; }

.chip-btn {
  font-family: var(--font);
  font-size: .78rem;
  font-weight: 700;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .7rem;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.chip-btn:hover { color: var(--fg); border-color: var(--muted); }
.chip-btn .on { color: var(--fg); }

.user-chip {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8rem;
  font-weight: 600;
  padding: .3rem .7rem .3rem .35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
}

.user-chip .avatar {
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--brand-grad);
  display: grid; place-items: center;
  color: #fff;
  font-size: .72rem;
  font-weight: 800;
}

/* ---------- Layout ---------- */

.wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem);
}

.page-head { margin-bottom: 1.75rem; display: flex; flex-wrap: wrap; align-items: end; gap: 1rem; justify-content: space-between; }

.scope-chip {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  font-size: .8rem;
  font-weight: 700;
  padding: .4rem .85rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
}
.scope-chip::before {
  content: '';
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--brand-grad);
}

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

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .9rem;
}

.kpi {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  position: relative;
  overflow: hidden;
  transition: transform .15s, box-shadow .15s;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi::after {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--brand-grad);
  opacity: .85;
}

.kpi-lbl { font-size: .74rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.kpi-val { font-size: 1.55rem; font-weight: 800; letter-spacing: -.02em; margin-top: .2rem; }
.kpi-sub { font-size: .78rem; color: var(--muted); margin-top: .15rem; }
.kpi-sub .up { color: var(--pos); font-weight: 700; }
.kpi-sub .down { color: var(--neg); font-weight: 700; }

/* ---------- Cards de seção ---------- */

.section-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.scard {
  display: block;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.35rem 1.2rem;
  transition: transform .15s, box-shadow .15s, border-color .15s;
}
.scard:hover { transform: translateY(-3px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand-a) 40%, var(--border)); }

.scard .eyebrow { margin-bottom: .4rem; }
.scard h3 { margin-bottom: .35rem; }
.scard p { font-size: .86rem; color: var(--muted); }

.scard .soon {
  display: inline-block;
  margin-top: .8rem;
  font-size: .68rem;
  font-weight: 800;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--warn);
}

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

.login-split {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100vh;
}

.login-hero {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(1.5rem, 5vw, 3.5rem);
  background:
    radial-gradient(1100px 600px at -10% 110%, color-mix(in srgb, var(--brand-a) 22%, transparent), transparent 60%),
    radial-gradient(900px 700px at 110% -10%, color-mix(in srgb, var(--brand-b) 20%, transparent), transparent 55%),
    var(--bg);
  border-right: 1px solid var(--border);
}

.login-hero h1 { max-width: 20ch; margin-top: 1rem; }
.login-hero .lede { max-width: 44ch; margin-top: .8rem; color: var(--muted); }

.login-points { margin-top: 2rem; display: grid; gap: .65rem; }
.login-points li {
  list-style: none;
  display: flex; gap: .6rem; align-items: baseline;
  font-size: .9rem; color: var(--muted);
}
.login-points li::before { content: '—'; color: var(--brand-a); font-weight: 800; }

.login-side {
  display: grid;
  place-items: center;
  padding: clamp(1.5rem, 4vw, 3rem);
  background: var(--bg-elev);
}

.login-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem;
  box-shadow: var(--shadow);
}

.login-card h2 { margin-bottom: .3rem; }
.login-card .sub { font-size: .85rem; color: var(--muted); margin-bottom: 1.4rem; }

.field { margin-bottom: 1rem; }
.field label { display: block; font-size: .78rem; font-weight: 700; color: var(--muted); margin-bottom: .35rem; }
.field input {
  width: 100%;
  font-family: var(--font);
  font-size: .95rem;
  color: var(--fg);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .7rem .85rem;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus { border-color: var(--brand-b); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand-b) 22%, transparent); }

.btn-primary {
  width: 100%;
  font-family: var(--font);
  font-size: .95rem;
  font-weight: 800;
  color: #fff;
  background: var(--brand-grad);
  border: none;
  border-radius: var(--radius-sm);
  padding: .8rem;
  cursor: pointer;
  transition: filter .15s, transform .1s;
}
.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:active { transform: scale(.99); }

.login-foot { margin-top: 1.2rem; font-size: .78rem; color: var(--muted); text-align: center; }

.login-error {
  display: none;
  font-size: .82rem;
  color: var(--neg);
  background: color-mix(in srgb, var(--neg) 12%, transparent);
  border: 1px solid color-mix(in srgb, var(--neg) 35%, transparent);
  border-radius: var(--radius-sm);
  padding: .55rem .8rem;
  margin-bottom: 1rem;
}

/* ---------- Notas / banners ---------- */

.demo-banner {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  font-size: .76rem;
  font-weight: 700;
  color: var(--warn);
  border: 1px dashed color-mix(in srgb, var(--warn) 55%, transparent);
  border-radius: 999px;
  padding: .3rem .8rem;
}

/* ---------- Footer ---------- */

.footer {
  margin-top: 3.5rem;
  border-top: 1px solid var(--border);
  padding: 1.75rem clamp(1rem, 4vw, 2.5rem);
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  font-size: .78rem;
  color: var(--muted);
}

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

@media (max-width: 900px) {
  .login-split { grid-template-columns: 1fr; }
  .login-hero { min-height: 38vh; border-right: none; border-bottom: 1px solid var(--border); }
}

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

/* ---------- Console admin ---------- */

.tabs { display: flex; gap: .35rem; margin: 1.25rem 0; flex-wrap: wrap; }
.tab-btn {
  font-family: var(--font); font-size: .85rem; font-weight: 700;
  color: var(--muted); background: transparent;
  border: 1px solid var(--border); border-radius: 999px;
  padding: .45rem .95rem; cursor: pointer;
}
.tab-btn.active { color: #fff; background: var(--brand-grad); border-color: transparent; }

.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1rem; }
.panel h3 { margin-bottom: .75rem; }

.table { width: 100%; border-collapse: collapse; font-size: .86rem; }
.table th {
  text-align: left; font-size: .7rem; font-weight: 800; letter-spacing: .08em;
  text-transform: uppercase; color: var(--muted);
  padding: .5rem .6rem; border-bottom: 1px solid var(--border);
}
.table td { padding: .55rem .6rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }

.tag {
  display: inline-block; font-size: .7rem; font-weight: 700;
  padding: .12rem .55rem; border-radius: 999px;
  border: 1px solid var(--border); color: var(--muted); margin: .1rem .15rem .1rem 0;
}
.tag.admin { color: #fff; background: var(--brand-grad); border-color: transparent; }
.tag.off { opacity: .5; text-decoration: line-through; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .7rem; align-items: end; }
.form-grid .field { margin-bottom: 0; }
.field select {
  width: 100%; font-family: var(--font); font-size: .9rem; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .65rem .7rem; outline: none;
}

.btn-secondary {
  font-family: var(--font); font-size: .85rem; font-weight: 700; color: var(--fg);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .6rem 1rem; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--muted); }
.btn-danger { color: var(--neg); }

.btn-sm { padding: .3rem .7rem; font-size: .76rem; }
.btn-primary.btn-sm, .btn-primary.inline { width: auto; padding: .6rem 1.2rem; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: .3rem .8rem; max-height: 260px; overflow-y: auto; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.check-grid label { display: flex; gap: .45rem; align-items: center; font-size: .82rem; color: var(--muted); cursor: pointer; }

.notice { font-size: .82rem; color: var(--muted); background: var(--surface-2); border-left: 3px solid var(--brand-b); border-radius: 6px; padding: .6rem .8rem; margin-bottom: 1rem; }
.msg-ok { color: var(--pos); font-size: .82rem; font-weight: 700; }
.msg-err { color: var(--neg); font-size: .82rem; font-weight: 700; }

/* ---------- Organograma (A Companhia) ---------- */

.org-toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-bottom: 1rem; }
.org-toolbar input {
  flex: 1; min-width: 220px; font-family: var(--font); font-size: .9rem;
  color: var(--fg); background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: .55rem 1rem; outline: none;
}
.org-toolbar input:focus { border-color: var(--brand-b); }

.org-stats { font-size: .8rem; color: var(--muted); margin-bottom: 1rem; }

.org-tree { list-style: none; }
.org-tree ul { list-style: none; margin-left: 1.1rem; padding-left: 1rem; border-left: 1px solid var(--border); }

.org-node { margin: .15rem 0; }
.org-row {
  display: flex; align-items: center; gap: .55rem; flex-wrap: wrap;
  padding: .42rem .6rem; border-radius: var(--radius-sm);
  transition: background .12s;
}
.org-row:hover { background: var(--surface); }

.org-toggle {
  width: 20px; height: 20px; flex: 0 0 20px;
  display: grid; place-items: center;
  font-size: .7rem; color: var(--muted);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 6px; cursor: pointer; user-select: none;
}
.org-toggle.leaf { visibility: hidden; }

.org-dot { width: 9px; height: 9px; border-radius: 50%; flex: 0 0 9px; }
.org-nome { font-weight: 700; font-size: .92rem; }
.org-cnpj { font-family: ui-monospace, 'JetBrains Mono', monospace; font-size: .74rem; color: var(--muted); }
.org-childcount { font-size: .72rem; color: var(--muted); }

.org-tag {
  font-size: .64rem; font-weight: 800; letter-spacing: .07em; text-transform: uppercase;
  padding: .1rem .5rem; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
}
.org-tag.holding { color: #fff; background: var(--brand-grad); border-color: transparent; }
.org-tag.subholding { color: var(--info); border-color: color-mix(in srgb, var(--info) 45%, transparent); }
.org-tag.share { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }

.pdf-frame {
  width: 100%; height: min(78vh, 900px);
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
}
