@font-face { font-family: "Bricolage Grotesque"; src: url("fonts/bricolage.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }
@font-face { font-family: "Hanken Grotesk"; src: url("fonts/hanken.woff2") format("woff2"); font-weight: 100 900; font-display: swap; }

:root {
	color-scheme: light;
	--bg: #f5f1e8;
	--surface: #fffdf8;
	--surface-2: #efe9dc;
	--line: #e3dccd;
	--line-2: #d9d0be;
	--text: #17150f;
	--text-2: #3b372f;
	--muted: #5e584c;
	--brand: #17150f;
	--brand-hover: #2e2a22;
	--marker: #ffe347;
	--marker-soft: #fff6bf;
	--ok: #1f6b3a;
	--bad: #b3261e;
	--warn: #8a5a00;
	--display: "Bricolage Grotesque", "Hanken Grotesk", system-ui, sans-serif;
	--radius: 12px;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

::selection { background: var(--marker); color: var(--text); }
* { scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-2); border: 2px solid var(--bg); border-radius: 99px; }
:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

body {
	margin: 0;
	min-height: 100vh;
	background: var(--bg);
	color: var(--text);
	font: 14px/1.5 "Hanken Grotesk", system-ui, "Segoe UI", sans-serif;
	-webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.01em; }
h1 { font-family: var(--display); font-weight: 800; letter-spacing: -.03em; }
h2 { font-size: 15px; }
p { margin: 0; }
.muted { color: var(--muted); }
.mono { font: 13px ui-monospace, Consolas, monospace; font-variant-numeric: tabular-nums; }
.num { font-variant-numeric: tabular-nums; }

/* controles */
input, select, textarea {
	height: 38px;
	padding: 0 11px;
	border: 1.5px solid var(--line-2);
	border-radius: 9px;
	background: var(--surface);
	color: var(--text);
	caret-color: var(--text);
	font: inherit;
	min-width: 0;
}
input:focus, select:focus, textarea:focus { border-color: var(--text); outline: none; }
textarea { display: block; width: 100%; height: auto; padding: 9px 11px; line-height: 1.45; resize: vertical; }
.notice-form .actions { margin-top: 12px; }
input::placeholder { color: #8f887a; }
label { display: block; margin: 14px 0 6px; color: var(--text-2); font-size: 13px; font-weight: 600; }

button {
	height: 38px;
	padding: 0 16px;
	border: 0;
	border-radius: 9px;
	background: var(--brand);
	color: var(--bg);
	font: inherit;
	font-weight: 700;
	cursor: pointer;
	white-space: nowrap;
	transition: background .12s;
}
button:hover { background: var(--brand-hover); }
button:disabled { opacity: .55; cursor: progress; }
button.secondary { background: transparent; border: 1.5px solid var(--line-2); color: var(--text); font-weight: 600; }
button.secondary:hover { background: var(--surface-2); border-color: var(--text); }
button.ghost { background: none; color: var(--muted); padding: 0 10px; font-weight: 600; }
button.ghost:hover { color: var(--text); background: none; }
button.danger { background: none; border: 1.5px solid rgba(179, 38, 30, .45); color: var(--bad); }
button.danger:hover { background: rgba(179, 38, 30, .07); }
button.danger.armed { background: var(--bad); border-color: var(--bad); color: #fff; }
button.link { height: auto; padding: 0; background: none; color: var(--text); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; }
button.link:hover { background: none; color: var(--muted); }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; padding: 30px 28px; border: 1px solid var(--line); border-radius: 18px; background: var(--surface); }
.login-card img { margin-bottom: 16px; }
.login-card h1 { font-size: 28px; margin-bottom: 6px; }
.login-card input { width: 100%; }
.login-card button { width: 100%; margin-top: 18px; height: 44px; }
.msg { margin-top: 12px; color: var(--muted); font-size: 13px; min-height: 20px; }
.msg.bad { color: var(--bad); font-weight: 600; }

/* topo */
.top {
	position: sticky; top: 0; z-index: 5;
	display: flex; align-items: center; gap: 20px;
	padding: 0 24px; height: 60px;
	border-bottom: 1px solid var(--line);
	background: rgba(245, 241, 232, .92);
	backdrop-filter: blur(10px);
}
.brand { display: flex; align-items: center; gap: 9px; }
.brand span { font-family: var(--display); font-size: 21px; font-weight: 800; letter-spacing: -.035em; line-height: 1; }
.brand small { padding: 1px 7px; border-radius: 5px; background: var(--marker); color: var(--text); font-weight: 700; font-size: 11px; }
nav { display: flex; gap: 2px; overflow-x: auto; }
nav a {
	display: flex; align-items: center; gap: 7px;
	padding: 7px 12px; border-radius: 8px;
	color: var(--text-2); text-decoration: none; font-weight: 600; white-space: nowrap;
}
nav a:hover { color: var(--text); background: var(--surface-2); }
nav a[aria-current=page] { background: var(--text); color: var(--bg); }
.count { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 99px; background: var(--bad); color: #fff; font-size: 11px; font-weight: 700; line-height: 18px; text-align: center; }
.who { margin-left: auto; display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; min-width: 0; }
.who span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { max-width: 1180px; margin: 0 auto; padding: 28px 24px 64px; outline: none; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 28px; }

.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px 20px; }
.panel + .panel { margin-top: 16px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 12px; margin-bottom: 12px; }
.panel + .grid2 { margin-top: 16px; }

/* números */
.grid2 { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; margin-bottom: 16px; }
.grid2 > .panel + .panel { margin-top: 0; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 14px 0 0; }
.stats div { padding: 2px 16px; border-left: 1px solid var(--line); }
.stats div:first-child { padding-left: 0; border-left: 0; }
.stats dt { color: var(--muted); font-size: 13px; }
.stats dd { margin: 4px 0 0; font-family: var(--display); font-size: 28px; font-weight: 800; letter-spacing: -.03em; }
.stats small { color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.banner { display: flex; flex-direction: column; gap: 4px; margin-bottom: 16px; padding: 14px 16px; border: 1px solid rgba(179, 38, 30, .35); border-radius: var(--radius); background: rgba(179, 38, 30, .06); }
.banner b { color: var(--bad); }

/* alertas */
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: grid; grid-template-columns: 10px 1fr auto; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.feed li:first-child { border-top: 0; }
.dot { width: 8px; height: 8px; margin-top: 7px; border-radius: 50%; background: var(--line-2); }
.ok .dot { background: var(--ok); }
.bad .dot { background: var(--bad); }
.warn .dot { background: #d9a400; }
.ev-title { font-weight: 700; }
.kind { margin-left: 6px; color: var(--muted); font-size: 12px; font-weight: 500; }
.ev-body { color: var(--text-2); font-size: 13px; margin-top: 2px; word-break: break-word; }
.feed time { color: var(--muted); font-size: 12px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.feed .new { position: relative; }
.feed .new .ev-title::after { content: "novo"; margin-left: 8px; padding: 1px 6px; border-radius: 5px; background: var(--marker); color: var(--text); font-size: 11px; font-weight: 700; }
.empty { padding: 28px 0; color: var(--muted); text-align: center; }

.chips { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chips button { height: 32px; padding: 0 12px; border: 1.5px solid var(--line-2); background: none; color: var(--text-2); font-weight: 600; }
.chips button:hover { background: var(--surface-2); }
.chips button[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); }

/* tabelas */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.toolbar form { display: flex; gap: 8px; flex: 1; min-width: 260px; }
.toolbar input { flex: 1; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
th { color: var(--muted); font-size: 12px; font-weight: 700; border-bottom: 1px solid var(--line); }
td { border-top: 1px solid var(--line); }
tbody tr:first-child td { border-top: 0; }
tbody tr[data-open], tbody tr[data-aff] { cursor: pointer; }
tbody tr[data-open]:hover, tbody tr[data-aff]:hover, tbody tr[aria-selected=true] { background: var(--marker-soft); }
.table-wrap + .panel { margin-top: 16px; }
.gen-row + .actions, .keybox + .gen-row { margin-top: 12px; }
.facts dd .link { white-space: normal; overflow-wrap: anywhere; text-align: right; }
td.right, th.right { text-align: right; }

.pill { display: inline-block; padding: 2px 9px; border: 1px solid var(--line-2); border-radius: 99px; color: var(--muted); font-size: 12px; font-weight: 700; }
.pill.ok { border-color: rgba(31, 107, 58, .45); color: var(--ok); }
.pill.bad { border-color: rgba(179, 38, 30, .45); color: var(--bad); }
.pill.warn { border-color: rgba(138, 90, 0, .45); color: var(--warn); }
.pill.brand { border-color: var(--marker); background: var(--marker); color: var(--text); }

/* licenças: lista + detalhe */
.split { display: grid; grid-template-columns: 1fr; gap: 16px; align-items: start; }
.split.open { grid-template-columns: minmax(0, 1fr) 380px; }
/* detalhe aberto: a coluna "Navegador" (repetida no detalhe) sai e a "Origem" cabe sem cortar */
.split.open th:nth-child(5), .split.open td:nth-child(5) { display: none; }
.detail { position: sticky; top: 76px; max-height: calc(100vh - 92px); overflow-y: auto; }
.detail-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; margin: 16px 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.adddays { display: flex; gap: 8px; margin-top: 10px; }
.adddays input { width: 90px; }
.sub { margin: 20px 0 8px; font-size: 13px; color: var(--muted); font-weight: 700; }
.history { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.history li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-top: 1px solid var(--line); }
.history li:first-child { border-top: 0; }
.history time { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }

.gen { margin-bottom: 16px; }
.gen-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.gen-row > div { display: flex; flex-direction: column; }
.gen-row label { margin-top: 0; }
.gen-row .grow { flex: 1; min-width: 180px; }
.keybox { display: flex; gap: 8px; margin-top: 14px; padding: 12px; border: 1.5px dashed var(--text); border-radius: 10px; background: var(--marker-soft); align-items: center; }
.keybox code { flex: 1; min-width: 0; overflow-wrap: anywhere; font: 15px ui-monospace, Consolas, monospace; letter-spacing: .02em; }
#checkedKey { margin: 0 0 18px; }

#toast {
	position: fixed; left: 50%; bottom: 24px; z-index: 20; transform: translateX(-50%);
	max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 10px;
	background: var(--text); color: var(--bg); font-weight: 600;
	box-shadow: 0 12px 30px -10px rgba(23, 21, 15, .45);
}
#toast.bad { background: var(--bad); color: #fff; }

.skeleton { color: var(--muted); padding: 40px 0; text-align: center; }
/* recarregando: mantém a tela anterior esmaecida em vez de piscar "Carregando…" */
#view { transition: opacity .15s; }
#view.stale { opacity: .55; pointer-events: none; }

/* relatórios */
.toolbar-inline { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { height: 30px; padding: 0 12px; background: none; color: var(--text-2); font-size: 13px; font-weight: 600; border-radius: 7px; }
.seg button:hover { background: none; color: var(--text); }
.seg button[aria-pressed=true] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(23, 21, 15, .12); }
.hero-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px 32px; flex-wrap: wrap; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--line); }
.label { color: var(--muted); font-size: 13px; }
.hero { margin-top: 2px; font-family: var(--display); font-size: 52px; line-height: 1.05; font-weight: 800; letter-spacing: -.04em; }
.inline-stats { display: flex; gap: 28px; margin: 0; flex-wrap: wrap; }
.inline-stats dt { color: var(--muted); font-size: 13px; }
.inline-stats dd { margin: 2px 0 0; font-family: var(--display); font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.inline-stats small { color: var(--muted); font-size: 12px; }
.chart-title { margin-bottom: 6px; }
.chart { position: relative; min-height: 200px; border-radius: 8px; }
.chart svg { display: block; overflow: visible; }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart .peak { fill: var(--text); font-size: 12px; font-weight: 700; }
.chart .bar { fill: var(--text); transition: fill .12s; }
.chart .bar.on { fill: var(--marker); stroke: var(--text); stroke-width: 1.5; }
.chart .hit { fill: transparent; cursor: default; }
.tip {
	position: absolute; top: -6px; transform: translateX(-50%); pointer-events: none; white-space: nowrap;
	display: flex; flex-direction: column; gap: 1px; padding: 7px 10px; border-radius: 8px;
	background: var(--text); color: var(--bg); box-shadow: 0 8px 20px -6px rgba(23, 21, 15, .4);
}
.tip strong { font-size: 14px; }
.tip span { color: #cfc7b8; font-size: 12px; }
.table-view { margin-top: 12px; }
.table-view summary { cursor: pointer; color: var(--text-2); font-size: 13px; font-weight: 600; width: fit-content; }
.table-view summary:hover { color: var(--text); }
.table-view .table-wrap { margin-top: 10px; max-height: 320px; overflow-y: auto; }
.table-wrap.flat { border: 0; background: none; margin-top: 10px; }
.table-wrap.flat th:first-child, .table-wrap.flat td:first-child { padding-left: 0; }
.table-wrap.flat th:last-child, .table-wrap.flat td:last-child { padding-right: 0; }
.facts.compact { margin: 14px 0 0; gap: 9px 16px; }
.facts.compact dd { font-weight: 700; }
.panel > h2 + .facts.compact { margin-top: 12px; }
.footnote { margin-top: 14px; font-size: 12px; }
.warn-text { color: var(--warn); }

@media (max-width: 900px) {
	.grid2 { grid-template-columns: 1fr; }
	.split.open { grid-template-columns: 1fr; }
	.detail { position: fixed; inset: 0; z-index: 10; top: 0; max-height: none; border-radius: 0; border: 0; padding: 20px 16px 40px; }
}
@media (max-width: 640px) {
	.top { flex-wrap: wrap; height: auto; padding: 10px 16px; gap: 8px 12px; }
	nav { order: 3; width: 100%; flex-wrap: wrap; overflow-x: visible; } /* 6 abas: quebra em 2 linhas em vez de esconder Alertas/Aviso */
	.who span { display: none; }
	main { padding: 20px 16px 48px; }
	.stats { grid-template-columns: 1fr; gap: 12px; }
	.stats div { padding: 0; border-left: 0; }
	.feed li { grid-template-columns: 10px 1fr; }
	.feed time { grid-column: 2; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
