:root {
  --bg: #f5f6f8;
  --panel: #ffffff;
  --ink: #1b1f24;
  --muted: #6b7280;
  --line: #e2e5ea;
  --brand: #2f6df6;
  --brand-ink: #ffffff;
  --ok: #137a4a;
  --warn: #9a6400;
  --err: #b42318;
  --ok-bg: #e7f6ee;
  --warn-bg: #fdf3e0;
  --err-bg: #fdecea;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 14px/1.5 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
}

h1, h2, h3 { margin: 0 0 .4rem; line-height: 1.25; }
h2 { font-size: 1.15rem; }
h3 { font-size: .95rem; }
code { background: #eceff3; padding: .1em .35em; border-radius: 4px; font-size: .92em; }
.muted { color: var(--muted); }
small.muted { display: block; margin-top: .25rem; }

/* topbar */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .7rem 1.2rem; background: #11161d; color: #fff;
}
.brand { font-weight: 600; letter-spacing: .2px; }
.brand span { color: #8fb0ff; font-weight: 400; }
.who { display: flex; align-items: center; gap: .8rem; font-size: .9rem; }

/* layout */
.layout { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; padding: 1rem; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }

.sidebar, .content { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.sidebar-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .6rem; }
#site-filter { width: 100%; margin-bottom: .6rem; }

.site-list { list-style: none; margin: 0; padding: 0; }
.site-list li { margin-bottom: .15rem; }
.site-list li.meta { font-size: .8rem; color: var(--muted); padding: .4rem .6rem; }
.site-list .site-item {
  display: block; width: 100%; text-align: left; padding: .5rem .6rem;
  border-radius: 8px; cursor: pointer; border: 1px solid transparent; background: none;
}
.site-list .site-item:hover { background: #f2f5fb; }
.site-list .site-item.active { background: #eaf0fe; border-color: #c9d9ff; }
.site-list .site-item:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }
.site-list .dom { display: block; font-weight: 600; }
.site-list .meta { display: block; font-size: .8rem; color: var(--muted); }
.site-list .site-item.off { opacity: .55; }

/* forms */
label { display: block; margin-bottom: .7rem; font-size: .85rem; color: #303743; }
input, textarea, select {
  width: 100%; padding: .5rem .6rem; border: 1px solid var(--line);
  border-radius: 8px; font: inherit; background: #fff; color: var(--ink);
}
textarea { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; }
input:focus, textarea:focus { outline: 2px solid #c9d9ff; border-color: var(--brand); }

button {
  font: inherit; padding: .45rem .85rem; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: #fff; color: var(--ink);
}
button.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
button.primary:disabled { opacity: .5; cursor: not-allowed; }
button.ghost { background: #fff; }
button.danger { color: var(--err); border-color: #f3c9c4; }
button.small { padding: .3rem .6rem; font-size: .85rem; }

.row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.grid2 .span2 { grid-column: 1 / -1; }
@media (max-width: 760px) { .grid2 { grid-template-columns: 1fr; } }

/* tabs */
.tabs { display: flex; gap: .3rem; border-bottom: 1px solid var(--line); margin: 1rem 0; flex-wrap: wrap; }
.tab { border: none; background: none; padding: .5rem .8rem; border-bottom: 2px solid transparent; border-radius: 0; color: var(--muted); }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); font-weight: 600; }

.site-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }
.site-actions { display: flex; gap: .5rem; }

.empty { padding: 2rem 1rem; color: var(--muted); }
.empty h2 { color: var(--ink); }

/* listas de URL */
.page-list { list-style: none; margin: 0 0 .6rem; padding: 0; }
.page-list li {
  border: 1px solid var(--line); border-radius: 8px; padding: .5rem .6rem;
  margin-bottom: .4rem; display: flex; justify-content: space-between; gap: .6rem;
}
.page-list .path { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 600; }
.page-list .slots { font-size: .8rem; color: var(--muted); word-break: break-all; }

.page-picker { display: flex; flex-wrap: wrap; gap: .5rem; margin: .8rem 0; }
.page-picker label {
  border: 1px solid var(--line); border-radius: 999px; padding: .3rem .7rem;
  margin: 0; display: flex; gap: .4rem; align-items: center; background: #fff;
}
.page-picker input { width: auto; }

.build-controls { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; }
.build-controls label { margin-bottom: 0; }
.build-controls input { min-width: 180px; }

/* tabelas */
.table-wrap { overflow-x: auto; margin-top: .8rem; }
table.data { border-collapse: collapse; width: 100%; font-size: .85rem; }
table.data th, table.data td { border-bottom: 1px solid var(--line); padding: .4rem .5rem; text-align: left; white-space: nowrap; }
table.data th { background: #f8f9fb; position: sticky; top: 0; font-weight: 600; }
table.data td.mono, table.data td .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
/* a mensagem de erro e a unica coluna que precisa quebrar linha: sem isto ela
   empurra a tabela inteira para fora da tela */
table.data td.detalhe { white-space: normal; min-width: 260px; max-width: 460px; }

.badge { padding: .1rem .45rem; border-radius: 999px; font-size: .78rem; font-weight: 600; }
.badge.add { background: var(--ok-bg); color: var(--ok); }
.badge.update { background: #e8effd; color: #1d4ed8; }
.badge.noop { background: #eef0f3; color: var(--muted); }
.badge.error { background: var(--err-bg); color: var(--err); }
.badge.ok { background: var(--ok-bg); color: var(--ok); }
.badge.partial { background: var(--warn-bg); color: var(--warn); }

.warnings { margin: .8rem 0; }
.warnings p {
  background: var(--warn-bg); color: var(--warn); border: 1px solid #f0dcb4;
  border-radius: 8px; padding: .45rem .6rem; margin: 0 0 .35rem;
}
.summary { margin: .6rem 0; font-weight: 600; }
.flash { font-size: .85rem; color: var(--ok); }
.flash.err { color: var(--err); }
.error { color: var(--err); min-height: 1.2em; }

/* bulk */
.bulk { border: 1px solid var(--line); border-radius: 8px; padding: .6rem .8rem; margin-bottom: 1rem; }
.bulk summary { cursor: pointer; font-weight: 600; }
.bulk textarea { margin: .6rem 0; }

/* dialog */
dialog {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 1.2rem;
  width: min(560px, 92vw); color: var(--ink);
}
dialog::backdrop { background: rgba(15, 20, 28, .45); }
fieldset { border: 1px solid var(--line); border-radius: 8px; margin: 0 0 .8rem; }
legend { font-size: .85rem; color: var(--muted); padding: 0 .3rem; }
.slot-checks { display: flex; flex-direction: column; gap: .2rem; max-height: 220px; overflow-y: auto; margin-bottom: .6rem; }
.slot-checks label { margin: 0; display: flex; gap: .45rem; align-items: center; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .82rem; }
.slot-checks input { width: auto; }

/* login */
.login-body { display: grid; place-items: center; min-height: 100vh; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.6rem; width: min(360px, 92vw); }
.login-card h1 { font-size: 1.3rem; }
.login-card h1 span { color: var(--brand); font-weight: 400; }
.login-card button { width: 100%; margin-top: .3rem; }

/* toast */
.toast {
  position: fixed; right: 1rem; bottom: 1rem; background: #11161d; color: #fff;
  padding: .6rem .9rem; border-radius: 8px; max-width: 420px; z-index: 50;
}
.toast.err { background: var(--err); }
