:root {
    --bg: #0f0e1f;
    --panel: #19173a;
    --panel-2: #221f4a;
    --line: #2f2b60;
    --text: #e9e6ff;
    --muted: #9d97c9;
    --accent: #b9a7ff;
    --accent-2: #7f6bff;
    --ok: #4fd18b;
    --warn: #f2c14e;
    --err: #ff6b7d;
    --info: #63b3ff;
    --radius: 10px;
    color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
    background: var(--bg);
    color: var(--text);
    font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    min-height: 100vh;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 16px; }
h2 { font-size: 1.1rem; margin: 24px 0 10px; color: var(--accent); }
h3 { font-size: 1rem; margin: 16px 0 8px; }
small, .muted { color: var(--muted); }
code, .mono { font-family: ui-monospace, Consolas, monospace; font-size: .9em; }

/* ---------- barra e menu */
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; gap: 12px;
    height: 52px; padding: 0 16px;
    background: #14122b; border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; color: var(--text); font-size: 1.05rem; }
.brand img { width: 26px; height: 26px; }
.brand small { color: var(--muted); font-weight: 400; }
.who { margin-left: auto; color: var(--muted); font-size: .9rem; white-space: nowrap; }
.menu-btn { display: none; background: none; border: 0; color: var(--text); font-size: 1.4rem; cursor: pointer; padding: 4px 8px; }

.sidenav {
    position: fixed; top: 52px; bottom: 0; left: 0; width: 220px;
    padding: 12px 8px; overflow-y: auto;
    background: #14122b; border-right: 1px solid var(--line);
}
.sidenav a {
    display: flex; align-items: center; gap: 6px;
    padding: 9px 12px; border-radius: 8px; color: var(--text); margin-bottom: 2px;
}
.sidenav a:hover { background: var(--panel); text-decoration: none; }
.sidenav a.active { background: var(--panel-2); color: var(--accent); }
.content { margin-left: 220px; padding: 22px 26px 60px; max-width: 1300px; }

@media (max-width: 860px) {
    .menu-btn { display: block; }
    .sidenav { transform: translateX(-100%); transition: transform .2s; z-index: 30; width: 250px; }
    body.nav-open .sidenav { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.5); }
    .content { margin-left: 0; padding: 16px 16px 60px; }
    .who { font-size: .8rem; }
}

