/* Max Gestor — tema escuro estilo streaming */
:root {
  --bg: #0a0a0f;
  --bg-2: #101017;
  --panel: #14141c;
  --panel-2: #1b1b25;
  --panel-3: #23232f;
  --border: #262633;
  --border-2: #33334a;
  --text: #f4f4f7;
  --muted: #9b9bad;
  --accent: #e50914;
  --accent-2: #ff3d47;
  --accent-soft: rgba(229, 9, 20, .14);
  --accent-glow: 0 0 0 1px rgba(229, 9, 20, .35), 0 8px 30px rgba(229, 9, 20, .25);
  --ok: #2fd27a;
  --ok-soft: rgba(47, 210, 122, .12);
  --warn: #ffb020;
  --warn-soft: rgba(255, 176, 32, .12);
  --bad: #ff4d5a;
  --bad-soft: rgba(255, 77, 90, .13);
  --wa: #1fb456;
  --shadow: 0 1px 0 rgba(255, 255, 255, .03) inset, 0 10px 30px rgba(0, 0, 0, .35);
  --radius: 14px;
  --side-w: 252px;
  --side-w-min: 76px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body {
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(229, 9, 20, .10), transparent 60%),
    radial-gradient(900px 400px at -10% 110%, rgba(120, 40, 200, .07), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 800; }
h2 { font-size: 15px; font-weight: 700; }
h3 { font-size: 17px; }
a { color: var(--accent-2); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* forms */
label { display: flex; flex-direction: column; gap: 6px; font-size: 12.5px; font-weight: 600; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg-2);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
input::placeholder, textarea::placeholder { color: #5f5f73; }
textarea { resize: vertical; min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=date]::-webkit-calendar-picker-indicator, input[type=month]::-webkit-calendar-picker-indicator { filter: invert(.8); }
.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; }
.check input { width: auto; accent-color: var(--accent); }
.stack { display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.span2 { grid-column: span 2; }
.span3 { grid-column: 1 / -1; }

.btn {
  font: inherit; font-weight: 700; cursor: pointer; border-radius: 10px; padding: 9px 15px;
  border: 1px solid var(--border-2); background: var(--panel-2); color: var(--text);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; text-decoration: none;
  transition: background .15s, transform .1s, box-shadow .15s, filter .15s;
}
.btn:hover { background: var(--panel-3); }
.btn:active { transform: translateY(1px); }
.btn.primary { background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: #fff; box-shadow: 0 6px 20px rgba(229, 9, 20, .3); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.wa { background: var(--wa); border-color: transparent; color: #fff; }
.btn.wa:hover { filter: brightness(1.1); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .6; cursor: progress; }
.link { background: none; border: 0; color: var(--accent-2); cursor: pointer; font: inherit; padding: 0; }
.link.forgot { align-self: center; font-size: 13px; font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--muted); cursor: pointer; padding: 7px; border-radius: 9px; display: inline-grid; place-items: center; font-size: 16px; }
.icon-btn:hover { background: var(--panel-2); color: var(--text); }
.icon-btn.accent { color: #fff; background: var(--accent); }

/* brand */
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; min-width: 0; }
.brand-lg { font-size: 22px; }
.logo { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: linear-gradient(135deg, var(--accent-2), #a3000a); box-shadow: 0 4px 16px rgba(229, 9, 20, .45); flex: none; }
.logo svg { width: 16px; height: 16px; fill: #fff; margin-left: 2px; }
.brand-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.2; }
.brand-text small { font-size: 11.5px; font-weight: 500; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 410px; background: rgba(20, 20, 28, .85); backdrop-filter: blur(10px); border: 1px solid var(--border); border-radius: 18px; padding: 30px; box-shadow: var(--shadow), 0 0 80px rgba(229, 9, 20, .08); }
.auth-card > p { margin: 8px 0 22px; }
.tabs { display: flex; gap: 4px; background: var(--bg-2); border: 1px solid var(--border); border-radius: 11px; padding: 4px; margin-bottom: 18px; }
.tab { flex: 1; border: 0; background: none; font: inherit; font-weight: 700; padding: 8px; border-radius: 8px; cursor: pointer; color: var(--muted); }
.tab.active { background: var(--panel-3); color: var(--text); }

/* layout */
.layout { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); min-height: 100vh; transition: grid-template-columns .2s; }
.layout.collapsed { grid-template-columns: var(--side-w-min) minmax(0, 1fr); }
.mobile-bar, .backdrop { display: none; }

.sidebar {
  background: rgba(14, 14, 20, .92); border-right: 1px solid var(--border);
  padding: 16px 12px; display: flex; flex-direction: column; gap: 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; overflow-x: hidden;
}
.sidebar > * { min-width: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; padding: 2px 4px 8px; }
.collapse-btn .ico { transition: transform .2s; }
.collapsed .collapse-btn .ico { transform: rotate(180deg); }

#nav { display: flex; flex-direction: column; gap: 2px; }
.nav-sec { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: #5f5f73; padding: 14px 12px 6px; }
.nav-sec:first-child { padding-top: 4px; }
#nav a {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font-weight: 600; white-space: nowrap;
  transition: background .15s, color .15s;
}
#nav a:hover { background: var(--panel-2); color: var(--text); }
#nav a.active { background: linear-gradient(90deg, var(--accent-soft), transparent); color: #fff; }
#nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 12px var(--accent); }
#nav a.active .ico { color: var(--accent-2); }
.nav-badge { margin-left: auto; background: var(--accent); color: #fff; font-size: 11px; font-weight: 800; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-grid; place-items: center; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 10px; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: var(--panel); border: 1px solid var(--border); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, #3b3b55, #23232f); display: grid; place-items: center; font-weight: 800; font-size: 13px; flex: none; }
.me-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: 13px; }
.sub-badge { font-size: 12px; padding: 9px 12px; border-radius: 10px; background: var(--panel); border: 1px solid var(--border); color: var(--muted); }
.sub-badge.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.sub-badge.bad { background: var(--bad-soft); border-color: transparent; color: var(--bad); }

/* menu recolhido (desktop) */
.collapsed .brand-text, .collapsed #nav a span, .collapsed .nav-badge, .collapsed .sub-badge, .collapsed .me-name { display: none; }
.collapsed .side-top { flex-direction: column; gap: 10px; padding: 2px 0 8px; }
.collapsed .nav-sec { font-size: 0; padding: 10px 0 4px; border-top: 1px solid var(--border); margin: 6px 8px 0; }
.collapsed .nav-sec:first-child { border-top: 0; margin-top: 0; }
.collapsed #nav a { justify-content: center; padding: 11px 0; }
.collapsed .me { flex-direction: column; padding: 8px 0; }

.main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: linear-gradient(180deg, rgba(255,255,255,.025), transparent 40%), var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 18px 20px 0; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 14px; }
.cards > *, .cols > * { min-width: 0; }
.stat { padding: 18px 20px; position: relative; overflow: hidden; }
.stat::after { content: ""; position: absolute; inset: 0 0 auto; height: 2px; background: var(--border-2); }
.stat .label { color: var(--muted); font-size: 12.5px; font-weight: 600; }
.stat .value { font-size: 28px; font-weight: 800; margin-top: 6px; letter-spacing: -.02em; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat.ok::after { background: var(--ok); box-shadow: 0 0 14px var(--ok); }
.stat.warn::after { background: var(--warn); box-shadow: 0 0 14px var(--warn); }
.stat.bad::after { background: var(--bad); box-shadow: 0 0 14px var(--bad); }
.stat.ok .value { color: var(--ok); }
.stat.warn .value { color: var(--warn); }
.stat.bad .value { color: var(--bad); }
a.stat { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
a.stat:hover { border-color: var(--border-2); transform: translateY(-2px); }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 14px; }

/* hero do painel */
.hero {
  position: relative; overflow: hidden; border-radius: 18px; padding: 26px 28px; margin-bottom: 16px;
  background: linear-gradient(110deg, #1a0306 0%, #3a0509 45%, #7a0710 100%);
  border: 1px solid rgba(229, 9, 20, .35); box-shadow: 0 20px 60px rgba(229, 9, 20, .18);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.hero::after { content: ""; position: absolute; right: -60px; top: -80px; width: 280px; height: 280px; border-radius: 50%; background: radial-gradient(circle, rgba(255, 61, 71, .45), transparent 70%); pointer-events: none; }
.hero h1 { font-size: 26px; }
.hero .muted { color: rgba(255, 255, 255, .7); }
.hero-nums { display: flex; gap: 28px; position: relative; z-index: 1; }
.hero-nums div { display: flex; flex-direction: column; }
.hero-nums b { font-size: 24px; font-weight: 800; }
.hero-nums span { font-size: 12px; color: rgba(255, 255, 255, .7); }

/* chart */
.bars { display: flex; align-items: flex-end; gap: 12px; height: 190px; padding: 18px 20px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; min-width: 0; }
.bar { width: 100%; max-width: 44px; background: linear-gradient(180deg, var(--accent-2), #8a0610); border-radius: 7px 7px 3px 3px; min-height: 3px; box-shadow: 0 0 18px rgba(229, 9, 20, .25); }
.bar-val { font-size: 11px; color: var(--muted); white-space: nowrap; }
.bar-lbl { font-size: 12px; color: var(--muted); }
.hbar { display: grid; grid-template-columns: 110px 1fr 40px; gap: 10px; align-items: center; padding: 7px 20px; font-size: 13px; }
.hbar-track { height: 8px; border-radius: 4px; background: var(--panel-3); overflow: hidden; }
.hbar-fill { height: 100%; background: linear-gradient(90deg, #8a0610, var(--accent-2)); border-radius: 4px; }

/* table */
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; padding: 14px; border-bottom: 1px solid var(--border); }
.toolbar input[type=search] { max-width: 300px; }
.toolbar select { width: auto; }
.due-range { display: flex; align-items: center; gap: 8px; }
.due-range input { width: auto; padding: 8px 10px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-2); background: transparent; border-radius: 999px; padding: 6px 13px; font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer; color: var(--muted); }
.chip:hover { color: var(--text); }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 4px 14px rgba(229, 9, 20, .35); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 700; background: var(--bg-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr { transition: background .12s; }
tbody tr:hover { background: rgba(255, 255, 255, .025); }
td .sub { display: block; font-size: 12px; color: var(--muted); }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 44px 20px; text-align: center; color: var(--muted); }

.pill { display: inline-block; font-size: 11.5px; font-weight: 800; padding: 3px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.muted { background: var(--panel-3); color: var(--muted); }
.mono { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }

/* dropdown */
.dd-menu { background: var(--panel-2); border: 1px solid var(--border-2); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.5); padding: 5px; z-index: 70; min-width: 220px; }
.dd-menu button { display: block; width: 100%; text-align: left; background: none; border: 0; font: inherit; color: var(--text); padding: 9px 11px; border-radius: 8px; cursor: pointer; }
.dd-menu button:hover { background: var(--panel-3); }

/* modal */
.modal { position: fixed; inset: 0; background: rgba(0, 0, 0, .7); backdrop-filter: blur(4px); display: grid; place-items: center; padding: 16px; z-index: 80; }
.modal-box { background: var(--panel); border: 1px solid var(--border-2); border-radius: 18px; width: 100%; max-width: 640px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 30px 80px rgba(0,0,0,.6); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--border); position: sticky; top: 0; background: var(--panel); z-index: 1; }
#modalBody { padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.access-box { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 12px; border: 1px solid var(--border-2); background: var(--bg-2); }
.access-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; }
.access-hint { font-size: 12.5px; color: var(--muted); }
.access-hint:empty { display: none; }
.access-hint strong { color: var(--text); }
.access-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.pay-box { display: flex; flex-direction: column; gap: 12px; padding: 14px; border-radius: 12px; border: 1px solid rgba(47, 210, 122, .3); background: var(--ok-soft); }
.info-box { background: var(--bg-2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; font-size: 13px; }

.toasts { position: fixed; bottom: 18px; right: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 90; }
.toast { background: var(--panel-3); border: 1px solid var(--border-2); color: var(--text); padding: 11px 16px; border-radius: 12px; font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,.5); max-width: 340px; border-left: 3px solid var(--ok); }
.toast.bad { border-left-color: var(--bad); }

.alert { padding: 14px 16px; border-radius: 12px; margin-bottom: 16px; font-weight: 600; }
.alert.bad { background: var(--bad-soft); color: var(--bad); }
.alert.warn { background: var(--warn-soft); color: var(--warn); }
.alert.ok-soft { background: var(--ok-soft); color: var(--ok); }
.placeholders code { background: var(--panel-3); color: var(--text); padding: 1px 6px; border-radius: 5px; font-size: 12px; margin: 2px; display: inline-block; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2c2c3a; border-radius: 10px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

@media (max-width: 1100px) {
  .cols { grid-template-columns: minmax(0, 1fr); }
}

/* celular e tablet: menu lateral em gaveta */
@media (max-width: 900px) {
  .layout, .layout.collapsed { grid-template-columns: minmax(0, 1fr); align-content: start; }
  .mobile-bar {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
    position: sticky; top: 0; z-index: 40; padding: 10px 12px;
    background: rgba(10, 10, 15, .9); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
  }
  .mobile-bar { padding: 8px 10px; min-height: 52px; }
  .mobile-title { flex: 1; font-size: 17px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .mobile-bar .icon-btn.accent { width: 36px; height: 36px; border-radius: 10px; }

  /* cabeçalho das páginas no formato tradicional: o título fica na barra de cima */
  .page-head { margin-bottom: 12px; gap: 8px; justify-content: flex-end; flex-wrap: nowrap; }
  .page-head:not(:has(.actions)) { display: none; }
  .page-head h1 { display: none; }
  .page-head > div:has(> h1) { display: none; }
  .page-head .actions { flex-wrap: nowrap; gap: 6px; width: 100%; justify-content: flex-end; }
  .page-head .actions .btn { padding: 7px 12px; font-size: 13px; }
  .page-head .actions input[type=month] { padding: 7px 10px; }

  /* filtros de clientes mais enxutos */
  .toolbar { gap: 8px; padding: 10px; }
  .toolbar input[type=search] { max-width: none; flex: 1 1 100%; }
  .chips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; flex: 1 1 100%; padding-bottom: 2px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; padding: 5px 11px; }
  .toolbar select { flex: 1 1 140px; min-width: 0; padding: 8px 10px; font-size: 13px; }
  .due-range { flex: 1 1 100%; }
  .due-range input { flex: 1; min-width: 0; font-size: 13px; }

  /* painel: faixa de boas-vindas compacta */
  .hero { padding: 16px 18px; border-radius: 14px; gap: 12px; margin-bottom: 12px; }
  .hero h1 { display: block; font-size: 18px; }
  .hero #newClient { display: none; }
  .hero > div:first-child > div[style] { margin-top: 0 !important; }
  .hero-nums { gap: 22px; }
  .hero-nums b { font-size: 19px; }
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; height: 100%; width: min(84vw, 300px); z-index: 60;
    transform: translateX(-102%); transition: transform .25s ease; box-shadow: 20px 0 60px rgba(0,0,0,.6);
    background: var(--bg-2); padding-bottom: max(16px, env(safe-area-inset-bottom));
  }
  .menu-open .sidebar { transform: none; }
  .backdrop { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, .6); z-index: 50; opacity: 0; pointer-events: none; transition: opacity .25s; }
  .menu-open .backdrop { opacity: 1; pointer-events: auto; }
  .collapse-btn { display: none; }
  /* dentro da gaveta, sempre expandido */
  .collapsed .brand-text { display: flex; }
  .collapsed #nav a span, .collapsed .me-name { display: inline; }
  .collapsed .sub-badge { display: block; }
  .collapsed .nav-badge { display: inline-grid; }
  .collapsed .side-top { flex-direction: row; }
  .collapsed .nav-sec { font-size: 10.5px; border-top: 0; margin: 0; padding: 14px 12px 6px; }
  .collapsed #nav a { justify-content: flex-start; padding: 10px 12px; }
  .collapsed .me { flex-direction: row; padding: 8px; }
  .main { padding: 18px 16px 50px; }
}

@media (max-width: 640px) {
  .grid2, .grid3 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; }
  .stat .value { font-size: 21px; }
  .toolbar input[type=search] { max-width: none; }
  .hbar { grid-template-columns: 90px 1fr 32px; padding: 7px 14px; }
}
