/* ============================================================
   DE VATCHI — admin.css
   Studio dashboard: login, tabs, stat cards, chart, tables,
   product form modal.
   ============================================================ */

/* ---------- login ---------- */
.admin-route #site-header, .admin-route #site-footer { display: none; }
.admin-route #app { min-height: 100vh; }
.admin-login { min-height: calc(100vh - 72px); display: grid; place-items: center; }
.login-card {
  width: min(420px, 100%);
  border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .7);
  padding: 44px 38px 34px;
  display: flex; flex-direction: column; gap: 6px;
  box-shadow: var(--shadow);
}
.login-mark { font-family: var(--serif); font-size: 56px; color: var(--red); line-height: 1; margin-bottom: 14px; }
.login-card h1 { font-size: 52px; margin-bottom: 24px; }
.login-card .full-button { margin-top: 6px; }
.login-hint { margin-top: 22px; font-size: 12px; color: var(--muted); text-align: center; }
.login-hint code { font-family: var(--mono); color: var(--red); background: rgba(101, 0, 0, .07); padding: 2px 6px; }

/* ---------- shell ---------- */
.admin { padding: 70px 0 60px; }
.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; flex-wrap: wrap; margin-bottom: 40px; }
.admin-head h1 { font-size: clamp(44px, 6vw, 84px); }
.admin-actions { display: flex; gap: 12px; }
.admin-grid { display: grid; grid-template-columns: 200px 1fr; gap: 40px; align-items: start; }
.admin-tabs { display: flex; flex-direction: column; gap: 4px; position: sticky; top: 100px; }
.admin-tabs button {
  text-align: left; padding: 13px 16px;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); border-left: 2px solid var(--line);
  transition: color .25s, border-color .25s, background .25s;
}
.admin-tabs button:hover { color: var(--red); }
.admin-tabs button.active { color: var(--red); border-color: var(--red); background: rgba(101, 0, 0, .05); }

/* ---------- stat cards + chart ---------- */
.stat-cards { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 26px; }
.stat-card { border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .7); padding: 22px; display: flex; flex-direction: column; gap: 6px; }
.stat-card span { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.stat-card strong { font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 3.4vw, 52px); line-height: 1; color: var(--red); }
.stat-card em { font-style: normal; font-size: 11px; color: var(--muted); }

