@import "../tokens.css";
:root {
  --bg: #f5f4f1;
  --panel: #ffffff;
  --line: #e6e1d8;
  --ink: #202226;
  --accent: var(--brand);
  --accent-strong: var(--brand-dark);
  --info: #5477df;
  --radius: var(--r-md);
  --radius-lg: var(--r-lg);
  --shadow: 0 2px 8px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; font-family: Inter, system-ui, sans-serif; color: var(--ink); background: var(--bg); -webkit-font-smoothing: antialiased; }
body { display: flex; flex-direction: column; }
.view { display: none; min-height: 100vh; }
.view.active { display: flex; }
[hidden] { display: none !important; }

/* ── Login ── */
#login-view { align-items: center; justify-content: center; padding: 24px; }
.login-card { width: min(400px, 100%); background: var(--panel); border-radius: var(--radius-lg); padding: 40px 32px; box-shadow: var(--shadow); }
.login-card { border-top: 4px solid var(--brand); }
.login-header { text-align: center; margin-bottom: 24px; }
.login-logo { height: 48px; margin-bottom: 12px; }
.login-header h1 { font-size: 28px; font-weight: 800; }
.login-header p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.role-tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); border-radius: var(--radius); padding: 4px; }
.role-tab { flex: 1; padding: 8px; border: none; background: none;   border-radius: var(--r-sm); font-size: 12px; font-weight: 600; color: var(--muted); cursor: pointer; transition: all .15s; }
.role-tab:hover { color: var(--ink); }
.role-tab.active { background: var(--panel); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.field span { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field textarea { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); font-size: 14px; background: var(--panel); color: var(--ink); transition: border-color 0.15s; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--accent); }
.btn-primary { padding: 12px 24px; background: var(--accent); color: #fff; border: none; border-radius: var(--radius); font-size: 14px; font-weight: 600; cursor: pointer; transition: background 0.15s; }
.btn-primary:hover { background: var(--accent-strong); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary.full { width: 100%; }
.btn-ghost { padding: 8px 16px; background: transparent; color: var(--muted); border: 1px solid var(--line); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s; }
.btn-ghost:hover, .btn-ghost.active { color: var(--ink); border-color: var(--ink); background: rgba(0,0,0,0.04); }
.btn-danger { padding: 8px 16px; background: transparent; color: var(--accent); border: 1px solid var(--accent); border-radius: var(--radius); font-size: 13px; font-weight: 500; cursor: pointer; }
.error-text { color: var(--accent); font-size: 13px; margin-top: 8px; min-height: 20px; }
.help-text { color: var(--muted); font-size: 13px; margin-top: 12px; }
.login-form { margin-top: 8px; }

/* ── Topbar ── */
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; gap: 12px; }
.topbar h1 { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.topbar-right .btn-ghost { font-size: 12px; padding: 6px 12px; }

/* ── Content ── */
.content { flex: 1; padding: 24px; max-width: 960px; margin: 0 auto; width: 100%; }
.section { display: none; }
.section.active { display: block; }
.section h2 { font-size: 22px; font-weight: 700; margin-bottom: 20px; }
.section h3 { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.cards-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.status-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; display: flex; align-items: center; gap: 12px; }
.status-card small { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.status-card strong { font-size: 15px; font-weight: 700; }
.status-dot { width: 12px; height: 12px; border-radius: 50%; flex-shrink: 0; }
.status-dot.online { background: var(--success); }
.status-dot.offline { background: var(--accent); }
.link-accent { color: var(--accent); text-decoration: none; font-weight: 600; }
.link-accent:hover { text-decoration: underline; }

/* ── Badge ── */
.badge { display: inline-flex; align-items: center; padding: 2px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; color: #fff; }
.badge.success { background: var(--success); }
.badge.warning { background: var(--warning); }
.badge.danger { background: var(--accent); }
.badge.info { background: var(--info); }
.status-badge { display: inline-block; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-badge.active { background: #eaf7ee; color: #177245; }
.status-badge.pending { background: #fdf3e3; color: #a35907; }
.status-badge.other { background: #fdecea; color: #b3261e; }

/* ── Billing / Financeiro ── */
.billing-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; margin: 16px 0; }
.billing-card h3 { font-size: 18px; margin-bottom: 12px; }
.billing-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.billing-row:last-child { border-bottom: none; }
.pix-charge { background: var(--bg);   border-radius: var(--r-md); padding: 20px; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.pix-charge h3 { font-size: 14px; color: var(--muted); font-weight: 600; text-align: center; }
.pix-amount { font-size: 28px; font-weight: 700; }
.pix-qr { width: 200px; height: 200px;   border-radius: var(--r-sm); background: #fff; }
.pix-copy { width: 100%; }
.pix-expiry { font-size: 12px; color: var(--muted); }

/* ── Tickets ── */
.tickets-list { display: flex; flex-direction: column; gap: 12px; }
.ticket-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.ticket-item header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.ticket-item header strong { font-size: 15px; }
.ticket-item p { color: var(--muted); font-size: 13px; }
.ticket-form { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; margin-top: 16px; }
.ticket-form h3 { margin-bottom: 16px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 16px; }
.hidden { display: none !important; }

/* ── Config ── */
.config-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; max-width: 480px; }
.config-card h3 { margin-bottom: 16px; }

/* ── Tab / Painel lojista ── */
.tab-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 24px; flex-wrap: wrap; }
.tab-head h2 { margin: 0; }
.tab-head .lead { color: var(--muted); margin: 0; font-size: 14px; }
.stats-row { display: flex; gap: 12px; }
.stat { background: var(--panel); border: 1.5px solid var(--border);   border-radius: var(--r-md); padding: 12px 20px; display: flex; flex-direction: column; min-width: 80px; }
.stat span { font-size: 11px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat b { font-size: 22px; font-weight: 800; }
.pedidos-list { display: flex; flex-direction: column; gap: 12px; }
.pedido-card { background: var(--panel); border: 1.5px solid var(--border);   border-radius: var(--r-lg); padding: 18px 22px; display: grid; grid-template-columns: 1fr auto; gap: 16px; }
.pedido-card.novo { border-left: 4px solid var(--brand); }
.pedido-card h3 { margin: 0 0 4px; font-size: 15px; font-weight: 700; }
.pedido-card .meta { display: flex; gap: 12px; font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.pedido-card .items { margin-top: 6px; font-size: 13px; color: var(--muted); }
.pedido-card .total { font-size: 20px; font-weight: 800; text-align: right; }

/* ── Loja ── */
.loja-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.info-card { background: var(--panel); border: 1.5px solid var(--border);   border-radius: var(--r-md); padding: 16px 20px; }
.info-card.full { grid-column: 1 / -1; }
.eyebrow { display: block; font-size: 11px; color: var(--muted); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 6px; }
.info-card b { font-size: 16px; font-weight: 700; }
.link-row { display: flex; gap: 8px; align-items: center; }
.link-row a { flex: 1; color: var(--brand); font-weight: 600; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.loja-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.ghost-btn { display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 1.5px solid var(--border);   border-radius: var(--r-sm); background: var(--panel); color: var(--ink); font-size: 13px; font-weight: 600; text-decoration: none; cursor: pointer; transition: border-color .15s; }
.ghost-btn:hover { border-color: var(--brand); }
.loja-toggle { display: flex; align-items: center; gap: 8px; cursor: pointer; }

/* ── Financeiro stats ── */
.fin-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.fin-card { background: var(--panel); border: 1.5px solid var(--border);   border-radius: var(--r-md); padding: 18px 20px; }
.fin-card b { display: block; font-size: 22px; font-weight: 800; margin: 4px 0; }
.fin-card b.brl { color: var(--success); }
.fin-card small { color: var(--muted); font-size: 12px; }
.extrato-section { margin-top: 20px; }

/* ── SaaS / Motoboy sections ── */
.saas-section { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; margin-top: 20px; }
.saas-section h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; }
.saas-section h3 svg { width: 18px; height: 18px; color: var(--accent); }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); }
.table th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.downloads-list { display: grid; gap: 10px; }
.download-item { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid var(--line);   border-radius: var(--r-md); padding: 14px 16px; text-decoration: none; color: inherit; }
.download-item:hover { border-color: var(--brand); }
.download-item b { font-size: 14px; }
.download-item svg { width: 18px; height: 18px; color: var(--brand); }

/* ── Withdraw ── */
.withdraw-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.withdraw-form .field { flex: 1; min-width: 180px; margin: 0; }

/* ── Toast ── */
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); padding: 12px 24px; background: #202226; color: #fff; border-radius: var(--radius); font-size: 14px; font-weight: 500; opacity: 0; transition: opacity .3s; pointer-events: none; z-index: 999; }
.toast.show { opacity: 1; }

/* ── Metric cards (admin) ── */
.metric { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 20px; }
.metric span { display: block; color: var(--muted); font-size: 12px; margin-bottom: 4px; }
.metric b { font-size: 20px; font-weight: 800; }
.surface { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 24px; }
.surface.stack { display: flex; flex-direction: column; gap: 12px; }

/* ── Responsive ── */
@media (max-width: 720px) {
  .topbar { flex-direction: column; align-items: flex-start; }
  .topbar-right { width: 100%; overflow-x: auto; }
  .cards-grid { grid-template-columns: 1fr; }
  .loja-cards { grid-template-columns: 1fr; }
  .fin-stats { grid-template-columns: 1fr; }
  .stats-row { flex-wrap: wrap; }
  .stat { min-width: 70px; flex: 1; }
  .table thead { display: none; }
  .table td { display: block; border: none; padding: 4px 0; }
  .table tr { display: block; border-bottom: 1px solid var(--line); padding: 10px 0; }
}

/* Despacho pra fila do entregador */
.pedido-card .total { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.pedido-ready-btn { padding: 8px 14px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.pedido-ready { font-size: 11px; font-weight: 700; color: #15803d; text-transform: uppercase; letter-spacing: .05em; }
