:root {
  --bg: #0f1115; --panel: #161a21; --hover: #1d222b; --line: #252b35;
  --text: #e6e8eb; --muted: #8a93a3; --accent: #7c94ff; --accent-soft: #7c94ff22; --err: #ff7b7b; --logo: #fc56c2;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f6f7f9; --panel: #ffffff; --hover: #f0f2f6; --line: #e3e6eb;
  --text: #1c2230; --muted: #6b7280; --accent: #4f6bed; --accent-soft: #4f6bed18; --err: #c62828; --logo: var(--text);
  color-scheme: light;
}
* { box-sizing: border-box; }
body {
  margin: 0; height: 100vh; display: grid; grid-template-columns: 300px 1fr;
  font: 14px/1.45 system-ui, "Segoe UI", sans-serif; background: var(--bg); color: var(--text);
  transition: background .2s, color .2s;
}
button { font: inherit; cursor: pointer; border: 0; border-radius: 8px; transition: background .15s, opacity .15s; }

aside { background: var(--panel); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
header { display: flex; gap: 10px; align-items: center; padding: 16px 16px 4px; }
#theme { margin-left: auto; }
header h1 { font-size: 15px; font-weight: 600; margin: 0; }
#theme { background: transparent; color: var(--muted); width: 32px; height: 32px; font-size: 16px; }
#theme:hover { background: var(--hover); color: var(--text); }
.me { display: flex; justify-content: space-between; gap: 8px; padding: 4px 16px 0; font-size: 12px; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Logo (logo.svg na raiz, uma cor só): usada como máscara e pintada com --logo, que muda por tema.
   O <img> fica invisível e só detecta se o arquivo existe; sem ele, o <img> se remove e fica o tracejado. */
.logo { display: inline-flex; flex: none; width: 28px; height: 28px; border-radius: 6px; }
.logo img { width: 100%; height: 100%; opacity: 0; }
.logo:not(:empty) { background: var(--logo); mask: url(/logo.svg) center / contain no-repeat; }
.logo:empty { border: 1.5px dashed var(--line); }
.logo-lg { width: 72px; height: 72px; border-radius: 14px; }

#q {
  margin: 12px 16px; padding: 9px 12px; border-radius: 8px; font: inherit;
  border: 1px solid var(--line); background: var(--bg); color: var(--text); outline: none;
}
#q:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
#users { list-style: none; margin: 0; padding: 0 8px 12px; overflow: auto; }
#users li { padding: 8px 10px; border-radius: 8px; cursor: pointer; transition: background .12s; }
#users li:hover { background: var(--hover); }
#users li.sel { background: var(--accent-soft); box-shadow: inset 3px 0 var(--accent); }
#users small, .muted { color: var(--muted); }

/* --pad e --bar-h posicionam os stickies: a barra encosta no topo, o cabeçalho da tabela logo abaixo dela */
main { --pad: 24px; --bar-h: 60px; padding: var(--pad) 32px; overflow: auto; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
h2 small { display: block; font-size: 13px; font-weight: 400; margin-top: 2px; }
.bar { position: sticky; top: calc(-1 * var(--pad)); z-index: 2; height: var(--bar-h); background: var(--bg); padding: 12px 0; display: flex; gap: 12px; align-items: center; }
#save { background: var(--accent); color: #fff; padding: 8px 18px; font-weight: 500; }
#save:disabled { opacity: .35; cursor: default; }
#msg { color: var(--muted); font-size: 13px; }

table { width: 100%; border-collapse: separate; border-spacing: 0; background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); }
tbody tr:last-child td { border-bottom: 0; }
th { font-size: 12px; font-weight: 500; color: var(--muted); position: sticky; top: calc(var(--bar-h) - var(--pad)); z-index: 1; background: var(--panel); }
/* sem overflow:hidden na tabela (quebraria o sticky), então os cantos vão nas células */
th:first-child { border-top-left-radius: 12px; } th:last-child { border-top-right-radius: 12px; }
tbody tr:last-child td:first-child { border-bottom-left-radius: 12px; } tbody tr:last-child td:last-child { border-bottom-right-radius: 12px; }
td.c, th.c { text-align: center; width: 130px; }
tbody tr:not(.sep):hover td { background: var(--hover); }
tr.noaccess td:first-child { color: var(--muted); }
tr.sep td { background: var(--bg); font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 8px 14px; }
input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; }
.tag { display: inline-block; background: var(--hover); border: 1px solid var(--line); border-radius: 999px; padding: 1px 8px; margin: 2px 2px 2px 0; font-size: 12px; color: var(--muted); }
.err { color: var(--err); white-space: pre-wrap; }

body.login { grid-template-columns: 1fr; place-items: center; }
.card { display: flex; flex-direction: column; align-items: center; gap: 8px; width: min(360px, calc(100vw - 32px)); padding: 40px 32px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 16px; text-align: center; }
.card h1 { font-size: 22px; font-weight: 600; margin: 12px 0 0; }
.card p { margin: 0; }
.btn { margin-top: 20px; width: 100%; padding: 10px; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 500; }
.btn:hover { text-decoration: none; filter: brightness(1.08); }
.card .err:empty { display: none; }
.card .err { margin-top: 8px; font-size: 13px; }
@media (max-width: 900px) { body { grid-template-columns: 220px 1fr; } main { --pad: 20px; padding: var(--pad); } th, td { padding: 8px 10px; } td.c, th.c { width: auto; } }
