:root {
  --bg: #f4f5f7; --card: #fff; --text: #1d2330; --muted: #6b7280; --line: #e3e6ea;
  --primary: #2a7de1; --primary-dark: #1f63b5; --ok: #16873a; --warn: #b26a00; --error: #c62828; --info: #2a7de1;
  --tg-bg: #dfe8d6; --tg-bubble: #fff;
}
* { box-sizing: border-box; }
body { margin: 0; font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

.topbar { display: flex; align-items: center; gap: 20px; padding: 0 20px; height: 54px; background: #172033; color: #fff; position: sticky; top: 0; z-index: 10; }
.topbar .brand { color: #fff; font-weight: 700; font-size: 16px; white-space: nowrap; }
.topbar .brand span { color: #6fb1ff; font-weight: 500; }
.topbar nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.topbar nav a { color: #c9d3e3; padding: 6px 10px; border-radius: 6px; white-space: nowrap; }
.topbar nav a:hover { background: #24304a; text-decoration: none; }
.topbar nav a.active { background: #2a3a5c; color: #fff; }
.topbar .link { background: none; border: 0; color: #c9d3e3; cursor: pointer; font: inherit; }

main { max-width: 1240px; margin: 0 auto; padding: 24px 20px 60px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: 1fr 1fr; }
.grid.sidebar { grid-template-columns: minmax(0, 1fr) 380px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
.stat b { display: block; font-size: 26px; }
.stat span { color: var(--muted); font-size: 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 12px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
tr:hover td { background: #fafbfc; }
td.thumb { width: 56px; }
td.thumb img { width: 48px; height: 48px; object-fit: contain; border-radius: 6px; background: #fff; border: 1px solid var(--line); }
td.nowrap, .nowrap { white-space: nowrap; }
.table-wrap { overflow-x: auto; }

label { display: block; font-weight: 600; font-size: 13px; margin: 12px 0 4px; }
label.inline { display: inline-flex; gap: 6px; align-items: center; font-weight: 500; margin: 6px 12px 6px 0; }
input[type=text], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=time], select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid #cfd5dc; border-radius: 7px; font: inherit; background: #fff;
}
textarea { min-height: 90px; resize: vertical; }
textarea.code { font-family: ui-monospace, Consolas, monospace; font-size: 13px; min-height: 260px; }
input:focus, select:focus, textarea:focus { outline: 2px solid #bcd6f7; border-color: var(--primary); }
.fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.hint { color: var(--muted); font-size: 12px; margin-top: 3px; }

button, .btn { display: inline-block; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--primary); background: var(--primary); color: #fff; font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; }
button:hover, .btn:hover { background: var(--primary-dark); text-decoration: none; }
.btn.secondary, button.secondary { background: #fff; color: var(--text); border-color: #cfd5dc; }
.btn.secondary:hover, button.secondary:hover { background: #f1f3f5; }
button.danger { background: #fff; color: var(--error); border-color: #efb4b4; }
button.danger:hover { background: #fdecec; }
button.small, .btn.small { padding: 4px 9px; font-size: 12px; }

.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #eef0f3; color: var(--muted); }
.badge.ok { background: #e3f4e8; color: var(--ok); }
.badge.warn { background: #fdf1dc; color: var(--warn); }
.badge.error { background: #fde6e6; color: var(--error); }
.badge.info { background: #e4efff; color: var(--info); }
.price { font-weight: 700; }
.old { color: var(--muted); text-decoration: line-through; font-size: 12px; }
.err { color: var(--error); font-size: 12px; }

.flash { padding: 11px 14px; border-radius: 8px; margin-bottom: 16px; border: 1px solid; word-break: break-word; }
.flash.ok { background: #e9f7ee; border-color: #b9e2c6; color: #11632b; }
.flash.warn { background: #fff6e5; border-color: #f2d49b; color: #7a4a00; }
.flash.error { background: #fdecec; border-color: #f2b8b8; color: #8e1b1b; }

.pager { display: flex; gap: 14px; justify-content: center; align-items: center; margin-top: 14px; color: var(--muted); }

/* Prévia estilo Telegram */
.tg { background: var(--tg-bg); border-radius: 10px; padding: 16px; }
.tg .bubble { background: var(--tg-bubble); border-radius: 10px; max-width: 360px; overflow: hidden; box-shadow: 0 1px 1px rgba(0,0,0,.12); }
.tg .bubble img { width: 100%; display: block; max-height: 320px; object-fit: contain; background: #fff; }
.tg .bubble .txt { padding: 8px 10px 10px; white-space: normal; word-break: break-word; font-size: 14px; }
.tg .bubble .txt code { background: #f0f0f0; padding: 0 4px; border-radius: 3px; }
.tg .tgbtn { margin-top: 4px; max-width: 360px; text-align: center; background: rgba(0,0,0,.18); color: #fff; border-radius: 8px; padding: 7px; font-weight: 600; }
pre.log { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f6f7f9; padding: 8px; border-radius: 6px; margin: 4px 0 0; }

.login { max-width: 360px; margin: 12vh auto; }
.steps li { margin-bottom: 6px; }

@media (max-width: 900px) {
  .grid.two, .grid.sidebar { grid-template-columns: 1fr; }
  .topbar { flex-wrap: wrap; height: auto; padding: 10px 14px; gap: 8px; }
  main { padding: 16px 12px 40px; }
}
