/* ============================================================
   Matheus Hunoff — Dashboard de Gestão
   Design system inspirado na identidade real das páginas do
   Matheus: preto quente + azul (#0f92ff), Barlow Condensed nos
   títulos, Plus Jakarta Sans no corpo do texto.
   ============================================================ */

:root{
  --bg: #0e0d0d;
  --bg-elevated: #131110;
  --surface: #171413;
  --surface-2: #1d1a18;
  --surface-hover: #242019;
  --border: rgba(246,238,227,.14);
  --border-soft: rgba(246,238,227,.08);

  --text-primary: #fff9f0;
  --text-secondary: #c7bfb3;
  --text-tertiary: #8c8479;

  --accent: #0f92ff;
  --accent-strong: #0c7ddb;
  --accent-soft: rgba(15,146,255,.16);
  --accent-ring: rgba(15,146,255,.35);

  --d10k: #20d38a;
  --d10k-soft: rgba(32,211,138,.15);
  --suportify: #20d38a;
  --suportify-soft: rgba(32,211,138,.15);
  --blackbox: #0f92ff;
  --blackbox-soft: rgba(15,146,255,.16);

  --success: #20d38a;
  --success-soft: rgba(32,211,138,.15);
  --warning: #f5a623;
  --warning-soft: rgba(245,166,35,.15);
  --danger: #f1554c;
  --danger-soft: rgba(241,85,76,.15);
  --muted-soft: rgba(199,191,179,.14);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 18px;
  --shadow-card: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px -18px rgba(0,0,0,.7);
  --sidebar-w: 248px;

  --font-display: 'Barlow Condensed', Impact, 'Arial Narrow', sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  color-scheme: dark;
}

:root[data-theme="light"]{
  --bg: #f6eee3;
  --bg-elevated: #efe5d5;
  --surface: #fffdfa;
  --surface-2: #f1e8da;
  --surface-hover: #e9ddc9;
  --border: rgba(23,20,19,.12);
  --border-soft: rgba(23,20,19,.08);

  --text-primary: #17140f;
  --text-secondary: #55504a;
  --text-tertiary: #8a8379;

  --accent-soft: rgba(15,146,255,.12);
  --success-soft: rgba(20,160,104,.14);
  --warning-soft: rgba(245,166,35,.16);
  --danger-soft: rgba(220,50,45,.13);
  --muted-soft: rgba(85,80,74,.1);
  --success: #14a068;
  --danger: #dc322d;

  --shadow-card: 0 1px 0 rgba(255,255,255,.6) inset, 0 10px 24px -16px rgba(23,20,19,.18);
  color-scheme: light;
}

