/* ===========================================================================
   Mauricinho Envia — design system (claro, moderno)
   =========================================================================== */
:root {
  --bg: #f4f6f8;            /* fundo da página */
  --surface: #ffffff;       /* cartões */
  --surface-2: #f9fafb;     /* zebra / cabeçalhos de tabela */
  --line: #e7eaee;          /* bordas */
  --line-2: #d6dbe3;
  --ink: #1a2230;           /* texto principal */
  --ink-2: #5b6675;         /* texto secundário */
  --ink-3: #8a93a3;         /* texto fraco */
  --brand: #378add;         /* azul Desoft7 (primário) */
  --brand-d: #285f96;       /* azul escuro p/ hover/realce */
  --brand-soft: #e8f2fc;    /* azul claro de fundo */
  --navy: #1d3d63;          /* navy Desoft7 — wordmark/realce */
  --green: #10b981;         /* verde-menta Desoft7 — sucesso/ativo */
  --green-d: #047857;
  --green-soft: #e7f7ef;
  --blue: #378add;          /* unificado ao azul da marca */
  --blue-soft: #e8f2fc;
  --orange: #f97316;        /* laranja Desoft7 — destaque/CTA */
  --orange-d: #ea580c;
  --orange-soft: #fff7ed;
  --amber: #ea580c;         /* atenção, alinhada ao laranja */
  --amber-soft: #fff3e8;
  --red: #dc2626;
  --red-soft: #fdecec;
  --purple: #7c3aed;
  --purple-soft: #f1ebfd;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(16,24,40,.05), 0 1px 3px rgba(16,24,40,.06);
  --shadow: 0 4px 12px rgba(16,24,40,.06), 0 2px 4px rgba(16,24,40,.04);
  --shadow-lg: 0 12px 32px rgba(16,24,40,.10);
  --font-body: "Inter", -apple-system, "Segoe UI", system-ui, Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Outfit", var(--font-body);
  font-family: var(--font-body);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background-color: var(--bg);
  background-image: radial-gradient(1000px 440px at 50% -180px, rgba(55,138,221,.08), transparent 72%);
  background-repeat: no-repeat;
  color: var(--ink); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility; font-size: 15px; line-height: 1.5;
}
a { color: var(--blue); text-decoration: none; }

/* ---------- ícones (Lucide) ---------- */
.lucide { width: 1.05em; height: 1.05em; stroke-width: 2; vertical-align: -.17em; flex-shrink: 0; }
.brand-mark { color: var(--brand); display: inline-flex; align-items: center; }
.brand-mark .lucide { width: 1.5rem; height: 1.5rem; }
.login-brand { display: flex; align-items: center; justify-content: center; gap: .4rem; }
.login-brand .lucide { color: var(--brand); width: 1.35rem; height: 1.35rem; vertical-align: -.2em; }
.side-nav .ico .lucide { width: 1.15rem; height: 1.15rem; }
.step .mark .lucide { width: 12px; height: 12px; }
.badge .lucide { width: 1em; height: 1em; vertical-align: -.13em; }
.spin { animation: ic-spin 1s linear infinite; }
@keyframes ic-spin { to { transform: rotate(360deg); } }

/* ---------- shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: 248px; flex-shrink: 0; background: linear-gradient(180deg, var(--surface), #fafbfd); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 1.25rem 1rem; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: .6rem; padding: .35rem .5rem 1.25rem; }
.brand-mark { font-size: 1.5rem; }
.brand-name { font-size: 1.12rem; color: var(--ink-2); font-weight: 600; font-family: var(--font-display); }
.brand-name strong { color: var(--navy); font-weight: 800; }
.side-nav { display: flex; flex-direction: column; gap: .2rem; }
.side-nav a, .nav-soon {
  display: flex; align-items: center; gap: .7rem; padding: .65rem .75rem; border-radius: 10px;
  color: var(--ink-2); font-weight: 600; font-size: .94rem;
}
.side-nav a:hover { background: var(--surface-2); color: var(--ink); }
.side-nav a.active { background: var(--brand-soft); color: var(--brand-d); box-shadow: inset 3px 0 0 var(--orange); }
.side-nav .ico { font-size: 1.05rem; width: 1.4rem; text-align: center; }
.nav-soon { color: var(--ink-3); cursor: default; }
.nav-soon em { font-size: .68rem; background: var(--surface-2); padding: .1rem .4rem; border-radius: 20px; margin-left: auto; font-style: normal; }
.side-foot { margin-top: auto; font-size: .8rem; color: var(--ink-3); padding: .5rem .75rem; display: flex; align-items: center; gap: .4rem; }

.main-wrap { flex: 1; min-width: 0; }
main { max-width: 1080px; margin: 0 auto; padding: 2.25rem 2.25rem 5rem; }

/* ---------- cabeçalho de página ---------- */
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; margin-bottom: 1.75rem; }
h1 { margin: 0 0 .35rem; font-size: 1.7rem; font-weight: 800; letter-spacing: -.02em; font-family: var(--font-display); }
h2 { margin: 0 0 1.1rem; font-size: 1.1rem; font-weight: 700; letter-spacing: -.01em; font-family: var(--font-display); }
.sub { margin: 0; color: var(--ink-2); font-size: .92rem; }
.back { color: var(--ink-2); font-weight: 600; font-size: .86rem; display: inline-block; margin-bottom: 1rem; }
.back:hover { color: var(--ink); }

