/* =====================================================================
   SysNetCell — Folha de estilo (Vanilla, temas claro/escuro)
   Paleta derivada das telas de referência: roxo vivo, cards claros,
   verde para receitas e laranja para despesas.
   ===================================================================== */

:root {
  --brand: #6c2bd9;
  --brand-600: #5b21b6;
  --brand-700: #4c1d95;
  --brand-soft: #ede9fe;
  --green: #16a34a;
  --green-soft: #dcfce7;
  --orange: #ea580c;
  --orange-soft: #ffedd5;
  --danger: #dc2626;

  /* Tema claro (padrão) */
  --bg: #eef0f3;
  --surface: #ffffff;
  --surface-2: #f7f7fb;
  --text: #1f2430;
  --text-muted: #6b7280;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 1px 2px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --radius: 12px;
  --radius-sm: 8px;
  --topbar-h: 56px;
  --sidebar-w: 248px;
  --sidebar-w-collapsed: 64px;
}

[data-theme="dark"] {
  --bg: #0f1117;
  --surface: #171a22;
  --surface-2: #1e222c;
  --text: #e6e8ee;
  --text-muted: #9aa2b1;
  --border: #2a2f3a;
  --brand-soft: #2a2140;
  --shadow: 0 1px 3px rgba(0, 0, 0, .5);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, .6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; height: 100%;
  font-family: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--brand); }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.hidden { display: none !important; }

/* ---------------------- Tela de Login ------------------------------ */
#login {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(108,43,217,.25), transparent 60%),
    var(--bg);
}
.login-card {
  width: 380px; max-width: calc(100vw - 32px);
  background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow-lg); padding: 28px 26px;
  border: 1px solid var(--border);
}
.login-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.login-brand .logo {
  width: 40px; height: 40px; border-radius: 10px; flex: none;
  background: linear-gradient(135deg, var(--brand), var(--brand-700));
  display: grid; place-items: center; color: #fff; font-weight: 800;
}
.login-brand h1 { font-size: 20px; margin: 0; letter-spacing: .3px; }
.login-brand small { color: var(--text-muted); }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-muted); margin-bottom: 6px; }
.field input, .field select, .form-container input, .form-container select, .form-container textarea {
  width: 100%; padding: 10px 12px; font-size: 14px;
  background: var(--surface-2); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .form-container input:focus, .form-container select:focus {
  border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); outline: none;
}
.btn {
  border: 1px solid transparent; border-radius: var(--radius-sm);
  padding: 10px 16px; font-weight: 600; font-size: 14px;
  background: var(--surface-2); color: var(--text);
}
.btn:hover { filter: brightness(.98); }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-600); }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; border-color: var(--border); }
.login-error { color: var(--danger); font-size: 13px; min-height: 18px; margin-top: 4px; }
.remember { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); margin-top: 6px; }

/* ---------------------- Layout do App ------------------------------ */
#app { display: none; height: 100%; }
#app.on { display: grid; grid-template-rows: var(--topbar-h) 1fr; }

.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 12px; color: #fff;
  background: linear-gradient(90deg, var(--brand), var(--brand-600));
  box-shadow: var(--shadow);
  z-index: 30;
}
.topbar .icon-btn {
  width: 38px; height: 38px; border-radius: 9px; border: none;
  background: rgba(255,255,255,.12); color: #fff; font-size: 18px;
  display: grid; place-items: center;
}
.topbar .icon-btn:hover { background: rgba(255,255,255,.22); }
.topbar .spacer { flex: 1; }
.topbar .user { font-size: 13px; opacity: .95; display: flex; align-items: center; gap: 8px; }

/* Barra de tarefas de janelas (ícones entre os botões extremos) */
.taskbar { display: flex; align-items: center; gap: 6px; overflow: hidden; max-width: 46vw; }
.taskbar .nav-arrow { flex: none; }
.taskbar .strip { display: flex; gap: 6px; overflow: hidden; scroll-behavior: smooth; }
.task-chip {
  display: flex; align-items: center; gap: 6px; flex: none;
  background: rgba(255,255,255,.14); color: #fff;
  border: none; border-radius: 8px; padding: 6px 10px; font-size: 12px; max-width: 160px;
}
.task-chip.active { background: rgba(255,255,255,.32); }
.task-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.body { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 0; }
.body.collapsed { grid-template-columns: var(--sidebar-w-collapsed) 1fr; }

/* ---------------------- Sidebar ------------------------------------ */
.sidebar {
  background: var(--surface); border-right: 1px solid var(--border);
  overflow-y: auto; padding: 8px 0;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border); border-radius: 8px; }
