/* ============================================================
   ItaPrint 3D — painel de gestão
   ============================================================ */

*,
*::before,
*::after { box-sizing: border-box; }

:root {
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-display: "Fraunces", Georgia, "Times New Roman", serif;

  --r-xs: 8px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 18px;
  --r-xl: 24px;

  --sidebar: 246px;
  --shadow-sm: 0 1px 2px rgba(24, 40, 33, .05), 0 4px 14px -8px rgba(24, 40, 33, .18);
  --shadow-md: 0 1px 2px rgba(24, 40, 33, .05), 0 18px 40px -24px rgba(24, 40, 33, .45);
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4efe4;
  --bg-deep: #ece5d6;
  --surface: #fffdf8;
  --surface-2: #faf6ec;
  --surface-3: #f1eadb;
  --text: #1b2a24;
  --text-soft: #3c4d45;
  --muted: #6f7d75;
  --faint: #98a49d;
  --line: #e7dfcf;
  --line-soft: #f0e9dc;
  --line-strong: #d8cdb8;
  --accent: #1f4a3c;
  --accent-strong: #173a2f;
  --accent-soft: #e4eee7;
  --on-accent: #fdfbf5;
  --gold: #a97f25;
  --gold-soft: #f6ecd2;
  --green: #2c7a5a;
  --green-soft: #e1efe7;
  --red: #ad4a35;
  --red-soft: #f8e5df;
  --amber: #a5711a;
  --amber-soft: #f8edd6;
  --blue: #436e8a;
  --blue-soft: #e5eef4;
  --chart-1: #2f7d5d;
  --chart-2: #c1883f;
  --chart-3: #5b7c9c;
  --chart-4: #a96a5b;
  --chart-5: #7a8f6a;
  --chart-6: #8f6f9c;
  --chart-grid: #ece5d7;
  --overlay: rgba(27, 42, 36, .38);
  --topbar: rgba(244, 239, 228, .82);
  --code: #efe8d8;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0c1411;
  --bg-deep: #0a110e;
  --surface: #131f1a;
  --surface-2: #17251f;
  --surface-3: #1d2d26;
  --text: #e9efe9;
  --text-soft: #c4d1c9;
  --muted: #92a49a;
  --faint: #6e8177;
  --line: #24362d;
  --line-soft: #1c2b24;
  --line-strong: #34493e;
  --accent: #8ec9ab;
  --accent-strong: #a6d8bd;
  --accent-soft: #1a2c24;
  --on-accent: #0b1812;
  --gold: #d5ad55;
  --gold-soft: #282214;
  --green: #74c39a;
  --green-soft: #15271f;
  --red: #e18a72;
  --red-soft: #2b1a15;
  --amber: #ddb163;
  --amber-soft: #2a2213;
  --blue: #8ab4cf;
  --blue-soft: #172630;
  --chart-1: #74c39a;
  --chart-2: #d5ad55;
  --chart-3: #8ab4cf;
  --chart-4: #d99a86;
  --chart-5: #a4b98d;
  --chart-6: #b79cc4;
  --chart-grid: #22332b;
  --overlay: rgba(0, 0, 0, .62);
  --topbar: rgba(12, 20, 17, .8);
  --code: #1b2a24;
}

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(60rem 40rem at 110% -10%, rgba(185, 139, 46, .10), transparent 60%),
    radial-gradient(50rem 36rem at -10% 10%, rgba(47, 125, 93, .08), transparent 55%);
}

:root[data-theme="dark"] body::before {
  background:
    radial-gradient(60rem 40rem at 110% -10%, rgba(213, 173, 85, .08), transparent 60%),
    radial-gradient(50rem 36rem at -10% 10%, rgba(116, 195, 154, .06), transparent 55%);
}

h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
svg { display: block; }
::selection { background: var(--accent); color: var(--on-accent); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; border: 3px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* ============================ layout ============================ */

.app { position: relative; z-index: 1; min-height: 100%; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar);
  padding: 26px 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 26px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  background: color-mix(in srgb, var(--bg) 72%, var(--surface));
  backdrop-filter: blur(18px);
  z-index: 40;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 0 8px;
}

.brand-mark {
  width: 40px;
  height: 40px;
  color: var(--accent);
  flex: 0 0 auto;
  filter: drop-shadow(0 6px 14px rgba(31, 74, 60, .22));
}
.brand-mark svg { width: 100%; height: 100%; }

