@import url('https://fonts.googleapis.com/css2?family=Assistant:wght@300;400;500;600;700;800&display=swap');

:root {
  /* Aran Cucine brand: black / red / white (aranisrael.co.il) */
  --navy: #171717;
  --navy-deep: #000000;
  --brand: #c1121f;
  --brand-soft: #e0525c;
  --brand-wash: rgba(193, 18, 31, 0.08);
  --ink: #171717;
  --muted: #5a5a60;
  --muted-strong: #3d3d42;
  --line: #e6e6e8;
  --surface: #f7f7f8;
  --card: #ffffff;
  --success: #1f8a5b;
  --success-wash: rgba(31, 138, 91, 0.1);
  --warn: #b7791f;
  --warn-wash: rgba(183, 121, 31, 0.12);
  --danger: #c0392b;
  --whatsapp: #123c2d;
  --whatsapp-hover: #0e3226;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.07);
  --radius: 16px;
  --radius-sm: 10px;
  --sidebar-w: 260px;
  --font: 'Assistant', system-ui, sans-serif;
}

* { box-sizing: border-box; }
html { direction: rtl; }
html[dir="ltr"] {
  direction: ltr;
}
html[dir="ltr"] body,
html[dir="ltr"] .app,
html[dir="ltr"] .modal,
html[dir="ltr"] .modal-backdrop {
  direction: ltr;
  text-align: start;
}
html[dir="ltr"] .field label,
html[dir="ltr"] .field input,
html[dir="ltr"] .field select,
html[dir="ltr"] .field textarea,
html[dir="ltr"] .modal h2 {
  text-align: left;
}
html[dir="ltr"] table.data th,
html[dir="ltr"] table.data td {
  text-align: left;
}
html[dir="ltr"] .metric {
  text-align: left;
}
body {
  margin: 0;
  font-family: var(--font);
  font-weight: 400;
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--surface);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; }

/* ---------- LOGIN ---------- */
.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background-color: #d8d8dc;
  background-image:
    radial-gradient(ellipse 80% 60% at 50% 40%, #ececef 0%, transparent 70%),
    linear-gradient(rgba(23, 23, 23, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 23, 23, 0.04) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}
.login-wrap {
  width: min(420px, 100%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
.login-card {
  width: 100%;
  background: #fff;
  border-radius: 18px;
  padding: 40px 36px 32px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 12px 28px rgba(0, 0, 0, 0.1),
    0 28px 64px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.7);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: var(--brand);
}
.login-card h1 {
  margin: 0 0 8px;
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--navy);
  letter-spacing: -0.01em;
}
.login-card .sub {
  text-align: center;
  color: var(--muted);
  margin: 0 0 26px;
  font-size: 0.9rem;
  font-weight: 400;
}
.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  margin-bottom: 7px;
  color: var(--navy);
}
.field input, .field select, .field textarea {
  width: 100%;
  border: 1.5px solid #c9c9cd;
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  background: #efeff1;
  color: var(--ink);
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
.field input::placeholder { color: #9a9aa0; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: #fff;
  box-shadow: 0 0 0 4px var(--brand-wash);
}
.login-logo {
  display: block;
  width: min(168px, 52vw);
  margin: 0 auto 22px;
  background: transparent;
  border-radius: 0;
  padding: 0;
}
.sidebar-logo {
  width: 78%;
  max-width: 160px;
  height: auto;
  background: transparent;
  border-radius: 0;
  padding: 0;
  margin: 0 auto 10px;
  display: block;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  background: #c1121f;
  color: #fff;
  box-shadow: 0 4px 14px rgba(193, 18, 31, 0.18);
  width: 100%;
  margin-top: 8px;
}
.btn-primary:hover {
  background: #a80f1a;
  box-shadow: 0 6px 16px rgba(193, 18, 31, 0.22);
}
.btn-primary:focus-visible {
  outline: 2px solid #c1121f;
  outline-offset: 2px;
}
.btn-login {
  background: var(--brand);
  box-shadow: 0 10px 22px rgba(193, 18, 31, 0.28);
  font-weight: 700;
  padding: 14px 20px;
  margin-top: 6px;
}
.btn-login:hover {
  background: #a30e19;
  box-shadow: 0 12px 26px rgba(193, 18, 31, 0.35);
}
.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--line);
}
.btn-soft { background: var(--brand-wash); color: var(--brand); }
.btn-danger {
  background: #fdecea;
  color: var(--danger);
  border: 1.5px solid #f0c4bf;
}
.btn-danger:hover {
  background: #f8d7d3;
  border-color: #e5a59d;
}
.btn-danger:focus-visible {
  outline: 2px solid var(--danger);
  outline-offset: 2px;
}
.login-hint {
  margin-top: 16px;
  padding: 12px 14px;
  background: #fdecea;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  color: var(--danger);
  text-align: center;
}
.login-foot {
  margin: 0;
  text-align: center;
  font-size: 0.75rem;
  color: #6b6b70;
  font-weight: 400;
}

