/* =====================================================================
   Aytan Market — Mağaza Zekâsı
   Tasarım sistemi: logo turuncusu + market yeşili, sıcak kâğıt zemin
   ===================================================================== */

:root {
  /* Marka */
  --brand-orange: #f25b22;
  --brand-orange-dark: #c9440f;
  --brand-orange-soft: #fff1ea;
  --brand-green: #096742;
  --brand-green-dark: #064d31;
  --brand-green-mid: #0e8a59;
  --brand-green-soft: #e8f5ee;

  /* Zemin & yüzey */
  --page: #f6f4ee;
  --surface: #ffffff;
  --surface-soft: #faf9f5;
  --surface-muted: #f1efe8;

  /* Metin */
  --ink: #17221c;
  --ink-2: #44524a;
  --muted: #69736c;

  /* Çizgi */
  --line: #e4e1d6;
  --line-soft: #efede5;
  --line-strong: #cdc9ba;

  /* Grafik serileri (JS ile senkron) */
  --series-1: #0e8a59;
  --series-2: #f25b22;
  --series-3: #e9a100;
  --series-4: #1a9ba8;
  --series-5: #c2477a;
  --series-6: #7fb13b;
  --series-7: #6b4fbb;
  --series-8: #d64545;

  /* Durum */
  --good: #12a150;
  --good-ink: #0b6b37;
  --good-soft: #e6f6ec;
  --warning: #e9a100;
  --warn-ink: #7a5200;
  --warn-soft: #fff4d6;
  --critical: #d64545;
  --bad-ink: #a42828;
  --bad-soft: #fdecec;

  /* Eski değişken adları (geriye uyum) */
  --blue: var(--brand-green);
  --blue-dark: var(--brand-green-dark);
  --blue-soft: var(--brand-green-soft);
  --violet: var(--brand-green-mid);

  --radius: 18px;
  --radius-sm: 11px;
  --shadow: 0 12px 36px rgba(23, 34, 28, 0.08);
  --shadow-soft: 0 1px 2px rgba(23, 34, 28, 0.04), 0 4px 14px rgba(23, 34, 28, 0.045);
  --shadow-hover: 0 2px 4px rgba(23, 34, 28, 0.05), 0 12px 28px rgba(23, 34, 28, 0.09);
  --focus: 0 0 0 3px rgba(14, 138, 89, 0.22);
  --assistant-width: 400px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  --ease: cubic-bezier(0.22, 0.8, 0.28, 1);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(900px 480px at 0% -8%, rgba(14, 138, 89, 0.09), transparent 62%),
    radial-gradient(760px 440px at 100% -4%, rgba(242, 91, 34, 0.08), transparent 60%),
    var(--page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
  font-family: inherit;
}

button {
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--brand-green-mid);
  outline-offset: 2px;
}

.hidden {
  display: none !important;
}

.app-shell {
  width: 100%;
  max-width: 1720px;
  margin: 0 auto;
  padding: 16px 24px 48px;
  transition: padding-right 0.28s var(--ease);
}

body:not(.assistant-panel-closed) .app-shell {
  padding-right: calc(var(--assistant-width) + 56px);
}

/* ---------- Top bar ---------- */

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 12px 10px 10px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(205, 201, 186, 0.55);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px) saturate(1.2);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
}

.brand-mark img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.brand-copy {
  min-width: 0;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-title .w-aytan {
  color: var(--brand-orange);
}

.brand-title .w-market {
  color: var(--brand-green);
  font-style: italic;
}

.brand-subtitle {
  font-size: 11px;
  color: var(--muted);
  margin-top: 3px;
  white-space: nowrap;
}

.brand-subtitle em {
  font-style: normal;
  color: var(--brand-green);
  font-weight: 600;
}

.demo-badge {
  margin-left: 4px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--brand-orange-soft);
  color: var(--brand-orange-dark);
  border: 1px solid #fbd3c1;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.freshness {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 1px solid var(--line);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 550;
  white-space: nowrap;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 0 4px rgba(18, 161, 80, 0.14);
}

.status-dot.is-stale {
  background: var(--warning);
  box-shadow: 0 0 0 4px rgba(233, 161, 0, 0.16);
}