/* ---------- botões ---------- */
.btn {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line-2);
  padding: .6rem 1rem; border-radius: var(--radius-sm); cursor: pointer; font-size: .9rem; font-weight: 600;
  display: inline-flex; align-items: center; gap: .45rem; white-space: nowrap; box-shadow: var(--shadow-sm);
  transition: transform .12s ease, box-shadow .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { background: var(--surface-2); border-color: var(--line-2); box-shadow: var(--shadow); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.btn:disabled, .btn[disabled] { opacity: .55; cursor: not-allowed; box-shadow: none; transform: none; }
.btn.primary { background: linear-gradient(180deg, #4a97e6, var(--brand)); color: #fff; border-color: transparent; box-shadow: 0 1px 2px rgba(55,138,221,.35), 0 6px 16px rgba(55,138,221,.22); }
.btn.primary:hover { background: linear-gradient(180deg, #3f8fdd, var(--brand-d)); }
.btn.accent { background: linear-gradient(180deg, #fb8a3c, var(--orange)); color: #fff; border-color: transparent; box-shadow: 0 1px 2px rgba(249,115,22,.35), 0 6px 16px rgba(249,115,22,.24); }
.btn.accent:hover { background: linear-gradient(180deg, #f6791d, var(--orange-d)); }
.btn.sm { padding: .4rem .7rem; font-size: .82rem; }
.btn.danger { color: var(--red); border-color: #f3c9c9; background: #fff; }
.btn.danger:hover { background: var(--red-soft); border-color: #ecb3b3; }

/* ---------- inputs ---------- */
input, select, textarea {
  background: #fff; color: var(--ink); border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  padding: .6rem .75rem; font-size: .92rem; width: 100%; font-family: inherit; transition: .15s;
}
input::placeholder, textarea::placeholder { color: var(--ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
input:hover:not(:focus), select:hover:not(:focus), textarea:hover:not(:focus) { border-color: #c2cad6; }
input[type=time], input[type=date] { width: auto; }
input[readonly] { background: var(--surface-2); color: var(--ink-2); }
textarea { resize: vertical; }
textarea.sql { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .85rem; line-height: 1.55; }

/* ---------- filtros ---------- */
.filtros { display: flex; gap: .6rem; margin-bottom: 1.5rem; }
.filtros input[type=search] { flex: 1; }

/* ---------- cards de métrica ---------- */
.cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.5rem; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.15rem 1.25rem; box-shadow: var(--shadow-sm); }
.card .num { font-size: 1.95rem; font-weight: 800; letter-spacing: -.02em; font-family: var(--font-display); font-variant-numeric: tabular-nums; }
.card:nth-child(2) .num { color: var(--green); }
.card:nth-child(3) .num { color: var(--brand); }
.card:nth-child(4) .num { color: var(--orange); }
.card .lbl { color: var(--ink-2); font-size: .82rem; font-weight: 600; margin-top: .2rem; }

/* ---------- painéis ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow-sm); margin-bottom: 1.25rem; }

/* ---------- tabelas ---------- */
table.grid { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.grid th, .grid td { text-align: left; padding: .8rem 1rem; border-bottom: 1px solid var(--line); font-size: .9rem; font-variant-numeric: tabular-nums; }
.grid thead th { color: var(--navy); font-weight: 700; font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; background: #f1f5fb; }
.grid tbody tr:last-child td { border-bottom: none; }
.grid tbody tr:hover { background: var(--surface-2); }
.grid td.empty { text-align: center; color: var(--ink-2); padding: 2.5rem; }
.grid.mini { box-shadow: none; }
.grid.mini th, .grid.mini td { padding: .6rem .7rem; }

.mono { font-family: ui-monospace, "Cascadia Code", Consolas, monospace; font-size: .86em; font-variant-numeric: tabular-nums; }
.dim { color: var(--ink-3); }
.srv { display: inline-block; min-width: 1.6em; text-align: center; background: var(--blue-soft); color: var(--blue); border-radius: 6px; padding: .1em .45em; font-weight: 700; font-size: .8em; }

/* status dot */
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: .4rem; vertical-align: middle; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.dot.off { background: #c2c9d3; }

/* ---------- badges / pills ---------- */
.badge { font-size: .74rem; padding: .25rem .6rem; border-radius: 20px; font-weight: 700; display: inline-block; }
.badge.ok { color: var(--green-d); background: var(--green-soft); }
.badge.pend { color: var(--amber); background: var(--amber-soft); }
.badge.per { color: var(--blue); background: var(--blue-soft); text-transform: capitalize; }

/* ---------- flash ---------- */
.flash { padding: .8rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1.1rem; font-size: .9rem; font-weight: 500; }
.flash.ok { background: var(--green-soft); color: var(--green-d); }
.flash.err { background: var(--red-soft); color: var(--red); }
.flash.pend { background: var(--amber-soft); color: var(--amber); }

.htmx-indicator { display: none; color: var(--ink-2); font-size: .85rem; } .htmx-request .htmx-indicator { display: inline; }
.htmx-request.btn { opacity: .65; }

/* ---------- forms ---------- */
.form { display: flex; flex-direction: column; gap: 1.25rem; }
.row { display: flex; gap: 1.1rem; margin-bottom: 1.1rem; flex-wrap: wrap; }
.row > label, .form > label, .panel form > label { flex: 1; min-width: 190px; display: flex; flex-direction: column; gap: .4rem; font-size: .82rem; color: var(--ink-2); font-weight: 600; }
label small { color: var(--ink-3); font-size: .76rem; font-weight: 400; }
label.check { flex-direction: row; align-items: center; gap: .5rem; color: var(--ink); min-width: auto; }
label.check input { width: auto; }
.actions { display: flex; justify-content: flex-end; gap: .6rem; margin-top: .25rem; }

/* ---------- abas ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.5rem; flex-wrap: wrap; }
.tab-btn { background: none; border: none; color: var(--ink-2); padding: .75rem 1.1rem; cursor: pointer; font-size: .95rem; font-weight: 700; border-bottom: 2px solid transparent; margin-bottom: -1px; transition: color .15s, border-color .15s; }
.tab-btn:hover { color: var(--ink); }
.tab-btn.active { color: var(--brand-d); border-bottom-color: var(--brand); }
.tab-btn .count { font-size: .74rem; color: var(--ink-3); font-weight: 600; margin-left: .4rem; background: var(--surface-2); padding: .1rem .45rem; border-radius: 20px; }
.tab-btn.active .count { color: var(--brand-d); background: var(--brand-soft); }
.tab-content { display: none; } .tab-content.active { display: block; }

.subtabs { display: inline-flex; gap: .2rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 11px; padding: .25rem; margin-bottom: 1.2rem; }
.subtab-btn { background: none; border: none; color: var(--ink-2); padding: .45rem 1rem; cursor: pointer; font-size: .86rem; font-weight: 700; border-radius: 8px; }
.subtab-btn:hover { color: var(--ink); }
.subtab-btn.active { background: #fff; color: var(--brand-d); box-shadow: var(--shadow-sm); }
.subtab-content { display: none; } .subtab-content.active { display: block; }

/* ---------- toggle switch ---------- */
.switch { position: relative; display: inline-block; width: 42px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider { position: absolute; inset: 0; background: #cfd5de; border-radius: 24px; transition: .2s; cursor: pointer; }
.switch .slider::before { content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: .2s; box-shadow: var(--shadow-sm); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---------- mestre-detalhe (régua) ---------- */
.master-detail { display: grid; grid-template-columns: 270px 1fr; gap: 1.25rem; align-items: start; }
.md-list { display: flex; flex-direction: column; gap: .5rem; }
.md-item { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 11px; padding: .75rem .85rem; cursor: pointer; color: var(--ink); font-size: .9rem; font-weight: 600; transition: .12s; box-shadow: var(--shadow-sm); }
.md-item:hover { border-color: var(--line-2); }
.md-item.active { border-color: var(--brand); background: var(--brand-soft); box-shadow: inset 3px 0 0 var(--orange); }
.md-item .meta { color: var(--ink-2); font-size: .78rem; font-weight: 500; margin-top: .25rem; }
.md-empty { color: var(--ink-2); font-size: .85rem; padding: 1rem; text-align: center; }
.placeholder { color: var(--ink-3); text-align: center; padding: 3rem 1.5rem; border: 1px dashed var(--line-2); border-radius: var(--radius); background: var(--surface-2); }

/* lista de selecionados */
.sel-list { list-style: none; padding: 0; margin: 0; }
.sel-list li { display: flex; align-items: center; gap: .7rem; padding: .7rem .25rem; border-bottom: 1px solid var(--line); font-size: .92rem; }
.sel-list li:last-child { border-bottom: none; }
.sel-list .chk { color: var(--green); font-weight: 800; }
.sel-list .ord { color: var(--ink-3); font-size: .8rem; min-width: 1.6em; font-weight: 700; }

/* ---------- SQL / código ---------- */
.sql-actions { display: flex; align-items: center; gap: .8rem; margin-top: .7rem; flex-wrap: wrap; }
.sql-msg { font-size: .86rem; font-weight: 600; }
.sql-msg.ok { color: var(--green-d); } .sql-msg.err { color: var(--red); }
pre.sql-ro { background: #0f172a; color: #cbd5e1; border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; font-size: .82rem; line-height: 1.6; white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; }

/* inline add */
.inline-add { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding-top: .5rem; }
.inline-add input { width: auto; flex: 1; min-width: 140px; }

/* linhas clicáveis */
.grid.clickable tbody tr { cursor: pointer; }
.cli-nome { font-weight: 700; }
.cli-sub { font-size: .76rem; color: var(--ink-3); margin-top: .1rem; }
.chev { text-align: right; color: var(--ink-3); font-size: 1.5rem; line-height: 1; width: 1.5rem; }

/* busca em destaque */
.searchbar { display: flex; gap: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .75rem; box-shadow: var(--shadow-sm); margin-bottom: 1.5rem; align-items: center; transition: border-color .15s, box-shadow .15s; }
.searchbar:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.searchbar .ico { font-size: 1.1rem; padding-left: .4rem; color: var(--ink-3); }
.searchbar input[type=search] { flex: 1; border: none; box-shadow: none; font-size: .98rem; }
.searchbar input[type=search]:focus { box-shadow: none; }
.searchbar select { width: auto; max-width: 230px; }
.searchbar .flt { display: flex; align-items: center; gap: .35rem; font-size: .82rem; color: var(--ink-3); white-space: nowrap; }
.searchbar .flt input[type=date] { width: auto; font-size: .9rem; }
.ind-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .25rem .9rem; margin: .4rem 0 1rem; }
.ind-grid .check { font-size: .9rem; }
.dest-editor { border: 1px solid var(--brand); }

/* breadcrumb */
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--ink-3); margin-bottom: 1rem; }
.crumbs a { color: var(--ink-2); font-weight: 600; }
.crumbs a:hover { color: var(--ink); }
.crumbs .sep { color: var(--ink-3); }

/* status de configuração (strip de etapas) */
.setup-strip { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.5rem; }
.step { display: inline-flex; align-items: center; gap: .45rem; padding: .5rem .8rem; border-radius: 10px; font-size: .84rem; font-weight: 600; border: 1px solid var(--line); background: var(--surface); }
.step .mark { width: 18px; height: 18px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: .7rem; color: #fff; }
.step.done { background: var(--green-soft); border-color: transparent; color: var(--green-d); }
.step.done .mark { background: var(--green); }
.step.todo { color: var(--ink-2); }
.step.todo .mark { background: var(--ink-3); }

.subhead { font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); margin: 1.1rem 0 .6rem; padding-bottom: .35rem; border-bottom: 1px solid var(--line); }

/* grupos de conferência da cobrança (por prazo) */
/* login */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
  background:
    radial-gradient(620px 420px at 12% 6%, rgba(55,138,221,.16), transparent 62%),
    radial-gradient(640px 440px at 88% 94%, rgba(249,115,22,.13), transparent 62%),
    var(--bg); }
.login-card { position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2.4rem 2.25rem 2.25rem; width: 350px; box-shadow: var(--shadow-lg); }
.login-card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--brand), var(--navy) 50%, var(--orange)); }
.login-brand { font-size: 1.5rem; text-align: center; margin-bottom: .25rem; font-weight: 700; color: var(--ink-2); font-family: var(--font-display); }
.login-brand strong { color: var(--navy); font-weight: 800; }
.side-user { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.su-nome { font-weight: 600; color: var(--ink); font-size: .85rem; }
.su-sair { display: inline-block; margin-top: .45rem; color: var(--blue); font-size: .82rem; font-weight: 600; }

.conf-grupo { margin-bottom: 1.3rem; }
.conf-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: .5rem 0 .45rem; font-size: .92rem; flex-wrap: wrap; }

/* ---------- responsivo ---------- */
@media (max-width: 880px) {
  .app { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; flex-direction: row; align-items: center; padding: .75rem 1rem; gap: 1rem; overflow-x: auto; }
  .brand { padding: 0; }
  .side-nav { flex-direction: row; }
  .side-foot, .nav-soon { display: none; }
  main { padding: 1.5rem 1.25rem 4rem; }
  .cards { grid-template-columns: repeat(2,1fr); }
  .master-detail { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: flex-start; }
}