.brand-text {
  display: flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--font-display);
  font-size: 20px;
  letter-spacing: -.01em;
}
.brand-text strong { font-weight: 600; }
.brand-text em { font-style: normal; font-size: 13px; color: var(--gold); font-weight: 600; letter-spacing: .08em; }

.nav { display: flex; flex-direction: column; gap: 4px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background .16s ease, color .16s ease, transform .16s ease;
}
.nav-item svg { width: 19px; height: 19px; flex: 0 0 auto; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.is-active { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 22px -14px var(--accent); }
.nav-item.is-active svg { opacity: .95; }

.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; }

.sync-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}
.sync-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px color-mix(in srgb, var(--amber) 18%, transparent); flex: 0 0 auto; }
.sync-dot.ok { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 18%, transparent); }
.sync-dot.err { background: var(--red); box-shadow: 0 0 0 3px color-mix(in srgb, var(--red) 18%, transparent); }
.sync-card strong { display: block; font-size: 12px; font-weight: 600; }
.sync-card small { display: block; font-size: 11px; color: var(--muted); }

.theme-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
  transition: border-color .16s, color .16s;
}
.theme-toggle:hover { border-color: var(--line-strong); color: var(--text); }
.theme-track {
  position: relative;
  width: 38px;
  height: 21px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--line);
  flex: 0 0 auto;
}
.theme-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--gold);
  display: grid;
  place-items: center;
  transition: transform .22s ease, background .22s ease;
}
.theme-thumb svg { width: 9px; height: 9px; color: #2a2312; }
.theme-thumb .i-moon { display: none; }
[data-theme="dark"] .theme-thumb { transform: translateX(17px); background: var(--accent); }
[data-theme="dark"] .theme-thumb svg { color: #0b1812; }
[data-theme="dark"] .theme-thumb .i-sun { display: none; }
[data-theme="dark"] .theme-thumb .i-moon { display: block; }

.main { margin-left: var(--sidebar); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 34px 18px;
  background: var(--topbar);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
  border-bottom-color: color-mix(in srgb, var(--line) 70%, transparent);
}

.topbar-title h1 {
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 600;
  letter-spacing: -.02em;
  line-height: 1.1;
}
.topbar-title p { margin-top: 5px; color: var(--muted); font-size: 12.5px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.content { padding: 26px 34px 44px; width: 100%; max-width: 1480px; margin: 0 auto; flex: 1; }

.view { animation: rise .3s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ============================ buttons ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 15px;
  border-radius: 11px;
  border: 1px solid transparent;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: transform .14s ease, box-shadow .14s ease, background .14s ease, border-color .14s ease;
}
.btn svg { width: 16px; height: 16px; }
.btn:active { transform: translateY(1px); }

.btn-primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 10px 22px -14px var(--accent); }
.btn-primary:hover { background: var(--accent-strong); box-shadow: 0 14px 26px -14px var(--accent); }

.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--text-soft); }
.btn-ghost:hover { border-color: var(--line-strong); background: var(--surface-2); }

.btn-danger { background: var(--red-soft); color: var(--red); border-color: color-mix(in srgb, var(--red) 25%, transparent); }
.btn-danger:hover { background: var(--red); color: #fff; }

.btn-sm { height: 34px; padding: 0 11px; font-size: 12px; border-radius: 9px; }
.btn[disabled] { opacity: .55; pointer-events: none; }

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  transition: color .14s, border-color .14s, background .14s;
}
.icon-btn svg { width: 17px; height: 17px; }
.icon-btn:hover { color: var(--text); border-color: var(--line-strong); background: var(--surface-2); }
.theme-btn { display: none; }
.theme-btn .i-sun { display: block; }
.theme-btn .i-moon { display: none; }
[data-theme="dark"] .theme-btn .i-sun { display: none; }
[data-theme="dark"] .theme-btn .i-moon { display: block; }