/* ---------- APP SHELL ---------- */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
  background: linear-gradient(180deg, var(--navy-deep) 0%, #0a0a0a 60%, var(--navy) 100%);
  border-inline-end: 3px solid var(--brand);
  color: #fff;
  padding: 28px 18px 24px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
}
.sidebar-brand {
  text-align: center;
  padding: 4px 8px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  margin-bottom: 18px;
}
.sidebar-brand strong { display: block; font-size: 1rem; font-weight: 800; letter-spacing: 0.02em; }
.sidebar-brand span { display: block; font-size: 0.72rem; font-weight: 300; opacity: 0.5; margin-top: 4px; }
.nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav a, .nav button {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 14px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.95rem;
  font-weight: 500;
  background: none;
  border: none;
  width: 100%;
  text-align: right;
  cursor: pointer;
}
.nav a:hover, .nav button:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.nav a.active {
  background: rgba(193, 18, 31, 0.28);
  color: #fff;
  font-weight: 700;
}
.sidebar-foot { padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.08); font-size: 0.78rem; opacity: 0.45; text-align: center; }

.main { padding: 28px 36px 48px; overflow-x: hidden; max-width: 100%; }
.topbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin-bottom: 28px; flex-wrap: wrap; }
.topbar h1 { margin: 0 0 6px; font-size: clamp(1.4rem, 2vw, 1.8rem); font-weight: 700; color: var(--navy); }
.topbar p { margin: 0; color: var(--muted); font-size: 0.95rem; font-weight: 300; }
.topbar-actions { display: flex; gap: 10px; flex-shrink: 0; }

/* ---------- METRICS ---------- */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.metric .label { font-size: 0.8rem; color: var(--muted); margin-bottom: 10px; }
.metric .value { font-size: 1.8rem; font-weight: 800; color: var(--navy); letter-spacing: -0.02em; }
.metric .delta { margin-top: 10px; font-size: 0.8rem; font-weight: 500; }
.delta.up { color: var(--success); }
.delta.warn { color: var(--warn); }
.delta.flat { color: var(--muted); }

.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }

