/* ══════════════════════════════════════════════════════════════
   SmartBiz · Design System
══════════════════════════════════════════════════════════════ */
:root {
  --emerald:     #00c896;
  --emerald-dim: rgba(0,200,150,.18);
  --emerald-glow:rgba(0,200,150,.08);
  --ink:         #080d0b;
  --ink2:        #0f1a12;
  --surface:     #131e16;
  --surface2:    #192419;
  --border:      rgba(0,200,150,.13);
  --text:        #e2ede6;
  --text-dim:    rgba(226,237,230,.4);
  --text-mid:    rgba(226,237,230,.7);
  --red:         #f05252;
  --yellow:      #f4a72a;
  --sidebar-w:   220px;
  --header-h:    56px;
  --bottom-nav-h:62px;
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { scroll-behavior:smooth; }
body {
  background:var(--ink);
  color:var(--text);
  font-family:'DM Sans', sans-serif;
  font-size:14px;
  line-height:1.6;
  display:flex;
  min-height:100vh;
  overflow-x:hidden;
}

body::before {
  content:'';position:fixed;inset:0;z-index:0;pointer-events:none;
  background-image:linear-gradient(rgba(0,200,150,.018) 1px,transparent 1px),
                   linear-gradient(90deg,rgba(0,200,150,.018) 1px,transparent 1px);
  background-size:48px 48px;
}

/* ══ SIDEBAR ══════════════════════════════════════════════════ */
.sidebar {
  width:var(--sidebar-w);
  height:100vh;
  max-height:100vh;
  background:var(--ink2);
  border-right:1px solid var(--border);
  display:flex;
  flex-direction:column;
  position:fixed;
  top:0; left:0;
  z-index:50;
  transition:transform .25s cubic-bezier(.4,0,.2,1);
  overflow-y:auto;
  overflow-x:hidden;
}
.sidebar-logo {
  padding:22px 20px;
  border-bottom:1px solid var(--border);
  font-family:'Syne', sans-serif;
  font-weight:800;
  font-size:20px;
  letter-spacing:-.5px;
  color:#fff;
}
.sidebar-logo span { color:var(--emerald); }
.sidebar-logo small {
  display:block;
  font-family:'DM Mono', monospace;
  font-size:9px;
  letter-spacing:3px;
  color:var(--text-dim);
  font-weight:400;
  margin-top:2px;
  text-transform:uppercase;
}
.nav-group-label {
  font-family:'DM Mono', monospace;
  font-size:8px;
  letter-spacing:3px;
  color:var(--text-dim);
  text-transform:uppercase;
  padding:18px 20px 6px;
}
.nav-item {
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 20px;
  color:var(--text-dim);
  text-decoration:none;
  font-size:13px;
  font-weight:500;
  transition:all .15s;
  border-left:2px solid transparent;
  position:relative;
}
.nav-item:hover { color:var(--text); background:var(--emerald-glow); }
.nav-item.active { color:var(--emerald); background:rgba(0,200,150,.06); border-left-color:var(--emerald); }
.nav-icon { width:32px; height:32px; display:flex; align-items:center; justify-content:center; font-size:16px; flex-shrink:0; }
.sidebar-footer { margin-top:auto; padding:16px 20px; border-top:1px solid var(--border); flex-shrink:0; }
.sidebar-footer p { font-family:'DM Mono', monospace; font-size:9px; letter-spacing:1px; color:var(--text-dim); text-transform:uppercase; }

.sidebar::-webkit-scrollbar { width:3px; }
.sidebar::-webkit-scrollbar-track { background:transparent; }
.sidebar::-webkit-scrollbar-thumb { background:var(--border); border-radius:2px; }
.sidebar::-webkit-scrollbar-thumb:hover { background:var(--text-dim); }

.nav-badge { margin-left:auto; background:var(--red); color:#fff; font-family:'DM Mono', monospace; font-size:9px; padding:1px 6px; border-radius:10px; letter-spacing:.5px; }

/* ══ SIDEBAR OVERLAY ══════════════════════════════════════════ */
.sidebar-overlay {
  display:none; position:fixed; inset:0;
  background:rgba(0,0,0,.65);
  z-index:49; backdrop-filter:blur(2px);
}
.sidebar-overlay.open { display:block; }

/* ══ MAIN ══════════════════════════════════════════════════════ */
.main { margin-left:var(--sidebar-w); flex:1; display:flex; flex-direction:column; position:relative; z-index:1; }

.topbar {
  min-height:var(--header-h);
  background:rgba(8,13,11,.9);
  backdrop-filter:blur(12px);
  border-bottom:1px solid var(--border);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 32px;
  position:sticky;
  top:0; z-index:40;
  gap:12px; flex-wrap:wrap;
}
.topbar-title { font-family:'Syne', sans-serif; font-size:17px; font-weight:700; color:#fff; display:flex; align-items:center; gap:10px; flex-shrink:0; white-space:nowrap; }
.topbar-title .page-icon { font-size:18px; }
.topbar-right { display:flex; align-items:center; gap:12px; }

/* Hamburger — oculto no desktop */
.btn-hamburger {
  display:none;
  background:transparent; border:1px solid var(--border); color:var(--text);
  width:36px; height:36px; border-radius:4px; cursor:pointer;
  align-items:center; justify-content:center; font-size:18px; flex-shrink:0;
  transition:all .15s;
}
.btn-hamburger:hover { border-color:var(--emerald); color:var(--emerald); }

.badge-online { display:flex; align-items:center; gap:6px; font-family:'DM Mono', monospace; font-size:10px; letter-spacing:1px; color:var(--emerald); text-transform:uppercase; white-space:nowrap; }
.dot-live { width:6px; height:6px; border-radius:50%; background:var(--emerald); box-shadow:0 0 6px var(--emerald); animation:blink 1.5s step-end infinite; }
.content { padding:28px 32px; }

/* ══ BOTTOM NAV ════════════════════════════════════════════════ */
.bottom-nav {
  display:none; position:fixed; bottom:0; left:0; right:0;
  height:var(--bottom-nav-h); background:var(--ink2);
  border-top:1px solid var(--border); z-index:48;
  justify-content:space-around; align-items:stretch;
}
.bottom-nav-item {
  flex:1; display:flex; flex-direction:column; align-items:center; justify-content:center;
  gap:3px; color:var(--text-dim); text-decoration:none;
  font-size:9px; font-family:'DM Mono', monospace; letter-spacing:.5px; text-transform:uppercase;
  transition:color .15s; padding:6px 4px; cursor:pointer;
  background:transparent; border:none;
}
.bottom-nav-item.active { color:var(--emerald); }
.bottom-nav-item:active { opacity:.7; }
.bottom-nav-icon { font-size:20px; line-height:1; }

/* ══ STAT CARDS ════════════════════════════════════════════════ */
.stat-grid { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; margin-bottom:28px; }
.stat-card { background:var(--surface); border:1px solid var(--border); border-radius:4px; padding:20px; }
.stat-label { font-family:'DM Mono', monospace; font-size:9px; letter-spacing:2px; color:var(--text-dim); text-transform:uppercase; margin-bottom:8px; }
.stat-value { font-family:'Syne', sans-serif; font-size:28px; font-weight:800; color:#fff; line-height:1; }
.stat-value.green  { color:var(--emerald); }
.stat-value.red    { color:var(--red); }
.stat-value.yellow { color:var(--yellow); }
.stat-delta { font-size:11px; color:var(--text-dim); margin-top:4px; }
.stat-delta.up { color:var(--emerald); }
.stat-delta.down { color:var(--red); }

/* ══ PANELS ════════════════════════════════════════════════════ */
.panel { background:var(--surface); border:1px solid var(--border); border-radius:4px; overflow:hidden; margin-bottom:20px; }
.panel-header {
  background:var(--surface2); padding:12px 20px;
  border-bottom:1px solid var(--border);
  display:flex; align-items:center; justify-content:space-between;
  font-family:'DM Mono', monospace; font-size:9px; letter-spacing:2px;
  color:var(--emerald); text-transform:uppercase; flex-wrap:wrap; gap:8px;
}
.panel-body { padding:20px; }
.panel-body.no-pad { padding:0; }
.two-col { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.three-col { display:grid; grid-template-columns:1fr 1fr 1fr; gap:16px; }
.sidebar-col { display:grid; grid-template-columns:360px 1fr; gap:24px; align-items:start; }
.sidebar-col-r { display:grid; grid-template-columns:1fr 360px; gap:24px; align-items:start; }

/* ══ FORMS ══════════════════════════════════════════════════════ */
.form-group { margin-bottom:14px; }
.form-label { display:block; font-family:'DM Mono', monospace; font-size:9px; letter-spacing:2px; color:var(--emerald); text-transform:uppercase; margin-bottom:5px; }
.form-input, .form-select { width:100%; background:#050a07; border:1px solid rgba(0,200,150,.22); color:var(--text); font-family:'DM Sans', sans-serif; font-size:13px; padding:9px 13px; outline:none; border-radius:3px; transition:border-color .2s; }
.form-input:focus, .form-select:focus { border-color:var(--emerald); }
.form-input::placeholder { color:var(--text-dim); }
.form-select option { background:#0a0f0d; }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.form-row-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:12px; }

/* ══ BUTTONS ════════════════════════════════════════════════════ */
.btn { display:inline-flex; align-items:center; gap:6px; font-family:'DM Mono', monospace; font-size:10px; letter-spacing:1.5px; text-transform:uppercase; padding:10px 20px; cursor:pointer; border:none; border-radius:3px; transition:all .15s; font-weight:500; white-space:nowrap; }
.btn-primary  { background:var(--emerald); color:#000; }
.btn-primary:hover { background:#00ffb8; }
.btn-outline  { background:transparent; border:1px solid var(--emerald); color:var(--emerald); }
.btn-outline:hover { background:var(--emerald); color:#000; }
.btn-ghost    { background:transparent; border:1px solid var(--border); color:var(--text-dim); }
.btn-ghost:hover { border-color:var(--text-dim); color:var(--text); }
.btn-danger   { background:transparent; border:1px solid rgba(240,82,82,.3); color:var(--red); }
.btn-danger:hover { background:rgba(240,82,82,.1); }
.btn-sm       { padding:6px 14px; font-size:9px; }
.btn-full     { width:100%; justify-content:center; }
.btn:disabled { opacity:.35; cursor:not-allowed; }

/* ══ TABLES ═════════════════════════════════════════════════════ */
.table-wrap { overflow-x:auto; -webkit-overflow-scrolling:touch; }
table { width:100%; border-collapse:collapse; }
thead th { font-family:'DM Mono', monospace; font-size:9px; letter-spacing:2px; color:var(--emerald); text-transform:uppercase; padding:10px 16px; text-align:left; border-bottom:1px solid var(--border); white-space:nowrap; }
tbody td { padding:12px 16px; font-size:13px; border-bottom:1px solid rgba(0,200,150,.05); vertical-align:middle; }
tbody tr:hover td { background:rgba(0,200,150,.02); }
tbody tr:last-child td { border-bottom:none; }

/* ══ BADGES ═════════════════════════════════════════════════════ */
.badge { display:inline-block; font-family:'DM Mono', monospace; font-size:9px; letter-spacing:1px; padding:2px 9px; border-radius:20px; text-transform:uppercase; white-space:nowrap; }
.badge-green  { background:rgba(0,200,150,.15); color:var(--emerald); }
.badge-yellow { background:rgba(244,167,42,.15); color:var(--yellow); }
.badge-red    { background:rgba(240,82,82,.15); color:var(--red); }
.badge-blue   { background:rgba(59,130,246,.15); color:#60a5fa; }
.badge-gray   { background:rgba(255,255,255,.08); color:var(--text-dim); }

/* ══ IA BOX ══════════════════════════════════════════════════════ */
.ia-box { background:rgba(0,200,150,.05); border:1px solid rgba(0,200,150,.2); border-radius:4px; padding:18px; }
.ia-box-label { font-family:'DM Mono', monospace; font-size:9px; letter-spacing:2px; color:var(--emerald); text-transform:uppercase; margin-bottom:10px; display:flex; align-items:center; gap:6px; }
.ia-box-text { font-size:13px; color:var(--text-mid); line-height:1.8; white-space:pre-wrap; }

/* ══ MISC ════════════════════════════════════════════════════════ */
.spinner { display:inline-block; width:12px; height:12px; border:2px solid rgba(0,200,150,.25); border-top-color:var(--emerald); border-radius:50%; animation:spin .65s linear infinite; vertical-align:middle; margin-right:6px; }
.empty-state { text-align:center; padding:48px 20px; color:var(--text-dim); font-size:13px; font-style:italic; }
.divider { border:none; border-top:1px solid var(--border); margin:20px 0; }
.text-mono { font-family:'DM Mono', monospace; }
.text-green { color:var(--emerald); }
.text-red   { color:var(--red); }
.text-dim   { color:var(--text-dim); }
.text-right { text-align:right; }
.bold       { font-weight:700; }
.gap-8      { display:flex; gap:8px; }
.gap-12     { display:flex; gap:12px; align-items:center; }
.qty-ctrl { display:flex; align-items:center; gap:4px; }
.qty-btn { width:28px; height:28px; border:1px solid var(--border); background:transparent; color:var(--emerald); cursor:pointer; font-size:16px; display:flex; align-items:center; justify-content:center; border-radius:2px; transition:all .15s; }
.qty-btn:hover { background:var(--emerald); color:#000; }
.qty-num { font-family:'DM Mono', monospace; font-size:13px; min-width:30px; text-align:center; }

/* ══ TOAST ═══════════════════════════════════════════════════════ */
.toast { position:fixed; bottom:28px; right:28px; background:var(--emerald); color:#000; font-family:'DM Mono', monospace; font-size:11px; letter-spacing:1px; padding:12px 22px; border-radius:3px; z-index:999; transform:translateY(60px); opacity:0; transition:all .3s; pointer-events:none; }
.toast.show { transform:translateY(0); opacity:1; }
.toast.error { background:var(--red); color:#fff; }

/* ══ MODAL ════════════════════════════════════════════════════════ */
.modal-bg { display:none; position:fixed; inset:0; background:rgba(0,0,0,.7); z-index:200; align-items:center; justify-content:center; padding:16px; }
.modal-bg.open { display:flex; }
.modal { background:var(--ink2); border:1px solid var(--border); border-radius:6px; padding:28px; width:100%; max-width:480px; box-shadow:0 24px 80px rgba(0,0,0,.6); max-height:90vh; overflow-y:auto; }
.modal-title { font-family:'Syne', sans-serif; font-size:17px; font-weight:700; margin-bottom:20px; color:#fff; }

@keyframes spin   { to { transform:rotate(360deg); } }
@keyframes blink  { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes fadein { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }
@keyframes slideup { from{transform:translateY(100%)} to{transform:translateY(0)} }

/* ══ TABLET (≤1100px) ═════════════════════════════════════════ */
@media(max-width:1100px) {
  .stat-grid { grid-template-columns:repeat(2,1fr); }
  .sidebar-col, .sidebar-col-r { grid-template-columns:1fr; }
  .three-col { grid-template-columns:1fr 1fr; }
}

/* ══ MOBILE (≤900px) ══════════════════════════════════════════ */
@media(max-width:900px) {

  /* Sidebar como overlay deslizante */
  .sidebar { transform:translateX(-100%); box-shadow:4px 0 40px rgba(0,0,0,.5); }
  .sidebar.open { transform:translateX(0); }

  /* Main sem margem, com espaço p/ bottom nav */
  .main { margin-left:0; padding-bottom:calc(var(--bottom-nav-h) + 6px); }

  /* Bottom nav visível */
  .bottom-nav { display:flex; }

  /* Hamburger visível */
  .btn-hamburger { display:flex; }

  /* Topbar responsiva — primeira linha: [☰] [título], segunda linha: [ações] */
  .topbar {
    padding:0 14px;
    height:auto;
    justify-content:flex-start;
    align-items:center;
    flex-wrap:wrap;
    gap:0;
  }
  .topbar-title {
    font-size:14px;
    padding:13px 0;
    flex:1;
    min-width:0;
    gap:8px;
  }
  .topbar-title .page-icon { font-size:15px; }
  .topbar-right {
    flex:0 0 100%;
    padding:0 0 10px;
    gap:8px;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    scrollbar-width:none;
    justify-content:flex-start;
  }
  .topbar-right::-webkit-scrollbar { display:none; }
  .topbar-right .badge-online,
  .topbar-right #clock { display:none !important; }
  .topbar-right .form-input  { font-size:13px; padding:8px 11px; }
  .topbar-right .form-select { font-size:13px; padding:8px 10px; }
  /* Esconder topbar-right se vazio (sem botões visíveis) */
  .topbar-right:empty { display:none; }

  /* Toast acima do bottom nav */
  .toast { bottom:calc(var(--bottom-nav-h) + 12px); left:12px; right:12px; text-align:center; }

  /* Grids */
  .stat-grid { grid-template-columns:1fr 1fr; gap:10px; margin-bottom:16px; }
  .two-col, .sidebar-col, .sidebar-col-r, .three-col { grid-template-columns:1fr; }

  /* Cards menores */
  .stat-card { padding:14px 12px; }
  .stat-value { font-size:20px; }
  .stat-label { font-size:8px; }

  /* Content padding */
  .content { padding:14px 12px 8px; }

  /* Forms */
  .form-row, .form-row-3 { grid-template-columns:1fr; gap:0; }

  /* Modal slide-up */
  .modal-bg { align-items:flex-end; padding:0; }
  .modal { max-width:100%; width:100%; border-radius:16px 16px 0 0; padding:24px 20px 36px; animation:slideup .3s cubic-bezier(.4,0,.2,1); max-height:92vh; }

  /* PDV — carrinho abaixo dos produtos */
  .pdv-wrap { grid-template-columns:1fr !important; }
  .produto-grid { grid-template-columns:repeat(2,1fr) !important; }
  .carrinho { position:static !important; }
  .cart-total-val { font-size:22px !important; }

  /* Panels: remover overflow hidden p/ não cortar modal */
  .panel { overflow:visible; }

  /* Botões de ação no topbar — menores no mobile */
  .topbar-right .btn { padding:7px 13px; font-size:9px; }
}

/* ══ MOBILE PEQUENO (≤480px) ══════════════════════════════════ */
@media(max-width:480px) {
  .stat-grid { grid-template-columns:1fr 1fr; }
  .stat-value { font-size:17px; }
}