*,*::before,*::after{ box-sizing: border-box; }
svg{ width:1em; height:1em; flex-shrink:0; display:inline-block; vertical-align:-0.15em; }
html,body{ height:100%; }
body{
  margin:0;
  background:
    radial-gradient(ellipse 900px 500px at 10% -10%, var(--accent-soft), transparent 60%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
a{ color: inherit; text-decoration:none; }
button{ font-family:inherit; }
ul{ margin:0; padding:0; list-style:none; }
h1,h2,h3,h4,p{ margin:0; }

::selection{ background: var(--accent-soft); color: var(--text-primary); }

/* Scrollbars */
*::-webkit-scrollbar{ width:8px; height:8px; }
*::-webkit-scrollbar-track{ background:transparent; }
*::-webkit-scrollbar-thumb{ background: var(--border); border-radius:8px; }
*::-webkit-scrollbar-thumb:hover{ background: var(--text-tertiary); }

/* ============ App shell ============ */
#app-shell{ display:flex; min-height:100vh; }

.sidebar{
  width: var(--sidebar-w);
  flex-shrink:0;
  background: var(--bg-elevated);
  border-right: 1px solid var(--border-soft);
  display:flex;
  flex-direction:column;
  position:fixed;
  top:0; left:0; bottom:0;
  z-index:40;
  transition: transform .25s ease;
}
.sidebar-brand{
  display:flex; align-items:center; gap:10px;
  padding: 22px 20px 18px;
  border-bottom:1px solid var(--border-soft);
}
.sidebar-brand img{ width:38px; height:38px; border-radius:10px; object-fit:cover; border:1.5px solid var(--accent); }
.sidebar-brand .brand-name{ font-family:var(--font-display); font-weight:800; font-size:18px; letter-spacing:.2px; line-height:1; }
.sidebar-brand .brand-sub{ font-size:11px; color:var(--text-tertiary); margin-top:3px; }

.sidebar-nav{ flex:1; padding: 14px 12px; overflow-y:auto; }
.sidebar-nav .nav-section-label{
  font-size: 10.5px; text-transform:uppercase; letter-spacing:.08em;
  color: var(--text-tertiary); padding: 14px 10px 6px;
  font-weight:600;
}
.nav-item{
  display:flex; align-items:center; gap:11px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size:13.5px; font-weight:500;
  cursor:pointer; margin-bottom:2px; transition: background .15s, color .15s;
  white-space:nowrap;
}
.nav-item svg{ width:18px; height:18px; flex-shrink:0; opacity:.85; }
.nav-item:hover{ background: var(--surface); color: var(--text-primary); }
.nav-item.active{ background: var(--accent-soft); color: var(--accent); }
.nav-item.active svg{ color: var(--accent); opacity:1; }

.sidebar-footer{ padding:14px 20px 18px; border-top:1px solid var(--border-soft); display:flex; flex-direction:column; gap:12px; }
.sidebar-footer .footer-label{ font-size:11px; color:var(--text-tertiary); }
.theme-toggle{
  display:flex; align-items:center; gap:2px; background:var(--surface); border:1px solid var(--border);
  border-radius:999px; padding:3px; width:fit-content;
}
.theme-toggle button{
  display:flex; align-items:center; gap:6px; border:none; background:transparent; color:var(--text-tertiary);
  font-size:12px; font-weight:600; padding:6px 11px; border-radius:999px; cursor:pointer; transition:.15s;
}
.theme-toggle button.active{ background:var(--accent); color:#fff; }
.theme-toggle svg{ width:13px; height:13px; }

.main{
  margin-left: var(--sidebar-w);
  flex:1; min-width:0;
  display:flex; flex-direction:column;
}

.topbar{
  position:sticky; top:0; z-index:30;
  display:flex; align-items:center; justify-content:space-between;
  gap:16px; padding: 18px 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); backdrop-filter: blur(10px);
  border-bottom:1px solid var(--border-soft);
}
.topbar-title h1{ font-family:var(--font-display); font-size:24px; font-weight:800; letter-spacing:.1px; line-height:1.1; }
.topbar-title p{ font-size:12.5px; color:var(--text-tertiary); margin-top:2px; }
.topbar-actions{ display:flex; align-items:center; gap:10px; }
.menu-toggle{
  display:none; width:36px; height:36px; border-radius:10px; border:1px solid var(--border);
  background:var(--surface); color:var(--text-secondary); align-items:center; justify-content:center; cursor:pointer;
}

.content{ padding: 24px 28px 60px; max-width:1480px; width:100%; margin:0 auto; }

.sidebar-scrim{ display:none; position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:35; }

@media (max-width: 980px){
  .sidebar{ transform: translateX(-100%); }
  .sidebar.open{ transform: translateX(0); }
  .main{ margin-left:0; }
  .menu-toggle{ display:inline-flex; }
  .sidebar.open ~ .sidebar-scrim, .sidebar-scrim.show{ display:block; }
  .content{ padding: 18px 16px 50px; }
  .topbar{ padding: 14px 16px; }
}

/* ============ Filter bar ============ */
.filterbar{
  display:flex; flex-wrap:wrap; align-items:center; gap:10px;
  margin-bottom: 22px;
}
.filterbar .seg{
  display:flex; background:var(--surface); border:1px solid var(--border); border-radius: var(--radius-sm);
  padding:3px; gap:2px;
}
.filterbar .seg button{
  border:none; background:transparent; color:var(--text-secondary); font-size:12.5px; font-weight:600;
  padding:6px 12px; border-radius:8px; cursor:pointer; transition:.15s;
}
.filterbar .seg button.active{ background:var(--accent); color:#fff; }
.filterbar select, .filterbar input[type="month"], .filterbar input[type="date"]{
  background:var(--surface); border:1px solid var(--border); color:var(--text-primary);
  border-radius: var(--radius-sm); padding:7px 10px; font-size:12.5px; font-weight:500;
}
.filterbar .spacer{ flex:1; }

/* ============ Grid helpers ============ */
.grid{ display:grid; gap:16px; }
.grid-kpi{ grid-template-columns: repeat(4, 1fr); }
.grid-2{ grid-template-columns: repeat(2, 1fr); }
.grid-3{ grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1200px){ .grid-kpi{ grid-template-columns: repeat(2,1fr);} .grid-3{grid-template-columns: repeat(2,1fr);} }
@media (max-width: 640px){ .grid-kpi{ grid-template-columns: 1fr;} .grid-2,.grid-3{grid-template-columns: 1fr;} }

.section{ margin-bottom:28px; }
.section-head{ display:flex; align-items:baseline; justify-content:space-between; margin-bottom:14px; gap:10px; flex-wrap:wrap; }
.section-head h2{ font-family:var(--font-display); font-size:19px; font-weight:800; letter-spacing:.1px; }
.section-head .section-sub{ font-size:12px; color:var(--text-tertiary); }

/* ============ Cards ============ */
.card{
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  padding: 18px;
}
.card-pad-lg{ padding:22px; }

.kpi-card{
  background: var(--surface); border:1px solid var(--border-soft); border-radius: var(--radius-md);
  padding:17px 18px; box-shadow: var(--shadow-card);
  display:flex; flex-direction:column; gap:10px; min-width:0;
}
.kpi-top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.kpi-label{ font-size:12px; color:var(--text-secondary); font-weight:600; letter-spacing:.1px; }
.kpi-icon{
  width:30px; height:30px; border-radius:9px; display:flex; align-items:center; justify-content:center;
  background: var(--accent-soft); color: var(--accent); flex-shrink:0;
}
.kpi-icon svg{ width:16px; height:16px; }
.kpi-value{ font-family:var(--font-display); font-size:30px; font-weight:800; letter-spacing:.1px; line-height:1; }
.kpi-value.small{ font-size:23px; }
.kpi-foot{ display:flex; align-items:center; gap:6px; font-size:12px; color:var(--text-tertiary); }
.delta{ display:inline-flex; align-items:center; gap:3px; font-weight:700; padding:2px 7px; border-radius:999px; font-size:11px; }
.delta svg{ width:11px; height:11px; }
.delta.up{ background: var(--success-soft); color: var(--success); }
.delta.down{ background: var(--danger-soft); color: var(--danger); }
.delta.flat{ background: var(--muted-soft); color: var(--text-secondary); }

/* ============ Product cards ============ */
.product-card{
  background: var(--surface); border:1px solid var(--border-soft); border-radius: var(--radius-lg);
  padding:20px; box-shadow: var(--shadow-card); position:relative; overflow:hidden;
}
.product-card .glow{ position:absolute; top:-60px; right:-60px; width:160px; height:160px; border-radius:50%; filter:blur(40px); opacity:.25; pointer-events:none; }
.product-card-head{ display:flex; align-items:center; gap:12px; margin-bottom:16px; position:relative; }
.product-logo{ width:46px; height:46px; border-radius:12px; object-fit:cover; background: var(--bg-elevated); border:1px solid var(--border); }
.product-card-head h3{ font-family:var(--font-display); font-size:19px; font-weight:800; line-height:1.1; }
.product-card-head .ptag{ font-size:11.5px; color:var(--text-tertiary); }
.product-metrics{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; margin-bottom:14px; }
.product-metric .m-label{ font-size:11px; color:var(--text-tertiary); margin-bottom:3px; }
.product-metric .m-value{ font-size:16.5px; font-weight:700; }
.product-bar-track{ height:6px; border-radius:99px; background:var(--surface-2); overflow:hidden; margin-top:4px; }
.product-bar-fill{ height:100%; border-radius:99px; }

/* ============ Buttons ============ */
.btn{
  display:inline-flex; align-items:center; gap:7px; justify-content:center;
  border-radius: var(--radius-sm); padding: 8px 14px; font-size:13px; font-weight:600;
  cursor:pointer; border:1px solid var(--border); background: var(--surface); color: var(--text-primary);
  transition:.15s; white-space:nowrap;
}
.btn svg{ width:15px; height:15px; }
.btn:hover{ background: var(--surface-hover); }
.btn-primary{ background: var(--accent); border-color: var(--accent); color:#fff; }
.btn-primary:hover{ background: var(--accent-strong); }
.btn-danger{ background:transparent; border-color: var(--danger); color: var(--danger); }
.btn-danger:hover{ background: var(--danger-soft); }
.btn-ghost{ background:transparent; border-color:transparent; }
.btn-ghost:hover{ background: var(--surface); }
.btn-sm{ padding:5px 10px; font-size:12px; border-radius:8px; }
.btn-icon{ width:32px; height:32px; padding:0; border-radius:9px; }
.btn[disabled]{ opacity:.45; cursor:not-allowed; }

/* ============ Tables ============ */
.table-wrap{ overflow-x:auto; border-radius: var(--radius-md); border:1px solid var(--border-soft); }
table.data-table{ width:100%; border-collapse:collapse; font-size:13px; min-width:640px; }
table.data-table thead th{
  text-align:left; font-size:11px; text-transform:uppercase; letter-spacing:.06em;
  color: var(--text-tertiary); font-weight:700; padding:12px 14px; background: var(--bg-elevated);
  border-bottom:1px solid var(--border-soft); white-space:nowrap;
}
table.data-table tbody td{ padding:12px 14px; border-bottom:1px solid var(--border-soft); color:var(--text-primary); vertical-align:middle; }
table.data-table tbody tr{ background: var(--surface); transition: background .15s; }
table.data-table tbody tr:last-child td{ border-bottom:none; }
table.data-table tbody tr:hover{ background: var(--surface-hover); }
table.data-table tbody td.num{ font-variant-numeric: tabular-nums; }
.row-actions{ display:flex; gap:6px; justify-content:flex-end; }

/* ============ Badges ============ */
.badge{ display:inline-flex; align-items:center; gap:5px; padding:3px 9px; border-radius:999px; font-size:11.5px; font-weight:700; white-space:nowrap; }
.badge-dot{ width:6px; height:6px; border-radius:50%; background:currentColor; }
.badge-success{ background: var(--success-soft); color: var(--success); }
.badge-warning{ background: var(--warning-soft); color: var(--warning); }
.badge-danger{ background: var(--danger-soft); color: var(--danger); }
.badge-muted{ background: var(--muted-soft); color: var(--text-secondary); }
.badge-accent{ background: var(--accent-soft); color: var(--accent); }

/* ============ Forms ============ */
.form-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:14px; }
.form-grid.cols-1{ grid-template-columns: 1fr; }
.field{ display:flex; flex-direction:column; gap:6px; }
.field.span-2{ grid-column: span 2; }
.field label{ font-size:12.5px; font-weight:600; color: var(--text-secondary); }
.field .hint{ font-size:11px; color:var(--text-tertiary); }
.input, select.input, textarea.input{
  background: var(--surface-2); border:1px solid var(--border); color: var(--text-primary);
  border-radius: var(--radius-sm); padding: 9px 11px; font-size:13.5px; font-family:inherit; width:100%;
  transition:.15s;
}
.input:focus, select.input:focus, textarea.input:focus{ outline:none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ring); }
.input::placeholder{ color: var(--text-tertiary); }
@media (max-width:640px){ .form-grid{ grid-template-columns:1fr; } .field.span-2{ grid-column:span 1; } }

/* ============ Modal / Drawer ============ */
.modal-overlay{
  position:fixed; inset:0; background: rgba(5,6,8,.65); backdrop-filter: blur(2px);
  display:flex; align-items:flex-start; justify-content:center; z-index:100; padding: 40px 16px; overflow-y:auto;
}
.modal{
  background: var(--bg-elevated); border:1px solid var(--border); border-radius: var(--radius-lg);
  width:100%; max-width:560px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.7); animation: modalIn .18s ease;
}
@keyframes modalIn{ from{ opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);} }
.modal-head{ display:flex; align-items:center; justify-content:space-between; padding:18px 20px; border-bottom:1px solid var(--border-soft); }
.modal-head h3{ font-family:var(--font-display); font-size:19px; font-weight:800; }
.modal-body{ padding:20px; max-height:65vh; overflow-y:auto; }
.modal-foot{ display:flex; justify-content:flex-end; gap:10px; padding:16px 20px; border-top:1px solid var(--border-soft); }