/* ---------- SEARCH / FILTERS ---------- */
.search-bar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.search-bar input[type="search"] { flex: 1; min-width: 200px; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 11px 14px; background: #fff; }
.search-bar input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.filter-row { display: flex; gap: 8px; margin-bottom: 18px; flex-wrap: wrap; }
.chip {
  border: 1.5px solid var(--line);
  border-radius: 4px;
  padding: 8px 14px;
  font-size: 0.82rem;
  font-weight: 700;
  background: #fff;
  color: var(--muted-strong);
  cursor: pointer;
  min-height: 36px;
}
.chip:hover { border-color: #c9c9cd; color: var(--navy); }
.chip:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.chip.active { border-color: transparent; color: #fff; }

/* ---------- TABLE ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.leads-table col.col-name { width: 8rem; }
.leads-table col.col-note { width: 14rem; }
.leads-table col.col-source { width: 8.75rem; }
.leads-table col.col-audience,
.leads-table col.col-ad { width: 9.5rem; }
.leads-table col.col-platform { width: 3.6rem; }
table.data th {
  text-align: right;
  padding: 14px 14px;
  font-size: 0.84rem;
  font-weight: 800;
  color: var(--navy);
  background: #f0f0f2;
  border-bottom: 2px solid #d8d8dc;
  white-space: nowrap;
  letter-spacing: 0.01em;
}
table.data td { padding: 14px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink); }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr { cursor: pointer; transition: background 0.15s; }
table.data tbody tr:nth-child(even) { background: #fafafb; }
table.data tbody tr:hover { background: #f3f5f9; }
.lead-unread { box-shadow: inset 3px 0 0 var(--brand); background: rgba(193, 18, 31, 0.04); }
.lead-name {
  font-weight: 700;
  color: var(--navy);
  display: block;
  line-height: 1.25;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Content sets bidi for correct truncation; UI lang sets visual alignment */
  unicode-bidi: plaintext;
  text-align: right;
}
html[dir="ltr"] .lead-name {
  text-align: left;
}
.cell-name {
  width: 1%;
  max-width: 8rem;
  min-width: 0;
}
.lead-note {
  display: block;
  margin-top: 3px;
  font-size: 0.84rem;
  font-weight: 500;
  color: var(--muted-strong);
  line-height: 1.35;
  max-width: 220px;
}
.cell-secondary {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted-strong);
  white-space: nowrap;
}
/* Source column: room for icon + «Клиент назначил» on two lines at a slightly smaller size. */
.cell-source {
  width: 1%;
  min-width: 8rem;
  max-width: 9.5rem;
  overflow: hidden;
  white-space: normal;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.25;
  color: var(--ink);
  text-align: start;
  vertical-align: middle;
}
.cell-note {
  width: 14rem;
  max-width: 16rem;
  min-width: 12rem;
  box-sizing: border-box;
  text-align: start;
  white-space: normal;
  vertical-align: middle;
}
.cell-audience,
.cell-ad {
  width: 1%;
  max-width: 9.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.86rem;
  text-align: start;
}
.cell-platform {
  width: 3.2rem;
  max-width: 3.6rem;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  white-space: nowrap;
}
.lead-meta { font-size: 0.84rem; color: var(--muted-strong); margin-top: 2px; font-weight: 500; }
.pulse {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand);
  box-shadow: 0 0 0 0 rgba(193, 18, 31, 0.5);
  animation: pulse 1.8s infinite;
  flex-shrink: 0;
}
@keyframes pulse {
  70% { box-shadow: 0 0 0 8px rgba(193, 18, 31, 0); }
  100% { box-shadow: 0 0 0 0 rgba(193, 18, 31, 0); }
}
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.78rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  border: none;
  line-height: 1.25;
  box-sizing: border-box;
}
/* Status + repeat count share one flex row so heights match. */
.status-badges {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  vertical-align: middle;
}
/* Repeat phone count — same padding/type as .badge for equal height. */
.phone-repeat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  align-self: stretch;
  min-width: 1.75rem;
  margin: 0;
  padding: 5px 10px;
  border: none;
  border-radius: 4px;
  background: #46799C;
  color: #fff;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.25;
  cursor: pointer;
  box-sizing: border-box;
}
.phone-repeat-count:hover {
  filter: brightness(1.08);
}
.deal-sum { font-weight: 800; color: var(--success); letter-spacing: -0.01em; }
.wa-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--whatsapp); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 15px;
}
.wa-btn:hover { opacity: 0.85; }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: nowrap; white-space: nowrap; }