.link-btn { border: 0; background: none; color: var(--accent); font-weight: 600; font-size: 12px; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* ============================ segmented ============================ */

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
}
.segmented button {
  height: 30px;
  padding: 0 11px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  transition: background .14s, color .14s, box-shadow .14s;
}
.segmented button:hover { color: var(--text); }
.segmented button.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ============================ cards ============================ */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 0;
}
.card-title { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.card-sub { margin-top: 3px; font-size: 11.5px; color: var(--muted); }
.card-body { padding: 18px 22px 22px; }

.grid { display: grid; gap: 16px; }
.grid-kpi { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }

/* ============================ kpi ============================ */

.kpi {
  position: relative;
  overflow: hidden;
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.kpi::after {
  content: "";
  position: absolute;
  inset: auto -30px -55px auto;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--kpi-tint, var(--accent)) 10%, transparent), transparent 70%);
  pointer-events: none;
}
.kpi-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.kpi-label { font-size: 10.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.kpi-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--surface-3);
  background: color-mix(in srgb, var(--kpi-tint, var(--accent)) 12%, transparent);
  color: var(--kpi-tint, var(--accent));
}
.kpi-icon svg { width: 15px; height: 15px; }
.kpi-value {
  margin-top: 12px;
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -.025em;
  line-height: 1.08;
  font-variant-numeric: tabular-nums;
}
.kpi-value small { font-size: 15px; color: var(--muted); font-family: var(--font-ui); font-weight: 500; }
.kpi-foot { margin-top: 8px; font-size: 11.5px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.kpi-foot strong { color: var(--text-soft); font-weight: 600; }
.kpi.positive .kpi-value { color: var(--green); }
.kpi.negative .kpi-value { color: var(--red); }

.trend {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 10.5px;
  font-weight: 600;
}
.trend.up { background: var(--green-soft); color: var(--green); }
.trend.down { background: var(--red-soft); color: var(--red); }
.trend.flat { background: var(--surface-3); color: var(--muted); }

/* ============================ section ============================ */

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  margin: 26px 0 12px;
}
.section-head:first-child { margin-top: 0; }
.section-head h2 { font-family: var(--font-display); font-size: 19px; font-weight: 600; letter-spacing: -.015em; }
.section-head p { color: var(--muted); font-size: 12px; margin-top: 2px; }

/* ============================ charts ============================ */

.chart-card { display: flex; flex-direction: column; min-height: 0; }
.chart-card .card-body { padding-top: 12px; }
.chart-box { position: relative; width: 100%; height: 260px; }
.chart-box.tall { height: 300px; }
.chart-box canvas { width: 100% !important; height: 100% !important; }
.chart-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 180px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-md);
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
  padding: 20px;
  background: var(--surface-2);
}

.legend { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }
.legend i { width: 8px; height: 8px; border-radius: 3px; display: inline-block; }

/* ============================ payback ============================ */

.payback { display: flex; flex-direction: column; gap: 14px; }
.payback-top { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.payback-big { font-family: var(--font-display); font-size: 38px; font-weight: 600; line-height: 1; letter-spacing: -.03em; }
.payback-big small { font-size: 16px; color: var(--muted); font-family: var(--font-ui); font-weight: 500; }
.payback-label { font-size: 10.5px; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 6px; }
.payback-note { font-size: 12px; color: var(--muted); max-width: 300px; text-align: right; }

.progress {
  height: 10px;
  border-radius: 99px;
  background: var(--surface-3);
  overflow: hidden;
  border: 1px solid var(--line);
}
.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--green), color-mix(in srgb, var(--green) 65%, var(--gold)));
  transition: width .6s cubic-bezier(.2, .8, .2, 1);
}
.payback-rows { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; padding-top: 2px; }
.payback-rows div { padding: 10px 12px; border-radius: 10px; background: var(--surface-2); border: 1px solid var(--line-soft); }
.payback-rows dt { font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; }
.payback-rows dd { margin: 4px 0 0; font-weight: 600; font-size: 14px; font-variant-numeric: tabular-nums; }

/* ============================ partners ============================ */

.partner-row { display: flex; flex-direction: column; gap: 10px; }
.partner-line { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: 0 0 auto;
}
.avatar.ju { background: var(--gold-soft); color: var(--gold); }
.avatar.vi { background: var(--accent-soft); color: var(--accent); }
.avatar.ed { background: var(--blue-soft); color: var(--blue); }
.partner-name { font-weight: 600; font-size: 12.5px; }
.partner-sub { font-size: 11px; color: var(--muted); }
.partner-value { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; font-size: 14px; }
.split-bar { display: flex; height: 8px; border-radius: 99px; overflow: hidden; background: var(--surface-3); }
.split-bar span { display: block; height: 100%; }
.split-bar .ju { background: var(--gold); }
.split-bar .vi { background: var(--accent); }
.split-bar .ed { background: var(--blue); }

