/* Segundo Cérebro — painel. Tema "neural": navy/grafite profundo com acentos violeta + verde-água. */

/* ------------------------------------------------------------------ tokens */
:root {
  color-scheme: dark;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Cascadia Mono", "Liberation Mono", monospace;
  --topbar-h: 62px;
  --sidebar-w: 276px;
  --radius: 16px;
  --radius-sm: 11px;
  --radius-xs: 8px;

  --bg: #060a14;
  --bg-elev: #0a1020;
  --surface: rgba(16, 23, 42, 0.78);
  --surface-solid: #10182c;
  --surface-2: #151f38;
  --surface-3: #1b2745;
  --surface-hover: rgba(30, 42, 74, 0.72);
  --border: rgba(148, 163, 214, 0.13);
  --border-strong: rgba(148, 163, 214, 0.25);
  --text: #e8ebf7;
  --text-2: #b8c1db;
  --muted: #8b95b4;
  --faint: #616c8c;
  --violet: #8b5cf6;
  --violet-2: #a78bfa;
  --violet-ink: #c4b5fd;
  --teal: #14b8a6;
  --teal-2: #2dd4bf;
  --teal-ink: #5eead4;
  --link: #b9a7ff;
  --danger: #f43f5e;
  --danger-ink: #fda4af;
  --warn: #f59e0b;
  --warn-ink: #fcd34d;
  --ok: #10b981;
  --ok-ink: #6ee7b7;
  --info: #38bdf8;
  --info-ink: #7dd3fc;
  --grad: linear-gradient(135deg, #7c3aed 0%, #5b5bf0 50%, #0d9488 100%);
  --grad-text: linear-gradient(100deg, #c4b5fd 0%, #a5b4fc 45%, #5eead4 100%);
  --grad-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.16), rgba(13, 148, 136, 0.12));
  --shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 14px 34px -20px rgba(0, 0, 0, 0.85);
  --shadow-lg: 0 30px 80px -24px rgba(0, 0, 0, 0.85), 0 0 0 1px rgba(148, 163, 214, 0.08);
  --glow: 0 0 0 1px rgba(139, 92, 246, 0.38), 0 10px 34px -10px rgba(124, 58, 237, 0.5);
  --ring: 0 0 0 3px rgba(45, 212, 191, 0.45);
  --code-bg: #0a1121;
  --code-border: rgba(148, 163, 214, 0.12);
  --hl-bg: rgba(250, 204, 21, 0.24);
  --hl-ink: #fef08a;
  --chip-l: 76%;
  --chip-bg-a: 0.13;
  --chip-bd-a: 0.30;
  --scroll: rgba(148, 163, 214, 0.22);
  --topbar-bg: rgba(6, 10, 20, 0.72);
  --sidebar-bg: rgba(8, 13, 26, 0.55);
  --dot: rgba(148, 163, 214, 0.055);
  --glow-a: rgba(124, 58, 237, 0.20);
  --glow-b: rgba(13, 148, 136, 0.13);

  --graph-edge: rgba(148, 163, 214, 0.28);
  --graph-edge-active: #a78bfa;
  --graph-label: #e7eaf6;
  --graph-halo: rgba(6, 10, 20, 0.92);
  --graph-ghost: #7c86a6;
  --graph-ghost-fill: #0b1122;
  --graph-node-stroke: rgba(6, 10, 20, 0.9);
  --graph-neutral: #a78bfa;
  --graph-ring: #2dd4bf;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f6fb;
  --bg-elev: #ffffff;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-2: #f3f4fa;
  --surface-3: #e9ecf6;
  --surface-hover: rgba(237, 240, 250, 0.95);
  --border: rgba(30, 41, 79, 0.11);
  --border-strong: rgba(30, 41, 79, 0.2);
  --text: #0f172a;
  --text-2: #334063;
  --muted: #5b6684;
  --faint: #8790aa;
  --violet: #7c3aed;
  --violet-2: #6d28d9;
  --violet-ink: #5b21b6;
  --teal: #0d9488;
  --teal-2: #0f766e;
  --teal-ink: #0f766e;
  --link: #6d28d9;
  --danger: #e11d48;
  --danger-ink: #be123c;
  --warn: #d97706;
  --warn-ink: #92400e;
  --ok: #059669;
  --ok-ink: #047857;
  --info: #0284c7;
  --info-ink: #075985;
  --grad-text: linear-gradient(100deg, #6d28d9 0%, #4f46e5 45%, #0f766e 100%);
  --grad-soft: linear-gradient(135deg, rgba(124, 58, 237, 0.08), rgba(13, 148, 136, 0.07));
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 10px 28px -18px rgba(15, 23, 42, 0.28);
  --shadow-lg: 0 30px 70px -26px rgba(15, 23, 42, 0.35), 0 0 0 1px rgba(30, 41, 79, 0.06);
  --glow: 0 0 0 1px rgba(124, 58, 237, 0.28), 0 10px 30px -14px rgba(124, 58, 237, 0.35);
  --ring: 0 0 0 3px rgba(13, 148, 136, 0.35);
  --code-bg: #f6f7fc;
  --code-border: rgba(30, 41, 79, 0.1);
  --hl-bg: rgba(250, 204, 21, 0.45);
  --hl-ink: #422006;
  --chip-l: 34%;
  --chip-bg-a: 0.11;
  --chip-bd-a: 0.28;
  --scroll: rgba(30, 41, 79, 0.2);
  --topbar-bg: rgba(255, 255, 255, 0.78);
  --sidebar-bg: rgba(255, 255, 255, 0.55);
  --dot: rgba(30, 41, 79, 0.06);
  --glow-a: rgba(124, 58, 237, 0.10);
  --glow-b: rgba(13, 148, 136, 0.08);

  --graph-edge: rgba(71, 85, 105, 0.32);
  --graph-edge-active: #6d28d9;
  --graph-label: #0f172a;
  --graph-halo: rgba(244, 246, 251, 0.95);
  --graph-ghost: #94a3b8;
  --graph-ghost-fill: #ffffff;
  --graph-node-stroke: rgba(255, 255, 255, 0.95);
  --graph-neutral: #7c3aed;
  --graph-ring: #0d9488;
}

/* ------------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; scrollbar-color: var(--scroll) transparent; }
body {
  margin: 0;
  min-height: 100vh;
  font: 15px/1.6 var(--font);
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 540px at 6% -10%, var(--glow-a), transparent 62%),
    radial-gradient(780px 520px at 104% -4%, var(--glow-b), transparent 60%),
    radial-gradient(var(--dot) 1px, transparent 1.3px);
  background-size: auto, auto, 26px 26px;
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4 { line-height: 1.25; margin: 0; font-weight: 680; letter-spacing: -0.01em; }
p { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
code, kbd, pre, samp { font-family: var(--mono); font-size: 0.9em; }
img, svg { vertical-align: middle; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
::selection { background: rgba(139, 92, 246, 0.35); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--scroll); border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--teal-2); outline-offset: 2px; border-radius: 6px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: fixed; left: 12px; top: -60px; z-index: 1000; padding: 10px 16px; border-radius: 10px;
  background: var(--surface-solid); color: var(--text); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; text-decoration: none; }
.noscript { padding: 40px; text-align: center; }

.ico { display: inline-flex; width: 18px; height: 18px; flex: none; }
.ico svg { width: 100%; height: 100%; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.mono { font-family: var(--mono); font-size: 0.88em; }
.nowrap { white-space: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grad-text { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
kbd, .kbd {
  display: inline-block; min-width: 1.6em; padding: 1px 6px; border-radius: 6px; font-size: 0.78em; line-height: 1.5;
  text-align: center; color: var(--muted); background: var(--surface-2); border: 1px solid var(--border-strong); border-bottom-width: 2px;
}

/* ---------------------------------------------------------------- botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 38px; padding: 7px 15px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface-2); color: var(--text);
  font-weight: 600; font-size: 0.92rem; line-height: 1.2; cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, transform 0.08s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}
.btn:hover { background: var(--surface-3); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: none; box-shadow: var(--ring); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: 0.55; cursor: not-allowed; transform: none; }
.btn .ico { width: 17px; height: 17px; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 8px 22px -12px rgba(124, 58, 237, 0.9); }
.btn-primary:hover { background: var(--grad); filter: brightness(1.08); border-color: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.btn-danger { background: rgba(244, 63, 94, 0.12); border-color: rgba(244, 63, 94, 0.35); color: var(--danger-ink); }
.btn-danger:hover { background: rgba(244, 63, 94, 0.2); border-color: rgba(244, 63, 94, 0.5); }
.btn-danger-solid { background: var(--danger); border-color: transparent; color: #fff; }
.btn-danger-solid:hover { background: var(--danger); filter: brightness(1.08); }
.btn-sm { min-height: 31px; padding: 4px 11px; font-size: 0.85rem; border-radius: 9px; }
.btn-xs { min-height: 26px; padding: 2px 9px; font-size: 0.8rem; border-radius: 8px; gap: 5px; }
.btn-xs .ico { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 38px; height: 38px; border-radius: 11px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border); }
.icon-btn:focus-visible { outline: none; box-shadow: var(--ring); }
.icon-btn .ico { width: 19px; height: 19px; }

/* --------------------------------------------------------------- campos */
.input, .select, .textarea {
  width: 100%; min-height: 40px; padding: 8px 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
  background: var(--bg-elev); color: var(--text); transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.input::placeholder, .textarea::placeholder { color: var(--faint); }
.input:hover, .select:hover, .textarea:hover { border-color: rgba(148, 163, 214, 0.38); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--teal-2); box-shadow: var(--ring); }
.input[aria-invalid="true"], .textarea[aria-invalid="true"] { border-color: var(--danger); }
.select {
  appearance: none; -webkit-appearance: none; padding-right: 34px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 52%, calc(100% - 12px) 52%;
  background-size: 5px 5px, 5px 5px; background-repeat: no-repeat;
}
.select option { background: var(--surface-solid); color: var(--text); }
.select-sm, .input-sm { min-height: 34px; padding-top: 5px; padding-bottom: 5px; font-size: 0.9rem; }
.textarea { resize: vertical; line-height: 1.55; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field-label, .label { font-weight: 600; font-size: 0.88rem; color: var(--text-2); }
.inline-label { display: inline-flex; align-items: center; gap: 8px; font-size: 0.88rem; color: var(--muted); white-space: nowrap; }
.inline-label .select, .inline-label .input { width: auto; }
.hint { font-size: 0.83rem; color: var(--muted); }
.form-error { color: var(--danger-ink); font-size: 0.88rem; min-height: 1.2em; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.9rem; color: var(--text-2); user-select: none; }
.check input { width: 17px; height: 17px; accent-color: var(--violet); cursor: pointer; }

/* ------------------------------------------------------------------ boot */
.boot { min-height: 100vh; display: grid; place-items: center; gap: 18px; align-content: center; color: var(--muted); }
.boot-orb, .login-orb, .empty-orb {
  width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center; font-size: 36px;
  background: radial-gradient(circle at 35% 30%, rgba(196, 181, 253, 0.55), rgba(124, 58, 237, 0.35) 40%, rgba(13, 148, 136, 0.25) 75%, transparent 76%);
  box-shadow: 0 0 60px -6px rgba(124, 58, 237, 0.55), inset 0 0 22px rgba(255, 255, 255, 0.08);
  animation: pulse 2.6s ease-in-out infinite;
}
@keyframes pulse { 0%, 100% { transform: scale(1); filter: brightness(1); } 50% { transform: scale(1.05); filter: brightness(1.15); } }
.error-screen { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.error-screen .card { max-width: 480px; text-align: center; }

/* ---------------------------------------------------------------- topbar */
.topbar {
  position: sticky; top: 0; z-index: 40; height: var(--topbar-h); display: flex; align-items: center; gap: 14px;
  padding: 0 18px; background: var(--topbar-bg); border-bottom: 1px solid var(--border);
  -webkit-backdrop-filter: blur(16px) saturate(150%); backdrop-filter: blur(16px) saturate(150%);
}
.menu-btn { display: none; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--text); font-weight: 750; font-size: 1.04rem; letter-spacing: -0.01em; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 34px; height: 34px; border-radius: 11px; display: grid; place-items: center; font-size: 19px;
  background: var(--grad); box-shadow: 0 6px 20px -8px rgba(124, 58, 237, 0.9);
}
.brand-name { background: var(--grad-text); -webkit-background-clip: text; background-clip: text; color: transparent; }
.global-search { position: relative; flex: 1 1 320px; max-width: 460px; margin-left: 8px; }
.global-search .input { padding-left: 38px; padding-right: 40px; min-height: 38px; border-radius: 12px; background: var(--surface); }
.gs-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.gs-icon .ico { width: 17px; height: 17px; }
.gs-kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.global-search .input:focus ~ .gs-kbd { opacity: 0; }
.topnav { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.topnav a {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 12px; border-radius: 10px; color: var(--text-2);
  font-weight: 600; font-size: 0.9rem; white-space: nowrap; transition: background 0.15s, color 0.15s;
}
.topnav a .ico { width: 16px; height: 16px; opacity: 0.85; }
.topnav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.topnav a[aria-current="page"] { color: var(--text); background: var(--grad-soft); box-shadow: inset 0 0 0 1px rgba(139, 92, 246, 0.35); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }

/* ---------------------------------------------------------------- layout */
.layout { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr); min-height: calc(100vh - var(--topbar-h)); }
.sidebar {
  position: sticky; top: var(--topbar-h); height: calc(100vh - var(--topbar-h)); overflow-y: auto; overscroll-behavior: contain;
  padding: 20px 16px 24px; border-right: 1px solid var(--border); background: var(--sidebar-bg);
  display: flex; flex-direction: column; gap: 22px;
}
.side-nav { display: none; flex-direction: column; gap: 2px; }
.side-nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; color: var(--text-2); font-weight: 600; }
.side-nav a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.side-nav a[aria-current="page"] { background: var(--grad-soft); color: var(--text); }
.side-section { display: flex; flex-direction: column; gap: 10px; }
.side-title { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.12em; color: var(--faint); font-weight: 700; }
.side-title-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; }
.side-stat { padding: 10px 11px; border-radius: 12px; background: var(--surface); border: 1px solid var(--border); min-width: 0; }
.side-stat dt { font-size: 0.72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-stat dd { margin: 2px 0 0; font-weight: 720; font-size: 1.05rem; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-meta { font-size: 0.8rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }
.side-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag-cloud { display: flex; flex-wrap: wrap; gap: 6px; }
.side-links { display: flex; flex-direction: column; gap: 2px; }
.side-links a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 10px; color: var(--text-2); font-weight: 600; font-size: 0.92rem; }
.side-links a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.side-links a[aria-current="page"] { background: var(--grad-soft); color: var(--text); }
.side-foot { margin-top: auto; font-size: 0.78rem; color: var(--faint); }
.link-btn { background: none; border: 0; padding: 0; color: var(--link); cursor: pointer; font-size: 0.82rem; font-weight: 600; }
.link-btn:hover { text-decoration: underline; }
.drawer-backdrop { position: fixed; inset: var(--topbar-h) 0 0 0; z-index: 44; background: rgba(3, 6, 14, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.main { min-width: 0; padding: 30px clamp(16px, 3.2vw, 44px) 72px; }
.main > * { max-width: 1240px; margin-left: auto; margin-right: auto; }
.main[data-view="grafo"] { padding: 0; }
.main[data-view="grafo"] > * { max-width: none; }

/* --------------------------------------------------------------- páginas */
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head h1 { font-size: clamp(1.45rem, 2.3vw, 1.85rem); }
.eyebrow { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.14em; color: var(--teal-ink); font-weight: 700; margin-bottom: 6px; }
.page-sub { color: var(--muted); margin-top: 6px; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.section { margin-top: 28px; }
.section-title { font-size: 1.05rem; margin-bottom: 12px; display: flex; align-items: center; gap: 8px; }
.card {
  position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.card-title { font-size: 1.06rem; display: flex; align-items: center; gap: 9px; }
.card-title .ico { color: var(--violet-2); }
.card-sub { color: var(--muted); font-size: 0.9rem; margin-top: 4px; max-width: 75ch; }
.divider { height: 1px; background: var(--border); margin: 18px 0; border: 0; }

/* chips de tag (cor estável por tag via --h) */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  --h: 262;
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 2px 10px; border-radius: 999px;
  font-size: 0.8rem; font-weight: 600; line-height: 1.6; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  color: hsl(var(--h) 80% var(--chip-l)); background: hsl(var(--h) 72% 58% / var(--chip-bg-a));
  border: 1px solid hsl(var(--h) 70% 58% / var(--chip-bd-a)); text-decoration: none;
}
a.chip:hover, button.chip:hover { text-decoration: none; filter: brightness(1.15); }
button.chip { cursor: pointer; font-family: inherit; }
.chip-count { font-variant-numeric: tabular-nums; opacity: 0.75; font-weight: 700; }
.chip.is-active { box-shadow: 0 0 0 2px hsl(var(--h) 75% 60% / 0.7); background: hsl(var(--h) 72% 58% / 0.26); }
.chip.is-off { opacity: 0.55; }
.chip-plain { --h: 230; }
.chip-x { display: inline-flex; width: 14px; height: 14px; opacity: 0.8; }
.filter-pill { display: inline-flex; align-items: center; gap: 8px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 1px 9px; border-radius: 999px; font-size: 0.76rem; font-weight: 700;
  border: 1px solid var(--border-strong); color: var(--text-2); background: var(--surface-2); white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.9; }
.pill-ok { color: var(--ok-ink); border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.1); }
.pill-off { color: var(--muted); }
.pill-warn { color: var(--warn-ink); border-color: rgba(245, 158, 11, 0.35); background: rgba(245, 158, 11, 0.1); }
.pill-violet { color: var(--violet-ink); border-color: rgba(139, 92, 246, 0.35); background: rgba(139, 92, 246, 0.1); }
.pill-plain::before { display: none; }

/* avisos */
.notice {
  display: flex; gap: 12px; align-items: flex-start; padding: 13px 15px; border-radius: 13px; border: 1px solid var(--border-strong);
  background: var(--surface-2); color: var(--text-2); font-size: 0.92rem;
}
.notice + .notice { margin-top: 10px; }
.notice .ico { margin-top: 2px; }
.notice strong { color: var(--text); }
.notice-info { border-color: rgba(56, 189, 248, 0.32); background: rgba(56, 189, 248, 0.08); }
.notice-info > .ico { color: var(--info-ink); }
.notice-warn { border-color: rgba(245, 158, 11, 0.38); background: rgba(245, 158, 11, 0.09); }
.notice-warn > .ico { color: var(--warn-ink); }
.notice-danger { border-color: rgba(244, 63, 94, 0.38); background: rgba(244, 63, 94, 0.08); }
.notice-danger > .ico { color: var(--danger-ink); }
.notice-ok { border-color: rgba(16, 185, 129, 0.35); background: rgba(16, 185, 129, 0.08); }
.notice-ok > .ico { color: var(--ok-ink); }
.notice-body { display: flex; flex-direction: column; gap: 4px; min-width: 0; flex: 1; }
.notice-close { margin-left: auto; }

/* estados vazios e carregamento */
.empty { text-align: center; padding: 46px 20px; color: var(--muted); border: 1px dashed var(--border-strong); border-radius: var(--radius); background: var(--surface); }
.empty h2, .empty h3 { color: var(--text); font-size: 1.1rem; margin-bottom: 8px; }
.empty p { max-width: 58ch; margin: 0 auto; }
.empty .row { justify-content: center; margin-top: 18px; }
.empty-icon { width: 46px; height: 46px; margin: 0 auto 14px; border-radius: 14px; display: grid; place-items: center; background: var(--grad-soft); color: var(--violet-2); border: 1px solid var(--border); }
.empty-icon .ico { width: 22px; height: 22px; }
.empty-hero { text-align: left; padding: clamp(24px, 4vw, 44px); background: var(--surface); border: 1px solid var(--border); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; position: relative; }
.empty-hero::before { content: ""; position: absolute; inset: -40% -10% auto auto; width: 460px; height: 460px; background: radial-gradient(circle, rgba(124, 58, 237, 0.22), transparent 65%); pointer-events: none; }
.empty-hero h2 { font-size: clamp(1.3rem, 2.2vw, 1.7rem); margin: 18px 0 8px; }
.empty-hero > p { color: var(--text-2); max-width: 70ch; }
.steps { list-style: none; counter-reset: step; padding: 0; margin: 24px 0 0; display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.steps li { counter-increment: step; position: relative; padding: 16px 16px 16px 58px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); font-size: 0.92rem; }
.steps li::before {
  content: counter(step); position: absolute; left: 16px; top: 15px; width: 30px; height: 30px; border-radius: 10px; display: grid; place-items: center;
  font-weight: 800; color: #fff; background: var(--grad);
}
.steps li strong { color: var(--text); display: block; margin-bottom: 3px; }
.empty-hero .row { margin-top: 24px; }
.loading { display: flex; align-items: center; gap: 12px; color: var(--muted); padding: 30px 4px; }
.spinner { width: 20px; height: 20px; border-radius: 50%; border: 2.5px solid var(--border-strong); border-top-color: var(--violet-2); animation: spin 0.8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { display: grid; gap: 12px; }
.sk { height: 76px; border-radius: 14px; background: linear-gradient(90deg, var(--surface) 25%, var(--surface-2) 50%, var(--surface) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border: 1px solid var(--border); }
@keyframes shimmer { to { background-position: -200% 0; } }
.error-state { text-align: center; padding: 40px 20px; border-radius: var(--radius); border: 1px solid rgba(244, 63, 94, 0.3); background: rgba(244, 63, 94, 0.05); }
.error-state h2 { font-size: 1.1rem; margin-bottom: 6px; }
.error-state p { color: var(--muted); }
.error-state .row { justify-content: center; margin-top: 16px; }

/* ------------------------------------------------------------------ home */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(165px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 4px; padding: 16px 16px 14px; border-radius: var(--radius);
  background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none;
  transition: border-color 0.15s, transform 0.15s;
}
.stat-card::after { content: ""; position: absolute; right: -30px; top: -30px; width: 110px; height: 110px; border-radius: 50%; background: radial-gradient(circle, hsl(var(--h, 262) 80% 60% / 0.16), transparent 70%); pointer-events: none; }
a.stat-card:hover { border-color: var(--border-strong); text-decoration: none; transform: translateY(-1px); }
.stat-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; color: hsl(var(--h, 262) 85% 72%); background: hsl(var(--h, 262) 70% 55% / 0.14); margin-bottom: 6px; }
[data-theme="light"] .stat-icon { color: hsl(var(--h, 262) 70% 38%); }
.stat-icon .ico { width: 17px; height: 17px; }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat-value { font-size: 1.6rem; font-weight: 760; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat-sub { font-size: 0.76rem; color: var(--faint); }
.tip-core { margin-bottom: 18px; }
.list-toolbar { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; margin-bottom: 14px; }
.list-count { color: var(--muted); font-size: 0.9rem; margin-right: auto; }
.mem-list { display: grid; gap: 10px; }
.mem-card {
  position: relative; display: flex; flex-direction: column; gap: 7px; padding: 15px 18px; border-radius: 14px;
  background: var(--surface); border: 1px solid var(--border); transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mem-card:hover { border-color: rgba(139, 92, 246, 0.4); background: var(--surface-hover); box-shadow: var(--glow); }
.mem-card:focus-within { border-color: var(--teal-2); }
.mem-card-head { display: flex; align-items: baseline; gap: 12px; justify-content: space-between; }
.mem-title { font-size: 1.02rem; font-weight: 680; min-width: 0; overflow-wrap: anywhere; }
.mem-link { color: var(--text); }
.mem-link:hover { text-decoration: none; }
.mem-link::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.mem-link:focus-visible { outline: none; }
.mem-link:focus-visible::after { box-shadow: var(--ring); }
.mem-meta { display: inline-flex; gap: 10px; color: var(--faint); font-size: 0.8rem; white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
.mem-snippet { color: var(--muted); font-size: 0.9rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.mem-card .chips { position: relative; z-index: 1; }
.load-more { display: flex; justify-content: center; margin-top: 18px; }

/* ------------------------------------------------------------- memória */
.crumbs { display: flex; align-items: center; gap: 6px; font-size: 0.86rem; color: var(--muted); margin-bottom: 12px; flex-wrap: wrap; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.mem-view { display: grid; grid-template-columns: minmax(0, 1fr) 310px; gap: 22px; align-items: start; }
.mem-main { min-width: 0; }
.mem-head { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.mem-h1 { font-size: clamp(1.5rem, 2.6vw, 2.05rem); letter-spacing: -0.02em; overflow-wrap: anywhere; }
.mem-metaline { display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--muted); font-size: 0.86rem; }
.meta-item { display: inline-flex; align-items: center; gap: 6px; }
.meta-item .ico { width: 15px; height: 15px; opacity: 0.8; }
.meta-item strong { color: var(--text-2); font-weight: 650; }
.mem-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.mem-actions .spacer { flex: 1; }
.mem-body-card { padding: clamp(18px, 3vw, 30px); }
.mem-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: calc(var(--topbar-h) + 18px); max-height: calc(100vh - var(--topbar-h) - 36px); overflow-y: auto; padding-right: 2px; }
.side-card { padding: 16px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border); }
.side-card h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.1em; color: var(--muted); margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.side-card h2 .count { margin-left: auto; font-variant-numeric: tabular-nums; color: var(--faint); }
.link-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.link-list a { display: flex; align-items: center; gap: 8px; padding: 6px 9px; border-radius: 9px; color: var(--text-2); font-size: 0.9rem; overflow-wrap: anywhere; }
.link-list a:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.link-list a .ico { width: 15px; height: 15px; color: var(--violet-2); flex: none; }
.link-list a.is-ghost { color: var(--faint); border: 1px dashed var(--border-strong); background: transparent; }
.link-list a.is-ghost .ico { color: var(--faint); }
.ghost-note { margin-left: auto; font-size: 0.72rem; white-space: nowrap; color: var(--faint); font-style: italic; }
.side-empty { color: var(--faint); font-size: 0.86rem; }
.hist-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.hist-item {
  width: 100%; display: flex; flex-direction: column; gap: 1px; text-align: left; padding: 8px 10px; border-radius: 10px;
  border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; font-size: 0.86rem;
}
.hist-item:hover { background: var(--surface-hover); border-color: var(--border); }
.hist-item:focus-visible { outline: none; box-shadow: var(--ring); }
.hist-item .hist-top { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 650; }
.hist-item .hist-sub { color: var(--faint); font-size: 0.8rem; }
.hist-current { cursor: default; background: var(--grad-soft); border-color: rgba(139, 92, 246, 0.25); }
.hist-current:hover { background: var(--grad-soft); }
.id-row { display: flex; align-items: center; gap: 8px; }
.id-row code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; color: var(--muted); }
.save-notes { margin-bottom: 16px; }

/* ------------------------------------------------------------ markdown */
.md-body { font-size: 1rem; line-height: 1.72; color: var(--text); overflow-wrap: anywhere; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }
.md-body p, .md-body ul, .md-body ol, .md-body blockquote, .md-body pre, .md-body .md-table-wrap, .md-body hr { margin: 0 0 1em; }
.md-body h1, .md-body h2, .md-body h3, .md-body h4, .md-body h5, .md-body h6 { margin: 1.5em 0 0.55em; line-height: 1.3; }
.md-body h1 { font-size: 1.6rem; }
.md-body h2 { font-size: 1.36rem; padding-bottom: 0.3em; border-bottom: 1px solid var(--border); }
.md-body h3 { font-size: 1.15rem; }
.md-body h4 { font-size: 1.02rem; }
.md-body h5, .md-body h6 { font-size: 0.95rem; color: var(--text-2); }
.md-body ul, .md-body ol { padding-left: 1.5em; }
.md-body li { margin: 0.22em 0; }
.md-body li > ul, .md-body li > ol { margin: 0.25em 0; }
.md-body li::marker { color: var(--violet-2); }
.md-body .md-task { list-style: none; position: relative; margin-left: -1.25em; padding-left: 1.75em; }
.md-body .md-check { position: absolute; left: 0.1em; top: 0.3em; width: 1.05em; height: 1.05em; border-radius: 5px; border: 1.5px solid var(--border-strong); background: var(--bg-elev); }
.md-body .md-done .md-check { background: var(--grad); border-color: transparent; }
.md-body .md-done .md-check::after { content: ""; position: absolute; left: 0.32em; top: 0.12em; width: 0.28em; height: 0.55em; border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg); }
.md-body .md-done { color: var(--muted); }
.md-body code { padding: 0.12em 0.4em; border-radius: 6px; background: var(--code-bg); border: 1px solid var(--code-border); font-size: 0.86em; color: var(--violet-ink); }
.md-body pre { position: relative; padding: 15px 16px; border-radius: 12px; background: var(--code-bg); border: 1px solid var(--code-border); overflow: auto; line-height: 1.55; tab-size: 4; }
.md-body pre code { padding: 0; border: 0; background: none; color: var(--text); font-size: 0.86rem; }
.md-body pre[data-lang]::before { content: attr(data-lang); position: absolute; top: 6px; right: 10px; font: 600 0.68rem/1 var(--font); text-transform: uppercase; letter-spacing: 0.08em; color: var(--faint); }
.md-body .md-frontmatter { background: transparent; border-style: dashed; color: var(--muted); }
.md-body .md-frontmatter code { color: var(--muted); }
.md-body blockquote { padding: 10px 16px; border-left: 3px solid var(--violet); background: rgba(139, 92, 246, 0.07); border-radius: 0 12px 12px 0; color: var(--text-2); }
.md-body blockquote > :last-child { margin-bottom: 0; }
.md-body .md-callout { border-left-color: var(--info); background: rgba(56, 189, 248, 0.07); }
.md-body .md-callout-title { font-weight: 700; color: var(--text); margin-bottom: 0.3em; }
.md-body .md-callout-warning, .md-body .md-callout-caution, .md-body .md-callout-attention { border-left-color: var(--warn); background: rgba(245, 158, 11, 0.08); }
.md-body .md-callout-danger, .md-body .md-callout-error, .md-body .md-callout-bug, .md-body .md-callout-failure { border-left-color: var(--danger); background: rgba(244, 63, 94, 0.07); }
.md-body .md-callout-tip, .md-body .md-callout-hint, .md-body .md-callout-success, .md-body .md-callout-check, .md-body .md-callout-done { border-left-color: var(--ok); background: rgba(16, 185, 129, 0.07); }
.md-body .md-callout-important, .md-body .md-callout-abstract, .md-body .md-callout-summary, .md-body .md-callout-tldr { border-left-color: var(--violet); background: rgba(139, 92, 246, 0.08); }
.md-body hr { border: 0; height: 1px; background: linear-gradient(90deg, transparent, var(--border-strong), transparent); margin: 1.8em 0; }
.md-body .md-table-wrap { overflow-x: auto; border-radius: 12px; border: 1px solid var(--border); }
.md-body table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
.md-body th, .md-body td { padding: 8px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.md-body th { background: var(--surface-2); font-weight: 680; }
.md-body tr:last-child td { border-bottom: 0; }
.md-body tbody tr:nth-child(even) td { background: rgba(148, 163, 214, 0.035); }
.md-body .md-al-c { text-align: center; }
.md-body .md-al-r { text-align: right; }
.md-body a.md-link { color: var(--teal-ink); text-decoration: underline; text-decoration-color: rgba(45, 212, 191, 0.35); text-underline-offset: 3px; }
.md-body a.md-link:hover { text-decoration-color: currentColor; }
.md-body a.md-wikilink {
  color: var(--violet-ink); font-weight: 600; padding: 0 3px; margin: 0 -1px; border-radius: 5px;
  background: rgba(139, 92, 246, 0.1); border-bottom: 1px solid rgba(139, 92, 246, 0.45); text-decoration: none;
}
.md-body a.md-wikilink:hover { background: rgba(139, 92, 246, 0.2); }
.md-body a.md-wikilink.md-ghost { color: var(--faint); font-weight: 500; background: transparent; border-bottom: 1px dashed var(--faint); }
.md-body a.md-wikilink.md-ghost:hover { color: var(--muted); background: rgba(148, 163, 214, 0.08); }
.md-body .md-blocked { color: var(--muted); text-decoration: line-through dotted; cursor: help; }
.md-body mark { background: var(--hl-bg); color: inherit; border-radius: 3px; padding: 0 2px; }
.md-body del { color: var(--muted); }
.md-body .md-wikilink-section { color: var(--violet-ink); }

/* ---------------------------------------------------------------- editor */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.editor-grid .field-wide { grid-column: 1 / -1; }
.title-input { font-size: 1.12rem; font-weight: 650; min-height: 46px; }
.tag-preview { min-height: 28px; }
.tag-suggest { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tag-suggest .hint { margin-right: 4px; }
.content-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--surface-2); border: 1px solid var(--border); gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); padding: 5px 12px; border-radius: 8px; font-size: 0.84rem; font-weight: 650; cursor: pointer; }
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { background: var(--surface-solid); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25), inset 0 0 0 1px var(--border); }
.seg button:focus-visible { outline: none; box-shadow: var(--ring); }
.editor-panes { display: grid; gap: 14px; grid-template-columns: minmax(0, 1fr); }
.editor-panes[data-mode="split"] { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.editor-panes[data-mode="write"] .editor-preview { display: none; }
.editor-panes[data-mode="preview"] .editor-textarea { display: none; }
.editor-textarea { min-height: 52vh; font-family: var(--mono); font-size: 0.9rem; line-height: 1.65; padding: 14px 16px; tab-size: 4; }
.editor-preview { min-height: 52vh; max-height: 75vh; overflow: auto; padding: 18px 22px; border-radius: var(--radius-sm); border: 1px solid var(--border); background: var(--surface); }
.editor-panes[data-mode="preview"] .editor-preview { max-height: none; }
.editor-preview:empty::before { content: "Nada para visualizar ainda."; color: var(--faint); }
.editor-foot { display: flex; gap: 8px 16px; flex-wrap: wrap; align-items: center; font-size: 0.82rem; color: var(--muted); }
.counter { font-variant-numeric: tabular-nums; }
.counter.is-over { color: var(--danger-ink); font-weight: 700; }
.counter.is-near { color: var(--warn-ink); }
.editor-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; flex-wrap: wrap; margin-top: 18px; }
.editor-actions .hint { margin-right: auto; }

/* ----------------------------------------------------------------- busca */
.search-form { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.search-box { position: relative; flex: 1 1 340px; }
.search-box .ico { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--faint); pointer-events: none; }
.search-box .input { padding-left: 42px; min-height: 48px; font-size: 1.04rem; border-radius: 14px; }
.search-form .select { width: auto; min-height: 48px; border-radius: 14px; }
.search-form .btn { min-height: 48px; border-radius: 14px; padding: 0 20px; }
.tag-filter { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 14px; align-items: center; }
.tag-filter .hint { margin-right: 4px; }
.search-meta { display: flex; flex-wrap: wrap; gap: 8px 14px; align-items: center; color: var(--muted); font-size: 0.9rem; margin: 20px 0 12px; }
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.result { position: relative; padding: 15px 18px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; gap: 7px; transition: border-color 0.15s, box-shadow 0.15s; }
.result:hover { border-color: rgba(139, 92, 246, 0.4); box-shadow: var(--glow); }
.result-head { display: flex; align-items: center; gap: 14px; justify-content: space-between; }
.result-rank { color: var(--faint); font-weight: 700; font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.result-title { font-size: 1.03rem; font-weight: 680; color: var(--text); overflow-wrap: anywhere; }
.result-title::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }
.result-title:hover { text-decoration: none; }
.result-title:focus-visible { outline: none; }
.result-title:focus-visible::after { box-shadow: var(--ring); }
.result .chips { position: relative; z-index: 1; }
.score { display: inline-flex; align-items: center; gap: 8px; flex: none; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.score-bar { width: 90px; height: 7px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.score-fill { display: block; height: 100%; border-radius: inherit; background: var(--grad); }
.result-snippet { color: var(--text-2); font-size: 0.92rem; overflow-wrap: anywhere; }
.result-meta { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; font-size: 0.8rem; color: var(--faint); }
mark.hl { background: var(--hl-bg); color: var(--hl-ink); border-radius: 4px; padding: 0 2px; }

/* ----------------------------------------------------------------- grafo */
.graph-page { display: flex; flex-direction: column; height: calc(100vh - var(--topbar-h)); min-height: 420px; }
.graph-toolbar { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: center; padding: 12px 18px; border-bottom: 1px solid var(--border); background: var(--topbar-bg); }
.graph-toolbar h1 { font-size: 1.08rem; margin-right: 6px; display: flex; align-items: center; gap: 8px; }
.graph-toolbar .input { width: 210px; min-height: 34px; }
.graph-count { margin-left: auto; color: var(--muted); font-size: 0.86rem; font-variant-numeric: tabular-nums; }
.zoom-group { display: inline-flex; gap: 2px; }
.graph-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; }
.graph-canvas { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; }
.graph-canvas:focus-visible { outline: 2px solid var(--teal-2); outline-offset: -3px; border-radius: 0; }
.graph-tip {
  position: absolute; z-index: 5; max-width: 300px; pointer-events: none; display: flex; flex-direction: column; gap: 3px;
  padding: 10px 12px; border-radius: 12px; background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg);
  font-size: 0.84rem;
}
.graph-tip strong { font-size: 0.93rem; overflow-wrap: anywhere; }
.graph-tip-tags { color: var(--violet-ink); font-size: 0.78rem; overflow-wrap: anywhere; }
.graph-tip-meta { color: var(--muted); font-size: 0.78rem; }
.graph-legend { position: absolute; left: 14px; bottom: 14px; display: flex; flex-wrap: wrap; gap: 6px; max-width: min(560px, calc(100% - 28px)); pointer-events: auto; }
.graph-legend .chip { background: var(--surface-solid); }
.legend-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; background: hsl(var(--h) 72% 62%); }
[data-theme="light"] .legend-dot { background: hsl(var(--h) 62% 46%); }
.legend-ghost { --h: 225; }
.legend-ghost .legend-dot { background: transparent; border: 1.5px dashed var(--graph-ghost); }
.graph-help { position: absolute; right: 14px; bottom: 14px; font-size: 0.76rem; color: var(--faint); background: var(--surface); border: 1px solid var(--border); padding: 6px 10px; border-radius: 10px; max-width: 360px; }
.graph-empty { position: absolute; inset: 0; display: grid; place-items: center; padding: 24px; }
.graph-empty .empty { max-width: 520px; }

/* -------------------------------------------------------------- atividade */
.client-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; margin-bottom: 22px; }
.client-card {
  display: flex; flex-direction: column; gap: 6px; text-align: left; padding: 14px 15px; border-radius: 14px; cursor: pointer;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); transition: border-color 0.15s, box-shadow 0.15s;
}
.client-card:hover { border-color: var(--border-strong); }
.client-card:focus-visible { outline: none; box-shadow: var(--ring); }
.client-card[aria-pressed="true"] { border-color: rgba(139, 92, 246, 0.6); box-shadow: var(--glow); }
.client-name { font-weight: 680; overflow-wrap: anywhere; font-size: 0.94rem; }
.client-nums { display: flex; gap: 12px; font-size: 0.8rem; color: var(--muted); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.client-bar { height: 6px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.client-bar span { display: block; height: 100%; background: var(--grad); border-radius: inherit; }
.table-wrap { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface); }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.data-table th, .data-table td { padding: 10px 14px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.data-table th { position: sticky; top: 0; background: var(--surface-solid); color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 700; white-space: nowrap; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: var(--surface-hover); }
.cell-num { text-align: right !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-when { white-space: nowrap; color: var(--text-2); }
.cell-detail { color: var(--text-2); max-width: 460px; overflow-wrap: anywhere; }
.cell-tool code { color: var(--violet-ink); background: var(--code-bg); border: 1px solid var(--code-border); padding: 1px 6px; border-radius: 6px; font-size: 0.82rem; white-space: nowrap; }
.cell-actions { text-align: right !important; white-space: nowrap; }

/* ------------------------------------------------------- lixeira / listas */
.item-list { display: grid; gap: 10px; }
.item-row { display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); flex-wrap: wrap; }
.item-row.is-revoked { opacity: 0.62; }
.item-main { flex: 1 1 260px; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.item-title { font-weight: 680; overflow-wrap: anywhere; }
.item-sub { color: var(--muted); font-size: 0.84rem; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.item-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form .field { flex: 1 1 260px; }
details.more { margin-top: 12px; }
details.more > summary { cursor: pointer; color: var(--muted); font-size: 0.88rem; font-weight: 600; padding: 6px 0; }
details.more > summary:hover { color: var(--text); }
details.more[open] > summary { margin-bottom: 10px; }

/* ---------------------------------------------------------------- conectar */
.url-box { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.url-code {
  flex: 1 1 320px; min-width: 0; padding: 12px 15px; border-radius: 12px; background: var(--code-bg); border: 1px solid var(--code-border);
  font-family: var(--mono); font-size: 0.98rem; color: var(--teal-ink); overflow-x: auto; white-space: nowrap;
}
.conn-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr)); gap: 14px; margin-top: 14px; }
.conn-card { display: flex; flex-direction: column; gap: 12px; margin: 0 !important; }
.conn-head { display: flex; align-items: center; gap: 12px; }
.conn-logo { width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; font-weight: 800; font-size: 0.9rem; color: #fff; flex: none; background: hsl(var(--h, 262) 65% 50%); box-shadow: 0 6px 18px -8px hsl(var(--h, 262) 70% 45%); }
.conn-title { font-size: 1rem; }
.conn-auth { margin-left: auto; }
.conn-steps { color: var(--text-2); font-size: 0.9rem; }
.conn-steps code, .conn-note code, .card-sub code, .hint code, .notice code, .steps code, .empty code, .page-sub code {
  font-size: 0.85em; padding: 1px 5px; border-radius: 5px; background: var(--code-bg); border: 1px solid var(--code-border); color: var(--violet-ink); overflow-wrap: anywhere;
}
.conn-note { font-size: 0.84rem; color: var(--muted); }
.snippet { display: flex; flex-direction: column; gap: 6px; }
.snippet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.snippet-label { font-size: 0.78rem; color: var(--muted); font-weight: 650; }
.snippet pre, .code-box {
  margin: 0; padding: 12px 14px; border-radius: 11px; background: var(--code-bg); border: 1px solid var(--code-border);
  font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; color: var(--text); overflow: auto; max-height: 340px; white-space: pre;
}
.code-box.wrap, .snippet pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.ctx-controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin-bottom: 12px; }
.ctx-controls .field { flex: 1 1 260px; }

/* --------------------------------------------------------------- diálogos */
dialog.dlg {
  width: min(560px, calc(100vw - 28px)); max-height: min(86vh, 900px); padding: 0; border-radius: 20px; border: 1px solid var(--border-strong);
  background: var(--surface-solid); color: var(--text); box-shadow: var(--shadow-lg); overflow: hidden;
}
dialog.dlg[open] { display: flex; flex-direction: column; animation: dlg-in 0.16s ease-out; }
dialog.dlg-wide { width: min(980px, calc(100vw - 28px)); }
dialog.dlg::backdrop { background: rgba(3, 6, 14, 0.62); -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px); }
dialog.dlg.dlg-fallback { position: fixed; inset: 0; margin: auto; z-index: 900; height: fit-content; }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(0.985); } to { opacity: 1; transform: none; } }
.dlg-head { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 12px; }
.dlg-title { font-size: 1.12rem; overflow-wrap: anywhere; }
.dlg-head .icon-btn { margin: -6px -8px 0 auto; }
.dlg-body { padding: 4px 20px 16px; overflow: auto; display: flex; flex-direction: column; gap: 12px; color: var(--text-2); }
.dlg-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; padding: 14px 20px; border-top: 1px solid var(--border); background: var(--surface); }
.dlg-foot .hint { margin-right: auto; }
.dlg-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 0.84rem; color: var(--muted); }
.dlg-scroll { max-height: 56vh; overflow: auto; border-radius: 12px; border: 1px solid var(--border); padding: 16px 18px; background: var(--surface); }
.token-box { display: flex; gap: 8px; align-items: stretch; flex-wrap: wrap; }
.token-box code { flex: 1 1 280px; min-width: 0; padding: 12px 14px; border-radius: 11px; background: var(--code-bg); border: 1px dashed rgba(45, 212, 191, 0.5); color: var(--teal-ink); font-size: 0.92rem; overflow-wrap: anywhere; user-select: all; }
.err-list { margin: 0; padding-left: 18px; max-height: 260px; overflow: auto; font-size: 0.88rem; }
.diff { font-family: var(--mono); font-size: 0.82rem; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.diff div { padding: 0 10px 0 26px; position: relative; border-radius: 4px; min-height: 1.55em; }
.diff div::before { position: absolute; left: 9px; color: var(--faint); }
.diff .d-add { background: rgba(16, 185, 129, 0.12); color: var(--ok-ink); }
.diff .d-add::before { content: "+"; color: var(--ok-ink); }
.diff .d-del { background: rgba(244, 63, 94, 0.11); color: var(--danger-ink); }
.diff .d-del::before { content: "−"; color: var(--danger-ink); }
.diff .d-ctx { color: var(--muted); }
.diff .d-gap { color: var(--faint); font-style: italic; }

/* ----------------------------------------------------------------- toasts */
.toasts { position: fixed; right: 18px; bottom: 18px; z-index: 1000; display: flex; flex-direction: column; gap: 10px; width: min(420px, calc(100vw - 36px)); pointer-events: none; }
.toast {
  pointer-events: auto; display: flex; align-items: flex-start; gap: 11px; padding: 12px 12px 12px 14px; border-radius: 14px;
  background: var(--surface-solid); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); color: var(--text);
  font-size: 0.9rem; position: relative; overflow: hidden; animation: toast-in 0.2s ease-out;
}
.toast::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--info); }
.toast-success::before { background: var(--ok); }
.toast-warn::before { background: var(--warn); }
.toast-error::before { background: var(--danger); }
.toast-icon { margin-top: 1px; }
.toast-info .toast-icon { color: var(--info-ink); }
.toast-success .toast-icon { color: var(--ok-ink); }
.toast-warn .toast-icon { color: var(--warn-ink); }
.toast-error .toast-icon { color: var(--danger-ink); }
.toast-msg { flex: 1; min-width: 0; overflow-wrap: anywhere; padding-top: 1px; }
.toast-actions { display: flex; gap: 4px; align-items: center; margin-top: -3px; }
.toast .icon-btn { width: 28px; height: 28px; border-radius: 8px; }
.toast .icon-btn .ico { width: 15px; height: 15px; }
.toast.is-leaving { animation: toast-out 0.18s ease-in forwards; }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateX(16px); } }

