:root {
  color-scheme: light;
  --bg: #f5f5f3;
  --surface: #fcfcfb;
  --surface-2: #f0efec;
  --border: #e4e3df;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-ink: #ffffff;
  --series: #2a78d6;
  --grid: #e9e8e4;
  --good: #0ca30c;
  --good-text: #006300;
  --warning: #fab219;
  --critical: #d03b3b;
  --shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 4px 16px rgba(0, 0, 0, .04);
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #2e2e2b;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e86;
    --accent: #3987e5;
    --series: #3987e5;
    --grid: #2a2a27;
    --good-text: #4cc94c;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211; --surface: #1a1a19; --surface-2: #232321; --border: #2e2e2b;
  --text: #f0efec; --text-2: #c3c2b7; --muted: #8f8e86; --accent: #3987e5;
  --series: #3987e5; --grid: #2a2a27; --good-text: #4cc94c; --shadow: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 Inter, system-ui, -apple-system, Segoe UI, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.center { text-align: center; }
code { font: 12px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--surface-2); padding: 2px 6px; border-radius: 6px; word-break: break-all; }
h2 { margin: 0; font-size: 22px; letter-spacing: -.01em; }
h3 { margin: 0 0 12px; font-size: 14px; font-weight: 600; color: var(--text-2); }
a { color: var(--accent); }