/* ============================ tables ============================ */

.table-card { overflow: hidden; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
th {
  padding: 11px 14px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
  font-size: 13px;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: var(--surface-2); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mono { font-variant-numeric: tabular-nums; }
.cell-main { font-weight: 600; }
.cell-sub { display: block; font-size: 11px; color: var(--muted); font-weight: 400; margin-top: 1px; }

.data-table th, .data-table td { padding-left: 9px; padding-right: 9px; }
.data-table th { white-space: normal; line-height: 1.2; font-size: 9.5px; }
.data-table td.cell-primary { max-width: 150px; }
.data-table .cell-main { overflow-wrap: anywhere; }
.data-table td.actions-cell { padding-left: 4px; padding-right: 4px; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; opacity: .45; transition: opacity .14s; }
tr:hover .row-actions { opacity: 1; }
.row-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
}
.row-btn:hover { background: var(--surface-3); color: var(--text); border-color: var(--line); }
.row-btn.danger:hover { background: var(--red-soft); color: var(--red); }
.row-btn svg { width: 14px; height: 14px; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: 99px;
  font-size: 10.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}
.pill svg { width: 11px; height: 11px; }
.pill.paid { background: var(--green-soft); color: var(--green); border-color: color-mix(in srgb, var(--green) 22%, transparent); }
.pill.pending { background: var(--amber-soft); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 22%, transparent); }
.pill.neutral { background: var(--surface-3); color: var(--muted); border-color: var(--line); }
.pill.ju { background: var(--gold-soft); color: var(--gold); }
.pill.vi { background: var(--accent-soft); color: var(--accent); }
.pill.ed { background: var(--blue-soft); color: var(--blue); }
button.pill { cursor: pointer; transition: filter .12s; }
button.pill:hover { filter: brightness(.96) saturate(1.1); }

.seller { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.seller .avatar { width: 22px; height: 22px; font-size: 9.5px; }

/* ============================ toolbar ============================ */

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.search {
  position: relative;
  flex: 1 1 220px;
  max-width: 330px;
}
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 15px; height: 15px; color: var(--faint); pointer-events: none; }
.search input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 35px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12.5px;
  outline: none;
  transition: border-color .14s, box-shadow .14s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent); }
.toolbar select, .select {
  height: 38px;
  padding: 0 30px 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: 12.5px;
  color: var(--text-soft);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f7d75' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  outline: none;
}
.toolbar select:focus { border-color: var(--accent); }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 11px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 11.5px;
  color: var(--muted);
}
.chip strong { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.chip.green { background: var(--green-soft); border-color: transparent; color: var(--green); }
.chip.green strong { color: var(--green); }
.chip.amber { background: var(--amber-soft); border-color: transparent; color: var(--amber); }
.chip.amber strong { color: var(--amber); }
.chip.plain { background: var(--surface-2); }

/* ============================ catalog ============================ */

.catalog-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.product-card {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform .18s ease, box-shadow .18s ease, border-color .18s;
  text-align: left;
  padding: 0;
  display: flex;
  flex-direction: column;
}
.product-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--line-strong); }
.product-photo {
  aspect-ratio: 4 / 3;
  background: var(--surface-3);
  overflow: hidden;
}
.product-photo img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s ease; }
.product-card:hover .product-photo img { transform: scale(1.03); }
.product-info { padding: 14px 15px 15px; display: flex; flex-direction: column; gap: 5px; flex: 1; }
.product-cat { font-size: 9.5px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--gold); }
.product-name { font-size: 13px; font-weight: 600; line-height: 1.3; }
.product-meta { margin-top: auto; padding-top: 10px; display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; }
.product-price { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.product-sold { font-size: 10.5px; color: var(--muted); text-align: right; line-height: 1.3; }
.product-edit {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  border: 1px solid rgba(255,255,255,.35);
  background: rgba(15, 26, 21, .45);
  color: #fff;
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity .14s;
}
.product-card:hover .product-edit { opacity: 1; }
.product-edit svg { width: 14px; height: 14px; }
.product-inactive { opacity: .55; }
.badge-off { position: absolute; top: 10px; left: 10px; }

/* ============================ empty ============================ */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 42px 24px;
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: var(--muted);
}
.empty .empty-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--faint);
}
.empty .empty-icon svg { width: 21px; height: 21px; }
.empty h3 { font-family: var(--font-display); font-size: 17px; color: var(--text); font-weight: 600; }
.empty p { font-size: 12.5px; max-width: 380px; }
.empty .btn { margin-top: 4px; }