/* ------------------------------------------------------------------ login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; position: relative; overflow: hidden; }
.login::before, .login::after { content: ""; position: absolute; border-radius: 50%; filter: blur(10px); pointer-events: none; }
.login::before { width: 620px; height: 620px; left: -180px; top: -220px; background: radial-gradient(circle, rgba(124, 58, 237, 0.28), transparent 65%); }
.login::after { width: 560px; height: 560px; right: -160px; bottom: -220px; background: radial-gradient(circle, rgba(13, 148, 136, 0.22), transparent 65%); }
.login-card { position: relative; z-index: 1; width: min(420px, 100%); padding: 34px 30px 28px; border-radius: 24px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow-lg); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 14px; text-align: center; margin-bottom: 24px; }
.login-brand h1 { font-size: 1.5rem; }
.login-brand p { color: var(--muted); font-size: 0.92rem; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 46px; min-height: 46px; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.login .btn-primary { min-height: 46px; font-size: 1rem; }
.login-hint { margin-top: 18px; text-align: center; }
.login-theme { position: absolute; top: 14px; right: 14px; z-index: 2; }

/* ------------------------------------------------------------ responsivo */
@media (max-width: 1180px) {
  .topnav a { padding: 8px 9px; }
  .topnav a .ico { display: none; }
  .mem-view { grid-template-columns: minmax(0, 1fr); }
  .mem-side { position: static; max-height: none; overflow: visible; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
}
@media (max-width: 900px) {
  :root { --topbar-h: 58px; }
  .menu-btn { display: inline-flex; }
  .topnav { display: none; }
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; z-index: 45; top: var(--topbar-h); left: 0; bottom: 0; height: auto; width: min(320px, 88vw);
    background: var(--bg-elev); transform: translateX(-104%); transition: transform 0.22s ease; box-shadow: var(--shadow-lg);
    visibility: hidden;
  }
  body.drawer-open .sidebar { transform: none; visibility: visible; }
  .side-nav { display: flex; }
  .global-search { margin-left: 0; max-width: none; }
  .gs-kbd { display: none; }
  .brand-name { display: none; }
  .editor-grid { grid-template-columns: minmax(0, 1fr); }
  .editor-panes[data-mode="split"] { grid-template-columns: minmax(0, 1fr); }
  .graph-help { display: none; }
  .graph-toolbar .input { width: 150px; }
}
@media (max-width: 560px) {
  .main { padding-top: 20px; }
  .mem-card-head, .result-head { flex-direction: column; align-items: flex-start; gap: 4px; }
  .stat-value { font-size: 1.35rem; }
  .card { padding: 16px; }
  .topbar { gap: 8px; padding: 0 10px; }
  .topbar-actions .btn { padding: 4px 9px; }
  .score-bar { width: 60px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; scroll-behavior: auto !important; }
}
@media print {
  .topbar, .sidebar, .mem-side, .mem-actions, .toasts, .crumbs { display: none !important; }
  .layout { display: block; }
  body { background: #fff; color: #000; }
}

/* --------------------------------------------- complementos usados pelo JS */
.brand-logo img, .boot-orb img, .login-orb img, .empty-orb img { display: block; pointer-events: none; }
.brand-logo img { width: 24px; height: auto; }
.boot-orb img, .login-orb img, .empty-orb img { width: 42px; height: auto; filter: drop-shadow(0 2px 8px rgba(124, 58, 237, 0.45)); }
.list-toolbar .inline-label { max-width: 100%; min-width: 0; }
.list-toolbar .inline-label .select { min-width: 0; max-width: 100%; text-overflow: ellipsis; }
.graph-toolbar .select { width: auto; max-width: 220px; }
.graph-stage .graph-count {
  position: absolute; top: 12px; right: 14px; z-index: 4; margin: 0; padding: 4px 10px; border-radius: 10px;
  background: var(--surface); border: 1px solid var(--border); pointer-events: none;
}
.table-wrap .data-table { min-width: 680px; }
.snippet pre code, .code-box code { font: inherit; color: inherit; background: none; border: 0; padding: 0; }
@media (max-width: 900px) {
  .global-search .input { padding-right: 12px; }
}
@media (max-width: 560px) {
  #logout-btn > span:not(.ico) { display: none; }
  .graph-stage .graph-count { top: 8px; right: 8px; font-size: 0.78rem; }
}