.icon-button {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  transition: background 0.18s ease, border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.icon-button:hover {
  border-color: rgba(14, 138, 89, 0.4);
  color: var(--brand-green);
  background: var(--brand-green-soft);
}

.icon-button:active {
  transform: scale(0.96);
}

/* ---------- Page heading ---------- */

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin: 22px 4px 12px;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.page-head p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.page-head-tag {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 7px 12px;
  border-radius: 999px;
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.page-head-tag svg {
  flex: 0 0 auto;
}

/* ---------- Filters ---------- */

.filter-bar {
  position: sticky;
  top: 86px;
  z-index: 18;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(205, 201, 186, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(14px);
}

.filter-grid {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 132px;
}

.field > span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  padding-left: 2px;
}

.field input,
.field select {
  height: 40px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-soft);
  color: var(--ink);
  font-size: 13px;
  outline: none;
  cursor: pointer;
  transition: border-color 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.field input:hover,
.field select:hover {
  border-color: var(--line-strong);
}

.field input:focus,
.field select:focus,
.assistant-composer textarea:focus {
  border-color: var(--brand-green-mid);
  box-shadow: var(--focus);
  background: #fff;
}

.field-store {
  min-width: 240px;
}

.field-store select {
  max-width: 320px;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 40px;
  padding: 0 20px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand-green-mid), var(--brand-green));
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 16px rgba(9, 103, 66, 0.26);
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.primary-button:hover {
  filter: brightness(1.06);
  box-shadow: 0 9px 20px rgba(9, 103, 66, 0.32);
}

.primary-button:active {
  transform: translateY(1px);
}

.quick-ranges {
  display: inline-flex;
  align-items: center;
  padding: 4px;
  border-radius: 12px;
  background: var(--surface-muted);
  flex: 0 0 auto;
}

.quick-ranges button {
  min-height: 32px;
  border: 0;
  background: transparent;
  color: var(--ink-2);
  border-radius: 9px;
  padding: 7px 12px;
  font-size: 12px;
  font-weight: 650;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.quick-ranges button:hover {
  color: var(--brand-green);
}

.quick-ranges button.active {
  background: #fff;
  color: var(--brand-green);
  box-shadow: 0 1px 6px rgba(23, 34, 28, 0.1);
}

/* ---------- Dashboard layout ---------- */

.dashboard {
  margin-top: 16px;
}

.warning-banner {
  margin-bottom: 14px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 1px solid #f3dc9e;
  background: var(--warn-soft);
  color: #6b4c00;
  font-size: 12.5px;
}

.warning-banner strong {
  font-weight: 750;
}

.kpi-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 14px;
}

.kpi-card {
  position: relative;
  min-height: 136px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(205, 201, 186, 0.5);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 3px;
  transition: box-shadow 0.22s ease, transform 0.22s ease, border-color 0.22s ease;
}

.kpi-card:not(.skeleton):hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
  border-color: color-mix(in srgb, var(--accent, var(--brand-green)) 30%, var(--line));
}

.kpi-card::before {
  content: "";
  position: absolute;
  top: -40px;
  right: -40px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent, var(--brand-green)) 7%, transparent);
  pointer-events: none;
}

.kpi-card.kpi-hero {
  border-color: transparent;
  background:
    radial-gradient(220px 160px at 110% -10%, rgba(255, 255, 255, 0.16), transparent 60%),
    linear-gradient(145deg, var(--brand-green-mid), var(--brand-green-dark));
  color: #fff;
  box-shadow: 0 10px 26px rgba(9, 103, 66, 0.28);
}

.kpi-card.kpi-hero::before {
  background: rgba(242, 91, 34, 0.22);
}

.kpi-card.kpi-hero .kpi-label,
.kpi-card.kpi-hero .kpi-caption,
.kpi-card.kpi-hero .kpi-delta .delta-label {
  color: rgba(255, 255, 255, 0.8);
}

.kpi-card.kpi-hero .kpi-icon {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

.kpi-card.kpi-hero .kpi-delta.up { color: #b8f5cf; }
.kpi-card.kpi-hero .kpi-delta.down { color: #ffd0c0; }

.kpi-top {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kpi-label {
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.kpi-icon {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: color-mix(in srgb, var(--accent, var(--brand-green)) 13%, white);
  color: var(--accent, var(--brand-green));
}

.kpi-icon svg {
  width: 17px;
  height: 17px;
}

.kpi-value {
  position: relative;
  font-family: var(--font-display);
  font-size: 27px;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin-top: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-variant-numeric: tabular-nums;
}

.kpi-caption {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  font-weight: 750;
  margin-top: 1px;
  white-space: nowrap;
  overflow: hidden;
}

.kpi-delta.up { color: var(--good-ink); }
.kpi-delta.down { color: var(--bad-ink); }
.kpi-delta.neutral { color: var(--muted); }

.kpi-delta .delta-label {
  color: var(--muted);
  font-weight: 500;
}

.kpi-spark {
  position: relative;
  height: 34px;
  margin-top: auto;
  padding-top: 4px;
}

.kpi-meter {
  margin-top: auto;
  height: 7px;
  border-radius: 999px;
  background: var(--surface-muted);
  overflow: hidden;
}

.kpi-meter > span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent, var(--brand-green)), color-mix(in srgb, var(--accent, var(--brand-green)) 60%, white));
  transition: width 0.6s var(--ease);
}

.kpi-card.skeleton {
  border-color: transparent;
  background: linear-gradient(90deg, #f1efe8 25%, #e8e5db 37%, #f1efe8 63%);
  background-size: 400% 100%;
  animation: shimmer 1.45s ease infinite;
}

.kpi-card.skeleton::before {
  display: none;
}

@keyframes shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: 0 0; }
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 16px 18px 14px;
  border: 1px solid rgba(205, 201, 186, 0.5);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-soft);
}

