/* ============================================================
   style.css — VERSIONE C3 (PRO SaaS Auto Light/Dark)
   Rebuild completo da zero
   - Light default
   - Dark quando body.dark è presente
   - Receipt resta in receipt.css
============================================================ */

/* -----------------------------
   DESIGN TOKENS
----------------------------- */
:root{
  --bg: #f5f7fb;
  --bg-soft: #eef2f7;
  --panel: #ffffff;
  --panel-2: #f8fafc;
  --border: #e6e9ef;
  --text: #0f172a;
  --muted: #64748b;
  --muted-2:#94a3b8;

  --brand: #2563eb;
  --brand-2:#1d4ed8;
  --ok: #16a34a;
  --warn:#f59e0b;
  --danger:#ef4444;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 24px rgba(15,23,42,0.06);
  --shadow-soft: 0 4px 12px rgba(15,23,42,0.05);

  --sidebar-w: 240px;
  --sidebar-w-collapsed: 72px;

  --topbar-h: 64px;
  --gap: 14px;
  --gap-lg: 18px;

  --font: system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

/* Dark tokens */
body.dark{
  --bg:#0b1220;
  --bg-soft:#0f172a;
  --panel:#111a2b;
  --panel-2:#0f1829;
  --border:#1f2a3a;
  --text:#e5e7eb;
  --muted:#9aa4b2;
  --muted-2:#6b7280;

  --shadow: 0 10px 28px rgba(0,0,0,0.35);
  --shadow-soft: 0 6px 16px rgba(0,0,0,0.25);
}

/* -----------------------------
   RESET BASE
----------------------------- */
*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  font-family:var(--font);
  background:var(--bg);
  color:var(--text);
}

a{ color:inherit; text-decoration:none; }
button, input, select{
  font-family:inherit;
}

/* -----------------------------
   APP SHELL
----------------------------- */
.app{
  display:flex;
  min-height:100vh;
  width:100%;
}

