/* Painel de operações TwoFaces: tokens e regras de documentation/ui.md
   (controlos em pílula, contentores em retângulo moderado, um só acento, sem blur, sem sombras internas, sem mono) */
@font-face { font-family: "Bebas"; src: url("/fonts/BebasNeueBold.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Gilroy"; font-weight: 300; src: url("/fonts/Gilroy-Light.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Gilroy"; font-weight: 500; src: url("/fonts/Gilroy-Medium.ttf") format("truetype"); font-display: swap; }
@font-face { font-family: "Gilroy"; font-weight: 700; src: url("/fonts/Gilroy-SemiBold.ttf") format("truetype"); font-display: swap; }

:root {
    --surface: #0a0a0c;
    --sidebar: #050509;
    --raised: #101014;
    --elevated: #17171c;
    --hover: #1f1f26;
    --ink: #f2f3f6;
    --muted: rgba(255, 255, 255, 0.62);
    --faint: rgba(255, 255, 255, 0.38);
    --accent: #2563eb;
    --accent-hover: #3b82f6;
    --steel: #8b93a7;
    --good: #4fae86;
    --bad: #dc6e6e;
    --warn: #d3963f;
    --line: rgba(255, 255, 255, 0.072);
    --line-strong: rgba(255, 255, 255, 0.14);
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    background: var(--surface);
    color: var(--ink);
    font: 500 14px/1.45 "Gilroy", system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; color: inherit; }
a { color: inherit; }
.noscript { padding: 24px; }

/* ── Estrutura ─────────────────────────────────────────────────────────────── */
.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px; background: var(--sidebar); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: baseline; gap: 14px; }
.wordmark { font: 26px/1 "Bebas", sans-serif; letter-spacing: 0.04em; }
.tag { font-weight: 700; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }
.userbar { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--elevated);
    border: 1px solid var(--line-strong); object-fit: cover; display: grid; place-items: center;
    font-weight: 700; font-size: 12px;
}
.username { color: var(--muted); }

main { max-width: 1040px; margin: 0 auto; padding: 28px 28px 80px; display: grid; gap: 30px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; gap: 12px; }
.label { font-weight: 700; font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--faint); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions.spaced { margin-top: 12px; }