.menu-group > .menu-item { font-weight: 600; }
.menu-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 16px; color: var(--text); cursor: pointer;
  border: none; background: none; width: 100%; text-align: left; font-size: 14px;
  position: relative;
}
.menu-item:hover { background: var(--surface-2); }
.menu-item.active { background: var(--brand); color: #fff; }
.menu-item .ico { width: 20px; text-align: center; flex: none; font-size: 16px; }
.menu-item .chev { margin-left: auto; transition: transform .18s; color: var(--text-muted); }
.menu-item.active .chev { color: #fff; }
.menu-group.open > .menu-item .chev { transform: rotate(90deg); }
.submenu { max-height: 0; overflow: hidden; transition: max-height .22s ease; background: var(--surface-2); }
.menu-group.open > .submenu { max-height: 600px; }
.submenu .menu-item { padding-left: 46px; font-weight: 400; font-size: 13px; }
.submenu .submenu .menu-item { padding-left: 64px; }

.body.collapsed .menu-item .label,
.body.collapsed .menu-item .chev { display: none; }
.body.collapsed .submenu { display: none; }
.body.collapsed .menu-item { justify-content: center; padding: 12px 0; }

/* ---------------------- Conteúdo / Dashboard ----------------------- */
.content { overflow: auto; padding: 20px; position: relative; }
.dash-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 18px; align-items: start; }
@media (max-width: 1000px) { .dash-grid { grid-template-columns: 1fr; } }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px;
}
.card h3 { margin: 0 0 12px; font-size: 15px; }
.card .muted { color: var(--text-muted); }
.stack { display: grid; gap: 18px; }