.admin-panels { display: grid; grid-template-columns: .9fr 1.1fr; gap: 16px; align-items: start; }
.panel { border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .7); padding: 24px; }
.panel.wide { grid-column: 1 / -1; }
.panel h3 { font-size: 24px; margin-bottom: 18px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.panel-head h3 { margin-bottom: 0; }
.panel-head > div { display: flex; gap: 10px; }

.chart { display: flex; align-items: flex-end; gap: 12px; height: 240px; padding-top: 10px; }
.bar { flex: 1; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 8px; height: 100%; }
.bar i { width: 100%; max-width: 46px; background: linear-gradient(180deg, var(--red), var(--red-deep)); min-height: 6px; transition: height .8s var(--ease); }
.bar span { font-family: var(--mono); font-size: 9px; letter-spacing: .1em; color: var(--muted); }

/* ---------- tables ---------- */
.table-scroll { overflow-x: auto; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.admin-table th {
  text-align: left; font-family: var(--mono); font-weight: 500;
  font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted);
  padding: 10px 12px; border-bottom: 1px solid var(--line-strong);
}
.admin-table td { padding: 13px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.admin-table tr:hover td { background: rgba(101, 0, 0, .035); }
.cell-thumb img { width: 52px; height: 64px; object-fit: cover; }
.cell-name { font-family: var(--serif); font-size: 17px; line-height: 1.2; }
.cell-name em { display: block; font-family: var(--mono); font-style: normal; font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.cell-actions { white-space: nowrap; }
.cell-actions .mini-btn { margin-left: 6px; }

.pill { display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; padding: 5px 10px; border: 1px solid; }
.pill-processing { color: #8a6a00; border-color: rgba(138, 106, 0, .4); background: rgba(138, 106, 0, .07); }
.pill-shipped { color: #1d5a8a; border-color: rgba(29, 90, 138, .4); background: rgba(29, 90, 138, .07); }
.pill-delivered { color: #2e6b34; border-color: rgba(46, 107, 52, .4); background: rgba(46, 107, 52, .07); }
.pill-cancelled { color: #a3271f; border-color: rgba(163, 39, 31, .4); background: rgba(163, 39, 31, .07); }

/* ---------- controls ---------- */
.mini-btn {
  border: 1px solid var(--line-strong); padding: 8px 14px;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--red);
  transition: background .25s, color .25s, border-color .25s;
}
.mini-btn:hover { background: var(--red); border-color: var(--red); color: var(--cream); }
.mini-btn.danger { color: #a3271f; border-color: rgba(163, 39, 31, .45); }
.mini-btn.danger:hover { background: #a3271f; border-color: #a3271f; color: var(--cream); }

.status-select {
  border: 1px solid var(--line-strong); background: transparent;
  padding: 8px 10px; font-size: 12px; color: var(--ink);
}
.status-select:focus { outline: none; border-color: var(--red); }

.check-line { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 6px 0 18px; cursor: pointer; }
.check-line input { width: 18px; height: 18px; accent-color: var(--red); }

.admin-form .field { margin-bottom: 16px; }
.admin-form .modal-actions { margin-top: 8px; }


@media (max-width: 1100px) {
  .stat-cards { grid-template-columns: repeat(2, 1fr); }
  .admin-panels { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .admin-grid { grid-template-columns: 1fr; }
  .admin-tabs { flex-direction: row; position: static; overflow-x: auto; }
  .admin-tabs button { border-left: 0; border-bottom: 2px solid var(--line); white-space: nowrap; }
  .admin-tabs button.active { border-color: var(--red); }
}

/* ============================================================
   Admin v2 — cloud badge, image upload, sections editor
   ============================================================ */
.admin-cloud {
  display: inline-flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  border: 1px solid var(--line-strong); padding: 7px 12px; color: var(--muted);
}
.admin-cloud i { width: 8px; height: 8px; border-radius: 50%; }
.admin-cloud.online i { background: #2e6b34; }
.admin-cloud.offline i { background: #a3271f; }

/* image upload drop/stash */
.upload-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.upload-row img { width: 64px; height: 80px; object-fit: cover; border: 1px solid var(--line); }
.upload-label {
  display: inline-flex; align-items: center; gap: 8px; cursor: pointer;
  border: 1px dashed var(--line-strong); color: var(--muted);
  padding: 10px 16px; font-size: 12px; letter-spacing: .06em;
}
.upload-label:hover { color: var(--red); border-color: var(--red); }
.upload-label input[type="file"] { display: none; }
.featured-picker { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.featured-picker label { position: relative; width: 72px; cursor: pointer; }
.featured-picker input { position: absolute; opacity: 0; }
.featured-picker img { display: block; width: 72px; height: 88px; object-fit: cover; border: 2px solid transparent; }
.featured-picker input:checked + img { border-color: var(--red); }
.featured-picker span { display: block; font-size: 9px; color: var(--muted); margin-top: 4px; }
.ads-admin-list { display: grid; gap: 12px; margin-top: 20px; }
.ads-admin-card { display: grid; grid-template-columns: 150px 1fr auto; gap: 16px; align-items: center; border: 1px solid var(--line); padding: 10px; }
.ads-admin-card img { width: 150px; height: 62px; object-fit: cover; background: var(--sand); }
.ads-admin-card strong, .ads-admin-card span { display: block; }
.ads-admin-card span { color: var(--muted); font-size: 11px; margin-top: 4px; }

/* sections editor */
.sec-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.sec-card {
  border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .7);
  padding: 22px 20px; display: flex; flex-direction: column; gap: 10px;
}
.sec-card .field { margin-bottom: 6px; }
.sec-card .field:last-child { margin-bottom: 0; }
.sec-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.sec-head span:first-child { font-family: var(--mono); font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.sec-head .mini-btn { padding: 6px 12px; font-size: 9px; }

@media (max-width: 1100px) {
  .sec-cards { grid-template-columns: 1fr; }
}

/* ============================================================
   Admin v3 — orders toolbar, discounts, customers, settings
   ============================================================ */

/* overview stat cards now flex for five-up */
.stat-cards { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }

/* orders toolbar: search + status chips */
.admin-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; flex-wrap: wrap; margin-bottom: 16px;
}
.toolbar-search {
  flex: 1; min-width: 220px; max-width: 340px;
  border: 1px solid var(--line-strong); background: transparent;
  padding: 10px 14px; font-size: 13px; color: var(--ink);
  transition: border-color .25s, background .25s;
}
.toolbar-search:focus { outline: none; border-color: var(--red); background: rgba(101, 0, 0, .04); }
.chip-row { display: flex; gap: 8px; flex-wrap: wrap; }
.chip-btn {
  border: 1px solid var(--line-strong); padding: 8px 14px;
  font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--muted); transition: all .25s;
}
.chip-btn:hover { color: var(--red); border-color: var(--red); }
.chip-btn.active { background: var(--red); border-color: var(--red); color: var(--cream); }

/* discount add form */
.inline-form {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--line);
}
.inline-form input {
  border: 1px solid var(--line-strong); background: transparent;
  padding: 10px 14px; font-size: 13px; color: var(--ink);
}
.inline-form input:focus { outline: none; border-color: var(--red); }
.inline-form #promo-code { text-transform: uppercase; letter-spacing: .1em; font-family: var(--mono); width: 160px; }
.inline-form #promo-pct { width: 84px; }
.pct-sign { font-family: var(--mono); font-size: 13px; color: var(--muted); margin-left: -4px; }
.inline-form .form-error { font-size: 12px; color: #a3271f; }

/* customers tab */
.sub-list { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line); }
.sub-list h4 { font-family: var(--serif); font-size: 20px; margin-bottom: 10px; }
.sub-list p { display: flex; flex-wrap: wrap; gap: 8px; }

/* settings tab spacing */
.admin-content .sec-cards { margin-bottom: 0; }
.admin-content .check-line { margin-bottom: 10px; }
/* inventory tab */
.inv-stock { display: inline-flex; align-items: center; gap: 6px; }
.inv-input {
  width: 64px; text-align: center; font-family: var(--mono); font-size: 13px;
  padding: 6px 4px; border: 1px solid var(--line-strong); background: transparent; color: inherit;
}
.inv-input:focus { outline: none; border-color: var(--red); }
.inv-pill {
  display: inline-block; font-family: var(--mono); font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; padding: 4px 9px; border-radius: 999px; white-space: nowrap;
}
.inv-pill.in { background: rgba(46, 107, 63, .14); color: #2e6b3f; }
.inv-pill.low { background: rgba(162, 98, 10, .16); color: #a2620a; }
.inv-pill.out { background: rgba(143, 31, 31, .14); color: #8f1f1f; }
.admin-table .color-dot { margin-inline-end: 2px; }

/* cloud badge states + database migration notice */
.admin-cloud.warn { color: #a2620a; border-color: rgba(162, 98, 10, .55); }
.admin-cloud.warn i { background: #d99a26; animation: stockBreath 2s ease-in-out infinite; }
.cloud-notice {
  margin-bottom: 22px; padding: 16px 18px;
  border: 1px solid rgba(162, 98, 10, .45); background: rgba(226, 180, 90, .12);
  font-size: 13px; line-height: 1.6;
}
.cloud-notice strong { display: block; margin-bottom: 4px; font-family: var(--mono); font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #a2620a; }
.cloud-notice code {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px;
  background: rgba(162, 98, 10, .14); border-radius: 4px;
}

/* ---------- final studio polish ---------- */
.admin { position: relative; max-width: 1440px; }
.admin::before {
  content: ''; position: absolute; inset: 20px 0 auto; height: 1px;
  background: linear-gradient(90deg, transparent, var(--line-strong), transparent);
  pointer-events: none;
}
.admin-head { padding: 18px 0 26px; border-bottom: 1px solid var(--line-strong); }
.admin-head h1 { letter-spacing: -.025em; line-height: .95; }
.admin-head .eyebrow { margin-bottom: 12px; }
.admin-head > div:first-child { display: flex; flex-direction: column; align-items: flex-start; gap: 14px; }
.admin-actions { align-items: center; flex-wrap: wrap; }
.admin-actions .button { min-height: 44px; }
.admin-grid { grid-template-columns: 216px minmax(0, 1fr); gap: 34px; }
.admin-tabs {
  padding: 8px; border: 1px solid var(--line-strong);
  background: rgba(255, 253, 249, .55); box-shadow: 0 12px 30px rgba(58, 18, 12, .04);
}
.admin-tabs button { border-left: 2px solid transparent; border-radius: 2px; transition: color .2s, background .2s, transform .2s; }
.admin-tabs button:hover { background: rgba(101, 0, 0, .06); transform: translateX(2px); }
.admin-tabs button.active { background: var(--red); color: var(--cream); border-color: var(--red); box-shadow: 0 7px 16px rgba(101, 0, 0, .16); }
.admin-content { min-width: 0; }
.admin-tab-select-label { display: none; }
.stat-card, .panel, .sec-card { background: rgba(255, 253, 249, .82); box-shadow: 0 10px 28px rgba(58, 18, 12, .035); }
.stat-card { min-height: 142px; justify-content: space-between; }
.stat-card strong { letter-spacing: -.025em; }
.panel { padding: 26px; }
.panel-head { padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.admin-table th { white-space: nowrap; }
.admin-table td { height: 70px; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table .cell-actions .mini-btn { min-height: 34px; }
.mini-btn:focus-visible, .admin-tabs button:focus-visible, .admin-actions .button:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }
.sec-card { min-height: 126px; }
.sec-card:hover { border-color: var(--red); box-shadow: 0 12px 28px rgba(58, 18, 12, .07); }
.media-upload-button { display: inline-flex; cursor: pointer; }
.media-upload-button input { display: none; }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 16px; }
.media-card { min-width: 0; border: 1px solid var(--line); padding: 10px; display: flex; flex-direction: column; gap: 7px; }
.media-card strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.media-card > span { color: var(--muted); font-family: var(--mono); font-size: 9px; letter-spacing: .06em; text-transform: uppercase; }
.media-preview { aspect-ratio: 1 / 1; background: var(--sand); overflow: hidden; }
.media-preview img, .media-preview video { width: 100%; height: 100%; object-fit: cover; }
.media-actions { display: flex; gap: 6px; margin-top: 5px; }
.media-actions .mini-btn { flex: 1; padding-inline: 6px; font-size: 9px; }

@media (max-width: 760px) {
  .admin { padding-top: 46px; }
  .admin-head { align-items: flex-start; }
  .admin-head h1 { font-size: clamp(42px, 14vw, 64px); }
  .admin-actions { width: 100%; }
  .admin-actions .button { flex: 1; min-width: 132px; }
  .admin-tabs { padding: 6px; gap: 4px; }
  .admin-tabs button { border-left: 0; border-bottom: 0; white-space: nowrap; }
  .panel { padding: 18px; }
  .stat-card { min-height: 118px; padding: 18px; }
  .ads-admin-card { grid-template-columns: 88px 1fr; }
  .ads-admin-card img { width: 88px; height: 58px; }
  .ads-admin-card .cell-actions { grid-column: 1 / -1; }
}

/* ---------- small-screen admin layout ---------- */
@media (max-width: 520px) {
  .admin { width: 100%; padding: 34px 14px 42px; }
  .admin::before { inset: 10px 14px auto; }
  .admin-head { gap: 18px; margin-bottom: 22px; padding-top: 12px; }
  .admin-head > div:first-child { width: 100%; gap: 10px; }
  .admin-head h1 { font-size: clamp(40px, 13vw, 56px); }
  .admin-cloud { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .admin-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .admin-actions .button { width: 100%; min-width: 0; padding-inline: 10px; font-size: 10px; }
  .admin-actions .button:last-child { grid-column: 1 / -1; }
  .admin-grid { grid-template-columns: 1fr; gap: 16px; }
  .admin-tabs { display: none; }
  .admin-tab-select-label { display: block; font-family: var(--mono); font-size: 10px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); }
  .admin-tab-select-label select { display: block; width: 100%; margin-top: 8px; padding: 13px 12px; border: 1px solid var(--line-strong); background: rgba(255, 253, 249, .82); color: var(--ink); font: inherit; letter-spacing: .04em; }
  .admin-tab-select-label select:focus { outline: 2px solid var(--red); outline-offset: 2px; }
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { min-height: 104px; padding: 14px 12px; }
  .stat-card strong { font-size: 32px; }
  .stat-card em { font-size: 10px; line-height: 1.3; }
  .admin-panels { gap: 10px; }
  .panel { padding: 15px 12px; }
  .panel-head { align-items: flex-start; gap: 10px; }
  .panel-head > div { width: 100%; }
  .panel-head h3 { font-size: 21px; }
  .panel-head > .mini-btn, .panel-head > div > .mini-btn { flex: 0 0 auto; }
  .table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .admin-table { min-width: 680px; font-size: 13px; }
  .admin-table.products { min-width: 760px; }
  .admin-table th { padding: 9px 8px; font-size: 9px; }
  .admin-table td { height: 62px; padding: 10px 8px; }
  .cell-thumb img { width: 44px; height: 54px; }
  .cell-name { font-size: 15px; }
  .toolbar-search { min-width: 100%; max-width: none; }
  .admin-toolbar { align-items: stretch; gap: 10px; }
  .chip-row { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 4px; }
  .chip-btn { flex: 0 0 auto; padding: 8px 11px; }
  .sec-cards { gap: 10px; }
  .sec-card { padding: 15px 12px; }
  .cms-editor .field-row { display: block; }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .media-card { padding: 7px; }
  .media-actions { flex-direction: column; }
  .inline-form { align-items: stretch; }
  .inline-form input, .inline-form #promo-code, .inline-form #promo-pct { width: 100%; }
  .inline-form .mini-btn { width: 100%; }
  .inv-stock { min-width: 180px; }
}

@media (min-width: 1200px) {
  .admin-content .panel { padding: 30px; }
  .admin-table { font-size: 15px; }
}

@media (min-width: 521px) and (max-width: 900px) {
  .admin-grid { grid-template-columns: 170px minmax(0, 1fr); gap: 20px; }
  .admin-tabs button { padding-inline: 11px; font-size: 10px; }
  .admin-actions .button { padding-inline: 13px; }
  .panel { padding: 20px; }
}

@media (max-width: 520px) {
  .login-card { padding: 32px 22px 26px; }
  .login-card h1 { font-size: 44px; }
  .upload-row { align-items: flex-start; }
  .upload-label { min-height: 44px; }
  .featured-picker img { width: 64px; height: 78px; }
  .featured-picker label { width: 64px; }
  .ads-admin-card strong { font-size: 13px; }
}



.category-chart-thumb{width:76px;height:76px;object-fit:contain;background:#fff;border-radius:6px}.category-chart-preview{display:block;max-width:100%;max-height:240px;object-fit:contain;margin:12px 0}.category-chart-preview[hidden]{display:none}

.category-chart-thumb{width:76px;height:76px;object-fit:contain;background:#fff;border-radius:6px}.category-chart-preview{display:block;max-width:100%;max-height:240px;object-fit:contain;margin:12px 0}.category-chart-preview[hidden]{display:none}

.category-chart-thumb{width:76px;height:76px;object-fit:contain;background:#fff;border-radius:6px}.category-chart-preview{display:block;max-width:100%;max-height:240px;object-fit:contain;margin:12px 0}.category-chart-preview[hidden]{display:none}

.category-chart-thumb{width:76px;height:76px;object-fit:contain;background:#fff;border-radius:6px}.category-chart-preview{display:block;max-width:100%;max-height:240px;object-fit:contain;margin:12px 0}.category-chart-preview[hidden]{display:none}

.admin-table .product-prices{display:inline-flex;gap:8px;flex-wrap:wrap}.admin-table .price-old{opacity:.6;text-decoration:line-through}.admin-table .price-current{font-weight:600}

.size-stock-editor {display:flex; flex-wrap:wrap; gap:12px; grid-column:1/-1;}
.size-stock-editor>strong {flex-basis:100%;}
.size-stock-editor>label {display:grid;gap:6px;min-width:80px;max-width:120px;}
.size-stock-editor input {width:100%;}

/* Order details remain readable on mobile and for long delivery addresses. */
.admin-order-details { overflow-wrap: anywhere; }
.admin-order-address { display: grid; gap: 12px; margin: 20px 0; }
.admin-order-address > div { display: grid; grid-template-columns: minmax(100px, 1fr) minmax(0, 2fr); gap: 12px; }
.admin-order-address dt { font-weight: 600; }
.admin-order-address dd { margin: 0; white-space: pre-wrap; }
.admin-order-items { list-style: none; padding: 0; }
.admin-order-items li { padding: 14px 0; border-bottom: 1px solid #ddd; }
.admin-order-items p { margin: 6px 0; }
@media (max-width: 480px) { .admin-order-address > div { grid-template-columns: 1fr; gap: 4px; } }

/* ---------- conversion dashboard (التحويل) ---------- */
.cv { --cv-ok: #1f6b3a; --cv-warn: #8a5a00; --cv-bad: #a3271f; --cv-ok-bg: rgba(31, 107, 58, .08); --cv-warn-bg: rgba(138, 90, 0, .09); --cv-bad-bg: rgba(163, 39, 31, .07);
  display: flex; flex-direction: column; gap: 20px; color: var(--ink); }
[data-theme="dark"] .cv { --cv-ok: #6fcf97; --cv-warn: #e3b85f; --cv-bad: #ff8f7e; --cv-ok-bg: rgba(111, 207, 151, .09); --cv-warn-bg: rgba(227, 184, 95, .09); --cv-bad-bg: rgba(255, 143, 126, .09); }
.cv > * { min-width: 0; }
.cv h2, .cv h3, .cv h4 { font-family: var(--sans); font-weight: 600; letter-spacing: 0; line-height: 1.4; margin: 0; }
.cv-bad { color: var(--cv-bad); }

/* header + toolbar */
.cv-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.cv-head h2 { font-size: clamp(26px, 3vw, 34px); }
.cv-head p { margin: 4px 0 0; color: var(--muted); font-size: 13.5px; }
.cv-actions { display: flex; gap: 8px; }
.cv-actions .mini-btn:disabled { opacity: .55; cursor: not-allowed; }
.cv-toolbar { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 12px 14px; border: 1px solid var(--line-strong); background: var(--surface, rgba(255, 253, 249, .7)); }
.cv-seg { display: inline-flex; border: 1px solid var(--line-strong); }
.cv-seg button { padding: 8px 14px; font-size: 12.5px; color: var(--muted); border-inline-start: 1px solid var(--line); }
.cv-seg button:first-child { border-inline-start: 0; }
.cv-seg button:hover { color: var(--ink); }
.cv-seg button.is-on { background: var(--accent, var(--red)); color: var(--bg, var(--cream)); }
.cv-field { display: grid; gap: 4px; font-size: 11.5px; color: var(--muted); }
.cv-field select { min-width: 140px; border: 1px solid var(--line-strong); background: var(--bg, var(--cream)); color: var(--ink); padding: 8px 10px; font: inherit; font-size: 13px; }
.cv-field select:focus-visible { outline: 2px solid var(--accent, var(--red)); outline-offset: 1px; }
.cv-check { display: flex; align-items: center; gap: 8px; padding-bottom: 9px; font-size: 12.5px; color: var(--muted); }
.cv-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 12.5px; }
.cv-message:empty { display: none; }

/* verdict */
.cv-verdict { padding: 16px 20px; border: 1px solid var(--line-strong); border-inline-start: 4px solid var(--cv-ok); background: var(--cv-ok-bg); }
.cv-verdict.cv-warn { border-inline-start-color: var(--cv-warn); background: var(--cv-warn-bg); }
.cv-verdict.cv-bad { border-inline-start-color: var(--cv-bad); background: var(--cv-bad-bg); }
.cv-verdict-main strong { font-size: 12.5px; color: var(--cv-ok); }
.cv-verdict.cv-warn .cv-verdict-main strong { color: var(--cv-warn); }
.cv-verdict.cv-bad .cv-verdict-main strong { color: var(--cv-bad); }
.cv-verdict-main p { margin: 4px 0 0; font-size: 16px; line-height: 1.7; max-width: 70ch; }
.cv-notes { margin-top: 12px; font-size: 13.5px; }
.cv-notes summary { cursor: pointer; color: var(--muted); }
.cv-notes ul { list-style: none; margin: 10px 0 0; padding: 0; display: grid; gap: 8px; }
.cv-notes li { position: relative; padding-inline-start: 16px; line-height: 1.7; }
.cv-notes li::before { content: ""; position: absolute; inset-inline-start: 0; top: .75em; width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.cv-notes li.cv-bad::before { background: var(--cv-bad); } .cv-notes li.cv-warn::before { background: var(--cv-warn); } .cv-notes li.cv-ok::before { background: var(--cv-ok); }
.cv-notes li.cv-bad, .cv-notes li.cv-warn, .cv-notes li.cv-ok { color: var(--ink); }

/* KPIs */
.cv-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--line-strong); background: var(--surface, rgba(255, 253, 249, .7)); }
.cv-kpi { display: flex; flex-direction: column; gap: 6px; padding: 18px 20px; border-inline-start: 1px solid var(--line); }
.cv-kpi:first-child { border-inline-start: 0; }
.cv-kpi span { font-size: 12.5px; color: var(--muted); }
.cv-kpi strong { font-size: clamp(26px, 3vw, 36px); font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.cv-kpi:last-child strong { color: var(--accent, var(--red)); }
.cv-kpi small { font-size: 12px; color: var(--muted); }
.cv-facts { display: flex; flex-wrap: wrap; gap: 6px 32px; margin: -6px 0 0; font-size: 12.5px; color: var(--muted); }
.cv-facts div { display: flex; gap: 8px; }
.cv-facts dt, .cv-facts dd { margin: 0; }
.cv-facts dd { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }

/* cards + layout */
.cv-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, .95fr); gap: 16px; align-items: stretch; }
.cv-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.cv-card { min-width: 0; padding: 20px; border: 1px solid var(--line-strong); background: var(--surface, rgba(255, 253, 249, .7)); }
.cv-card-head { margin-bottom: 14px; }
.cv-card-head h3 { font-size: 16px; }
.cv-card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.cv-empty { display: grid; place-items: center; min-height: 110px; color: var(--muted); font-size: 13px; text-align: center; }
.cv-error { display: grid; gap: 6px; padding: 18px 20px; border: 1px solid var(--cv-bad); background: var(--cv-bad-bg); color: var(--cv-bad); line-height: 1.6; }
.cv-error span { color: var(--muted); font-size: 13px; }

/* funnel */
.cv-funnel { list-style: none; margin: 0; padding: 0; display: grid; gap: 14px; }
.cv-step-top { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.cv-step-top strong { font-size: 16px; font-variant-numeric: tabular-nums; }
.cv-step-top em { margin-inline-start: 8px; padding: 1px 7px; border: 1px solid var(--cv-bad); border-radius: 2px; color: var(--cv-bad); font-size: 11px; font-style: normal; }
.cv-bar { height: 8px; margin: 6px 0 5px; background: var(--tint, rgba(101, 0, 0, .08)); }
.cv-bar i { display: block; height: 100%; background: var(--accent, var(--red)); }
.cv-step.is-worst .cv-bar i { background: var(--cv-bad); }
.cv-step-meta { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; color: var(--muted); }
.cv-step.is-worst .cv-lost { color: var(--cv-bad); font-weight: 600; }

/* daily chart */
.cv-chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.cv-chart text { fill: var(--muted); font-family: var(--sans); font-size: 11px; }
.cv-axis { stroke: var(--line-strong); stroke-width: 1; }
.cv-b-visit { fill: var(--accent, var(--red)); opacity: .28; }
.cv-b-cart { fill: var(--accent, var(--red)); }
.cv-b-order { fill: var(--cv-ok); }
.cv-legend { list-style: none; display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 12px 0 0; padding: 0; font-size: 12px; color: var(--muted); }
.cv-legend li { display: flex; align-items: center; gap: 6px; }
.cv-legend i { width: 10px; height: 10px; display: inline-block; }
.cv-k-visit { background: var(--accent, var(--red)); opacity: .28; } .cv-k-cart { background: var(--accent, var(--red)); } .cv-k-order { background: var(--cv-ok); border-radius: 50%; }

/* tabs */
.cv-tabs { display: flex; gap: 2px; overflow-x: auto; border-bottom: 1px solid var(--line-strong); margin-bottom: -4px; }
.cv-tab { display: inline-flex; align-items: center; gap: 6px; padding: 12px 16px; font-size: 13.5px; color: var(--muted); white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.cv-tab:hover { color: var(--ink); }
.cv-tab.is-on { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent, var(--red)); }
.cv-tab b { min-width: 20px; padding: 1px 6px; border-radius: 2px; background: var(--cv-bad); color: #fff; font-size: 11px; font-weight: 600; text-align: center; }
[data-theme="dark"] .cv-tab b { color: #1a0d0a; }

/* tables */
.cv-table-wrap { overflow-x: auto; }
.cv-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.cv-table th { padding: 8px 10px; border-bottom: 1px solid var(--line-strong); color: var(--muted); font-size: 12px; font-weight: 500; text-align: start; white-space: nowrap; }
.cv-table td { padding: 11px 10px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; vertical-align: middle; }
.cv-table tbody tr:last-child td { border-bottom: 0; }
.cv-num { text-align: end !important; font-variant-numeric: tabular-nums; white-space: nowrap; }
.cv-table td small { color: var(--muted); font-size: 11.5px; }
.cv-page { font-weight: 500; }
.cv-table code, .cv-page + code { margin-inline-start: 8px; color: var(--muted); font-family: var(--mono); font-size: 11px; unicode-bidi: isolate; }
.cv-sub { display: block; margin-top: 1px; color: var(--muted); font-size: 11.5px !important; }

/* sessions */
.cv-sessions-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.cv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.cv-chips button { padding: 6px 12px; border: 1px solid var(--line-strong); font-size: 12.5px; color: var(--muted); }
.cv-chips button:hover { color: var(--ink); }
.cv-chips button.is-on { background: var(--accent, var(--red)); border-color: var(--accent, var(--red)); color: var(--bg, var(--cream)); }
.cv-table-sessions td { white-space: nowrap; }
.cv-row { cursor: pointer; }
.cv-row:hover td { background: var(--tint-weak, rgba(101, 0, 0, .04)); }
.cv-row:focus-visible { outline: 2px solid var(--accent, var(--red)); outline-offset: -2px; }
.cv-go { width: 24px; color: var(--muted); font-size: 18px; text-align: end; }
.cv-more { display: flex; justify-content: center; padding-top: 14px; }
.cv-pill { display: inline-block; margin-inline-end: 6px; padding: 2px 9px; border: 1px solid var(--line-strong); border-radius: 2px; font-size: 12px; line-height: 1.5; color: var(--ink); }
.cv-pill-visit { color: var(--muted); border-color: var(--line); }
.cv-pill-cart { border-color: var(--accent, var(--red)); }
.cv-pill-checkout, .cv-pill-submit { color: var(--cv-warn); border-color: var(--cv-warn); background: var(--cv-warn-bg); }
.cv-pill-order { color: var(--cv-ok); border-color: var(--cv-ok); background: var(--cv-ok-bg); font-weight: 600; }
.cv-pill-failed { color: var(--cv-bad); border-color: var(--cv-bad); background: var(--cv-bad-bg); }
.cv-status { display: flex; align-items: center; gap: 8px; margin: 0; font-size: 12px; color: var(--muted); }
.cv-status:empty { display: none; }
.cv-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.cv-dot.is-ok { background: var(--cv-ok); } .cv-dot.is-bad { background: var(--cv-bad); }

/* visitor journey drawer */
.cv-scrim { position: fixed; inset: 0; z-index: 1199; background: rgba(20, 8, 6, .45); }
.cv-drawer { position: fixed; top: 0; bottom: 0; left: 0; z-index: 1200; width: min(460px, 100vw); display: flex; flex-direction: column; background: var(--float, var(--cream)); border-right: 1px solid var(--line-strong); box-shadow: var(--shadow); animation: cv-in .22s ease-out; }
.cv-scrim[hidden], .cv-drawer[hidden] { display: none; }
@keyframes cv-in { from { transform: translateX(-28px); opacity: 0; } to { transform: none; opacity: 1; } }
.cv-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 20px; border-bottom: 1px solid var(--line-strong); }
.cv-drawer-head h3 { font-size: 18px; }
.cv-drawer-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.cv-drawer-tags { display: flex; flex-wrap: wrap; gap: 6px 0; margin-top: 10px; }
.cv-close { flex: none; width: 34px; height: 34px; border: 1px solid var(--line-strong); color: var(--muted); font-size: 14px; }
.cv-close:hover { color: var(--ink); border-color: var(--ink); }
.cv-drawer-body { flex: 1; overflow-y: auto; padding: 8px 20px 28px; }
.cv-group h4 { display: flex; justify-content: space-between; align-items: center; margin-top: 16px; padding: 7px 12px; background: var(--tint-weak, rgba(101, 0, 0, .04)); font-size: 13px; }
.cv-group h4 time, .cv-ev time { font-family: var(--mono); font-size: 11px; font-weight: 400; color: var(--muted); direction: ltr; }
.cv-group ul { list-style: none; margin: 0; padding: 0; }
.cv-ev { display: grid; grid-template-columns: 48px 1fr; gap: 10px; padding: 9px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
.cv-ev time { padding-top: 3px; }
.cv-ev strong { font-weight: 500; }
.cv-ev.is-key { border-inline-start: 3px solid var(--accent, var(--red)); } .cv-ev.is-key strong { font-weight: 600; }
.cv-ev.is-ok { border-inline-start: 3px solid var(--cv-ok); background: var(--cv-ok-bg); } .cv-ev.is-ok strong { color: var(--cv-ok); font-weight: 600; }
.cv-ev.is-bad { border-inline-start: 3px solid var(--cv-bad); background: var(--cv-bad-bg); } .cv-ev.is-bad strong { color: var(--cv-bad); font-weight: 600; }
.cv-ev-empty { display: block; color: var(--muted); }
.cv-chips-inline { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 4px; }
.cv-chip { padding: 1px 8px; border: 1px solid var(--line); font-size: 12px; color: var(--ink); overflow-wrap: anywhere; }
.cv-chip em { margin-inline-end: 4px; color: var(--muted); font-style: normal; }

@media (max-width: 1000px) {
  .cv-split, .cv-grid { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .cv-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cv-kpi:nth-child(3) { border-inline-start: 0; }
  .cv-kpi:nth-child(n+3) { border-top: 1px solid var(--line); }
  .cv-toolbar { align-items: stretch; }
  .cv-seg { width: 100%; } .cv-seg button { flex: 1; padding: 9px 4px; }
  .cv-field, .cv-field select { width: 100%; }
  .cv-card { padding: 16px; }
  .cv-drawer { width: 100vw; }
}
@media (prefers-reduced-motion: reduce) { .cv-drawer { animation: none; } }