/* ============================ recent ============================ */

.recent { display: flex; flex-direction: column; }
.recent-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); }
.recent-item:last-child { border-bottom: 0; padding-bottom: 0; }
.recent-item:first-child { padding-top: 0; }
.recent-icon { width: 32px; height: 32px; border-radius: 10px; display: grid; place-items: center; flex: 0 0 auto; }
.recent-icon.in { background: var(--green-soft); color: var(--green); }
.recent-icon.out { background: var(--gold-soft); color: var(--gold); }
.recent-icon svg { width: 15px; height: 15px; }
.recent-main { min-width: 0; }
.recent-main strong { display: block; font-size: 12.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-main small { display: block; font-size: 10.5px; color: var(--muted); }
.recent-value { margin-left: auto; font-weight: 600; font-size: 12.5px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.recent-value.in { color: var(--green); }
.recent-value.out { color: var(--gold); }

/* ============================ dialogs ============================ */

dialog.modal {
  width: min(540px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-xl);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 30px 80px -30px rgba(0,0,0,.5);
  overflow: hidden;
}
dialog.modal::backdrop { background: var(--overlay); backdrop-filter: blur(4px); }
dialog.modal[open] { animation: pop .22s cubic-bezier(.2,.8,.2,1); }
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.985); } to { opacity: 1; transform: none; } }

.modal-head { display: flex; align-items: flex-start; gap: 12px; padding: 20px 22px 0; }
.modal-head-text { flex: 1; }
.modal-head h2 { font-family: var(--font-display); font-size: 21px; font-weight: 600; letter-spacing: -.02em; }
.modal-head p { margin-top: 3px; font-size: 12px; color: var(--muted); }
.modal-close { width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); display: grid; place-items: center; }
.modal-close:hover { color: var(--text); }
.modal-close svg { width: 15px; height: 15px; }

.modal-body { padding: 18px 22px 4px; display: flex; flex-direction: column; gap: 13px; max-height: min(66vh, 620px); overflow-y: auto; }
.modal-foot { display: flex; align-items: center; gap: 8px; padding: 16px 22px 20px; }
.modal-foot .spacer { flex: 1; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field > label, .field-label { font-size: 11px; font-weight: 600; color: var(--muted); letter-spacing: .02em; }
.field .hint { font-size: 10.5px; color: var(--faint); }
.field input, .field select, .field textarea {
  width: 100%;
  height: 40px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color .14s, box-shadow .14s, background .14s;
}
.field textarea { height: auto; padding: 9px 11px; resize: vertical; min-height: 58px; }
.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}
.field select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236f7d75' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 11px center; padding-right: 30px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }

.switch { display: inline-flex; align-items: center; gap: 9px; height: 40px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span.track {
  position: relative;
  width: 42px;
  height: 24px;
  border-radius: 99px;
  background: var(--surface-3);
  border: 1px solid var(--line-strong);
  transition: background .18s, border-color .18s;
}
.switch span.track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
  transition: transform .18s;
}
.switch input:checked + span.track { background: var(--green); border-color: var(--green); }
.switch input:checked + span.track::after { transform: translateX(18px); background: #fff; }
.switch em { font-style: normal; font-size: 12px; color: var(--muted); }

.calc {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.calc-row { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; font-size: 12px; }
.calc-row span { color: var(--muted); }
.calc-row strong { font-variant-numeric: tabular-nums; font-weight: 600; }
.calc-row.total { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 2px; }
.calc-row.total strong { font-size: 14px; }
.calc-note { font-size: 10.5px; color: var(--faint); line-height: 1.45; }

/* ============================ toast / loader / banner ============================ */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translate(-50%, 20px);
  z-index: 100;
  max-width: min(440px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: var(--text);
  color: var(--bg);
  font-size: 12.5px;
  font-weight: 500;
  box-shadow: 0 16px 40px -16px rgba(0,0,0,.5);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--red); color: #fff; }

.loader {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  background: var(--bg);
  transition: opacity .35s ease, visibility .35s;
}
.loader.hide { opacity: 0; visibility: hidden; }
.loader-inner { display: flex; flex-direction: column; align-items: center; gap: 14px; }
.loader-mark { width: 54px; height: 54px; color: var(--accent); animation: pulse 1.4s ease-in-out infinite; }
.loader-mark svg { width: 100%; height: 100%; }
@keyframes pulse { 0%,100% { transform: scale(1); opacity: 1; } 50% { transform: scale(.94); opacity: .6; } }
.loader p { font-size: 12px; color: var(--muted); letter-spacing: .02em; }

.offline-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 34px 0;
  padding: 10px 14px;
  border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  background: var(--amber-soft);
  color: var(--amber);
  border-radius: 12px;
  font-size: 12px;
}
.offline-bar svg { width: 17px; height: 17px; flex: 0 0 auto; }
.offline-bar span { flex: 1; }
.offline-bar .link-btn { color: var(--amber); }

.skeleton {
  border-radius: 12px;
  background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }

/* ============================ tabbar ============================ */

.tabbar { display: none; }

/* ============================ extras ============================ */

.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.neg-text { color: var(--red); }

.start-banner {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid color-mix(in srgb, var(--gold) 30%, var(--line));
  border-radius: var(--r-lg);
  background:
    linear-gradient(100deg, color-mix(in srgb, var(--gold-soft) 75%, var(--surface)), var(--surface) 62%);
  box-shadow: var(--shadow-sm);
}
.start-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--gold-soft);
  color: var(--gold);
  border: 1px solid color-mix(in srgb, var(--gold) 25%, transparent);
}
.start-icon svg { width: 20px; height: 20px; }
.start-text { flex: 1; min-width: 0; }
.start-text strong { display: block; font-family: var(--font-display); font-size: 16px; font-weight: 600; }
.start-text p { margin-top: 2px; font-size: 12px; color: var(--muted); max-width: 620px; }

.partner-info { flex: 1; min-width: 0; }
.partner-bar {
  height: 4px;
  border-radius: 99px;
  background: var(--surface-3);
  margin-top: 6px;
  overflow: hidden;
  max-width: 190px;
}
.partner-bar span { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.partner-line:nth-child(1) .partner-bar span { background: var(--gold); }
.partner-value.neg { color: var(--red); }

.mini-table th { padding: 8px 10px; background: transparent; }
.mini-table td { padding: 9px 10px; }
.mini-table th:last-child, .mini-table td:last-child { width: 120px; }
.mini-bar { height: 5px; width: 100%; max-width: 110px; border-radius: 99px; background: var(--surface-3); overflow: hidden; margin-left: auto; }
.mini-bar span { display: block; height: 100%; border-radius: 99px; background: var(--green); }

.stat-list { display: flex; flex-direction: column; }
.stat-list > div { display: flex; align-items: baseline; justify-content: space-between; gap: 14px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.stat-list > div:last-child { border-bottom: 0; }
.stat-list span { color: var(--muted); font-size: 12px; }
.stat-list strong { font-variant-numeric: tabular-nums; font-size: 13px; }

.stat-line { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line-soft); font-size: 12.5px; }
.stat-line:last-of-type { border-bottom: 0; }
.stat-line .muted { flex: 1; font-size: 11px; }
.stat-line strong { font-variant-numeric: tabular-nums; }

.product-placeholder {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--faint);
  background: var(--surface-3);
  background:
    radial-gradient(circle at 30% 20%, color-mix(in srgb, var(--gold) 12%, transparent), transparent 60%),
    var(--surface-3);
}
.product-placeholder svg { width: 34px; height: 34px; }

.avatar.neutral { background: var(--surface-3); color: var(--muted); }