/* ---------- blocos */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 8px; }
@media (max-width: 420px) { .cards { grid-template-columns: 1fr 1fr; gap: 8px; } .card { padding: 10px 12px; } .card .value { font-size: 1.35rem; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.card .label { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 1.7rem; font-weight: 700; margin-top: 2px; }
.card .sub { color: var(--muted); font-size: .82rem; }
.card.ok .value { color: var(--ok); } .card.err .value { color: var(--err); } .card.warn .value { color: var(--warn); }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-main { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 860px) { .grid2, .grid3, .grid-main { grid-template-columns: 1fr; } }

/* ---------- tabelas */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; background: #1c1a40; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #1f1c46; }
tr.unread td { font-weight: 600; }
tr.unread td:first-child { box-shadow: inset 3px 0 var(--accent); }
td.num, th.num { text-align: right; }
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
dl.kv dt { color: var(--muted); }
dl.kv dd { margin: 0; word-break: break-word; }

/* ---------- etiquetas */
.tag { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--panel-2); color: var(--muted); white-space: nowrap; }
.tag.open { background: #3a2c10; color: var(--warn); }
.tag.in_progress { background: #13304d; color: var(--info); }
.tag.answered { background: #2b2357; color: var(--accent); }
.tag.resolved, .tag.active, .tag.on { background: #12382a; color: var(--ok); }
.tag.closed, .tag.off { background: #2a2a35; color: #aaa; }
.tag.banned, .tag.urgent { background: #451825; color: var(--err); }
.tag.high { background: #45301a; color: #ffad5c; }
.tag.low { background: #23233a; color: #9a9ab8; }
.tag.premium { background: #3b2f12; color: #ffd76a; }
.badge { background: var(--err); color: #fff; border-radius: 99px; font-size: .72rem; padding: 1px 7px; margin-left: auto; font-weight: 700; }

/* ---------- formulários */
form.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row > * { flex: 0 1 auto; }
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field label, label.lbl { color: var(--muted); font-size: .85rem; }
input[type=text], input[type=password], input[type=number], input[type=search], input[type=datetime-local], input[type=file], select, textarea {
    background: #0f0e24; color: var(--text); border: 1px solid var(--line); border-radius: 8px;
    padding: 9px 11px; font: inherit; min-width: 0; width: 100%;
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-2); border-color: transparent; }
.row input, .row select { width: auto; }
.row .grow { flex: 1 1 220px; }
.row .grow input, .row .grow select { width: 100%; }
button, .btn {
    display: inline-flex; align-items: center; gap: 6px; justify-content: center;
    background: var(--accent-2); color: #fff; border: 0; border-radius: 8px;
    padding: 9px 15px; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { filter: brightness(1.12); text-decoration: none; }
button.secondary, .btn.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); }
button.danger, .btn.danger { background: #b3263c; }
button.ok, .btn.ok { background: #1f8f58; }
button.small, .btn.small { padding: 5px 10px; font-size: .85rem; }
.actions { display: flex; flex-wrap: wrap; gap: 6px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--text); }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; font-weight: 500; }
.flash.ok { background: #12382a; color: #b4f5d2; border: 1px solid #1f6e4a; }
.flash.err { background: #451825; color: #ffc4cc; border: 1px solid #7d2a3c; }
.empty { color: var(--muted); padding: 20px; text-align: center; }

/* ---------- conversa do chamado */
.chat { display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 82%; padding: 10px 13px; border-radius: 12px; background: var(--panel-2); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg.player { align-self: flex-start; border-bottom-left-radius: 3px; }
.msg.admin { align-self: flex-end; background: #2c2470; border-bottom-right-radius: 3px; }
.msg.internal { align-self: flex-end; background: #3b3112; border: 1px dashed #8a6d1d; }
.msg.system { align-self: center; background: none; border: 0; color: var(--muted); font-size: .85rem; }
.msg .meta { display: block; font-size: .75rem; color: var(--muted); margin-bottom: 4px; white-space: normal; }
.msg img { display: block; max-width: 100%; max-height: 360px; border-radius: 8px; margin-top: 8px; cursor: zoom-in; }
@media (max-width: 860px) { .msg { max-width: 95%; } }

/* ---------- barras simples */
.bars { display: flex; align-items: flex-end; gap: 4px; height: 120px; padding-top: 10px; }
.bars .bar { flex: 1; background: var(--accent-2); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars .bar span { position: absolute; top: -18px; left: 0; right: 0; text-align: center; font-size: .7rem; color: var(--muted); }
.bars-x { display: flex; gap: 4px; font-size: .68rem; color: var(--muted); }
.bars-x span { flex: 1; text-align: center; }
.hbar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 8px; align-items: center; margin: 4px 0; font-size: .88rem; }
.hbar .track { background: #0f0e24; border-radius: 4px; height: 10px; overflow: hidden; }
.hbar .fill { background: var(--accent); height: 100%; }

.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: #666; margin-right: 6px; }
.dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.off { background: var(--err); }

/* ---------- login */
.login-box { max-width: 380px; margin: 10vh auto; padding: 0 16px; }
.login-box .panel { padding: 24px; }
.login-box h1 { display: flex; align-items: center; gap: 10px; }
.login-box img { width: 40px; }

/* ---------- site público */
body.public { background: radial-gradient(ellipse at top, #2a2160 0%, var(--bg) 60%) fixed; }
.public-content { max-width: 760px; margin: 0 auto; padding: 32px 16px 60px; }
.hero { text-align: center; padding: 30px 0 10px; }
.hero img { width: 110px; height: 110px; filter: drop-shadow(0 0 24px rgba(185,167,255,.45)); }
.hero h1 { font-size: 2.2rem; margin: 12px 0 6px; letter-spacing: .02em; }
.hero p { color: var(--muted); font-size: 1.05rem; margin: 0 auto; max-width: 520px; }
.download { text-align: center; margin: 26px 0; }
.download .btn { font-size: 1.1rem; padding: 14px 26px; border-radius: 12px; }
.steps { counter-reset: s; list-style: none; padding: 0; }
.steps li { counter-increment: s; position: relative; padding: 10px 0 10px 44px; border-bottom: 1px solid var(--line); }
.steps li::before { content: counter(s); position: absolute; left: 0; top: 9px; width: 30px; height: 30px; border-radius: 50%; background: var(--accent-2); color: #fff; font-weight: 700; display: grid; place-items: center; }
footer.public-footer { text-align: center; color: var(--muted); font-size: .85rem; margin-top: 40px; }