.panel-trend { grid-column: span 8; }
.panel-category { grid-column: span 4; }
.panel-products { grid-column: span 7; }
.panel-payment { grid-column: span 5; }
.panel-stores { grid-column: span 6; }
.panel-stock { grid-column: span 6; }

.panel-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-title {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  min-width: 0;
}

.panel-icon {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  background: var(--brand-green-soft);
  color: var(--brand-green);
}

.panel-icon.orange {
  background: var(--brand-orange-soft);
  color: var(--brand-orange-dark);
}

.panel-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 750;
  letter-spacing: -0.015em;
}

.panel-header p {
  margin: 3px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding-top: 2px;
}

.export-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink-2);
  padding: 6px 11px;
  font-size: 11.5px;
  font-weight: 700;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease;
}

.export-button svg {
  width: 14px;
  height: 14px;
}

.export-button:hover {
  border-color: rgba(14, 138, 89, 0.4);
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 3px;
  display: inline-block;
}

.legend-dot.series-1 { background: var(--series-1); }
.legend-dot.series-2 { background: var(--series-2); }
.legend-dot.series-4 { background: var(--series-4); }

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-right: 14px;
}

.legend-line {
  display: inline-block;
  width: 16px;
  height: 0;
  border-top: 2.5px solid var(--series-2);
  border-radius: 2px;
}

.panel-actions .seg-tabs {
  margin-bottom: 0;
}

.seg-compact button {
  min-height: 28px;
  padding: 4px 11px;
  font-size: 11.5px;
}

.chart {
  position: relative;
  width: 100%;
  min-width: 0;
}

.chart-trend { height: 230px; }
.chart-return { height: 110px; }
.chart-donut { height: 220px; }
.chart-donut-small { height: 280px; }
.chart-products { height: 250px; }

.trend-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 2px 0 2px 2px;
  color: var(--ink-2);
  font-size: 11px;
  font-weight: 650;
}

.trend-label-return {
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
}

.mini-table {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-top: 8px;
}

.mini-row {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  padding: 8px 6px;
  border-top: 1px solid var(--line-soft);
  font-size: 12px;
}

.mini-row:first-child {
  border-top: 0;
}

.mini-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}

.mini-name {
  color: var(--ink-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-value {
  color: var(--ink);
  font-weight: 750;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.payment-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
  align-items: center;
  flex: 1;
}

.grid-stores { height: 386px; }

.seg-tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 2px;
  padding: 4px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: var(--surface-muted);
}

.seg-tabs button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: 6px 12px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

.seg-tabs button:hover {
  color: var(--brand-green);
}

.seg-tabs button.active {
  background: #fff;
  color: var(--brand-green-dark);
  box-shadow: 0 1px 6px rgba(23, 34, 28, 0.1);
}

.seg-tabs .tab-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--brand-orange-soft);
  color: var(--brand-orange-dark);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.seg-tabs button.active .tab-count {
  background: var(--brand-green-soft);
  color: var(--brand-green-dark);
}
.grid-stock { height: 320px; }

.data-quality {
  display: block;
  margin-top: 8px;
  padding: 9px 11px;
  border-radius: 10px;
  background: var(--surface-soft);
  color: var(--ink-2);
  font-size: 11.5px;
  line-height: 1.45;
}

.data-quality strong {
  color: #9a5b00;
  font-weight: 750;
}

/* ---------- Data tables (sade HTML) ---------- */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.grid {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.table-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid var(--line);
}

.data-table {
  width: 100%;
  min-width: 460px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  font-size: 12.5px;
}