/* ============ Empty states ============ */
.empty-state{
  display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center;
  padding: 46px 20px; color: var(--text-tertiary); gap:10px;
}
.empty-state .ei{ width:46px; height:46px; border-radius:14px; background:var(--surface-2); display:flex; align-items:center; justify-content:center; color:var(--text-tertiary); margin-bottom:4px;}
.empty-state .ei svg{ width:22px; height:22px; }
.empty-state h4{ font-size:14px; color: var(--text-secondary); font-weight:700; }
.empty-state p{ font-size:12.5px; max-width:360px; }

/* ============ Charts ============ */
.chart-card{ background: var(--surface); border:1px solid var(--border-soft); border-radius: var(--radius-md); padding:20px; box-shadow: var(--shadow-card); }
.chart-card .chart-head{ display:flex; align-items:center; justify-content:space-between; margin-bottom:14px; }
.chart-card .chart-head h3{ font-family:var(--font-display); font-size:17px; font-weight:800; }
.chart-card .chart-head .chart-sub{ font-size:11.5px; color:var(--text-tertiary); }
.chart-box{ position:relative; height:260px; }
.chart-box.sm{ height:200px; }

/* ============ Funnel ============ */
.funnel{ display:flex; flex-direction:column; gap:0; align-items:stretch; }
.funnel-step{ display:flex; align-items:center; gap:16px; padding:16px 0; }
.funnel-bar-wrap{ flex:1; }
.funnel-bar-label{ display:flex; justify-content:space-between; font-size:12.5px; margin-bottom:6px; color:var(--text-secondary); font-weight:600;}
.funnel-bar-track{ height:34px; border-radius:10px; background:var(--surface-2); overflow:hidden; }
.funnel-bar-fill{ height:100%; border-radius:10px; display:flex; align-items:center; padding-left:12px; color:#fff; font-weight:800; font-size:13px; transition: width .4s ease; white-space:nowrap; }
.funnel-value{ width:72px; text-align:right; font-family:var(--font-display); font-weight:800; font-size:24px; flex-shrink:0; }
.funnel-connector{ display:flex; align-items:center; gap:8px; padding-left:4px; color:var(--text-tertiary); font-size:11.5px; }
.funnel-connector svg{ width:14px; height:14px; }
.funnel-connector .rate{ font-weight:800; color: var(--accent); }

/* ============ Misc ============ */
.pill-tabs{ display:flex; gap:6px; border-bottom:1px solid var(--border-soft); margin-bottom:18px; }
.pill-tabs button{ background:transparent; border:none; color:var(--text-tertiary); font-weight:600; font-size:13px; padding:10px 4px; margin-right:18px; cursor:pointer; border-bottom:2px solid transparent; }
.pill-tabs button.active{ color:var(--text-primary); border-color: var(--accent); }

.toast-wrap{ position:fixed; bottom:20px; right:20px; z-index:200; display:flex; flex-direction:column; gap:8px; }
.toast{ background: var(--surface-2); border:1px solid var(--border); color:var(--text-primary); padding:12px 16px; border-radius:12px; font-size:13px; font-weight:600; box-shadow:0 10px 30px -10px rgba(0,0,0,.6); display:flex; align-items:center; gap:8px; animation: toastIn .2s ease; }
.toast.success{ border-color: rgba(34,197,94,.4); }
.toast.danger{ border-color: rgba(241,85,76,.4); }
@keyframes toastIn{ from{opacity:0; transform:translateY(8px);} to{opacity:1; transform:translateY(0);} }

.search-input{ position:relative; }
.search-input svg{ position:absolute; left:11px; top:50%; transform:translateY(-50%); width:15px; height:15px; color:var(--text-tertiary); }
.search-input input{ padding-left:32px; }

.text-tertiary{ color:var(--text-tertiary); }
.text-secondary{ color:var(--text-secondary); }
.text-success{ color:var(--success); }
.text-danger{ color:var(--danger); }
.mt-0{ margin-top:0; }
.flex{ display:flex; } .items-center{ align-items:center; } .justify-between{ justify-content:space-between; } .gap-8{ gap:8px; } .gap-10{ gap:10px; }
.w-full{ width:100%; }
.clickable{ cursor:pointer; }
.fw-icon-btn{ background:none;border:none;color:var(--text-tertiary);cursor:pointer;display:flex;align-items:center;justify-content:center;padding:4px;border-radius:7px; }
.fw-icon-btn:hover{ background:var(--surface-2); color:var(--text-primary); }
.fw-icon-btn svg{ width:15px; height:15px; }
.menu-toggle svg{ width:18px; height:18px; }
.toast svg{ width:16px; height:16px; }

.loader-page{ display:flex; align-items:center; justify-content:center; min-height:40vh; color:var(--text-tertiary); font-size:13px; }

/* ============ Tela de senha (sincronização) ============ */
#sync-gate{
  position:fixed; inset:0; z-index:300; background: var(--bg);
  display:flex; align-items:center; justify-content:center; padding:20px;
}
.sync-gate-box{
  width:100%; max-width:360px; text-align:center;
  background: var(--bg-elevated); border:1px solid var(--border); border-radius: var(--radius-lg);
  padding: 32px 28px; box-shadow: 0 30px 70px -20px rgba(0,0,0,.7);
}
.sync-gate-box img{ width:56px; height:56px; border-radius:14px; object-fit:cover; border:1.5px solid var(--accent); margin-bottom:14px; }
.sync-gate-box h2{ font-family:var(--font-display); font-size:21px; font-weight:800; margin-bottom:6px; }
.sync-gate-box p{ font-size:13px; color:var(--text-secondary); margin-bottom:18px; }
.sync-gate-box .input{ text-align:center; margin-bottom:12px; }
.sync-gate-box .btn{ width:100%; justify-content:center; }
.sync-gate-error{ margin-top:12px; font-size:12.5px; color:#f1554c; min-height:16px; }

.footer-label.sync-status{ margin-top:-6px; opacity:.85; }