/* Keep edit/delete visible when the wide table scrolls horizontally */
table.data th:last-child,
table.data td:last-child {
  position: sticky;
  inset-inline-end: 0;
  z-index: 2;
  background: #fff;
  box-shadow: -6px 0 10px -8px rgba(15, 17, 21, 0.18);
}
html[dir="ltr"] table.data th:last-child,
html[dir="ltr"] table.data td:last-child {
  box-shadow: 6px 0 10px -8px rgba(15, 17, 21, 0.18);
}
table.data tbody tr:nth-child(even) td:last-child { background: #fafafb; }
table.data tbody tr:hover td:last-child { background: #f3f5f9; }
table.data thead th:last-child { background: #f7f7f8; z-index: 3; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--line); background: #fff;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--muted);
}
.icon-btn:hover { background: var(--brand-wash); color: var(--brand); border-color: rgba(193, 18, 31, 0.3); }

/* ---------- LEAD DETAIL ---------- */
.detail-grid { display: grid; grid-template-columns: 1fr 340px; gap: 18px; align-items: start; }
.detail-main, .detail-side { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.detail-main { padding: 24px 26px; }
.detail-side { padding: 20px; position: sticky; top: 24px; }
.side-block { margin-bottom: 20px; }
.side-block:last-child { margin-bottom: 0; }
.side-block h3 { margin: 0 0 10px; font-size: 0.82rem; font-weight: 800; color: var(--navy); letter-spacing: 0.02em; }
.side-block-quiet h3 { color: var(--muted-strong); font-weight: 700; }
.side-block select, .side-block input[type="number"], .side-block input[type="text"], .side-block input[type="datetime-local"], .side-block input[type="date"], .side-block input[type="time"], .side-block input[type="email"], .side-block input[type="tel"], .side-block textarea {
  width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: 8px; background: #fff;
}
.side-block label { display: block; font-size: 0.78rem; font-weight: 700; color: var(--muted-strong); margin: 8px 0 4px; }
.field-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.phone-edit-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.phone-edit-row input { flex: 1; margin-bottom: 0 !important; }
.cal-section { margin-top: 28px; }
.cal-section-title {
  margin: 0 0 12px;
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--navy);
}
.stats-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 14px 20px;
  margin: 0 0 18px;
  position: relative;
  z-index: 1;
  overflow: visible;
}
.stats-compare-hint {
  margin: 6px 0 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted-strong);
}
.stats-all-time-btn {
  box-sizing: border-box;
  height: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 2px solid #9a9aa1;
  border-radius: 10px;
  background: #fff;
  color: #141418;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease;
}
.stats-all-time-btn:hover {
  background: #fafafa;
  border-color: #6f6f76;
}
.stats-all-time-btn:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.stats-all-time-btn.is-active {
  background: #46799c;
  border-color: #46799c;
  color: #fff;
}