.data-table th {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.data-table th:not([aria-sort]) {
  padding: 10px 8px;
}

.data-table th.num,
.data-table td.num {
  text-align: right;
}

.th-sort {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: 100%;
  min-height: 38px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-transform: inherit;
  transition: color 0.16s ease, background 0.16s ease;
}

th.num .th-sort {
  justify-content: flex-end;
}

.th-sort:hover {
  color: var(--brand-green);
  background: var(--surface-soft);
}

.th-sort.active {
  color: var(--brand-green-dark);
}

.sort-icon {
  font-size: 9px;
  opacity: 0.55;
}

.th-sort.active .sort-icon {
  opacity: 1;
}

.data-table td {
  padding: 9px 8px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  vertical-align: middle;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.data-table tbody tr {
  transition: background 0.14s ease;
}

.data-table tbody tr:hover td {
  background: #f4faf6;
}

.data-table tfoot td {
  position: sticky;
  bottom: 0;
  background: var(--brand-green-soft);
  border-top: 1px solid #cfe7da;
  border-bottom: 0;
  color: var(--brand-green-dark);
  font-weight: 800;
}

.cell-text {
  min-width: 0;
}

.muted-text {
  color: var(--muted);
  font-weight: 600;
}

.bar-cell {
  position: relative;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 4px;
}

.bar-fill {
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(14, 138, 89, 0.22), rgba(14, 138, 89, 0.05));
  pointer-events: none;
}

.bar-cell span {
  position: relative;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  font-weight: 750;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.pill.good { color: var(--good-ink); background: var(--good-soft); }
.pill.warn { color: var(--warn-ink); background: var(--warn-soft); }
.pill.bad { color: var(--bad-ink); background: var(--bad-soft); }
.pill.neutral { color: var(--ink-2); background: var(--surface-muted); }

.rank {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-right: 9px;
  border-radius: 7px;
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 800;
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
}

.rank.top {
  background: var(--brand-orange-soft);
  color: var(--brand-orange-dark);
}

.store-cell {
  display: flex;
  align-items: center;
  min-width: 0;
}

.store-name {
  font-weight: 700;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-sub {
  display: block;
  color: var(--muted);
  font-size: 11px;
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Assistant ---------- */

.assistant-panel {
  position: fixed;
  top: 16px;
  right: 24px;
  bottom: 16px;
  z-index: 50;
  width: var(--assistant-width);
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid rgba(205, 201, 186, 0.6);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(23, 34, 28, 0.16);
  overflow: hidden;
  transition: transform 0.32s var(--ease), opacity 0.22s ease;
}

body.assistant-panel-closed .assistant-panel {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  pointer-events: none;
}

.assistant-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 15px;
  background:
    radial-gradient(260px 140px at 100% 0%, rgba(242, 91, 34, 0.28), transparent 70%),
    linear-gradient(140deg, var(--brand-green-mid), var(--brand-green-dark));
  color: #fff;
}

.assistant-heading {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 11px;
}

.ai-orb {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 13px;
  background: #fff;
  overflow: hidden;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.16);
}

.ai-orb img,
.welcome-orb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 3px;
}

.assistant-title {
  font-family: var(--font-display);
  font-size: 15.5px;
  font-weight: 800;
  letter-spacing: -0.015em;
}

.assistant-subtitle {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.8);
  font-size: 11px;
}

.assistant-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.assistant-header .icon-button,
.assistant-header .ghost-button {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.assistant-header .icon-button:hover,
.assistant-header .ghost-button:hover {
  background: rgba(255, 255, 255, 0.26);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.ghost-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 38px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 12px;
  padding: 0 12px;
  font-size: 12px;
  font-weight: 700;
  transition: background 0.16s ease, border-color 0.16s ease;
}

.ghost-button:hover {
  border-color: rgba(14, 138, 89, 0.4);
  color: var(--brand-green);
}

.assistant-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  background: var(--surface-soft);
}

.welcome-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(280px 160px at 100% 0%, rgba(242, 91, 34, 0.08), transparent 70%),
    #fff;
}

.welcome-orb {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: #fff;
  border: 1px solid var(--line);
  overflow: hidden;
  margin-bottom: 12px;
  color: var(--brand-green);
  font-size: 20px;
}

.welcome-card h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -0.015em;
}

.welcome-card p {
  margin: 6px 0 14px;
  color: var(--ink-2);
  font-size: 12.5px;
  line-height: 1.55;
}

.suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.suggestion {
  position: relative;
  text-align: left;
  border: 1px solid var(--line);
  background: var(--surface-soft);
  color: var(--ink-2);
  padding: 10px 34px 10px 12px;
  border-radius: 12px;
  font-size: 12.5px;
  line-height: 1.4;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease, transform 0.16s ease;
}

.suggestion::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-top: 2px solid currentColor;
  border-right: 2px solid currentColor;
  transform: translateY(-50%) rotate(45deg);
  opacity: 0.35;
  transition: opacity 0.16s ease, right 0.16s ease;
}

.suggestion:hover {
  border-color: rgba(14, 138, 89, 0.45);
  color: var(--brand-green-dark);
  background: var(--brand-green-soft);
}

.suggestion:hover::after {
  opacity: 0.9;
  right: 11px;
}

.message {
  max-width: 94%;
  font-size: 13px;
  line-height: 1.58;
  animation: message-in 0.22s ease;
}

@keyframes message-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  padding: 10px 13px;
  border-radius: 16px 16px 5px 16px;
  background: linear-gradient(135deg, var(--brand-green-mid), var(--brand-green));
  color: #fff;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 4px 12px rgba(9, 103, 66, 0.18);
}