.kpi-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; }
@media (max-width: 720px) { .kpi-row { grid-template-columns: repeat(2, 1fr); } }
.kpi { text-align: center; }
.kpi .n { font-size: 34px; font-weight: 800; line-height: 1; }
.kpi .lbl { color: var(--text-muted); font-size: 12px; margin-bottom: 8px; }
.pill { display: inline-block; padding: 6px 14px; border-radius: 999px; color: #fff; font-weight: 700; font-size: 13px; }
.pill.violet { background: var(--brand); } .pill.green { background: var(--green); }
.pill.orange { background: var(--orange); } .pill.violet-2 { background: #a855f7; }

.donut-wrap { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 720px) { .donut-wrap { grid-template-columns: 1fr; } }
.donut { display: grid; place-items: center; text-align: center; }
.donut svg { transform: rotate(-90deg); }
.donut .pct { font-size: 22px; font-weight: 800; }

table.grid { width: 100%; border-collapse: collapse; }
table.grid th, table.grid td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.grid th { color: var(--text-muted); font-weight: 600; user-select: none; }
table.grid tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.status-chip { padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.status-Pendente { background: #111827; color: #fff; }
.status-EmAndamento { background: var(--orange-soft); color: var(--orange); }
.status-Concluida { background: var(--green-soft); color: var(--green); }

/* ---------------------- Grade (telas de cadastro) ------------------ */
.grid-toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.grid-toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.grid-toolbar .search input { width: 100%; padding-left: 34px; }
.grid-toolbar .search .mag { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.pager { display: flex; align-items: center; gap: 10px; justify-content: flex-end; margin-top: 12px; color: var(--text-muted); font-size: 13px; }
.pager button { width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.pager button:disabled { opacity: .4; cursor: default; }
.row-actions { display: flex; gap: 10px; justify-content: flex-end; }
.row-actions button { border: none; background: none; color: var(--text-muted); font-size: 15px; }
.row-actions button:hover { color: var(--brand); }
.row-actions button.del:hover { color: var(--danger); }

/* ---------------------- Janelas arrastáveis ------------------------ */
.window {
  position: fixed; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; min-width: 320px; min-height: 160px;
  overflow: hidden; z-index: 100;
}
.window.minimized { display: none; }
.window .titlebar {
  display: flex; align-items: center; gap: 8px; cursor: move;
  padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border);
  user-select: none;
}
.window .titlebar .tt { font-weight: 700; font-size: 14px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.window .win-btns { display: flex; gap: 6px; }
.window .win-btns button {
  width: 26px; height: 26px; border-radius: 7px; border: none; background: transparent;
  color: var(--text-muted); font-size: 14px; display: grid; place-items: center;
}
.window .win-btns button:hover { background: var(--border); color: var(--text); }
.window .win-btns button.close:hover { background: var(--danger); color: #fff; }
.window .win-body { padding: 16px 18px; overflow: auto; flex: 1; }

/* Formulários dentro das janelas */
.form-container h2 { margin: 0 0 14px; font-size: 16px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-container label { display: block; font-size: 12px; color: var(--text-muted); margin: 0 0 5px; }
.form-container .req::after { content: " *"; color: var(--danger); }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* Painéis expansíveis (destaque vermelho da imagem6) */
.panel { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-top: 14px; overflow: hidden; }
.panel > .panel-head {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  padding: 10px 12px; background: var(--surface-2); font-weight: 600;
}
.panel > .panel-head .ico { color: var(--brand); }
.panel > .panel-head .chev { margin-left: auto; transition: transform .18s; color: var(--text-muted); }
.panel.open > .panel-head .chev { transform: rotate(180deg); }
.panel > .panel-body { padding: 14px 12px; display: none; }
.panel.open > .panel-body { display: block; }

.checkbox { display: flex; align-items: center; gap: 8px; font-size: 13px; margin-top: 4px; }
.checkbox input { width: auto; }

/* Toast */
#toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 999; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--brand);
  box-shadow: var(--shadow-lg); border-radius: 10px; padding: 12px 14px; font-size: 13px; min-width: 220px;
  animation: slidein .2s ease;
}
.toast.ok { border-left-color: var(--green); }
.toast.err { border-left-color: var(--danger); }
@keyframes slidein { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

/* Indicador SSE */
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #94a3b8; display: inline-block; }
.live-dot.on { background: #22c55e; box-shadow: 0 0 0 3px rgba(34,197,94,.25); }

/* ===================================================================
   Módulos Vendas (PDV) e Caixa
   =================================================================== */
.muted { color: var(--text-muted); }
.green { color: var(--green); }
.orange { color: var(--orange); }
.linkbtn { background: none; border: none; cursor: pointer; font-size: 15px; }

/* ---- PDV de vendas ---- */
.pdv-search { position: relative; margin: 6px 0 12px; }
.pdv-search .mag { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-muted); }
.pdv-search input { width: 100%; padding-left: 34px; }
.pdv-results {
  position: absolute; z-index: 5; left: 0; right: 0; top: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
  max-height: 240px; overflow: auto; margin-top: 4px;
}
.pdv-item {
  display: flex; justify-content: space-between; align-items: center;
  gap: 10px; padding: 9px 12px; cursor: pointer; font-size: 13px;
}
.pdv-item:hover { background: var(--brand-soft); }
.pdv-itens td .cell {
  width: 100%; padding: 6px 8px; text-align: right;
  border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
}
.pdv-itens td:nth-child(3) .cell { text-align: center; }
.pdv-empty { color: var(--text-muted); text-align: center; padding: 20px; font-size: 13px; }

.venda-foot {
  display: flex; justify-content: space-between; align-items: center;
  gap: 16px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.venda-total { font-size: 15px; color: var(--text-muted); }
.venda-total b { font-size: 24px; color: var(--text); margin-left: 8px; }

/* ---- Recibo ---- */
.recibo-head { display: flex; justify-content: space-between; margin-bottom: 10px; }
.recibo-cli { margin: 6px 0 12px; }

/* ---- Caixa ---- */
.caixa-wrap { display: block; }
.caixa-status {
  display: inline-block; padding: 5px 14px; border-radius: 999px;
  font-weight: 800; font-size: 13px; letter-spacing: .3px;
}
.caixa-status.aberto { background: var(--green-soft); color: var(--green); }
.caixa-status.fechado { background: var(--orange-soft); color: var(--orange); }
.caixa-fechado { text-align: center; padding: 10px; }
.caixa-fechado .caixa-status { margin-bottom: 10px; }
.abrir-card { max-width: 340px; margin: 16px auto 0; text-align: left; }
.abrir-card label { display: block; font-size: 13px; color: var(--text-muted); margin-bottom: 6px; }
.abrir-card input { width: 100%; margin-bottom: 12px; }

.caixa-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 14px; }
.caixa-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.ccard {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px;
}
.ccard .lbl { font-size: 12px; color: var(--text-muted); margin-bottom: 4px; }
.ccard .v { font-size: 18px; font-weight: 800; }
.ccard.saldo { background: var(--brand-soft); border-color: var(--brand); }
.lanc-form h3 { margin-top: 0; }

@media (max-width: 620px) {
  .caixa-cards { grid-template-columns: repeat(2, 1fr); }
}
