:root {
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f7f9fc; --border: #e2e8f0; --text: #0b1726; --muted: #5f6f84;
  --primary: #1688c1; --primary-600: #0f6f9f; --primary-50: #e7f4fb; --accent: #12a0e6;
  --danger: #dc2626; --warning: #d97706; --info: #1677c1; --success: #16a34a;
  --side: #08172a; --side-2: #0c2038; --side-text: #b8c7d9; --side-active: #ffffff;
  --radius: 12px; --shadow: 0 1px 2px rgba(11,23,38,.05), 0 6px 20px rgba(11,23,38,.05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; font-weight: 650; }
h3 { font-size: 14px; margin: 0 0 8px; font-weight: 650; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; word-break: break-all; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* Layout */
.layout { display: grid; grid-template-columns: 248px 1fr; min-height: 100vh; }
.sidebar { background: linear-gradient(180deg, var(--side-2), var(--side) 60%); color: var(--side-text); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto; border-right: 1px solid rgba(148,180,212,.12); scrollbar-width: thin; }
.brand { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 20px 20px 16px; color: #fff; border-bottom: 1px solid rgba(148,180,212,.14); }
.brand-logo { height: 30px; width: auto; display: block; }
.brand-sub { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: #7fc6ec; }
.nav { padding: 8px 10px 16px; display: flex; flex-direction: column; gap: 1px; }
.nav-sec { font-size: 10.5px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: #6f86a1; padding: 14px 12px 6px; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 0 12px; min-height: 38px; border-radius: 9px; color: var(--side-text); font-weight: 550; font-size: 13.5px; transition: background .15s, color .15s; }
.nav a:hover { background: rgba(255,255,255,.06); text-decoration: none; color: #fff; }
.nav a.active { background: rgba(18,160,230,.16); color: var(--side-active); box-shadow: inset 3px 0 0 var(--accent); font-weight: 650; }
.nav a.active .ico { color: #5cc4f5; }
.nav .ico { width: 18px; height: 18px; display: grid; place-items: center; flex: none; opacity: .95; }
.side-foot { margin: auto 12px 14px; padding: 12px; font-size: 12px; border: 1px solid rgba(148,180,212,.16); border-radius: 12px; background: rgba(255,255,255,.03); display: grid; gap: 6px; }
.st-row { display: flex; align-items: center; gap: 8px; }
.st-row:empty { display: none; }
.st-row b { margin-left: auto; color: #e8eef7; font-weight: 650; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; flex: none; }
.dot.ok { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.18); }
.dot.warn { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.18); }
.dot.err { background: #ef4444; box-shadow: 0 0 0 3px rgba(239,68,68,.18); }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { height: 64px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 16px; padding: 0 24px; position: sticky; top: 0; z-index: 20; }
.crumb { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.crumb-sec { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
.crumb b { font-size: 15px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-wrap { flex: 1; max-width: 440px; margin-left: auto; position: relative; color: var(--muted); }
.search-wrap svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.topbar .search { width: 100%; padding-left: 34px; background: var(--surface-2); border-color: var(--border); border-radius: 10px; min-height: 38px; }
.topbar .user { display: flex; align-items: center; gap: 10px; }
.uname { display: flex; flex-direction: column; line-height: 1.2; }
.uname b { font-size: 13px; font-weight: 650; }
.uname span { font-size: 11.5px; color: var(--muted); }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #1aa9ee, #0d5f8f); color: #fff; display: grid; place-items: center; font-weight: 750; font-size: 12.5px; flex: none; }
.menu-btn { display: none; }
.content { padding: 24px; max-width: 1440px; width: 100%; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.env-banner { background: #fff7ed; color: #9a3412; border-bottom: 1px solid #fed7aa; padding: 7px 24px; font-size: 12.5px; }

/* Cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.card + .card { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); margin-bottom: 16px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--k, var(--primary)); }
.kpi .label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.kpi .value { font-size: 24px; font-weight: 750; margin-top: 8px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi { padding: 16px 18px; transition: box-shadow .15s, transform .15s; }
.kpi::before { width: 3px; }
.kpi-sec { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); margin: 4px 0 8px; }
.kpis-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.kpis-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
a.kpi-link { color: inherit; display: block; }
a.kpi-link:hover { text-decoration: none; box-shadow: 0 2px 4px rgba(11,23,38,.06), 0 10px 26px rgba(11,23,38,.09); transform: translateY(-1px); border-color: #cbd8e6; }
@media (max-width: 1100px) { .kpis-4, .kpis-5 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); } }
.chart-box { position: relative; height: 260px; }

/* Forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: #334155; margin-bottom: 5px; }
.field { margin-bottom: 12px; min-width: 0; }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 4px; }
input, select, textarea { width: 100%; font: inherit; color: var(--text); background: #fff; border: 1px solid #cfd8e3; border-radius: 9px; padding: 8px 11px; min-height: 38px; outline: none; transition: border-color .15s, box-shadow .15s; }
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(22,136,193,.16); }
input[type=checkbox], input[type=radio] { width: auto; min-height: 0; margin: 0 6px 0 0; vertical-align: middle; accent-color: var(--primary); }
input[type=color] { padding: 2px; height: 38px; }
.check { display: inline-flex; align-items: center; font-weight: 500; margin: 0 14px 6px 0; cursor: pointer; }
.form-grid { display: grid; gap: 0 14px; grid-template-columns: repeat(12, minmax(0, 1fr)); }
.c12 { grid-column: span 12; } .c8 { grid-column: span 8; } .c6 { grid-column: span 6; } .c4 { grid-column: span 4; } .c3 { grid-column: span 3; } .c2 { grid-column: span 2; } .c9 { grid-column: span 9; }
.input-err { border-color: var(--danger) !important; }
.section-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin: 6px 0 10px; grid-column: span 12; border-bottom: 1px solid var(--border); padding-bottom: 6px; }

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 650; border-radius: 9px; padding: 0 14px; min-height: 36px; border: 1px solid #cfd8e3; background: #fff; color: var(--text); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, box-shadow .15s; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { box-shadow: 0 1px 2px rgba(15,111,159,.25); }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-600); }
.btn.success { background: var(--success); border-color: var(--success); color: #fff; }
.btn.danger { background: #fff; border-color: #fecaca; color: var(--danger); }
.btn.danger:hover { background: #fef2f2; }
.btn.sm { padding: 0 10px; min-height: 30px; font-size: 12.5px; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Tables */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow); }
.toolbar label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.toolbar .field { margin: 0; min-width: 140px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; white-space: nowrap; }
tbody tr:hover { background: #f3f9fd; }
.table-wrap { box-shadow: var(--shadow); }
.table-wrap td:first-child > b { white-space: nowrap; }
tbody tr:last-child td { border-bottom: 0; }
td.money, th.money { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
tr.clickable { cursor: pointer; }
.empty { padding: 36px; text-align: center; color: var(--muted); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 2px; color: var(--muted); font-size: 12.5px; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; background: #eef2f7; color: #334155; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.b-pending { background: #f1f5f9; color: #475569; }
.b-awaiting_payment { background: #eff6ff; color: #1d4ed8; }
.b-paid, .b-sent, .b-active, .b-approved, .b-processed, .b-done, .b-conectado { background: #ecfdf5; color: #047857; }
.b-overdue, .b-failed, .b-error, .b-charged_back { background: #fef2f2; color: #b91c1c; }
.b-cancelled, .b-finished, .b-ignored, .b-desconectado { background: #f3f4f6; color: #6b7280; }
.b-refunded { background: #faf5ff; color: #7e22ce; }
.b-in_review, .b-paused, .b-queued, .b-sending, .b-running, .b-warn, .b-reconectando, .b-aguardando_qr, .b-conectando { background: #fffbeb; color: #b45309; }
.b-info { background: #eff6ff; color: #1d4ed8; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Detail */
.dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px 18px; }
.dl div > span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 600; }
.dl div > b { font-weight: 600; word-break: break-word; }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox .mono { flex: 1; background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; max-height: 90px; overflow: auto; }
.alert { padding: 10px 14px; border-radius: 8px; border: 1px solid; margin-bottom: 12px; font-size: 13px; }
.alert.warn { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.alert.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.alert.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }
.alert.ok { background: #ecfdf5; border-color: #a7f3d0; color: #065f46; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { padding: 8px 0 8px 18px; border-left: 2px solid var(--border); position: relative; font-size: 13px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 50%; background: var(--primary); }

/* Modal */
.modal-bg { position: fixed; inset: 0; background: rgba(15,23,42,.45); display: grid; place-items: center; z-index: 100; padding: 16px; animation: fade .12s ease-out; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 720px; max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.lg { max-width: 980px; }
.modal.sm { max-width: 460px; }
.modal-head { display: flex; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.modal-head h2 { margin: 0; }
.modal-head .x { margin-left: auto; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* Toast */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 200; max-width: min(420px, calc(100vw - 32px)); }
.toast { background: #0f172a; color: #fff; padding: 11px 14px; border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.2); font-size: 13.5px; border-left: 4px solid var(--info); animation: fade .15s; }
.toast.ok { border-left-color: #22c55e; } .toast.err { border-left-color: #ef4444; } .toast.warn { border-left-color: #f59e0b; }

/* Login */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 480px); background: var(--bg); }
.auth-side { background: radial-gradient(900px 500px at 0% 0%, rgba(18,160,230,.28), transparent), linear-gradient(160deg, #0c2038, #08172a); color: #b8c7d9; display: flex; flex-direction: column; justify-content: center; padding: 48px 56px; }
.auth-side .brand { border: 0; padding: 0 0 18px; }
.auth-side .brand-logo { height: 44px; }
.auth-side p { max-width: 380px; font-size: 15px; line-height: 1.55; margin: 0; }
.auth-card { width: 100%; max-width: 400px; align-self: center; justify-self: center; margin: 24px; padding: 28px; }
.auth-card h2 { font-size: 20px; margin-bottom: 18px; }
.auth-wrap.solo { grid-template-columns: 1fr; place-items: center; }
@media (max-width: 760px) { .auth-wrap { grid-template-columns: 1fr; } .auth-side { padding: 28px 24px; } .auth-side p { display: none; } }

.qr-box { display: flex; gap: 20px; align-items: center; flex-wrap: wrap; }
.qr-box img { width: 240px; height: 240px; border: 1px solid var(--border); border-radius: 10px; }
.code-big { font-family: Consolas, monospace; font-size: 26px; letter-spacing: 4px; font-weight: 700; }
.spinner { width: 16px; height: 16px; border: 2px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 50%; animation: spin .7s linear infinite; display: inline-block; }
.btn:not(.primary):not(.success) .spinner { border-color: rgba(15,23,42,.2); border-top-color: var(--text); }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { padding: 40px; text-align: center; color: var(--muted); }

/* Responsivo */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 60; transform: translateX(-100%); transition: transform .2s; }
  body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  body.nav-open::after { content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 50; }
  .menu-btn { display: inline-flex; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .content { padding: 14px; }
  .topbar { padding: 0 12px; }
  .topbar .uname, .topbar .crumb, #pwd { display: none; }
  .search-wrap { margin-left: 0; }
  .c8, .c6, .c4, .c3, .c2, .c9 { grid-column: span 12; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .kpis { grid-template-columns: 1fr 1fr; }
  .kpi .value { font-size: 18px; }
  .page-head .actions { margin-left: 0; width: 100%; }
  .modal-body { padding: 14px; }
}
@media print { .sidebar, .topbar, .page-head .actions, .toolbar { display: none !important; } .layout { display: block; } }