.message.assistant {
  align-self: stretch;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px 16px 16px 5px;
  background: #fff;
  color: var(--ink);
  word-break: break-word;
}

.message.assistant .md p { margin: 0 0 8px; }
.message.assistant .md p:last-child { margin-bottom: 0; }
.message.assistant .md strong { font-weight: 750; }

.message.assistant .md ul,
.message.assistant .md ol {
  margin: 6px 0 8px;
  padding-left: 18px;
}

.message.assistant .md li { margin: 2px 0; }

.message.assistant .md table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 11.5px;
}

.message.assistant .md th,
.message.assistant .md td {
  border-bottom: 1px solid var(--line);
  padding: 6px 6px;
  text-align: left;
}

.message.assistant .md th {
  color: var(--muted);
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.message.assistant .md code {
  background: var(--surface-muted);
  border-radius: 4px;
  padding: 1px 4px;
  font-size: 11px;
}

.message.assistant .md pre {
  background: #13201a;
  color: #d9f2e4;
  padding: 9px;
  border-radius: 9px;
  overflow: auto;
  font-size: 10.5px;
}

.message.assistant .md pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.message.assistant.is-error {
  border-color: #f3c5c5;
  background: #fff6f6;
}

.message-meta {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 9px;
}

.tool-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.tool-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--surface-muted);
  color: var(--ink-2);
  font-size: 10.5px;
  font-weight: 650;
}

.tool-chip.running { background: var(--brand-orange-soft); color: var(--brand-orange-dark); }
.tool-chip.done { background: var(--good-soft); color: var(--good-ink); }
.tool-chip.error { background: var(--bad-soft); color: var(--bad-ink); }

.tool-chip .chip-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.tool-chip.running .chip-dot {
  animation: pulse 1s ease infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

.export-card {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  padding: 11px 12px;
  border: 1px solid #cfe7da;
  border-radius: 12px;
  background: var(--brand-green-soft);
  color: var(--ink);
  text-decoration: none;
  transition: border-color 0.16s ease, background 0.16s ease;
}

.export-card:hover {
  border-color: var(--brand-green-mid);
  background: #dcf0e5;
}

.export-icon {
  flex: 0 0 auto;
  border-radius: 7px;
  background: var(--brand-green);
  color: #fff;
  padding: 6px 7px;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.export-text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
  gap: 2px;
}

.export-text strong {
  font-size: 12px;
  font-weight: 750;
}

.export-text small {
  overflow: hidden;
  color: var(--muted);
  font-size: 10.5px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.export-action {
  flex: 0 0 auto;
  color: var(--brand-green-dark);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.tech-details {
  border-top: 1px dashed var(--line);
  padding-top: 6px;
}

.tech-details summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  list-style: none;
}

.tech-details summary::-webkit-details-marker { display: none; }
.tech-details summary::before { content: "▸ "; }
.tech-details[open] summary::before { content: "▾ "; }

.tech-details pre {
  margin: 6px 0 0;
  max-height: 150px;
  overflow: auto;
  background: #13201a;
  color: #d9f2e4;
  border-radius: 9px;
  padding: 9px;
  font-size: 10px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-size: 12px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-orange);
  animation: typing 1.2s infinite ease-in-out;
}

.typing i:nth-child(2) { animation-delay: 0.15s; background: var(--brand-green-mid); }
.typing i:nth-child(3) { animation-delay: 0.3s; }

.typing-text { margin-left: 4px; }

@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-3px); opacity: 1; }
}

.assistant-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line-soft);
  background: #fff;
}

.assistant-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 112px;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface-soft);
  padding: 11px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--ink);
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.send-button {
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, #ff7a45, var(--brand-orange));
  color: #fff;
  box-shadow: 0 7px 16px rgba(242, 91, 34, 0.3);
  transition: filter 0.16s ease, opacity 0.16s ease, transform 0.16s ease;
}

.send-button:hover { filter: brightness(1.05); }
.send-button:active { transform: scale(0.96); }

.send-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.assistant-footer {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px 12px;
  color: var(--muted);
  font-size: 11px;
}

.assistant-footer .mini-dot,
.mini-dot.status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--warning);
}

.assistant-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 55;
  display: none;
  align-items: center;
  gap: 9px;
  border: 0;
  border-radius: 999px;
  padding: 8px 18px 8px 8px;
  background: linear-gradient(135deg, #ff7a45, var(--brand-orange));
  color: #fff;
  font-size: 13.5px;
  font-weight: 750;
  box-shadow: 0 14px 32px rgba(242, 91, 34, 0.38);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.assistant-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 38px rgba(242, 91, 34, 0.45);
}

.assistant-fab img {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: 50%;
  background: #fff;
  padding: 2px;
}

body.assistant-panel-closed .assistant-fab {
  display: inline-flex;
}

