/* Hub de Operações — estilos (Operations UI) */

/* Botão principal: no claro, branco sobre accent dá 3,6:1; usamos accent-hover (5,2:1) como base. */
:root { --btn-primary: var(--accent-hover); --btn-primary-hover: #9a3412; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --btn-primary: var(--accent); --btn-primary-hover: var(--accent-hover); } }
:root[data-theme="dark"] { --btn-primary: var(--accent); --btn-primary-hover: var(--accent-hover); }

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 20px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1, h2, h3, p { margin: 0; }
a { color: inherit; }
button { font: inherit; color: inherit; }
img, svg { display: block; }
.ic { flex: none; }
.num { font-variant-numeric: tabular-nums; }
.t3 { color: var(--text-3); }
.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; }
.span-all { grid-column: 1 / -1; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--radius-xs); }

.skip { position: absolute; left: 16px; top: -60px; z-index: 100; background: var(--ink); color: var(--on-ink); padding: 8px 14px; border-radius: var(--radius-sm); text-decoration: none; }
.skip:focus { top: 12px; }

/* ---------- tipografia ---------- */
.overline { font-size: 11px; line-height: 14px; font-weight: 500; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.lead { font-size: 14.5px; line-height: 21px; color: var(--text-2); }
.label { font-size: 13.5px; line-height: 18px; font-weight: 500; }
.caption { font-size: 12.5px; line-height: 18px; color: var(--text-3); }
.body { font-size: 14px; line-height: 20px; color: var(--text-2); }
.card-title { font-size: 15px; line-height: 20px; font-weight: 600; letter-spacing: -.01em; }
.code, .host { font-family: var(--mono); font-size: 12px; line-height: 16px; font-weight: 500; }
.unit { font-size: .55em; font-weight: 500; color: var(--text-3); margin-left: 3px; letter-spacing: 0; }

/* ---------- controles ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: var(--control-height); padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-full);
  background: var(--surface); color: var(--text);
  font-size: 13.5px; line-height: 18px; font-weight: 500;
  text-decoration: none; cursor: pointer; white-space: nowrap;
  transition: background-color .15s var(--ease), border-color .15s var(--ease), color .15s var(--ease);
}
.btn:hover { background: var(--surface-2); border-color: var(--text-3); }
.btn:disabled { opacity: .6; cursor: progress; }
.btn-primary { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; }
.btn-primary:hover { background: var(--btn-primary-hover); border-color: var(--btn-primary-hover); }
:root[data-theme="dark"] .btn-primary { color: var(--on-accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn-primary { color: var(--on-accent); } }
.btn-danger { background: var(--red); border-color: var(--red); color: #fff; }
.btn-danger:hover { filter: brightness(.92); background: var(--red); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); border-color: var(--line); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after { content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%; border: 2px solid #fff; border-right-color: transparent; animation: spin .7s linear infinite; }
.btn .rot { transform: rotate(180deg); }

.icon-btn {
  display: inline-grid; place-items: center;
  width: var(--control-height); height: var(--control-height);
  border: 1px solid var(--line-strong); border-radius: var(--radius-control);
  background: var(--surface); color: var(--text-2); cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn-sm { width: 32px; height: 32px; border-radius: var(--radius-tag); }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 22px; padding: 0 8px; border-radius: var(--radius-pill);
  font-size: 12px; line-height: 16px; font-weight: 600; white-space: nowrap;
  background: var(--surface-3); color: var(--text-2);
}
.pill .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill-green { background: var(--green-soft); color: var(--green); }
.pill-amber { background: var(--amber-soft); color: var(--amber); }
.pill-red { background: var(--red-soft); color: var(--red); }
.pill-blue { background: var(--blue-soft); color: var(--blue); }
.pill-violet { background: var(--violet-soft); color: var(--violet); }
.pill-accent { background: var(--accent-soft); color: var(--accent-hover); }
:root[data-theme="dark"] .pill-accent { color: var(--accent); }

.tag { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: var(--radius-tag); background: var(--surface-3); color: var(--text-2); font-size: 12px; font-weight: 500; }

.chip {
  height: 32px; padding: 0 12px; border-radius: var(--radius-full);
  border: 1px solid var(--line); background: var(--surface); color: var(--text-2);
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background-color .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.chip:hover { border-color: var(--line-strong); color: var(--text); }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }

.kbd { font-family: var(--mono); font-size: 11px; line-height: 1; padding: 3px 6px; border: 1px solid var(--line-strong); border-radius: 5px; color: var(--text-3); }

/* ---------- topo ---------- */
.topbar { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.topbar-in { max-width: 1400px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; min-height: 44px; }
.brand-mark { display: grid; place-items: center; width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--ink); color: var(--on-ink); }
.brand-name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.nav { display: flex; gap: 2px; }
.nav a { display: inline-flex; align-items: center; min-height: 36px; padding: 0 12px; border-radius: var(--radius-sm); text-decoration: none; color: var(--text-2); font-size: 13.5px; font-weight: 500; transition: background-color .15s var(--ease), color .15s var(--ease); }
.nav a:hover { background: var(--surface-3); color: var(--text); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.search { display: flex; align-items: center; gap: 8px; height: var(--control-height); padding: 0 8px 0 12px; width: 260px; border: 1px solid var(--line-strong); border-radius: var(--radius-full); background: var(--surface); color: var(--text-3); cursor: text; }
.search:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.search input { flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 13.5px; }
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { filter: grayscale(1); }
.user { display: flex; align-items: center; gap: 8px; }
.user-name { font-size: 13.5px; font-weight: 500; color: var(--text-2); max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- tela de acesso ---------- */
.gate { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; position: relative; isolation: isolate; }
.gate[hidden] { display: none; }
.gate::before { content: ""; position: absolute; inset: 0; z-index: -1; background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 9px); -webkit-mask-image: radial-gradient(ellipse at center, transparent 20%, #000 75%); mask-image: radial-gradient(ellipse at center, transparent 20%, #000 75%); }
.gate-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-dialog); box-shadow: var(--shadow); padding: 28px 28px 22px; display: grid; gap: 10px; }
.gate-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.gate-title { font-size: 26px; line-height: 30px; font-weight: 600; letter-spacing: -.025em; }
.gate-form { display: grid; gap: 14px; margin-top: 12px; }
.gate-form .demo-hint { margin: 0; }
.demo-hint-warn { background: var(--amber-soft); color: var(--text); }
.demo-hint code { font-family: var(--mono); font-size: 11.5px; }
.gate-foot { text-align: center; padding-top: 4px; color: var(--text-2); }
.btn-lg { height: 44px; font-size: 14px; }
body.is-locked .topbar, body.is-locked main, body.is-locked .site-foot, body.is-locked .skip { display: none; }

/* ---------- página ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 20px 24px 40px; display: grid; gap: 40px; }

/* ---------- hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-canvas);
  box-shadow: var(--shadow-sm);
  padding: 28px var(--pad-canvas) var(--pad-canvas);
}
.hero::before {
  content: ""; position: absolute; z-index: -1; inset: 0 0 auto auto; width: 62%; height: 220px;
  background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 8px);
  -webkit-mask-image: linear-gradient(to left, #000 10%, transparent), linear-gradient(to bottom, #000 30%, transparent);
  -webkit-mask-composite: source-in; mask-image: linear-gradient(to left, #000 10%, transparent); mask-composite: intersect;
}
.hero-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 24px; }
.hero-title { font-size: clamp(28px, 3.4vw, 44px); line-height: 1.05; font-weight: 600; letter-spacing: -.035em; margin: 8px 0 8px; text-wrap: balance; }
.hero-side { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.clock { font-size: clamp(40px, 5vw, 64px); line-height: 1; font-weight: 600; letter-spacing: -.045em; }
.hero-summary { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; min-height: 32px; }
.sum-chip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 5px 0 10px; border: 1px solid var(--line); border-radius: var(--radius-full); background: var(--surface); color: var(--text-2); font-size: 13px; font-weight: 500; }

.hero-grid { display: grid; grid-template-columns: 1fr 1fr 1.3fr; gap: var(--gap-grid); align-items: start; }

/* Painel no padrão KPI: moldura surface-2, corpo surface */
.panel { background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius); padding: var(--gap-xs); display: flex; flex-direction: column; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px 10px; }
.panel-head .card-title { display: inline-flex; align-items: center; gap: 8px; }
.panel-head .card-title .ic { color: var(--text-3); }
.panel-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-inner); padding: var(--pad-card-y) var(--pad-card-x); display: flex; flex-direction: column; gap: 18px; min-height: 120px; }
.panel-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 9px 10px 5px; }
.link-ext { display: inline-flex; align-items: center; gap: 5px; color: var(--text-2); font-weight: 500; text-decoration: none; min-height: 24px; }
.link-ext:hover { color: var(--accent-hover); text-decoration: underline; text-underline-offset: 3px; }