/* -----------------------------
   SIDEBAR PRO
----------------------------- */
.sidebar{
  width:var(--sidebar-w);
  background:linear-gradient(180deg, #0c1630 0%, #0a1325 100%);
  color:#fff;
  position:sticky;
  top:0;
  height:100vh;
  padding:16px 12px;
  display:flex;
  flex-direction:column;
  transition:width .25s ease;
  z-index:10;
}

body.dark .sidebar{
  background:linear-gradient(180deg, #050913 0%, #060b16 100%);
}

.sidebar.collapsed{
  width:var(--sidebar-w-collapsed);
}

/* Brand */
.sidebar .brand{
  display:flex;
  align-items:center;
  gap:10px;
  margin-bottom:12px;
  padding:10px 8px;
  border-radius:10px;
}
.sidebar .brand .dot{
  width:10px;height:10px;border-radius:50%;
  background:#22c55e;
  box-shadow:0 0 0 3px rgba(34,197,94,0.18);
}
.sidebar .brand-text{
  font-weight:700;
  font-size:16px;
  letter-spacing:.2px;
  line-height:1.1;
  white-space:nowrap;
}
.sidebar.collapsed .brand-text{ display:none; }

/* Collapse btn */
.sidebar-toggle{
  margin-left:auto;
  background:rgba(255,255,255,0.06);
  border:1px solid rgba(255,255,255,0.08);
  color:#fff;
  border-radius:8px;
  padding:4px 6px;
  cursor:pointer;
  transition:.2s;
}
.sidebar-toggle:hover{ background:rgba(255,255,255,0.12); }
.sidebar .icon-sm{ width:16px;height:16px; }

/* Nav */
.nav{
  display:flex;
  flex-direction:column;
  gap:6px;
  margin-top:6px;
}

/* Main nav item */
.nav-item{
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 10px;
  border-radius:10px;
  color:#cbd5e1;
  cursor:pointer;
  transition:.18s;
  position:relative;
}
.nav-item .icon{
  width:18px;height:18px;
  opacity:.9;
  flex:0 0 auto;
}
.nav-item:hover{
  background:rgba(255,255,255,0.06);
  color:#fff;
}
.nav-item.active{
  background:rgba(37,99,235,0.18);
  color:#fff;
  border:1px solid rgba(37,99,235,0.5);
}
.nav-text{
  font-size:14px;
  font-weight:600;
  white-space:nowrap;
}
.sidebar.collapsed .nav-text{ display:none; }

/* Reports accordion always open */
.nav-accordion{
  margin-top:4px;
  border-radius:10px;
  overflow:hidden;
}
.nav-accordion .nav-item{
  border-radius:10px 10px 0 0;
}
.accordion-content{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:6px 6px 8px 30px;
}
.sub-item{
  font-size:13px;
  padding:7px 8px;
  border-radius:8px;
  color:#aab4c3;
  cursor:pointer;
  transition:.18s;
}
.sub-item:hover{
  background:rgba(255,255,255,0.06);
  color:#fff;
}

/* Sidebar footer */
.sidebar-footer{
  margin-top:auto;
  padding:10px 8px;
  border-top:1px dashed rgba(255,255,255,0.08);
  font-size:12px;
  color:#cbd5e1;
  line-height:1.4;
}
.sidebar.collapsed .sidebar-footer{ display:none; }

.sidebar-cache-btn{
  width:100%;
  height:31px;
  margin-bottom:10px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:7px;
  border:1px solid rgba(148,163,184,.22);
  border-radius:7px;
  background:rgba(15,23,42,.36);
  color:#e2e8f0;
  font-size:12px;
  font-weight:700;
  cursor:pointer;
  transition:border-color .18s, background .18s, color .18s;
}
.sidebar-cache-btn:hover{
  border-color:rgba(96,165,250,.45);
  background:rgba(37,99,235,.22);
  color:#fff;
}

.install-panel{
  background:rgba(239,246,255,.96);
  border:1px solid rgba(37,99,235,.18);
  border-radius:10px;
  padding:12px;
  margin-bottom:10px;
  color:#0f172a;
}
.install-panel-title{
  font-size:11px;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.5px;
  color:#1e40af;
  margin-bottom:8px;
  line-height:1.4;
}
.install-status{
  font-size:12px;
  color:#334155;
  margin-bottom:6px;
  line-height:1.5;
}

.sidebar-service-status{
  display:flex;
  align-items:center;
  gap:8px;
  margin-top:8px;
  color:#f8fafc;
  font-weight:600;
  font-size:12px;
  line-height:1.2;
}
.status-dot{
  width:8px;
  height:8px;
  border-radius:50%;
  flex:0 0 auto;
  background:#22c55e;
  box-shadow:0 0 0 3px rgba(34,197,94,0.18);
  transition:background .18s, box-shadow .18s;
}
.status-dot.offline{
  background:#ef4444;
  box-shadow:0 0 0 3px rgba(239,68,68,0.18);
}
.sidebar-version-time{
  margin-top:4px;
  color:#cbd5e1;
  font-size:11px;
  line-height:1.25;
}

/* -----------------------------
   MAIN AREA + TOPBAR
----------------------------- */
.main{
  flex:1;
  padding:18px 18px 28px;
  min-width:0;
}

/* Topbar sticky */
.topbar{
  position:sticky;
  top:0;
  z-index:5;
  background:var(--bg);
  padding:8px 2px 14px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
}
body.dark .topbar{
  background:var(--bg);
}

#pageTitle{
  margin:0;
  font-size:26px;
  font-weight:800;
  letter-spacing:.2px;
}

/* Toggles bar (Charts / Dark) */
.top-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

/* Switch widget */
.switch{
  display:flex;
  align-items:center;
  gap:8px;
  background:var(--panel);
  border:1px solid var(--border);
  box-shadow:var(--shadow-soft);
  border-radius:999px;
  padding:6px 10px;
  cursor:pointer;
  user-select:none;
  transition:.2s;
  font-size:13px;
  font-weight:600;
  color:var(--muted);
}
.switch:hover{ transform:translateY(-1px); }
.switch .knob{
  width:40px;height:20px;border-radius:999px;
  background:var(--bg-soft);
  position:relative;
  transition:.2s;
}
.switch .knob::after{
  content:"";
  position:absolute;top:2px;left:2px;
  width:16px;height:16px;border-radius:50%;
  background:var(--panel);
  box-shadow:0 2px 5px rgba(0,0,0,.12);
  transition:.2s;
}

/* when active add .on class via JS */
.switch.on{ color:var(--text); }
.switch.on .knob{
  background:rgba(37,99,235,.2);
}
.switch.on .knob::after{
  left:22px;
  background:var(--brand);
}

/* Error box */
.error{
  display:none;
  margin:8px 0 12px;
  padding:10px 12px;
  border-radius:10px;
  background:#fee2e2;
  color:#991b1b;
  border:1px solid #fecaca;
  font-size:14px;
}
body.dark .error{
  background:#3a0d15;
  border-color:#5f1521;
  color:#fecdd3;
}

/* -----------------------------
   KPI CARDS (glass)
----------------------------- */
.kpis{
  display:grid;
  grid-template-columns:repeat(5, minmax(0,1fr));
  gap:var(--gap);
  margin-bottom:12px;
}

.cardx{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px 14px;
  box-shadow:var(--shadow-soft);
  min-height:76px;
  display:flex;
  flex-direction:column;
  justify-content:center;
  gap:4px;
  transition:.2s;
}
.cardx:hover{
  transform:translateY(-2px);
  box-shadow:var(--shadow);
}

.cardx .label{
  font-size:12px;
  font-weight:700;
  color:var(--muted);
  text-transform:uppercase;
  letter-spacing:.6px;
}
.cardx .value{
  font-size:20px;
  font-weight:800;
}

/* -----------------------------
   FILTERS PRO (icons centered)
----------------------------- */
.filters{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:12px;
  display:grid;
  grid-template-columns:repeat(4, minmax(0,1fr)) auto auto auto auto;
  gap:10px;
  align-items:end;
  margin-bottom:12px;
  box-shadow:var(--shadow-soft);
}

.filters-presets {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
	grid-column: 1 / -1; 
}

.field{
  display:flex;
  flex-direction:column;
  gap:6px;
}
.field label{
  font-size:12px;
  font-weight:700;
  color:var(--muted);
}

/* input with icon */
.input-icon{
  position:relative;
}
.input-icon i{
  position:absolute;
  left:10px;
  top:50%;
  transform:translateY(-50%);
  font-size:15px;
  color:var(--muted-2);
  pointer-events:none;
}
.input-icon input,
.input-icon select{
  width:100%;
  padding:9px 10px 9px 30px; /* space for icon */
  background:var(--panel-2);
  border:1px solid var(--border);
  border-radius:10px;
  font-size:14px;
  outline:none;
  transition:.15s;
  color:var(--text);
}
.input-icon input:focus,
.input-icon select:focus{
  border-color:rgba(37,99,235,.7);
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
  background:var(--panel);
}

/* plain input/select (fallback) */
.filters input:not(.no-pro),
.filters select:not(.no-pro){
  width:100%;
  padding:9px 10px;
  background:var(--panel-2);
  border:1px solid var(--border);
  border-radius:10px;
  font-size:14px;
  outline:none;
  transition:.15s;
  color:var(--text);
}
.filters input:focus,
.filters select:focus{
  border-color:rgba(37,99,235,.7);
  box-shadow:0 0 0 3px rgba(37,99,235,.12);
  background:var(--panel);
}

/* Buttons PRO */
.btnx{
  padding:9px 14px;
  border-radius:10px;
  border:0;
  font-size:14px;
  font-weight:700;
  cursor:pointer;
  transition:.18s;
  box-shadow:var(--shadow-soft);
  white-space:nowrap;
}
.btnx:active{ transform:scale(.98); }

.btnx-primary{ background:var(--brand); color:#fff; }
.btnx-primary:hover{ background:var(--brand-2); }

.btnx-secondary{ background:#64748b; color:#fff; }
.btnx-secondary:hover{ background:#475569; }

.btnx-success{ background:var(--ok); color:#fff; }
.btnx-success:hover{ background:#15803d; }

.btnx-warning{ background:var(--warn); color:#111827; }
.btnx-warning:hover{ background:#d97706; color:#fff; }

.btnx-danger{ background:var(--danger); color:#fff; }
.btnx-danger:hover{ background:#dc2626; }

/* -----------------------------
   TABLE PRO
----------------------------- */
.table-wrap{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  overflow:auto;
  box-shadow:var(--shadow-soft);
}

table{
  width:100%;
  border-collapse:collapse;
}

thead th{
  position:sticky;
  top:0;
  z-index:1;
  background:var(--bg-soft);
  color:var(--text);
  font-size:12px;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:.5px;
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  cursor:pointer;
  white-space:nowrap;
}
tbody td{
  padding:10px 10px;
  border-bottom:1px solid var(--border);
  font-size:14px;
  color:var(--text);
  white-space:nowrap;
}
tbody tr:hover{
  background:rgba(37,99,235,0.06);
}

/* Actions column */
tbody td:last-child{
  text-align:center;
}
tbody td .btnx{
  padding:6px 10px;
  font-size:13px;
  border-radius:8px;
}

/* -----------------------------
   PAGER PRO
----------------------------- */
.pager{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-top:10px;
}

.pager-left{
  display:flex;
  align-items:center;
}

.pager-center{
  display:flex;
  align-items:center;
  gap:10px;
}

.pager-right{
  display:flex;
  align-items:center;
  gap:8px;
}
#pageInfo{
  font-weight:700;
  color:var(--muted);
  font-size:14px;
}

/* -----------------------------
   CHART AREA
----------------------------- */
.charts{
  margin-top:14px;
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:var(--gap);
}
.charts canvas{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:10px;
  height:300px !important;
  box-shadow:var(--shadow-soft);
}

/* -----------------------------
   REPORTS / SETTINGS BASE
----------------------------- */
.report-submenu{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-bottom:12px;
}
.rep-tab{
  background:transparent;
}

/* simple report boxes */
.report-box{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  box-shadow:var(--shadow-soft);
}

/* -----------------------------
   MODAL OVERLAY base (receipt modal uses receipt.css)
----------------------------- */
.modal-overlay{
  position:fixed;
  inset:0;
  background:rgba(15,23,42,.45);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px;
  z-index:100;
}
.modal-box{
  background:var(--panel);
  border:1px solid var(--border);
  border-radius:16px;
  box-shadow:var(--shadow);
  width:min(980px, 96vw);
  max-height:90vh;
  overflow:auto;
  padding:18px;
}

.report-table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

.report-table-wrap table{
  width:100%;
  min-width:560px;
  border-collapse:collapse;
}

.report-table-wrap th,
.report-table-wrap td{
  white-space:nowrap;
}

/* =============================
   REPORT TABLE RESPONSIVE
============================= */
.report-table-wrap{
  width:100%;
  overflow-x:auto;
  -webkit-overflow-scrolling:touch;
}

.report-table-wrap table{
  width:100%;
  min-width:560px;
  border-collapse:collapse;
}

.report-table-wrap th,
.report-table-wrap td{
  white-space:nowrap;
}

@media (max-width:768px){
  .report-table-wrap table{
    min-width:520px;
  }
}

@media (max-width:480px){
  .report-table-wrap table{
    min-width:480px;
  }
}