:root {
  --red:#c0001b;
  --red-dark: #8f0014;
  --red-soft: #fff1f3;
  --black:#090909;
  --ink: #171717;
  --muted: #6f7177;
  --muted-2: #92959c;
  --line: #e7e8eb;
  --line-strong: #d6d8dd;
  --surface: #ffffff;
  --page: #f1f2f4;
  --green: #157543;
  --shadow-sm: 0 6px 20px rgba(12, 12, 15, .045);
  --shadow: 0 18px 55px rgba(12, 12, 15, .10);
  --radius: 16px;
}

* { box-sizing: border-box; }
html { color-scheme: light; }
body { margin: 0; background: var(--page); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
input, select { accent-color: var(--red); }
.hidden { display: none !important; }
.button { min-height: 42px; border: 0; border-radius: 11px; padding: 10px 16px; font-size: 12px; font-weight: 850; cursor: pointer; transition: transform .16s ease, box-shadow .16s ease, border-color .16s ease, background .16s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { background: linear-gradient(135deg, var(--red), #a50017); color: #fff; box-shadow: 0 9px 23px rgba(192, 0, 27, .23); }
.button.dark { background: #111; color: #fff; }
.button.outline { border: 1px solid var(--line-strong); background: #fff; color: #25262a; }
.button.ghost { background: transparent; color: #666970; }
.button.ghost:hover { background: #f0f1f3; color: #222; }
.error { padding: 11px 13px; border-radius: 10px; background: var(--red-soft); color: #a40017; font-size: 12px; }
.kicker { color: var(--red); font-size: 10px; font-weight: 950; letter-spacing: .16em; }

.login-page { min-height: 100vh; display: grid; grid-template-columns: 1.1fr .9fr; background: #080808; }
.login-brand { display: grid; place-content: center; padding: 8vw; color: #fff; background: radial-gradient(circle at 18% 18%, #62000e, transparent 44%), linear-gradient(145deg, #070707, #181818); }
.login-brand p { color: #aaa; }
.login-card { align-self: center; margin: 7vw; display: grid; gap: 17px; padding: 38px; border-radius: 22px; background: #fff; box-shadow: var(--shadow); }
.login-card h1 { margin: 0 0 8px; }
.login-card label, .form-grid label, .settings label { display: grid; gap: 7px; font-size: 12px; font-weight: 800; }
.login-card input, .form-grid input, .form-grid select, .settings input { width: 100%; padding: 12px 13px; border: 1px solid var(--line-strong); border-radius: 10px; background: #fff; outline: 0; }
.login-card input:focus, .form-grid input:focus, .form-grid select:focus, .settings input:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(192, 0, 27, .08); }

.layout { min-height: 100vh; display: grid; grid-template-columns: 250px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; background: #090909; color: #fff; padding: 20px 16px; display: flex; flex-direction: column; border-right: 4px solid var(--red); }
.banner-slot { width: 100%; height: auto; aspect-ratio: 15 / 4; display: grid; place-items: center; overflow: hidden; background: transparent; margin-bottom: 28px; }
.banner-slot img { display: block; width: 100%; height: 100%; object-fit: contain; object-position: center; }
.banner-slot span { font-weight: 950; letter-spacing: .12em; color: #fff; }
.banner-slot span b { display: block; color: var(--red); font-size: 11px; text-align: center; }
.banner-slot.compact { width: min(540px, 70vw); height: auto; aspect-ratio: 15 / 4; }
.sidebar nav { display: grid; gap: 7px; }
.nav { width: 100%; border: 0; background: transparent; color: #999ca2; padding: 13px 14px; border-radius: 10px; display: flex; gap: 12px; text-align: left; font-weight: 750; transition: .16s ease; }
.nav:hover, .nav.active { background: #1d1d1f; color: #fff; }
.nav.active { box-shadow: inset 3px 0 var(--red); }
.sidebar-note { margin-top: auto; display: flex; gap: 10px; align-items: center; padding: 14px; border: 1px solid #29292c; border-radius: 12px; }
.sidebar-note i { width: 9px; height: 9px; border-radius: 50%; background: #ff2442; box-shadow: 0 0 14px #ff2442; }
.sidebar-note div { display: grid; }
.sidebar-note small { color: #777b82; font-size: 10px; }
.logout { border: 0; background: transparent; color: #777b82; text-align: left; padding: 16px 5px; }
main { min-width: 0; }
header { height: 100px; display: flex; justify-content: space-between; align-items: center; padding: 0 34px; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--line); backdrop-filter: blur(12px); }
header h1 { margin: 3px 0; font-size: 25px; }
header p { margin: 0; color: var(--muted); font-size: 12px; }
header span { font-size: 9px; color: var(--red); font-weight: 950; letter-spacing: .14em; }
.content { padding: 30px; max-width: 1500px; margin: auto; }
.headline { display: flex; justify-content: space-between; gap: 20px; align-items: flex-end; margin-bottom: 24px; }
.headline h2 { margin: 0 0 5px; font-size: 23px; letter-spacing: -.02em; }
.headline p { margin: 0; color: var(--muted); font-size: 13px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-sm); }

.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 15px; margin-bottom: 20px; }
.metrics article { background: #fff; border: 1px solid var(--line); border-radius: 15px; padding: 20px; display: grid; gap: 8px; box-shadow: var(--shadow-sm); }
.metrics article.red { background: linear-gradient(135deg, #c0001b, #870012); color: #fff; border: 0; }
.metrics span { font-size: 9px; font-weight: 950; letter-spacing: .11em; color: #858890; }
.metrics .red span, .metrics .red small { color: #ffdbe0; }
.metrics strong { font-size: 25px; }
.metrics small { color: #999ca2; font-size: 10px; }
.report-metrics { grid-template-columns: repeat(2, 1fr); }
.user-metrics { grid-template-columns: repeat(4, 1fr); }

.split { display: grid; grid-template-columns: 1.5fr .8fr; gap: 18px; }
.panel-title { padding: 19px 20px; border-bottom: 1px solid var(--line); }
.panel-title h3 { margin: 0 0 4px; }
.panel-title p { margin: 0; color: var(--muted); font-size: 11px; }
.section-panel { margin-top: 18px; }
.table-wrap { overflow: auto; scrollbar-width: thin; scrollbar-color: #c9cbd0 transparent; }
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th { position: sticky; top: 0; z-index: 1; text-align: left; color: #858890; font-size: 9px; letter-spacing: .08em; padding: 13px 17px; background: #fafafb; }
td { padding: 14px 17px; border-top: 1px solid #eeeeef; white-space: nowrap; }
tbody tr { transition: background .14s ease; }
tbody tr:hover { background: #fcfcfd; }
code { padding: 3px 6px; border-radius: 6px; background: #f2f3f5; color: #50535a; font-size: 10px; }
.status { display: inline-flex; padding: 5px 9px; border-radius: 99px; font-size: 9px; font-weight: 950; }
.status.APPROVED { background: #e8f8ee; color: var(--green); }
.status.PENDING { background: #fff4d7; color: #866000; }
.status.FAILED, .status.CANCELED, .status.EXPIRED { background: #ffe8ec; color: #a00017; }
.gateway { font-weight: 950; color: var(--red); font-size: 10px; }
.record-state { display: inline-flex; padding: 5px 8px; border-radius: 99px; background: #eaf7ee; color: var(--green); font-size: 9px; font-weight: 950; }
.record-state.archived { background: #eeeef0; color: #656870; }
.table-action { min-height: 32px; padding: 6px 10px !important; font-size: 9px !important; }
.empty-cell { text-align: center; color: var(--muted-2); padding: 32px; }
.pager { padding: 14px 17px; display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: 11px; border-top: 1px solid var(--line); }
.pager .button { min-width: 42px; padding: 8px 12px; }
.logs { padding: 12px; }
.log { padding: 11px; border-bottom: 1px solid #eee; display: grid; gap: 3px; }
.log b { font-size: 11px; }
.log small { color: #999; font-size: 9px; }

.filter-panel { margin-bottom: 18px; padding: 0; overflow: hidden; border-color: #dedfe3; box-shadow: 0 12px 35px rgba(12,12,15,.055); }
.filter-header { min-height: 78px; padding: 17px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: linear-gradient(180deg, #fff, #fcfcfd); }
.filter-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.filter-icon { flex: 0 0 auto; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); font-size: 19px; font-weight: 900; }
.filter-heading h3 { margin: 0 0 3px; font-size: 15px; letter-spacing: -.01em; }
.filter-heading p { margin: 0; color: var(--muted); font-size: 11px; }
.filter-count { flex: 0 0 auto; padding: 7px 10px; border: 1px solid var(--line); border-radius: 99px; background: #f8f8f9; color: var(--muted); font-size: 9px; font-weight: 900; }
.filter-count.has-filters { border-color: #f1bdc5; background: var(--red-soft); color: #9b0016; }
.filter-grid { display: grid; grid-template-columns: repeat(4, minmax(150px, 1fr)); gap: 14px; }
.filter-primary { padding: 20px; }
.filter-grid label { display: grid; align-content: start; gap: 7px; min-width: 0; color: #51545a; font-size: 10px; font-weight: 850; }
.filter-grid label > span { padding-left: 1px; }
.filter-grid input, .filter-grid select { width: 100%; min-width: 0; height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); border-radius: 11px; background: #fff; color: #24262a; outline: 0; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.filter-grid input::placeholder { color: #abadb3; }
.filter-grid input:hover, .filter-grid select:hover { border-color: #bfc2c8; }
.filter-grid input:focus, .filter-grid select:focus { border-color: var(--red); box-shadow: 0 0 0 4px rgba(192,0,27,.075); }
.filter-grid input.invalid, .filter-grid select.invalid { border-color: var(--red); background: #fff7f8; }
.field-wide { grid-column: span 2; }
.input-affix { height: 44px; display: flex; align-items: stretch; border: 1px solid var(--line-strong); border-radius: 11px; overflow: hidden; background: #fff; transition: border-color .16s ease, box-shadow .16s ease; }
.input-affix:focus-within { border-color: var(--red); box-shadow: 0 0 0 4px rgba(192,0,27,.075); }
.input-affix b { flex: 0 0 auto; display: grid; place-items: center; padding: 0 12px; border-right: 1px solid var(--line); background: #f5f5f6; color: #7a7d84; font-size: 12px; }
.input-affix input { height: 42px; border: 0 !important; border-radius: 0 !important; box-shadow: none !important; }
.money-affix b { min-width: 47px; color: #51545a; }
.money-affix input { text-align: right; font-variant-numeric: tabular-nums; }
.quick-period { padding: 0 20px 18px; display: flex; align-items: center; gap: 12px; }
.quick-period > span { flex: 0 0 auto; color: #777a81; font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .06em; }
.quick-period > div { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-period button { min-height: 30px; border: 1px solid var(--line); border-radius: 99px; padding: 6px 10px; background: #fafafb; color: #62656c; font-size: 9px; font-weight: 850; transition: .15s ease; }
.quick-period button:hover { border-color: #c6c8cd; background: #f2f3f5; color: #222; }
.quick-period button.active { border-color: var(--red); background: var(--red-soft); color: #9d0016; box-shadow: 0 0 0 2px rgba(192,0,27,.05); }
.advanced-filters { border-top: 1px solid var(--line); background: #fafafb; }
.advanced-filters summary { min-height: 57px; padding: 13px 20px; display: flex; align-items: center; justify-content: space-between; gap: 12px; list-style: none; cursor: pointer; user-select: none; }
.advanced-filters summary::-webkit-details-marker { display: none; }
.advanced-filters summary span { display: grid; gap: 2px; }
.advanced-filters summary b { color: #33353a; font-size: 11px; }
.advanced-filters summary small { color: var(--muted-2); font-size: 9px; }
.advanced-filters summary i { width: 28px; height: 28px; border: 1px solid var(--line); border-radius: 8px; display: grid; place-items: center; background: #fff; color: #777; font-style: normal; transition: transform .18s ease; }
.advanced-filters[open] summary i { transform: rotate(180deg); }
.advanced-filters[open] summary { border-bottom: 1px solid var(--line); }
.advanced-body { padding: 18px 20px 20px; background: #fff; }
.advanced-body.compact-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.advanced-body.date-grid { grid-template-columns: repeat(2, minmax(180px, 280px)); }
.report-filter-grid { grid-template-columns: repeat(3, minmax(180px, 1fr)); }
.active-filters { padding: 13px 20px; display: flex; align-items: center; flex-wrap: wrap; gap: 7px; border-top: 1px dashed #dddfe3; background: #fff; }
.active-filters::before { content: "Filtros ativos"; margin-right: 2px; color: #777a81; font-size: 9px; font-weight: 900; text-transform: uppercase; letter-spacing: .05em; }
.filter-chip { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; border: 1px solid #f1c1c8; border-radius: 99px; padding: 5px 8px 5px 10px; background: var(--red-soft); color: #8f0014; font-size: 9px; font-weight: 800; }
.filter-chip b { font-size: 12px; line-height: 1; }
.filter-actions { min-height: 66px; padding: 12px 20px; display: flex; justify-content: flex-end; align-items: center; gap: 9px; border-top: 1px solid var(--line); background: #fff; }
.apply-filter { min-width: 164px; display: inline-flex; justify-content: center; align-items: center; gap: 13px; }
.apply-filter b { font-size: 15px; }
.result-strip { display: grid; grid-template-columns: repeat(3, minmax(150px, 1fr)); gap: 10px; margin: 0 0 15px; }
.result-strip span { min-height: 48px; padding: 10px 14px; display: flex; align-items: center; gap: 7px; border: 1px solid var(--line); border-radius: 12px; background: #fff; color: #7b7e85; font-size: 10px; box-shadow: var(--shadow-sm); }
.result-strip b { color: #202226; font-size: 14px; }

.owner-pill { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 12px; border-radius: 10px; margin: 14px 0 10px; border: 1px solid var(--line); background: #f7f7f8; }
.owner-pill .owner-label { color: #666b73; font-size: 9px; letter-spacing: .12em; text-transform: uppercase; font-weight: 900; }
.owner-pill strong { font-size: 12px; color: #171717; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.owner-pill.owner-set { background: rgba(21, 117, 67, 0.08); border-color: #bde2c9; }
.owner-pill.owner-set strong { color: var(--green); }
.owner-pill.owner-empty { background: rgba(192, 0, 27, 0.04); border-color: #f4d1d8; }
.owner-pill.owner-empty strong { color: #9d0016; }

.bots-grid { display: grid; grid-template-columns: repeat(3, minmax(260px, 1fr)); gap: 17px; }
.bot-card { padding: 19px; }
.bot-card.archived { opacity: .72; border-style: dashed; }
.bot-card.archived .bot-icon { background: #777; }
.bot-top { display: flex; align-items: center; gap: 11px; }
.bot-icon { width: 40px; height: 40px; border-radius: 11px; background: #111; color: #fff; display: grid; place-items: center; border-bottom: 3px solid var(--red); }
.bot-top div { display: grid; }
.bot-top small { color: #888; }
.online { margin-left: auto; font-size: 9px; font-weight: 950; color: #198547; }
.offline { color: #999; }
.archived-label { margin-left: auto; color: #777; font-size: 9px; font-weight: 950; }
.bot-data { margin: 17px 0; display: grid; gap: 8px; padding: 12px; background: #f7f7f8; border-radius: 10px; }
.bot-data div { display: flex; justify-content: space-between; gap: 12px; font-size: 10px; }
.bot-data span { color: #888; }
.bot-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.bot-actions button { min-height: 34px; padding: 8px 10px; font-size: 10px; }
.webhook { padding: 10px; border-radius: 9px; background: #fff4f5; color: #850013; font-size: 9px; word-break: break-all; margin-bottom: 12px; }
.empty { padding: 60px; display: grid; place-items: center; gap: 8px; color: #888; }
.user-handle { display: grid; gap: 2px; }
.user-handle b { color: #171717; }
.user-handle small { color: #999; }
.settings { padding: 24px; display: grid; grid-template-columns: 1fr 1fr auto; gap: 20px; align-items: end; }
.money-input { display: flex; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; background: #fff; }
.money-input b { display: grid; place-items: center; padding: 0 11px; background: #f2f2f3; color: #777; }
.money-input input { border: 0 !important; box-shadow: none !important; border-radius: 0 !important; }
.settings small { color: #888; }
.security-box { padding: 13px; background: #101010; color: #fff; border-radius: 10px; }
.security-box p { margin: 4px 0 0; color: #aaa; font-size: 10px; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.72); display: grid; place-items: center; padding: 20px; z-index: 5; backdrop-filter: blur(5px); }
.modal-card { width: min(760px, 100%); max-height: 94vh; overflow: auto; background: #fff; border-radius: 19px; padding: 24px; box-shadow: var(--shadow); }
.modal-title { display: flex; justify-content: space-between; align-items: start; }
.modal-title h2 { margin: 4px 0 18px; }
.modal-title > button { border: 0; background: #f0f0f1; border-radius: 50%; width: 34px; height: 34px; font-size: 20px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid small { font-weight: 400; color: #888; }
.gateway-card { margin-top: 16px; padding: 17px; border: 1px solid #ddd; border-radius: 12px; }
.gateway-card > div:first-child { display: flex; gap: 10px; align-items: center; margin-bottom: 13px; }
.gateway-card > div:first-child span { width: 30px; height: 30px; border-radius: 8px; background: #111; color: #fff; display: grid; place-items: center; font-weight: 950; }
.gateway-card h3 { margin: 0; }
.gateway-card small { color: #888; }
.gateway-card.mistic { border-color: #f0b7bf; }
.gateway-card.mistic > div:first-child span { background: var(--red); }
.gateway-card > p { font-size: 10px; color: #888; margin: 10px 0 0; }
.modal-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 18px; }
.toasts { position: fixed; right: 20px; bottom: 20px; z-index: 10; display: grid; gap: 8px; }
.toast { padding: 13px 16px; background: #111; color: #fff; border-left: 4px solid var(--red); border-radius: 9px; box-shadow: var(--shadow); font-size: 12px; }

@media (max-width: 1120px) {
  .filter-grid { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .field-wide { grid-column: span 2; }
  .metrics { grid-template-columns: 1fr 1fr; }
  .split { grid-template-columns: 1fr; }
  .bots-grid { grid-template-columns: 1fr 1fr; }
  .settings { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .filter-grid, .report-filter-grid, .advanced-body.compact-grid { grid-template-columns: 1fr 1fr; }
  .field-wide { grid-column: 1 / -1; }
  .advanced-body.date-grid { grid-template-columns: 1fr 1fr; }
  .user-metrics { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 720px) {
  .login-page { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px; border-right: 0; border-bottom: 3px solid var(--red); }
  .banner-slot { width: min(250px, 100%); height: auto; margin: 0 auto 10px; }
  .sidebar nav { grid-template-columns: repeat(3, 1fr); }
  .nav { justify-content: center; padding: 12px 8px; }
  .nav span, .sidebar-note, .logout { display: none; }
  header { height: auto; padding: 17px 16px; }
  .content { padding: 16px; }
  .headline { align-items: start; flex-direction: column; margin-bottom: 18px; }
  .metrics, .bots-grid, .report-metrics { grid-template-columns: 1fr; }
  .filter-header { align-items: flex-start; padding: 15px; }
  .filter-heading p { display: none; }
  .filter-icon { width: 36px; height: 36px; }
  .filter-count { white-space: nowrap; }
  .filter-primary, .advanced-body { padding: 15px; }
  .filter-grid, .report-filter-grid, .advanced-body.compact-grid, .advanced-body.date-grid { grid-template-columns: 1fr; }
  .field-wide { grid-column: auto; }
  .quick-period { padding: 0 15px 15px; align-items: flex-start; flex-direction: column; gap: 8px; }
  .quick-period > div { display: grid; grid-template-columns: repeat(2, 1fr); width: 100%; }
  .quick-period button { width: 100%; }
  .advanced-filters summary { padding: 13px 15px; }
  .active-filters { padding: 12px 15px; }
  .filter-actions { position: sticky; bottom: 0; z-index: 2; padding: 11px 15px; justify-content: stretch; box-shadow: 0 -8px 25px rgba(0,0,0,.04); }
  .filter-actions .button { flex: 1; }
  .apply-filter { min-width: 0; }
  .result-strip { grid-template-columns: 1fr; }
  .result-strip span { justify-content: space-between; }
  .form-grid { grid-template-columns: 1fr; }
  .form-grid .full { grid-column: auto; }
  .pager { gap: 10px; }
  .pager > span { max-width: 65%; }
  .toasts { left: 16px; right: 16px; bottom: 16px; }
}
@media (max-width: 430px) {
  .filter-header { flex-direction: column; }
  .filter-count { align-self: flex-start; }
  .user-metrics { grid-template-columns: 1fr; }
}