/* ── Contentores ───────────────────────────────────────────────────────────── */
.panel { background: var(--raised); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.ledger { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cell { background: var(--raised); padding: 16px 18px; display: grid; gap: 6px; align-content: start; }
.cell .k { font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }
.cell .v { font: 28px/1.1 "Bebas", sans-serif; letter-spacing: 0.03em; }
.cell .s { color: var(--muted); font-size: 13px; }

.rows > .row { display: grid; grid-template-columns: 36px 1fr auto; gap: 14px; align-items: center; padding: 14px 18px; }
.rows > .row + .row { border-top: 1px solid var(--line); }
.chip {
    width: 36px; height: 36px; border-radius: 50%; background: var(--elevated);
    border: 1px solid var(--line-strong); display: grid; place-items: center; color: var(--muted);
}
.row-main { min-width: 0; display: grid; gap: 4px; }
.row-title { font-weight: 700; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row-sub { color: var(--muted); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.sha { font-weight: 700; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); }

/* ── Controlos (pílulas) ───────────────────────────────────────────────────── */
.btn, .pill {
    display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 16px;
    border-radius: 999px; border: 1px solid var(--line-strong); background: var(--elevated);
    cursor: pointer; text-decoration: none; white-space: nowrap; font-weight: 700; font-size: 13px;
}
.btn:hover:not(:disabled) { background: var(--hover); }
.btn:disabled { opacity: 0.42; cursor: not-allowed; }
.btn svg, .pill svg { width: 15px; height: 15px; }
.btn.primary, .pill.primary { border-color: rgba(37, 99, 235, 0.25); background: linear-gradient(rgba(37, 99, 235, 0.08), rgba(37, 99, 235, 0.08)), var(--elevated); color: var(--accent-hover); }
.btn.primary:hover:not(:disabled) { border-color: var(--accent); }
.btn.danger { border-color: rgba(220, 110, 110, 0.3); color: var(--bad); }
.btn.icon { width: 34px; padding: 0; justify-content: center; }
.badge {
    display: inline-flex; align-items: center; gap: 6px; height: 22px; padding: 0 10px; border-radius: 999px;
    font-weight: 700; font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
    background: rgba(139, 147, 167, 0.12); color: var(--steel);
}
.badge.good { background: rgba(79, 174, 134, 0.12); color: var(--good); }
.badge.bad { background: rgba(220, 110, 110, 0.12); color: var(--bad); }
.badge.warn { background: rgba(211, 150, 63, 0.12); color: var(--warn); }
.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

input.field {
    width: 100%; height: 40px; padding: 0 18px; border-radius: 999px; background: var(--surface);
    border: 1px solid var(--line-strong); outline: none;
}
input.field:focus { border-color: var(--accent); }
input.code { text-align: center; letter-spacing: 0.4em; font-weight: 700; font-size: 18px; }

/* ── Logs e bots ───────────────────────────────────────────────────────────── */
.console { max-height: 340px; overflow: auto; padding: 14px 18px; display: grid; gap: 2px; font-size: 12.5px; color: var(--muted); }
.console div { white-space: pre-wrap; word-break: break-word; }
.console .err { color: var(--bad); }
.bot-logs { grid-column: 1 / -1; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; font-size: 12.5px; color: var(--muted); display: grid; gap: 2px; }
.bot-logs div { white-space: pre-wrap; word-break: break-word; }
.bot-logs .err { color: var(--bad); }
.empty { padding: 22px 18px; color: var(--faint); }

/* ── Activity ──────────────────────────────────────────────────────────────── */
.feed { max-height: 566px; overflow-y: auto; }
.feed .row { grid-template-columns: 1fr auto; padding: 11px 18px; }
.when { color: var(--faint); font-size: 12px; }

/* ── Banner do trabalho em curso, toasts, modal ────────────────────────────── */
.banner { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border: 1px solid rgba(37, 99, 235, 0.25); background: rgba(37, 99, 235, 0.08); border-radius: 12px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--line-strong); border-top-color: var(--accent); animation: spin 0.9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 20px; top: 70px; display: grid; gap: 10px; z-index: 30; width: min(380px, calc(100vw - 40px)); }
.toast { background: var(--raised); border: 1px solid var(--line-strong); border-radius: 12px; padding: 12px 16px; display: flex; gap: 12px; align-items: flex-start; animation: slide 0.22s ease-out; }
.toast.good { border-color: rgba(79, 174, 134, 0.45); }
.toast.bad { border-color: rgba(220, 110, 110, 0.45); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.good svg { color: var(--good); }
.toast.bad svg { color: var(--bad); }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.badge.clickable { border: none; cursor: pointer; font-family: inherit; }
.badge.clickable:hover { background: rgba(211, 150, 63, 0.22); }
.modal.wide { width: min(780px, 100%); max-height: calc(100vh - 40px); overflow: auto; }
.filelist { overflow-y: auto; max-height: 44vh; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.file { display: grid; grid-template-columns: 22px auto 1fr auto; gap: 10px; align-items: center; padding: 8px 12px; }
.file + .file, .file + .diff { border-top: 1px solid var(--line); }
.file .path { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file input[type="checkbox"] { width: 16px; height: 16px; accent-color: #2563eb; cursor: pointer; }
.linkbtn { background: none; border: none; color: var(--steel); cursor: pointer; text-decoration: underline; font-size: 12px; padding: 0; }
.diff { padding: 8px 12px 12px; display: grid; gap: 1px; font-size: 12px; background: var(--raised); max-height: 260px; overflow: auto; }
.diff div { white-space: pre-wrap; word-break: break-all; color: var(--muted); }
.diff .add { color: var(--good); }
.diff .del { color: var(--bad); }
.diff .hunk { color: var(--steel); }
.stack { display: grid; gap: 8px; }
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, 0.75); display: grid; place-items: center; z-index: 40; padding: 20px; }
.modal { width: min(420px, 100%); background: var(--raised); border: 1px solid var(--line-strong); border-radius: 12px; padding: 22px; display: grid; gap: 14px; }
.modal h3 { margin: 0; font: 22px/1.1 "Bebas", sans-serif; letter-spacing: 0.04em; }
.modal p { margin: 0; color: var(--muted); }
.modal .err { color: var(--bad); min-height: 18px; font-size: 13px; }
.modal .buttons { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Login ─────────────────────────────────────────────────────────────────── */
.center { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.card { width: min(400px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 30px; display: grid; gap: 18px; text-align: center; }
.card .wordmark { font-size: 40px; }
.card p { margin: 0; color: var(--muted); }
.card .err { color: var(--bad); min-height: 18px; font-size: 13px; }
.card .pill, .card .btn { justify-content: center; height: 42px; }
.linklike { background: none; border: none; color: var(--faint); cursor: pointer; text-decoration: underline; }
.notice-body { display: grid; place-items: center; min-height: 100vh; padding: 20px; }
.notice { width: min(420px, 100%); background: var(--raised); border: 1px solid var(--line); border-radius: 12px; padding: 30px; display: grid; gap: 14px; text-align: center; }
.notice h1 { margin: 0; font: 30px/1.1 "Bebas", sans-serif; letter-spacing: 0.04em; }
.notice p { margin: 0; color: var(--muted); }
.notice .pill { justify-content: center; }

@media (max-width: 760px) {
    .ledger { grid-template-columns: repeat(2, 1fr); }
    .rows > .row { grid-template-columns: 36px 1fr; }
    .row-actions { grid-column: 1 / -1; justify-content: flex-start; }
    .rows.feed > .row { grid-template-columns: 1fr auto; }
    .topbar, main { padding-left: 16px; padding-right: 16px; }
}