.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; }
.brand.big { font-size: 22px; justify-content: center; }
.logo { width: 28px; height: 28px; border-radius: 8px; background: var(--accent); position: relative; flex: none; }
.logo::before { content: ""; position: absolute; inset: 7px; border: 2.4px solid #fff; border-radius: 5px; }
.logo::after { content: ""; position: absolute; inset: 11px; border: 2.4px solid #fff; border-radius: 50%; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(360px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 28px; display: grid; gap: 14px; text-align: center; box-shadow: var(--shadow); }
.error { color: var(--critical); min-height: 1em; margin: 0; }

/* Layout */
#app { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 20px 14px; border-right: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; gap: 20px; }
nav { display: grid; gap: 2px; }
nav a { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 10px; color: var(--text-2); text-decoration: none; font-weight: 500; }
nav a:hover { background: var(--surface-2); }
nav a.on { background: var(--surface-2); color: var(--text); }
.pill { font-size: 11px; background: var(--accent); color: var(--accent-ink); border-radius: 99px; padding: 0 7px; min-width: 18px; text-align: center; }
.pill:empty { display: none; }
.side-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; }
.live { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.live.on i { background: var(--good); box-shadow: 0 0 0 0 rgba(12, 163, 12, .5); animation: pulse 2s infinite; }
.live.on { color: var(--good-text); }
@keyframes pulse { 70% { box-shadow: 0 0 0 7px rgba(12, 163, 12, 0); } 100% { box-shadow: 0 0 0 0 rgba(12, 163, 12, 0); } }

main { padding: 24px 28px 60px; max-width: 1180px; width: 100%; }
section { display: none; }
section.on { display: grid; gap: 16px; }
.view-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 12px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); min-width: 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Botões e campos */
.btn { appearance: none; border: 1px solid var(--border); background: var(--surface); color: var(--text); padding: 8px 14px; border-radius: 10px; font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--critical); }
.btn.sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: default; }
.link { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 0; }
input, textarea, select { width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
input:focus, textarea:focus, select:focus { outline: 2px solid color-mix(in srgb, var(--accent) 40%, transparent); border-color: var(--accent); }
textarea { resize: vertical; }
.form { display: grid; gap: 14px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field label { font-weight: 500; color: var(--text-2); font-size: 13px; display: flex; justify-content: space-between; gap: 8px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.check { display: flex; gap: 8px; align-items: center; color: var(--text-2); }
.check input { width: auto; }
.form-foot { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }
.form-foot .muted { margin-right: auto; }
.inline { display: flex; gap: 8px; }
details.more summary { cursor: pointer; color: var(--text-2); font-weight: 500; }
details.more[open] { display: grid; gap: 12px; }

.seg { display: inline-flex; background: var(--surface-2); padding: 3px; border-radius: 11px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; font: inherit; font-weight: 500; color: var(--text-2); cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg.small button { padding: 5px 10px; font-size: 13px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { border: 1px solid var(--border); background: var(--surface); border-radius: 99px; padding: 7px 12px; font: inherit; font-size: 13px; cursor: pointer; color: var(--text-2); }
.chips button.on { border-color: var(--accent); color: var(--text); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

/* Várias contas */
.acct-switch { font-weight: 600; }
.acct { font-size: 11px; font-weight: 600; color: var(--text-2); background: var(--surface-2); padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.acct-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 10px; }
.acct-card { display: flex; gap: 12px; align-items: center; text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 12px; cursor: pointer; font: inherit; color: inherit; min-width: 0; }
.acct-card:hover { background: var(--surface-2); }
.avatar { width: 40px; height: 40px; border-radius: 50%; object-fit: cover; background: var(--surface-2); flex-shrink: 0; display: grid; place-items: center; font-weight: 700; color: var(--muted); }
.acct-card .n { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.acct-card .s { font-size: 12px; color: var(--muted); }
.acct-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); flex-wrap: wrap; }
.acct-row:first-of-type { border-top: 0; }
.acct-row .grow { flex: 1; min-width: 160px; }

.drop { border: 1.5px dashed var(--border); border-radius: var(--radius); padding: 28px; text-align: center; color: var(--muted); cursor: pointer; display: block; }
.drop.over { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 6%, transparent); }
.drop input { display: none; }
.previews { display: flex; gap: 10px; flex-wrap: wrap; }
.previews:empty { display: none; }
.prev { position: relative; width: 96px; height: 120px; border-radius: 10px; overflow: hidden; background: var(--surface-2); }
.prev img, .prev video { width: 100%; height: 100%; object-fit: cover; }
.prev button { position: absolute; top: 4px; right: 4px; border: 0; border-radius: 50%; width: 22px; height: 22px; background: rgba(0, 0, 0, .6); color: #fff; cursor: pointer; }
.prev .bar { position: absolute; left: 0; bottom: 0; height: 4px; background: var(--accent); width: 0; transition: width .2s; }
.prev .idx { position: absolute; left: 6px; top: 4px; color: #fff; font-size: 11px; font-weight: 600; text-shadow: 0 1px 2px rgba(0, 0, 0, .6); }

/* Perfil e números */
.profile { display: flex; align-items: center; gap: 14px; }
.profile img { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.profile .name { font-size: 20px; font-weight: 700; }
.profile .sub { color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tiles .tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); }
.tiles.compact { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 8px; }
.tiles.compact .tile { background: var(--surface-2); border: 0; box-shadow: none; padding: 10px 12px; }
.tile .label { color: var(--muted); font-size: 12px; font-weight: 500; }
.tile .value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.tiles.compact .value { font-size: 20px; }
.tile .delta { font-size: 12px; color: var(--text-2); }

/* Gráficos */
.chart { position: relative; min-height: 180px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--muted); font-size: 11px; }
.chart .gridline { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--series); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .area { fill: var(--series); opacity: .1; }
.chart .bar { fill: var(--series); }
.chart .bar.dim { opacity: .35; }
.chart .cross { stroke: var(--muted); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .dot { fill: var(--series); stroke: var(--surface); stroke-width: 2; }
.chart .empty { color: var(--muted); text-align: center; padding: 60px 0; }
.tip { position: fixed; pointer-events: none; background: var(--text); color: var(--bg); padding: 6px 10px; border-radius: 8px; font-size: 12px; opacity: 0; transition: opacity .1s; z-index: 50; white-space: nowrap; }
.tip.on { opacity: 1; }

/* Grade de mídia */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.media-grid.big { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.m { border-radius: 12px; overflow: hidden; background: var(--surface); border: 1px solid var(--border); cursor: pointer; display: grid; text-align: left; padding: 0; font: inherit; color: inherit; }
.m .thumb { aspect-ratio: 4 / 5; background: var(--surface-2) center / cover no-repeat; position: relative; }
.m .kind { position: absolute; top: 6px; left: 6px; background: rgba(0, 0, 0, .55); color: #fff; font-size: 10px; font-weight: 600; padding: 2px 6px; border-radius: 6px; }
.m .meta { padding: 8px 10px; display: flex; gap: 10px; font-size: 12px; color: var(--text-2); flex-wrap: wrap; font-variant-numeric: tabular-nums; }
.stories { display: flex; gap: 10px; overflow-x: auto; }
.story { flex: none; width: 92px; color: inherit; text-decoration: none; }
.story .thumb { width: 92px; height: 150px; border-radius: 10px; background: var(--surface-2) center / cover; }
.story .meta { font-size: 11px; color: var(--text-2); margin-top: 4px; }

/* Listas */
.list { display: grid; gap: 10px; }
.item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: grid; grid-template-columns: auto 1fr auto; gap: 14px; align-items: center; }
.item .thumbs { display: flex; }
.item .thumbs div { width: 48px; height: 60px; border-radius: 8px; background: var(--surface-2) center / cover; margin-right: -18px; border: 2px solid var(--surface); display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.item .thumbs div:last-child { margin-right: 0; }
.item .body { min-width: 0; }
.item .title { font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.item .desc { color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .desc.wrap { white-space: normal; }
.item .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.item.simple { grid-template-columns: 1fr auto; }
.badge { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.good { color: var(--good-text); }
.badge.warn { color: #9a6700; }
.badge.bad { color: var(--critical); }
.badge.info { color: var(--accent); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.warn { color: var(--warning); } }
.acts { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.empty-state { text-align: center; color: var(--muted); padding: 40px 16px; border: 1px dashed var(--border); border-radius: var(--radius); }
.tester { display: grid; grid-template-columns: 1fr 160px auto; gap: 8px; align-items: center; }
.tester #test-out { grid-column: 1 / -1; }

/* Direct */
.dm { display: grid; grid-template-columns: 280px 1fr; gap: 16px; min-height: 480px; }
.dm-list { display: grid; gap: 6px; align-content: start; }
.dm-list button { text-align: left; border: 1px solid var(--border); background: var(--surface); border-radius: 12px; padding: 10px 12px; cursor: pointer; font: inherit; color: inherit; }
.dm-list button.on { border-color: var(--accent); }
.dm-thread { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; display: flex; flex-direction: column; gap: 8px; }
.msgs { display: flex; flex-direction: column; gap: 6px; flex: 1; overflow-y: auto; max-height: 60vh; }
.msg { max-width: 75%; padding: 8px 12px; border-radius: 14px; background: var(--surface-2); white-space: pre-wrap; word-break: break-word; }
.msg.out { align-self: flex-end; background: var(--accent); color: var(--accent-ink); }
.msg small { display: block; opacity: .7; font-size: 10px; }

/* Drawer de comentários */
.drawer { position: fixed; inset: 0; background: rgba(0, 0, 0, .4); display: flex; justify-content: flex-end; z-index: 40; }
.drawer-body { width: min(520px, 100%); height: 100%; background: var(--bg); padding: 20px; overflow-y: auto; display: grid; gap: 12px; align-content: start; }
.comment { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.comment .who { font-weight: 600; }
.comment .replies { margin: 8px 0 0 14px; display: grid; gap: 6px; }
.kv { display: grid; gap: 8px; }
.kv div { display: grid; grid-template-columns: 170px 1fr auto; gap: 10px; align-items: center; }

#banner:empty { display: none; }
.banner { padding: 12px 16px; border-radius: 12px; background: color-mix(in srgb, var(--warning) 18%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warning) 50%, var(--border)); }
.toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 10px; opacity: 0; transition: .2s; pointer-events: none; z-index: 60; max-width: calc(100% - 32px); }
.toast.on { opacity: 1; transform: translateX(-50%); }
.toast.bad { background: var(--critical); color: #fff; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { position: sticky; height: auto; z-index: 10; flex-direction: row; align-items: center; padding: 10px 16px; gap: 12px; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--border); }
  .sidebar .brand { font-size: 0; gap: 0; }
  nav { display: flex; gap: 2px; }
  nav a { white-space: nowrap; padding: 7px 10px; }
  .side-foot { margin: 0; gap: 10px; }
  .acct-switch { width: auto; min-width: 130px; flex-shrink: 0; padding: 6px 10px; }
  main { padding: 16px 16px 60px; }
  .grid-2, .row, .dm { grid-template-columns: 1fr; }
  .item { grid-template-columns: auto 1fr; }
  .item .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .tester { grid-template-columns: 1fr; }
  .kv div { grid-template-columns: 1fr auto; }
  .kv div > span:first-child { grid-column: 1 / -1; }
}