/* ---------- Loading & toast ---------- */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  background: rgba(246, 244, 238, 0.74);
  backdrop-filter: blur(6px);
  color: var(--ink-2);
  font-size: 13px;
  font-weight: 600;
}

.loader {
  position: relative;
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
}

.loader::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 3px solid rgba(242, 91, 34, 0.16);
  border-top-color: var(--brand-orange);
  border-right-color: var(--brand-green-mid);
  animation: spin 0.9s linear infinite;
}

.loader img {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: contain;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  z-index: 90;
  max-width: min(520px, calc(100vw - 32px));
  padding: 11px 16px;
  border-radius: 12px;
  background: #13201a;
  color: #f4faf6;
  font-size: 12.5px;
  box-shadow: 0 14px 40px rgba(19, 32, 26, 0.3);
}

/* ---------- Empty / warning states ---------- */

.panel-empty {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

.panel-empty strong {
  color: var(--ink-2);
  font-size: 13.5px;
}

.chart-empty {
  display: flex;
  height: 100%;
  min-height: 64px;
  align-items: center;
  justify-content: center;
  border: 1px dashed var(--line);
  border-radius: 12px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Product table ---------- */

.product-table-wrap {
  margin-top: 6px;
  max-height: 260px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
}

.product-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.product-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 10.5px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
  white-space: nowrap;
}

.product-table td {
  padding: 8px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-table tbody tr {
  transition: background 0.14s ease;
}

.product-table tbody tr:hover td {
  background: #f4faf6;
}

.product-table th:nth-child(1),
.product-table td:nth-child(1) { width: 38px; text-overflow: clip; }

.product-table .rank {
  margin-right: 0;
}
.product-table th:nth-child(3),
.product-table td:nth-child(3) { width: 15%; }
.product-table th:nth-child(4),
.product-table td:nth-child(4) { width: 13%; }
.product-table th:nth-child(5),
.product-table td:nth-child(5) { width: 14%; }
.product-table th:nth-child(6),
.product-table td:nth-child(6) { width: 10%; }

.product-table .pt-title {
  display: flex;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.product-table .pt-title .mini-dot {
  flex: 0 0 auto;
}

.product-table .kpi-delta {
  margin: 0;
  font-size: 11px;
}

.compact-select {
  height: 32px;
  max-width: 170px;
  padding: 0 28px 0 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-soft);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
}

.compact-select:hover {
  border-color: var(--line-strong);
}

.compact-select:focus {
  outline: none;
  border-color: var(--brand-green-mid);
  box-shadow: var(--focus);
}

.product-table .pt-code {
  color: var(--muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.product-table .pt-name {
  color: var(--ink);
  font-weight: 650;
}

.product-table .pt-name small {
  margin-left: 6px;
  color: var(--muted);
  font-weight: 500;
}

.product-table .pt-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product-table td.pt-num strong {
  color: var(--ink);
  font-weight: 750;
}

/* ---------- Clickable payment row ---------- */

.mini-row.clickable {
  cursor: pointer;
  border-radius: 9px;
  transition: background 0.16s ease;
}

.mini-row.clickable:hover {
  background: var(--brand-green-soft);
}

.mini-row.clickable:focus-visible {
  outline: 2px solid var(--brand-green-mid);
  outline-offset: 1px;
}

.mini-row.clickable .mini-name {
  color: var(--brand-green-dark);
  font-weight: 700;
}

.mini-row.clickable .mini-name::after {
  content: " ↗";
  color: var(--brand-green-mid);
  font-size: 10px;
}

/* ---------- Card breakdown modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 75;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(19, 32, 26, 0.45);
  backdrop-filter: blur(4px);
}

.modal-card {
  width: min(740px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: 0 24px 70px rgba(19, 32, 26, 0.3);
  animation: message-in 0.22s ease;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-header h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: -0.02em;
}

.modal-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
  gap: 16px;
  align-items: center;
  padding: 16px 20px 8px;
}

.modal-body .chart-donut {
  height: 260px;
  margin: 0;
}

.modal-footer {
  padding: 0 20px 18px;
  color: var(--muted);
  font-size: 11.5px;
}

/* ---------- Footer ---------- */

.app-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 26px;
  padding: 0 4px;
  color: var(--muted);
  font-size: 11.5px;
}

.app-footer em {
  color: var(--brand-orange-dark);
  font-style: italic;
  font-weight: 600;
}

/* ---------- Responsive ---------- */

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

@media (max-width: 1360px) {
  .panel-products,
  .panel-payment,
  .panel-stores,
  .panel-stock {
    grid-column: span 12;
  }
}

@media (max-width: 1200px) {
  body:not(.assistant-panel-closed) .app-shell {
    padding-right: 24px;
  }

  .assistant-panel {
    top: 12px;
    right: 12px;
    bottom: 12px;
    width: min(var(--assistant-width), calc(100vw - 24px));
    transform: translateX(calc(100% + 24px));
    opacity: 0;
    pointer-events: none;
  }

  body.assistant-panel-open .assistant-panel {
    transform: translateX(0);
    opacity: 1;
    pointer-events: auto;
  }

  .assistant-fab { display: inline-flex; }
  body.assistant-panel-open .assistant-fab { display: none; }

  .panel-trend,
  .panel-category {
    grid-column: span 12;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: 10px 14px 34px;
  }

  .topbar {
    position: static;
    flex-wrap: wrap;
  }

  .page-head {
    flex-direction: column;
    align-items: flex-start;
    margin-top: 16px;
  }

  .page-head h1 { font-size: 22px; }

  .filter-bar {
    position: static;
    flex-direction: column;
    align-items: stretch;
  }

  .filter-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .field-store { min-width: 0; }
  .field-store select { max-width: none; }

  .primary-button { width: 100%; }
  .quick-ranges { align-self: flex-start; }

  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .payment-body { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .brand-subtitle,
  .freshness {
    display: none;
  }

  .filter-grid { grid-template-columns: 1fr; }
  .kpi-row { grid-template-columns: 1fr; }
  .kpi-card { min-height: 120px; }

  .chart-trend { height: 200px; }
  .chart-return { height: 96px; }
  .grid-stores { height: 360px; }

  .panel { padding: 14px; }

  .app-footer {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 700px) {
  .modal-body { grid-template-columns: 1fr; }
  .modal-body .chart-donut { height: 220px; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---------- Reyon payı (renkli yatay çubuk + tablo) ---------- */

.reyon-crumb {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.reyon-crumb .ghost-button {
  min-height: 32px;
}

.reyon-crumb-name {
  font-weight: 800;
  color: var(--brand-green-dark);
  font-size: 13px;
}

.chart-reyon {
  height: 188px;
}

.reyon-table-wrap {
  margin-top: 6px;
  max-height: 240px;
  overflow: auto;
  border-top: 1px solid var(--line-soft);
}

.reyon-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.reyon-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.reyon-table th:first-child { width: 42%; }

.reyon-table th.num,
.reyon-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.reyon-table td {
  padding: 6px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reyon-table td:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reyon-table .mini-dot {
  flex: 0 0 auto;
}

.reyon-table .reyon-name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 650;
}

.reyon-table .kpi-delta {
  margin: 0;
  font-size: 11px;
}

.reyon-table tr.clickable {
  cursor: pointer;
  transition: background 0.14s ease;
}

.reyon-table tr.clickable:hover td,
.reyon-table tr.clickable:focus-visible td {
  background: var(--brand-green-soft);
}

.reyon-table tr.clickable:focus-visible {
  outline: 2px solid var(--brand-green-mid);
  outline-offset: -2px;
}

/* ---------- Ödeme dağılımı (halka + açılır tablo) ---------- */

.chart-pay {
  height: 190px;
}

.pay-table-wrap {
  margin-top: 6px;
  border-top: 1px solid var(--line-soft);
  overflow-x: auto;
}

.pay-table {
  width: 100%;
  min-width: 380px;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 12px;
}

.pay-table th {
  padding: 7px 6px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 10px;
  font-weight: 750;
  letter-spacing: 0.05em;
  text-align: left;
  text-transform: uppercase;
}

.pay-table th:nth-child(1) { width: 33%; }
.pay-table th:nth-child(2) { width: 20%; }
.pay-table th:nth-child(3) { width: 14%; }
.pay-table th:nth-child(4) { width: 15%; }
.pay-table th:nth-child(5) { width: 18%; }

.pay-table th.num,
.pay-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.pay-table td {
  padding: 7px 6px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pay-table td:first-child {
  display: flex;
  align-items: center;
  gap: 7px;
}

.pay-group td {
  color: var(--ink);
  font-weight: 700;
}

.pay-detail td {
  background: var(--surface-soft);
  font-size: 11.5px;
}

.pay-detail td:first-child {
  padding-left: 44px;
}

.pay-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

.pay-fx {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.pay-toggle,
.pay-toggle-spacer {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
}

.pay-toggle {
  display: inline-grid;
  place-items: center;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink-2);
  font-size: 11px;
  line-height: 1;
  transition: border-color 0.16s ease, color 0.16s ease, background 0.16s ease;
}

.pay-toggle:hover {
  border-color: rgba(14, 138, 89, 0.45);
  color: var(--brand-green);
  background: var(--brand-green-soft);
}

.pay-table .mini-dot {
  flex: 0 0 auto;
}

/* ---------- Kasa performansı · saatlik yoğunluk ---------- */

.chart-pos-hourly {
  height: 300px;
}

.store-name .mini-dot {
  display: inline-block;
  vertical-align: middle;
  margin-right: 2px;
}

/* ---------- Asistan: esnek genişlik, geçmiş, tablo araçları ---------- */

.assistant-panel {
  transition: transform 0.32s var(--ease), opacity 0.22s ease, width 0.28s var(--ease);
}

body.is-resizing,
body.is-resizing * {
  cursor: ew-resize !important;
  user-select: none !important;
}

body.is-resizing .assistant-panel,
body.is-resizing .app-shell {
  transition: none !important;
}

.assistant-resizer {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 4;
  width: 9px;
  cursor: ew-resize;
  touch-action: none;
}

.assistant-resizer::after {
  content: "";
  position: absolute;
  left: 3px;
  top: 50%;
  width: 3px;
  height: 46px;
  transform: translateY(-50%);
  border-radius: 999px;
  background: var(--line-strong);
  opacity: 0;
  transition: opacity 0.16s ease, background 0.16s ease;
}

.assistant-panel:hover .assistant-resizer::after,
.assistant-resizer:focus-visible::after,
body.is-resizing .assistant-resizer::after {
  opacity: 1;
}

.assistant-resizer:hover::after,
body.is-resizing .assistant-resizer::after {
  background: var(--brand-green-mid);
}

.assistant-resizer:focus-visible {
  outline: none;
}

#widthToggle .icon-narrow,
#widthToggle.is-wide .icon-widen {
  display: none;
}

#widthToggle.is-wide .icon-narrow {
  display: block;
}

.send-button .icon-stop,
.send-button.is-stop .icon-send {
  display: none;
}

.send-button.is-stop .icon-stop {
  display: block;
}

.send-button.is-stop {
  background: linear-gradient(135deg, #3b4a42, #17221c);
  box-shadow: 0 7px 16px rgba(23, 34, 28, 0.25);
}

/* geçmiş paneli */
.history-panel {
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-top: 1px solid var(--line-soft);
}

.history-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.history-head strong {
  font-size: 14px;
}

.history-note {
  margin-right: auto;
  color: var(--muted);
  font-size: 11px;
}

.history-head .ghost-button,
.history-head .icon-button {
  min-height: 34px;
  height: 34px;
}

.history-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.history-ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item {
  display: flex;
  align-items: stretch;
  gap: 4px;
  border-radius: 12px;
  transition: background 0.14s ease;
}

.history-item:hover {
  background: var(--surface-soft);
}

.history-item.current {
  background: var(--brand-green-soft);
}

.history-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  border-radius: 12px;
}

.history-title {
  font-size: 13px;
  font-weight: 650;
  color: var(--ink);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-meta {
  font-size: 11px;
  color: var(--muted);
}

.history-delete {
  flex: 0 0 auto;
  align-self: center;
  min-width: 36px;
  height: 36px;
  margin-right: 6px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}

.history-delete:hover {
  color: var(--bad-ink);
  background: var(--bad-soft);
}

.history-delete.confirm {
  padding: 0 10px;
  color: #fff;
  background: var(--critical);
  border-color: var(--critical);
}

.history-empty {
  padding: 24px 12px;
  color: var(--muted);
  font-size: 12.5px;
  text-align: center;
}

/* sohbet tabloları */
.message.assistant .md-table {
  margin: 10px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.md-table-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--line-soft);
}

.md-table-info {
  margin-right: auto;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.md-tool {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-2);
  font-size: 11.5px;
  font-weight: 700;
  transition: border-color 0.14s ease, color 0.14s ease, background 0.14s ease;
}

.md-tool:hover {
  border-color: rgba(14, 138, 89, 0.45);
  color: var(--brand-green-dark);
  background: var(--brand-green-soft);
}

.md-tool:disabled {
  opacity: 0.6;
  cursor: progress;
}

.md-tool.subtle {
  border-color: transparent;
  background: transparent;
  color: var(--muted);
}

.md-table-scroll {
  max-height: 420px;
  overflow: auto;
}

.message.assistant .md-table table {
  margin: 0;
  min-width: 100%;
  width: max-content;
  font-size: 12px;
}

.message.assistant .md-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #fff;
  white-space: nowrap;
}

.message.assistant .md-table td {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.message.assistant .md-table tbody tr:nth-child(even) td {
  background: var(--surface-soft);
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

/* Pano, asistan paneli genişledikçe kendi genişliğine göre yeniden dizilir (ekran genişliğinden bağımsız). */
.dashboard {
  container-type: inline-size;
  container-name: dash;
}

@container dash (max-width: 1040px) {
  .kpi-row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .panel-trend,
  .panel-category {
    grid-column: span 12;
  }
}

@container dash (max-width: 880px) {
  .panel-products,
  .panel-payment,
  .panel-stores,
  .panel-stock {
    grid-column: span 12;
  }
}

@container dash (max-width: 520px) {
  .kpi-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