@media (min-width: 1500px) {
  .catalog-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

@media (max-width: 1180px) {
  .catalog-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 980px) {
  .grid-kpi { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
  .payback-note { text-align: left; }
}

@media (max-width: 860px) {
  :root { --sidebar: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; }
  .topbar { padding: 16px 18px 12px; align-items: flex-start; flex-wrap: wrap; gap: 12px; }
  .topbar-title h1 { font-size: 23px; }
  .topbar-title p { display: none; }
  .topbar-actions { width: 100%; justify-content: space-between; gap: 8px; }
  .segmented { order: 2; width: 100%; justify-content: space-between; }
  .segmented button { flex: 1; padding: 0 6px; }
  .theme-btn { display: inline-grid; }
  .content { padding: 18px 18px 104px; }
  .offline-bar { margin: 12px 18px 0; }  .tabbar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    padding: 7px 6px calc(7px + env(safe-area-inset-bottom));
    background: var(--bg);
    background: color-mix(in srgb, var(--bg) 88%, var(--surface));
    backdrop-filter: blur(18px);
    border-top: 1px solid var(--line);
  }
  .tab-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 600;
    letter-spacing: .01em;
  }
  .tab-item svg { width: 20px; height: 20px; }
  .tab-item.is-active { color: var(--accent); }
  .tab-item.is-active svg { stroke-width: 2.2; }
  .toast { bottom: 92px; }
  .section-head { margin-top: 22px; }
  .payback-rows { grid-template-columns: 1fr 1fr; }
  .payback-big { font-size: 32px; }
}

@media (max-width: 720px) {
  .field input, .field select, .field textarea, .search input, .toolbar select { font-size: 16px; }
  .start-banner { flex-direction: column; align-items: flex-start; gap: 12px; }
  .start-banner .btn { width: 100%; }
  .grid-kpi { gap: 10px; }
  .kpi { padding: 14px; border-radius: 16px; }
  .kpi-value { font-size: 23px; margin-top: 9px; }
  .kpi-label { font-size: 9.5px; }
  .kpi-icon { width: 26px; height: 26px; }
  .kpi-foot { font-size: 10.5px; }

  .catalog-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .product-info { padding: 10px 11px 12px; }
  .product-name { font-size: 11.5px; }
  .product-price { font-size: 17px; }
  .product-sold { font-size: 9.5px; }
  .product-cat { font-size: 8.5px; }
  .product-edit { opacity: 1; width: 26px; height: 26px; top: 7px; right: 7px; }

  .table-card { background: transparent; border: 0; box-shadow: none; }
  .table-wrap { overflow: visible; }
  table, thead, tbody, tr, td { display: block; }
  thead { display: none; }
  tbody tr {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 15px;
    padding: 8px 0;
    margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
  }
  tbody tr:hover { background: var(--surface); }
  td {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 6px 15px;
    border: 0;
    font-size: 12.5px;
    text-align: right;
  }
  td::before {
    content: attr(data-label);
    color: var(--muted);
    font-size: 9.5px;
    font-weight: 700;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: left;
    flex: 0 0 auto;
  }
  td.cell-primary { display: block; text-align: left; padding: 8px 15px 9px; border-bottom: 1px dashed var(--line-soft); margin-bottom: 4px; }
  td.cell-primary::before { display: none; }
  td.hide-mobile { display: none; }
  td.actions-cell { justify-content: flex-end; gap: 6px; padding-top: 8px; }
  td.actions-cell::before { content: ""; }
  .row-actions { opacity: 1; }
  .num { text-align: right; }

  .toolbar { gap: 6px; }
  .search { max-width: none; flex-basis: 100%; }
  .toolbar select { flex: 1 1 calc(50% - 4px); min-width: 0; }
  .btn-export { font-size: 0; gap: 0; padding: 0 11px; }
  .btn-export svg { width: 16px; height: 16px; }
  .chips { gap: 6px; }
  .chip { font-size: 10.5px; padding: 6px 9px; }

  .card-head { padding: 16px 16px 0; }
  .card-body { padding: 14px 16px 18px; }
  .chart-box { height: 220px; }
  .chart-box.tall { height: 240px; }
  .section-head h2 { font-size: 17px; }
  .section-head p { font-size: 11px; }
  .payback-rows { grid-template-columns: 1fr; }
  .modal-foot { flex-wrap: wrap; }
  dialog.modal { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; }
  dialog.modal[open] { animation: sheet .25s cubic-bezier(.2,.8,.2,1); }
  @keyframes sheet { from { transform: translateY(30px); opacity: .6; } to { transform: none; opacity: 1; } }
  .modal-body { max-height: 70vh; }
  .grid-form { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
}

@media (max-width: 380px) {
  .catalog-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 21px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}

@media print {
  .sidebar, .topbar, .tabbar, .toast, .row-actions { display: none !important; }
  .main { margin: 0; }
  body { background: #fff; }
}