/* Google Ads-style chart */
.stats-chart-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px 18px;
  margin: 0 0 20px;
}
.stats-chart-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}
.stats-chart-card {
  appearance: none;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  background: #fff;
  padding: 14px 16px;
  text-align: start;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, box-shadow 160ms ease;
  min-height: 72px;
  color: var(--navy);
}
.stats-chart-card:hover {
  border-color: color-mix(in srgb, var(--series, var(--brand)) 45%, var(--line));
}
.stats-chart-card:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}
.stats-chart-card.is-on {
  background: var(--series, var(--brand));
  border-color: var(--series, var(--brand));
  color: #fff;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--series, var(--brand)) 28%, transparent);
}
.stats-chart-card-label {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 6px;
}
.stats-chart-card-value {
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.1;
}
.stats-chart-grain {
  margin: 0 0 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
}
.stats-chart-canvas-wrap {
  position: relative;
  width: 100%;
  min-height: 240px;
}
.stats-chart-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 300px;
  cursor: crosshair;
}
.stats-chart-tip {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  min-width: 140px;
  max-width: 220px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 28px rgba(20, 20, 24, 0.14);
  pointer-events: none;
  font-size: 0.8rem;
}
.stats-chart-tip-title {
  font-weight: 800;
  color: var(--navy);
  margin-bottom: 8px;
}
.stats-chart-tip-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
  color: var(--muted-strong);
}
.stats-chart-tip-row .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.stats-chart-tip-row strong {
  margin-inline-start: auto;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 720px) {
  .stats-chart-cards { grid-template-columns: 1fr; }
}
.stats-date-mount { flex: 0 1 auto; }
.stats-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1 1 280px;
}
.stats-filter {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  flex: 1 1 160px;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted-strong);
}
.stats-filter select {
  min-height: 44px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 6px 10px;
  font: inherit;
  font-weight: 600;
  color: var(--navy);
  background: #fff;
}
.stats-table-panel { margin-bottom: 16px; overflow: visible; }
.stats-table-panel .table-wrap { overflow-x: auto; margin-top: 10px; }
.stats-effectiveness-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
}
.stats-effectiveness-head h3 { margin: 0; }
.stats-view-tabs {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px;
  border-radius: 12px;
  background: #eceef3;
}
.stats-view-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #3a3f4d;
  font: inherit;
  font-weight: 800;
  font-size: 0.86rem;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  min-height: 40px;
  transition: background 0.15s, color 0.15s;
}
.stats-view-tab:hover { background: rgba(255, 255, 255, 0.65); }
.stats-view-tab.is-active {
  background: #fff;
  color: var(--navy, #14213d);
  box-shadow: 0 1px 3px rgba(20, 33, 61, 0.12);
}
.stats-table-panel .data tfoot tr {
  background: #f3f4f8;
  border-top: 2px solid #c9cdd8;
  font-weight: 800;
}
.stats-table-panel .data tfoot td {
  padding-top: 12px;
  padding-bottom: 12px;
  color: var(--navy, #14213d);
}
#audience-ad-table thead th[data-sort],
#branch-quality-table thead th[data-sort] {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
#audience-ad-table thead th[data-sort].is-sorted,
#branch-quality-table thead th[data-sort].is-sorted { color: var(--brand); }
#audience-ad-table thead th[data-sort].is-sorted-asc::after,
#branch-quality-table thead th[data-sort].is-sorted-asc::after { content: ' ▲'; font-size: 0.7em; }
#audience-ad-table thead th[data-sort].is-sorted-desc::after,
#branch-quality-table thead th[data-sort].is-sorted-desc::after { content: ' ▼'; font-size: 0.7em; }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}
.stats-bars { display: flex; flex-direction: column; gap: 10px; }
.stats-bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 40px;
  gap: 10px;
  align-items: center;
}
.stats-bar-label { font-size: 0.88rem; font-weight: 700; color: var(--navy); }
.stats-bar-track {
  height: 10px;
  background: #ececef;
  border-radius: 999px;
  overflow: hidden;
}
.stats-bar-track span {
  display: block;
  height: 100%;
  border-radius: 999px;
  min-width: 2px;
}
.stats-bar-count { font-weight: 800; color: var(--navy); text-align: left; }
.panel.side-block { padding: 18px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.log-entry { border-bottom: 1px solid var(--line); padding: 14px 0; }
.log-entry:last-child { border-bottom: none; }
.log-entry .log-meta { font-size: 0.82rem; color: var(--muted-strong); margin-bottom: 4px; font-weight: 600; }
.log-entry .log-note { font-size: 0.95rem; color: var(--ink); white-space: pre-wrap; }
.log-form textarea { width: 100%; border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px; min-height: 80px; margin-bottom: 10px; resize: vertical; }
.log-form textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-wash); }
.immutable-hint { font-size: 0.82rem; color: var(--muted-strong); margin-top: 8px; text-align: center; font-weight: 600; }

@media (max-width: 1100px) {
  .metrics { grid-template-columns: repeat(2, 1fr); }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-side { position: static; }
  .stats-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 8px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .sidebar-foot { display: none; }
  .main { padding: 20px 16px 40px; }
  table.data { font-size: 0.85rem; }
  .field-row-2 { grid-template-columns: 1fr; }
  .stats-bar-row { grid-template-columns: 90px 1fr 36px; }
}