.fresh { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.fresh .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }
.fresh.is-stale { color: var(--amber); }
.fresh.is-stale .dot { background: var(--amber); }

.hero-num { font-size: 54px; line-height: 1; font-weight: 600; letter-spacing: -.045em; }
.hero-unit { font-size: 22px; font-weight: 500; letter-spacing: -.01em; color: var(--text-3); margin-left: 4px; vertical-align: 22px; }
.wx-cond { font-size: 14.5px; line-height: 21px; font-weight: 500; color: var(--text-2); margin-top: 6px; }
.wx-now, .wind-now { display: flex; align-items: center; gap: 18px; }
.wx-icon { color: var(--text); }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; margin: 0; padding: 14px 0 0; border-top: 1px solid var(--line); }
.stats div { min-width: 0; }
.stats .span-2 { grid-column: span 2; }
.stats dt { font-size: 12.5px; line-height: 18px; color: var(--text-3); }
.stats dd { margin: 2px 0 0; font-size: 18px; line-height: 24px; font-weight: 600; letter-spacing: -.02em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.stats dd .t3 { font-size: 13px; font-weight: 500; letter-spacing: 0; }
.stats dd .caption { font-weight: 400; letter-spacing: 0; }

.hours { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }
.hour { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 0; border-radius: var(--radius-tag); }
.hour:first-child { background: var(--surface-2); }
.hour-ic { color: var(--text-2); }
.hour-t { font-size: 13.5px; font-weight: 600; }
.hour-pop { font-size: 11.5px; color: var(--text-3); }
.hour-pop.is-wet { color: var(--blue); font-weight: 600; }
.sun { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.sun span { display: inline-flex; align-items: center; gap: 5px; }

/* bússola */
.compass { width: 92px; height: 92px; flex: none; }
.cp-ring { fill: var(--surface-2); stroke: var(--line-strong); stroke-width: 1; }
.compass .tk { stroke: var(--text-3); stroke-width: 1; }
.compass .tk-major { stroke: var(--text-2); stroke-width: 1.6; }
.cp-n { font: 600 10px var(--sans); fill: var(--text-2); text-anchor: middle; }
.cp-arrow { fill: var(--ink); }
.cp-hub { fill: var(--surface); stroke: var(--ink); stroke-width: 1.5; }

/* gráfico de vento */
.wchart { position: relative; }
.wbars { list-style: none; margin: 0; padding: 0; height: 108px; display: grid; grid-template-columns: repeat(12, 1fr); gap: 4px; }
.wbar { display: grid; grid-template-rows: 1fr 18px; align-items: end; justify-items: center; gap: 0; min-width: 0; }
.wbar .caption { font-size: 11px; line-height: 18px; }
.wbar .is-now { color: var(--text); font-weight: 600; }
.wbar-track { position: relative; width: 100%; max-width: 18px; height: 100%; }
.wbar-gust { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px 4px 2px 2px; border-top: 2px solid var(--text-3); background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 4px), var(--surface-2); }
.wbar-fill { position: absolute; left: 0; right: 0; bottom: 0; border-radius: 4px 4px 2px 2px; }
.wchart-lim { position: absolute; left: 0; right: 0; bottom: calc(18px + (100% - 18px) * var(--p)); border-top: 1px dashed var(--amber); pointer-events: none; }
.wchart-lim .caption { position: absolute; left: 0; bottom: 2px; font-size: 10.5px; line-height: 12px; font-weight: 600; color: var(--amber); background: var(--surface); padding: 0 4px 0 0; }
.wnote { display: flex; align-items: center; gap: 8px; margin-top: -6px; padding: 9px 12px; border-radius: var(--radius-panel); font-size: 13px; line-height: 18px; color: var(--text); }
.wnote > span:first-of-type { flex: 1; }
.wnote-warn { background: var(--amber-soft); }
.wnote-warn > .ic { color: var(--amber); }
.wnote-alert { background: var(--red-soft); }
.wnote-alert > .ic { color: var(--red); }
.s-ok { background: var(--blue); }
.s-warn { background: var(--amber); }
.s-alert, .s-crit { background: var(--red); }
.s-none { background: var(--text-3); }
.legend { display: flex; gap: 14px; margin-top: -8px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.lg-wind { background: var(--blue); }
.lg-gust { background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 3px), var(--surface-3); border-top: 2px solid var(--text-3); }

/* rios */
.situacao { border-radius: var(--radius-panel); padding: 12px 14px; background: var(--surface-2); border: 1px solid var(--line); }
.situacao.sit-alert, .situacao.sit-crit { background: var(--red-soft); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.situacao.sit-warn { background: var(--amber-soft); border-color: color-mix(in srgb, var(--amber) 25%, transparent); }
.situacao-top { display: flex; align-items: center; gap: 8px; }
.situacao.sit-alert .situacao-top > .ic, .situacao.sit-crit .situacao-top > .ic { color: var(--red); }
.situacao.sit-warn .situacao-top > .ic { color: var(--amber); }
.situacao-top .label { flex: 1; }
.situacao-txt { margin-top: 8px; font-size: 13px; line-height: 19px; color: var(--text); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rv-summary { margin-bottom: -8px; }
.rv-summary strong { color: var(--text); font-weight: 600; }
.rv-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rv { display: grid; gap: 6px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.rv:first-child { padding-top: 4px; }
.rv:last-child { border-bottom: 0; padding-bottom: 0; }
.rv-head { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px; min-width: 0; }
.rv-head .code { color: var(--text-3); }
.rv-name { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rv-body { display: grid; grid-template-columns: 76px 1fr; align-items: center; gap: 12px; }
.rv-level { font-size: 22px; line-height: 26px; font-weight: 600; letter-spacing: -.03em; }
.rv-bar { position: relative; height: 10px; border-radius: 5px; background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 5px), var(--surface-2); border: 1px solid var(--line); }
.rv-fill { position: absolute; left: 0; top: 0; bottom: 0; border-radius: 4px; transition: width .25s var(--ease); }
.rv-mark { position: absolute; top: -5px; bottom: -5px; width: 2px; margin-left: -1px; border-radius: 1px; }
.rv-mark-atencao { background: var(--amber); }
.rv-mark-alerta { background: var(--red); }
.rv-mark-emergencia { background: var(--ink); }
.rv-foot { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.trend { color: var(--text-2); font-weight: 500; }
.trend.up { color: var(--red); }
.trend.down { color: var(--green); }

/* ---------- seções ---------- */
.section { display: grid; gap: 18px; }
.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-title { font-size: 24px; line-height: 30px; font-weight: 600; letter-spacing: -.025em; margin-bottom: 4px; }
.section-actions { display: flex; gap: 8px; }
.cat-filter { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-filter:empty { display: none; }

/* cards de aplicação */
.apps-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: var(--gap-grid); }
.app-card {
  position: relative; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden;
  transition: border-color .2s var(--ease), transform .2s var(--ease), box-shadow .2s var(--ease);
}
.app-card:hover { border-color: var(--line-strong); transform: translateY(-2px); box-shadow: var(--shadow); }
.app-art { aspect-ratio: 16 / 9; background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 8px), var(--surface-2); border-bottom: 1px solid var(--line); overflow: hidden; }
.app-art > img { width: 100%; height: 100%; object-fit: cover; }
.app-art > .art { width: 100%; height: 100%; transition: transform .35s var(--ease); }
.app-card:hover .app-art > .art { transform: scale(1.035); }
.app-body { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 16px var(--pad-card-x) 4px; flex: 1; }
.app-body .card-title { font-size: 16px; line-height: 22px; }
.app-desc { font-size: 14px; line-height: 20px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.app-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px var(--pad-card-x) 16px; }
.app-foot .host { color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.btn-go { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn-go:hover { background: var(--btn-primary); border-color: var(--btn-primary); color: #fff; }
:root[data-theme="dark"] .btn-go:hover { color: var(--on-accent); }
.btn-go .ic { transition: transform .15s var(--ease); }
.btn-go:hover .ic { transform: translateX(2px); }
.admin-tools { position: absolute; top: 10px; right: 10px; display: flex; gap: 6px; }
.admin-tools .icon-btn { box-shadow: var(--shadow-sm); }

.app-add { align-items: center; justify-content: center; gap: 8px; min-height: 300px; padding: 24px; border: 1.5px dashed var(--line-strong); background: transparent; cursor: pointer; text-align: center; }
.app-add:hover { border-color: var(--accent); background: var(--accent-soft); }
.add-ic { display: grid; place-items: center; width: 48px; height: 48px; border-radius: var(--radius-control); background: var(--surface-3); color: var(--text-2); margin-bottom: 4px; }
.app-add:hover .add-ic { background: var(--btn-primary); color: #fff; }

/* ilustrações */
.art path, .art line, .art circle, .art rect { stroke: var(--text-2); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.art .f { fill: var(--surface); }
.art .f2 { fill: var(--surface-3); }
.art .a { fill: var(--accent); stroke: var(--accent-hover); }
.art .k { fill: var(--ink); stroke: var(--ink); }
.art .il { fill: none; stroke-width: 2; }
.art .il-thin { fill: none; stroke-width: 1; opacity: .75; }
.art .il-ground { stroke: var(--line-strong); stroke-width: 1.5; }
.art .il-bar { stroke-width: 5; stroke: var(--text-2); }
.art .il-dash { fill: none; stroke-dasharray: 4 5; stroke: var(--text-3); }
.art .a-stroke { fill: none; stroke: var(--accent); stroke-width: 3.5; }
.art .on-a { fill: none; stroke: var(--on-accent); stroke-width: 3.5; }
:root:not([data-theme="dark"]) .art .on-a { stroke: #fff; }

/* links úteis */
.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: var(--gap-grid); }
.link-card { display: flex; align-items: center; gap: 14px; padding: 16px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); transition: border-color .2s var(--ease); }
.link-card:hover { border-color: var(--line-strong); }
.link-ic { display: grid; place-items: center; width: 44px; height: 44px; flex: none; border-radius: var(--radius-control); background: var(--surface-2); border: 1px solid var(--line); color: var(--text); }
.link-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.link-name { font-size: 14.5px; line-height: 20px; font-weight: 600; letter-spacing: -.01em; }
.link-desc { font-size: 13px; line-height: 18px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.link-main .host { color: var(--text-3); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-actions { display: flex; align-items: center; gap: 6px; flex: none; }

/* vazio e carregando */
.empty { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 32px 16px; text-align: center; color: var(--text-2); border: 1px dashed var(--line-strong); border-radius: var(--radius-panel); background: var(--surface); }
.panel-body .empty { border: 0; padding: 40px 8px; }
.empty .ic { color: var(--text-3); }
.skeleton { border-radius: var(--radius-panel); background: linear-gradient(90deg, var(--surface-2) 0%, var(--surface-3) 50%, var(--surface-2) 100%); background-size: 200% 100%; animation: shimmer 1.4s ease-in-out infinite; }

/* ---------- diálogos e formulários ---------- */
.dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 1px solid var(--line); border-radius: var(--radius-dialog); background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); }
.dialog-wide { width: min(680px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.dialog[open] { animation: dlg-in .2s var(--ease); }
.dialog-in { display: flex; flex-direction: column; gap: 16px; padding: 20px 22px 22px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head .card-title { font-size: 17px; line-height: 24px; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.demo-hint { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--violet-soft); color: var(--text-2); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.field > label, .field > legend { font-size: 13.5px; line-height: 18px; font-weight: 500; color: var(--text-2); padding: 0; margin-bottom: 0; }
fieldset.field > legend { margin-bottom: 8px; }
.field input, .field textarea {
  width: 100%; min-height: var(--field-height); padding: 9px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text); font: inherit; font-size: 14px;
  transition: border-color .15s var(--ease);
}
.field textarea { resize: vertical; min-height: 84px; line-height: 20px; }
.field input:hover, .field textarea:hover { border-color: var(--text-3); }
.field input:focus-visible, .field textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 0; border-color: transparent; border-radius: var(--radius-sm); }
.help { font-size: 12.5px; line-height: 18px; color: var(--text-2); }
.form-error { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--red-soft); color: var(--red); font-size: 13.5px; font-weight: 500; }
:root:not([data-theme="dark"]) .form-error { color: #b91c1c; }

.seg { display: inline-flex; gap: 2px; padding: 3px; border-radius: var(--radius-inner); background: var(--surface-2); border: 1px solid var(--line); align-self: flex-start; margin-bottom: 10px; }
.seg-btn { height: 30px; padding: 0 12px; border: 0; border-radius: var(--radius-tag); background: transparent; color: var(--text-2); font-size: 13px; font-weight: 500; cursor: pointer; }
.seg-btn[aria-selected="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }

.img-lib { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; max-height: 300px; overflow-y: auto; padding: 2px; }
.img-opt { display: flex; flex-direction: column; gap: 4px; padding: 4px 4px 6px; border: 1px solid var(--line); border-radius: var(--radius-panel); background: var(--surface); cursor: pointer; text-align: left; }
.img-opt .art { width: 100%; aspect-ratio: 16 / 9; height: auto; border-radius: 8px; background: repeating-linear-gradient(135deg, var(--hatch) 0 1px, transparent 1px 6px), var(--surface-2); }
.img-opt .caption { padding: 0 4px; color: var(--text-2); font-size: 12px; line-height: 16px; }
.img-opt:hover { border-color: var(--line-strong); }
.img-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px; border: 1.5px dashed var(--line-strong); border-radius: var(--radius-panel); background: var(--surface-2); color: var(--text-2); text-align: center; cursor: pointer; transition: background-color .15s var(--ease), border-color .15s var(--ease); }
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
.upload-preview { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.upload-preview img { width: 160px; aspect-ratio: 16 / 9; object-fit: cover; border-radius: var(--radius-tag); border: 1px solid var(--line); }

.icon-picker { display: grid; grid-template-columns: repeat(auto-fill, minmax(44px, 1fr)); gap: 6px; }
.icon-opt { display: grid; place-items: center; height: 44px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface); color: var(--text-2); cursor: pointer; }
.icon-opt:hover { border-color: var(--line-strong); color: var(--text); }
.icon-opt[aria-checked="true"] { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); color: var(--text); }

/* usuários */
.users-toolbar { display: flex; gap: 8px; align-items: center; }
.search-inline { flex: 1; width: auto; }
.users-list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden auto; max-height: min(460px, 55dvh); }
.users-list > .skeleton, .users-list > .empty { border: 0; border-radius: 0; margin: 0; }
.urow { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.urow:last-child { border-bottom: 0; }
.urow:hover { background: var(--surface-2); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.urow-main { display: grid; min-width: 0; }
.urow-name { font-size: 14px; line-height: 20px; font-weight: 600; display: flex; align-items: center; gap: 6px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow-name .tag { height: 18px; font-size: 11px; padding: 0 6px; }
.urow-mail { font-family: var(--mono); font-size: 12px; line-height: 16px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.urow-actions { display: flex; gap: 6px; }
.icon-btn:disabled { opacity: .4; cursor: not-allowed; }
.seg-sm { margin: 0; padding: 2px; }
.seg-sm .seg-btn { height: 28px; padding: 0 10px; font-size: 12.5px; }
.seg-btn[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--line); }
.seg-btn[data-role="admin"][aria-pressed="true"] { color: var(--accent-hover); }
:root[data-theme="dark"] .seg-btn[data-role="admin"][aria-pressed="true"] { color: var(--accent); }
.seg-btn:disabled { cursor: not-allowed; }
.seg-btn:disabled:not([aria-pressed="true"]) { opacity: .45; }
.users-note { margin-top: -4px; }

.role-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-opt { position: relative; cursor: pointer; }
.role-opt input { position: absolute; opacity: 0; pointer-events: none; }
.role-opt-in { display: grid; gap: 2px; height: 100%; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: var(--radius-panel); background: var(--surface); font-size: 13.5px; transition: border-color .15s var(--ease), background-color .15s var(--ease); }
.role-opt-in .caption { color: var(--text-2); }
.role-opt:hover .role-opt-in { border-color: var(--text-3); }
.role-opt input:checked + .role-opt-in { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); background: var(--accent-soft); }
.role-opt input:focus-visible + .role-opt-in { outline: 2px solid var(--accent); outline-offset: 2px; }

.warn-box { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-radius: var(--radius-sm); background: var(--amber-soft); font-size: 13px; line-height: 19px; color: var(--text); }
.warn-box > .ic { color: var(--amber); margin-top: 1px; }

/* toasts */
.toasts { position: fixed; z-index: 60; inset: auto auto 20px 50%; transform: translateX(-50%); display: grid; gap: 8px; width: max-content; max-width: calc(100vw - 32px); margin: 0; padding: 0; border: 0; background: transparent; overflow: visible; color: inherit; }
.toasts[popover]:not(:popover-open) { display: none; }
.toast { display: flex; align-items: center; gap: 10px; padding: 11px 16px; border-radius: var(--radius-panel); background: var(--ink); color: var(--on-ink); font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg); animation: toast-in .2s var(--ease); }
.toast-error .ic { color: var(--red); }
.toast.out { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }

.site-foot { max-width: 1400px; margin: 0 auto; padding: 20px 24px 32px; display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--line); }

/* ---------- animações ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: -100% 0; } }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.985); } }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- responsivo ---------- */
@media (max-width: 1240px) {
  .hero-grid { grid-template-columns: 1fr 1fr; }
  .panel-rivers { grid-column: 1 / -1; }
}
@media (max-width: 980px) {
  .nav { display: none; }
}
@media (max-width: 760px) {
  .topbar-in { flex-wrap: wrap; gap: 10px; padding: 8px 16px 10px; }
  .topbar-actions { margin-left: auto; }
  .search { order: 10; width: 100%; flex: 1 1 100%; }
  .topbar-actions { display: contents; }
  .topbar-in > .brand { margin-right: auto; }
  .kbd, .hide-sm, .user-name, #mode-badge { display: none; }
  main { padding: 16px 16px 32px; gap: 32px; }
  .hero { padding: 20px 16px 16px; border-radius: var(--radius-dialog); }
  .hero-head { flex-direction: column; align-items: flex-start; gap: 14px; }
  .hero-side { align-items: flex-start; flex-direction: row-reverse; flex-wrap: wrap; justify-content: space-between; width: 100%; }
  .hero-summary { justify-content: flex-start; }
  .hero-grid { grid-template-columns: 1fr; }
  .panel-body { padding: 16px; }
  .hero-num { font-size: 46px; }
  .hours { grid-template-columns: repeat(6, 1fr); }
  .hours .hour:nth-child(n+7) { display: none; }
  .links-grid { grid-template-columns: 1fr; }
  .link-card { flex-wrap: wrap; }
  .link-actions { width: 100%; justify-content: flex-end; }
  .form-grid { grid-template-columns: 1fr; }
  .users-toolbar { flex-direction: column; align-items: stretch; }
  .users-toolbar .search { flex: none; }
  .user { gap: 6px; }
  .urow { grid-template-columns: auto 1fr auto; row-gap: 10px; }
  .urow .seg { grid-column: 2 / 3; justify-self: start; }
  .urow-actions { grid-column: 3; grid-row: 1; }
  .role-opts { grid-template-columns: 1fr; }
  .form-grid .span-2 { grid-column: auto; }
  .site-foot { padding: 16px; }
}
@media (max-width: 440px) {
  .brand-name { display: none; }
}
@media (max-width: 380px) {
  .rv-body { grid-template-columns: 66px 1fr; }
  .rv-level { font-size: 19px; }
}
