:root {
  --bg: #edf4fb;
  --surface: #ffffff;
  --surface-soft: #f4f9ff;
  --line: #cddded;
  --text: #10263f;
  --muted: #5d7893;
  --accent: #006da8;
  --accent-2: #005888;
  --accent-rgb: 0, 109, 168;
  --accent-soft: #dcedfb;
  --accent-soft-2: #e8f3fd;
  --accent-soft-border: #a9cae6;
  --accent-ink: #264e73;
  --accent-ink-strong: #0a446b;
  --control-bg: #ffffff;
  --control-bg-hover: #eef6ff;
  --control-border: #cbdff0;
  --control-text: #264e73;
  --control-muted: #5a7592;
  --menu-hover-bg: #e2effa;
  --menu-hover-text: #084d79;
  --menu-active-bg-start: #d3e7f8;
  --menu-active-bg-end: #e8f3fd;
  --menu-active-border: #aecfea;
  --menu-active-text: #0a446b;
  --logo-frame-border: #0f6ea8;
  --logo-frame-bg: #006da8;
  --logo-frame-shadow: rgba(0, 109, 168, 0.28);
  --logo-placeholder-start: #0c5f92;
  --logo-placeholder-end: #2a8fc8;
  --bg-orb-1: rgba(0, 109, 168, 0.13);
  --bg-orb-2: rgba(0, 88, 136, 0.09);
  --accent-red: #e30613;
  --accent-orange: #f36f21;
  --accent-yellow: #f7b625;
  --green: #0d9a6c;
  --amber: #b06a00;
  --red: #c81e2d;
  --shadow: 0 10px 28px rgba(20, 50, 82, 0.09);
  --surface-glass: rgba(255, 255, 255, 0.9);
  --surface-card: rgba(255, 255, 255, 0.95);
  --sidebar-grad-start: rgba(255, 255, 255, 0.96);
  --sidebar-grad-end: rgba(244, 250, 255, 0.96);
  --popover-bg: rgba(255, 255, 255, 0.98);
  --popover-shadow: rgba(16, 38, 63, 0.14);
  --card-title: #4a6684;
  --chart-subtle: #5f7894;
  --radius-lg: 16px;
  --radius-md: 12px;
}

:root[data-color-mode="dark"] {
  --bg: #0c131c;
  --surface: #121b26;
  --surface-soft: #182434;
  --line: #263546;
  --text: #e4edf7;
  --muted: #9ab0c6;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --surface-glass: rgba(18, 27, 38, 0.88);
  --surface-card: rgba(18, 27, 38, 0.94);
  --sidebar-grad-start: rgba(15, 22, 31, 0.98);
  --sidebar-grad-end: rgba(18, 28, 40, 0.98);
  --popover-bg: rgba(17, 25, 36, 0.97);
  --popover-shadow: rgba(0, 0, 0, 0.42);
  --control-bg: #152030;
  --control-bg-hover: #1b2a3d;
  --control-border: #2d4055;
  --control-text: #d9e8f8;
  --control-muted: #9eb7cf;
  --menu-hover-bg: rgba(var(--accent-rgb), 0.14);
  --menu-hover-text: #ebf5ff;
  --menu-active-bg-start: rgba(var(--accent-rgb), 0.22);
  --menu-active-bg-end: rgba(var(--accent-rgb), 0.12);
  --menu-active-border: rgba(var(--accent-rgb), 0.35);
  --menu-active-text: #eff6ff;
  --accent-soft: rgba(var(--accent-rgb), 0.18);
  --accent-soft-2: rgba(var(--accent-rgb), 0.12);
  --accent-soft-border: rgba(var(--accent-rgb), 0.33);
  --accent-ink: #d7e9fb;
  --accent-ink-strong: #f0f7ff;
  --bg-orb-1: rgba(var(--accent-rgb), 0.16);
  --bg-orb-2: rgba(var(--accent-rgb), 0.06);
  --card-title: #a9bfd5;
  --chart-subtle: #91a9c0;
}

:root[data-color-scheme="forest"] {
  --bg: #edf5f1;
  --surface: #ffffff;
  --surface-soft: #f2faf6;
  --line: #cfe2da;
  --text: #142f2a;
  --muted: #5a7670;
  --accent: #2f7d6b;
  --accent-2: #1f5f51;
  --accent-rgb: 47, 125, 107;
  --accent-soft: #dcefe8;
  --accent-soft-2: #e9f6f1;
  --accent-soft-border: #afd5c7;
  --accent-ink: #25584c;
  --accent-ink-strong: #1f5146;
  --control-border: #cfe3dc;
  --control-text: #28584d;
  --control-muted: #5f7f78;
  --control-bg-hover: #edf8f3;
  --menu-hover-bg: #e4f2ec;
  --menu-hover-text: #235a4d;
  --menu-active-bg-start: #d7ebe3;
  --menu-active-bg-end: #eaf6f1;
  --menu-active-border: #b3d6ca;
  --menu-active-text: #1f5448;
  --logo-frame-border: #2f7d6b;
  --logo-frame-bg: #2f7d6b;
  --logo-frame-shadow: rgba(47, 125, 107, 0.22);
  --logo-placeholder-start: #245f53;
  --logo-placeholder-end: #4ea08c;
  --bg-orb-1: rgba(47, 125, 107, 0.14);
  --bg-orb-2: rgba(31, 95, 81, 0.1);
}

:root[data-color-scheme="amber"] {
  --bg: #f7f1e7;
  --surface: #fffdf9;
  --surface-soft: #fbf6ef;
  --line: #e6d7c0;
  --text: #3b2b1f;
  --muted: #7c6650;
  --accent: #b8742b;
  --accent-2: #8f5720;
  --accent-rgb: 184, 116, 43;
  --accent-soft: #f4e5d2;
  --accent-soft-2: #faefe2;
  --accent-soft-border: #e0bf95;
  --accent-ink: #73502b;
  --accent-ink-strong: #62411f;
  --control-border: #e5d8c7;
  --control-text: #6e5336;
  --control-muted: #8b735b;
  --control-bg-hover: #fdf7ef;
  --menu-hover-bg: #f5eadb;
  --menu-hover-text: #7b4f21;
  --menu-active-bg-start: #f0dfc7;
  --menu-active-bg-end: #faf2e6;
  --menu-active-border: #dfc39c;
  --menu-active-text: #71461a;
  --logo-frame-border: #b8742b;
  --logo-frame-bg: #b8742b;
  --logo-frame-shadow: rgba(184, 116, 43, 0.2);
  --logo-placeholder-start: #9d6025;
  --logo-placeholder-end: #cf9450;
  --bg-orb-1: rgba(184, 116, 43, 0.12);
  --bg-orb-2: rgba(143, 87, 32, 0.08);
}

:root[data-color-scheme="slate"] {
  --bg: #eef4f6;
  --surface: #ffffff;
  --surface-soft: #f2f8fa;
  --line: #cfe0e4;
  --text: #132f35;
  --muted: #5f7981;
  --accent: #0c7f88;
  --accent-2: #085f66;
  --accent-rgb: 12, 127, 136;
  --accent-soft: #daf0f2;
  --accent-soft-2: #e8f7f8;
  --accent-soft-border: #add8dc;
  --accent-ink: #225963;
  --accent-ink-strong: #174a52;
  --control-border: #cee1e6;
  --control-text: #23565f;
  --control-muted: #5d7c84;
  --control-bg-hover: #edf8fa;
  --menu-hover-bg: #e2f2f4;
  --menu-hover-text: #1f5961;
  --menu-active-bg-start: #d6ecee;
  --menu-active-bg-end: #eaf6f8;
  --menu-active-border: #abd3d8;
  --menu-active-text: #184d54;
  --logo-frame-border: #0c7f88;
  --logo-frame-bg: #0c7f88;
  --logo-frame-shadow: rgba(12, 127, 136, 0.22);
  --logo-placeholder-start: #0b636b;
  --logo-placeholder-end: #34a6ae;
  --bg-orb-1: rgba(12, 127, 136, 0.14);
  --bg-orb-2: rgba(8, 95, 102, 0.08);
}

:root[data-color-scheme="plum"] {
  --bg: #f4edf3;
  --surface: #ffffff;
  --surface-soft: #faf3f8;
  --line: #e0d1dd;
  --text: #341f31;
  --muted: #746177;
  --accent: #7f3f72;
  --accent-2: #5f2d54;
  --accent-rgb: 127, 63, 114;
  --accent-soft: #eddced;
  --accent-soft-2: #f6eaf4;
  --accent-soft-border: #d3afd0;
  --accent-ink: #6a3d61;
  --accent-ink-strong: #512b49;
  --control-border: #e1d4df;
  --control-text: #643f5d;
  --control-muted: #7e687d;
  --control-bg-hover: #fbf2f8;
  --menu-hover-bg: #f0e2ef;
  --menu-hover-text: #63385d;
  --menu-active-bg-start: #ead7e8;
  --menu-active-bg-end: #f7ecf5;
  --menu-active-border: #d0b0ce;
  --menu-active-text: #582f52;
  --logo-frame-border: #7f3f72;
  --logo-frame-bg: #7f3f72;
  --logo-frame-shadow: rgba(127, 63, 114, 0.2);
  --logo-placeholder-start: #623159;
  --logo-placeholder-end: #a35a95;
  --bg-orb-1: rgba(127, 63, 114, 0.14);
  --bg-orb-2: rgba(95, 45, 84, 0.08);
}

/* Apply dark mode after color-scheme presets so surfaces stay dark for every scheme. */
:root[data-color-mode="dark"] {
  --bg: #0b1118;
  --surface: #121a24;
  --surface-soft: #182231;
  --line: #253446;
  --text: #e7eef7;
  --muted: #9fb2c7;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.34);
  --surface-glass: rgba(18, 26, 36, 0.88);
  --surface-card: rgba(20, 29, 40, 0.96);
  --sidebar-grad-start: rgba(13, 19, 28, 0.98);
  --sidebar-grad-end: rgba(16, 24, 35, 0.98);
  --popover-bg: rgba(16, 23, 33, 0.98);
  --popover-shadow: rgba(0, 0, 0, 0.38);
  --control-bg: #132031;
  --control-bg-hover: #1b2a3d;
  --control-border: #2c3f54;
  --control-text: #dce9f7;
  --control-muted: #9fb5cc;
  --menu-hover-bg: rgba(var(--accent-rgb), 0.16);
  --menu-hover-text: #f1f7ff;
  --menu-active-bg-start: rgba(var(--accent-rgb), 0.26);
  --menu-active-bg-end: rgba(var(--accent-rgb), 0.12);
  --menu-active-border: rgba(var(--accent-rgb), 0.34);
  --menu-active-text: #f2f7ff;
  --accent-soft: rgba(var(--accent-rgb), 0.16);
  --accent-soft-2: rgba(var(--accent-rgb), 0.11);
  --accent-soft-border: rgba(var(--accent-rgb), 0.32);
  --accent-ink: #d9eafc;
  --accent-ink-strong: #f2f8ff;
  --bg-orb-1: rgba(var(--accent-rgb), 0.11);
  --bg-orb-2: rgba(var(--accent-rgb), 0.04);
  --card-title: #afc2d7;
  --chart-subtle: #8ea6bd;
  --logo-frame-shadow: rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

html.fonts-loading body {
  visibility: visible;
}

html.fonts-ready body {
  visibility: visible;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Manrope", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 8% 0%, var(--bg-orb-1), transparent 34%),
    radial-gradient(circle at 100% 0%, var(--bg-orb-2), transparent 26%),
    var(--bg);
}

body {
  overflow: hidden;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

button,
select {
  font: inherit;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-columns: 285px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid var(--line);
  padding: 20px 16px;
  background: linear-gradient(180deg, var(--sidebar-grad-start), var(--sidebar-grad-end));
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
  z-index: 35;
}

.sidebar-top {
  overflow-y: auto;
  padding-right: 4px;
}

.brand-row {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 18px;
}

.brand-head {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.brand-row.is-square-logo {
  gap: 14px;
  margin-bottom: 16px;
}

.brand-row.is-square-logo .brand-head {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 12px;
  padding: 12px;
  border-radius: 11px;
  border: 1px solid var(--line);
  background: var(--surface) !important;
  background-color: var(--surface) !important;
  background-image: none !important;
  box-shadow: 0 6px 14px rgba(16, 38, 63, 0.05);
  opacity: 1;
}

.brand-logo-wrap {
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--logo-frame-border);
  background: var(--logo-frame-bg);
  box-shadow: 0 8px 20px var(--logo-frame-shadow);
  min-height: 92px;
  max-height: 108px;
  display: grid;
  place-items: center;
  padding: 10px 12px;
}

.brand-logo-wrap.is-placeholder {
  border-color: var(--logo-frame-border);
  background: linear-gradient(135deg, var(--logo-placeholder-start), var(--logo-placeholder-end));
}

.brand-logo-wrap.is-square-logo {
  width: 56px;
  min-width: 56px;
  min-height: 56px;
  max-height: 56px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  place-items: center;
  grid-column: 1;
  grid-row: 1;
  align-self: center;
}

.brand-logo {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 84px;
  object-fit: contain;
  object-position: center;
}

.brand-row.is-square-logo .brand-logo {
  width: 56px;
  height: 56px;
  max-height: none;
  border-radius: 8px;
}

.brand-row.is-square-logo .kicker {
  align-self: center;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1;
  margin: 0;
}

.brand-row.is-square-logo h1 {
  font-size: 18px;
  line-height: 1.15;
  margin: 0;
}

.kicker {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.07em;
}

.brand-row h1 {
  font-size: 17px;
  margin-top: 3px;
}

.menu-section {
  margin-bottom: 18px;
}

.section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
  font-weight: 700;
}

#menu {
  display: grid;
  gap: 8px;
}

.menu-item {
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  color: var(--control-text);
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s ease;
}

.menu-item:hover {
  background: var(--menu-hover-bg);
  color: var(--menu-hover-text);
}

.menu-item.active {
  background: linear-gradient(130deg, var(--menu-active-bg-start), var(--menu-active-bg-end));
  box-shadow: inset 0 0 0 1px var(--menu-active-border);
  color: var(--menu-active-text);
}

.menu-item.muted {
  font-weight: 500;
}

.sidebar-bottom {
  display: grid;
  gap: 0;
  padding-top: 4px;
  position: relative;
  overflow: visible;
}

.theme-popover {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--popover-bg);
  box-shadow: 0 16px 34px var(--popover-shadow);
  padding: 10px;
  z-index: 20;
  transform-origin: bottom right;
  transform: translateY(6px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.16s ease, opacity 0.16s ease;
  backdrop-filter: blur(8px);
}

.theme-popover[hidden] {
  display: none;
}

.theme-popover.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

.theme-popover::after {
  content: "";
  position: absolute;
  right: 20px;
  bottom: -7px;
  width: 12px;
  height: 12px;
  background: var(--popover-bg);
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transform: rotate(45deg);
}

.theme-popover-head {
  padding: 2px 2px 8px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  padding: 2px;
  margin: 0 0 8px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface-soft) 86%, var(--surface));
}

.mode-toggle-btn {
  border: 0;
  border-radius: 10px;
  min-height: 34px;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.mode-toggle-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--surface) 70%, transparent);
}

.mode-toggle-btn.is-active {
  color: var(--accent-ink-strong);
  background: color-mix(in srgb, var(--accent-soft) 72%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--accent-soft-border);
}

.theme-popover-kicker {
  font-size: 10px;
  line-height: 1;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.theme-popover-head h3 {
  margin-top: 4px;
  font-size: 15px;
  color: var(--text);
}

.theme-options {
  display: grid;
  gap: 7px;
}

.theme-option {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, var(--surface), color-mix(in srgb, var(--surface-soft) 72%, white));
  color: inherit;
  padding: 8px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.16s ease, background-color 0.16s ease, box-shadow 0.16s ease;
}

.theme-option:hover {
  border-color: var(--accent-soft-border);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 16%, transparent);
}

.theme-option.is-active {
  border-color: var(--accent-soft-border);
  background: linear-gradient(180deg, var(--accent-soft-2), color-mix(in srgb, var(--accent-soft) 75%, white));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 18%, transparent);
}

.theme-option-preview {
  display: inline-grid;
  grid-template-columns: repeat(2, 12px);
  grid-template-rows: repeat(2, 12px);
  gap: 3px;
  padding: 4px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 85%, white);
}

.theme-swatch {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  background: var(--swatch);
}

.theme-option-copy {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.theme-option-name {
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.1;
}

.theme-option-desc {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
}

.theme-option-check {
  width: 20px;
  height: 20px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  font-size: 10px;
  line-height: 1;
}

.user-row {
  display: block;
  width: 100%;
}

.team-box,
.user-box {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 10px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.user-box-with-settings {
  width: 100%;
  justify-content: flex-start;
  gap: 0;
  padding: 0;
  overflow: hidden;
}

.user-main {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
}

.user-main > div {
  min-width: 0;
}

.settings-btn {
  flex: 0 0 56px;
  width: 56px;
  border: 0;
  border-left: 1px solid var(--line);
  border-radius: 0;
  background: color-mix(in srgb, var(--control-bg) 82%, var(--accent) 18%);
  color: var(--accent-ink);
  display: grid;
  place-items: center;
  font-size: 28px;
  line-height: 1;
  align-self: stretch;
  margin-left: auto;
  padding: 0;
  cursor: pointer;
}

.settings-btn:hover {
  background: var(--control-bg-hover);
  color: var(--accent-ink-strong);
}

.settings-btn[aria-expanded="true"] {
  background: var(--accent-soft);
  color: var(--accent-ink-strong);
}

.team-dot,
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 13px;
}

.team-dot {
  background: linear-gradient(145deg, var(--accent-orange), var(--accent-red));
}

.avatar {
  background: linear-gradient(145deg, #334155, #1e293b);
}

.team-name,
.user-name {
  font-size: 13px;
  font-weight: 700;
}

.user-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 12px;
  color: var(--muted);
}

.main {
  min-height: 0;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: visible;
}

.topbar {
  border: 1px solid var(--line);
  background: var(--surface-glass);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 15px;
}

.topbar h2 {
  margin-top: 3px;
  font-size: 24px;
}

.topbar-left {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.top-actions {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-wrap: nowrap;
  justify-content: flex-end;
}

.top-control {
  display: grid;
  gap: 4px;
  min-width: 138px;
}

.top-control-range {
  min-width: 320px;
  flex: 0 1 420px;
  max-width: 460px;
}

.top-control > span {
  font-size: 11px;
  line-height: 1.1;
  font-weight: 700;
  color: var(--control-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.floating-menu-btn,
.sidebar-close-btn {
  width: 40px;
  height: 40px;
  border: 1px solid var(--control-border);
  border-radius: 10px;
  background: var(--control-bg);
  color: var(--accent-ink);
  display: none;
  place-items: center;
  font-size: 22px;
  cursor: pointer;
}

.floating-menu-btn:hover,
.sidebar-close-btn:hover {
  background: var(--control-bg-hover);
}

.floating-menu-btn {
  position: fixed;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 12px;
  z-index: 42;
  box-shadow: 0 8px 20px rgba(10, 36, 62, 0.22);
}

.sidebar-close-btn {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 12px;
  z-index: 3;
}

.ghost {
  border: 1px solid var(--control-border);
  border-radius: 10px;
  padding: 8px 11px;
  background: var(--control-bg);
  font-weight: 600;
  color: var(--control-text);
  cursor: pointer;
  min-height: 42px;
}

.top-actions > .ghost {
  align-self: end;
  flex: 0 0 auto;
  min-width: 116px;
}

.ghost-select {
  min-width: 148px;
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--control-muted) 50%),
    linear-gradient(135deg, var(--control-muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) calc(50% - 2px), calc(100% - 11px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.ghost-date-range {
  width: 100%;
  min-width: 240px;
  padding-right: 10px;
}

.ghost.active {
  background: var(--accent-soft);
  border-color: var(--accent-soft-border);
  color: var(--accent-ink-strong);
}

.flatpickr-calendar {
  border: 1px solid #c8dcef;
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(17, 51, 86, 0.18);
  font-family: "Manrope", "Segoe UI", sans-serif;
}

.flatpickr-months .flatpickr-month {
  color: #173a5c;
  fill: #173a5c;
}

.flatpickr-weekdays {
  background: #f5f9ff;
}

.flatpickr-weekday {
  color: #4c6783;
}

.flatpickr-day {
  border-radius: 8px;
}

.flatpickr-day.startRange,
.flatpickr-day.endRange,
.flatpickr-day.selected {
  background: #006da8;
  border-color: #006da8;
}

.flatpickr-day.inRange {
  background: #dbeefe;
  border-color: #dbeefe;
  box-shadow: -5px 0 0 #dbeefe, 5px 0 0 #dbeefe;
}

.filter-row {
  position: relative;
  z-index: 70;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-glass);
  box-shadow: var(--shadow);
  padding: 10px;
  overflow: visible;
}

.filter-row.hidden {
  display: none;
}

.filter-row-inner {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  min-width: 0;
  width: 100%;
  flex-wrap: nowrap;
  overflow: visible;
}

.filter-group {
  min-width: 158px;
}

.filter-group label {
  display: block;
  font-size: 12px;
  color: var(--control-muted);
  margin-bottom: 5px;
  font-weight: 700;
}

.filter-group select,
.filter-multi > summary {
  width: 100%;
  border: 1px solid var(--control-border);
  border-radius: 9px;
  background: color-mix(in srgb, var(--control-bg) 80%, var(--surface-soft));
  padding: 6px 9px;
  min-height: 42px;
}

.filter-multi {
  position: relative;
  z-index: 1;
}

.filter-multi > summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  color: var(--control-text);
  font-weight: 600;
  padding-right: 28px;
}

.filter-multi > summary::-webkit-details-marker {
  display: none;
}

.filter-multi > summary::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--control-muted);
  border-bottom: 2px solid var(--control-muted);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
  transition: transform 0.16s ease, border-color 0.16s ease;
}

.filter-multi[open] > summary {
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  background: var(--surface);
}

.filter-multi[open] > summary::after {
  transform: translateY(-35%) rotate(-135deg);
  border-color: var(--accent-ink);
}

.filter-multi[open] {
  z-index: 120;
}

.filter-multi-menu {
  position: absolute;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  z-index: 121;
  border: 1px solid var(--control-border);
  border-top: 0;
  border-radius: 0 0 9px 9px;
  background: var(--surface);
  box-shadow: 0 10px 20px rgba(16, 38, 63, 0.08);
  max-height: 220px;
  overflow: auto;
  padding: 4px;
  color: var(--control-text);
}

.filter-multi-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: 8px;
  color: var(--control-text);
  cursor: pointer;
}

.filter-multi-option:hover {
  background: color-mix(in srgb, var(--accent-soft-2) 80%, white);
}

.filter-multi-option input {
  margin: 0;
}

.filter-multi-option span {
  min-width: 0;
}

.clear-filter {
  border: 1px dashed var(--accent-soft-border);
  background: color-mix(in srgb, var(--surface-soft) 70%, white);
  border-radius: 9px;
  min-height: 42px;
  padding: 0 12px;
  color: var(--accent-ink);
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid color-mix(in srgb, var(--line) 80%, transparent);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  position: relative;
  z-index: 72;
}

.filter-chip {
  border: 1px solid var(--control-border);
  background: linear-gradient(180deg, color-mix(in srgb, var(--surface) 92%, white), color-mix(in srgb, var(--surface-soft) 82%, white));
  color: var(--control-text);
  border-radius: 999px;
  min-height: 32px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 2px 8px rgba(16, 38, 63, 0.04);
}

.filter-chip:hover {
  border-color: var(--accent-soft-border);
  background: color-mix(in srgb, var(--accent-soft-2) 78%, white);
}

.filter-chip-label {
  color: var(--control-muted);
  font-weight: 700;
}

.filter-chip-value {
  color: var(--accent-ink-strong);
  font-weight: 700;
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.filter-chip-x {
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(var(--accent-rgb), 0.1);
  color: var(--accent-ink);
  font-size: 11px;
  line-height: 1;
}

.view {
  position: relative;
  z-index: 1;
  overflow: auto;
  display: grid;
  gap: 12px;
  min-height: 0;
}

.objective {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(
    130deg,
    color-mix(in srgb, var(--surface-soft) 78%, var(--surface)),
    color-mix(in srgb, var(--accent-soft-2) 45%, var(--surface))
  );
  padding: 12px 14px;
}

.objective .label {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.objective .text {
  margin-top: 4px;
  font-weight: 600;
}

.score-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.skeleton-line,
.skeleton-pill,
.skeleton-chart,
.skeleton-table-row > span {
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--surface-soft) 82%, var(--surface-card)) 15%,
    color-mix(in srgb, var(--surface) 86%, white) 50%,
    color-mix(in srgb, var(--surface-soft) 82%, var(--surface-card)) 85%
  );
  background-size: 220% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
}

.score {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow);
  padding: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.score-main {
  min-width: 0;
  width: 100%;
}

.score .title {
  color: var(--card-title);
  font-size: 12px;
}

.kpi-caption {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.score .value {
  margin-top: 8px;
  font-size: 23px;
  font-family: "Sora", "Manrope", sans-serif;
}

.score .meta {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}

.score-bundle {
  grid-column: span 2;
  justify-content: flex-start;
  text-align: left;
}

.score-bundle .title {
  text-align: left;
}

.score-bundle .kpi-caption {
  justify-content: flex-start;
}

.score-bundle-formula {
  margin-top: 3px;
  color: var(--chart-subtle);
  font-size: 11px;
  font-weight: 700;
}

.score-bundle-grid {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.score-bundle-item {
  border: 1px solid color-mix(in srgb, var(--line) 88%, white);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 84%, white);
  padding: 8px;
  min-width: 0;
}

.skeleton-score {
  align-items: flex-start;
  justify-content: flex-start;
  text-align: left;
}

.skeleton-score .score-main {
  display: grid;
  gap: 8px;
}

.skeleton-score .skeleton-meta {
  display: flex;
  align-items: center;
  gap: 8px;
}

.skeleton-line {
  display: block;
  border-radius: 999px;
  height: 11px;
}

.skeleton-pill {
  display: inline-block;
  width: 48px;
  height: 20px;
  border-radius: 999px;
}

.sk-title { width: 52%; height: 10px; }
.sk-value { width: 74%; height: 22px; }
.sk-meta { width: 34%; height: 10px; }
.sk-formula { width: 62%; height: 9px; }
.sk-bundle-label { width: 58%; height: 9px; }
.sk-bundle-value { width: 78%; height: 16px; }

.skeleton-score-bundle .score-bundle-item {
  background: color-mix(in srgb, var(--surface) 84%, white);
}

.skeleton-bundle-item {
  display: grid;
  gap: 7px;
}

.bundle-label {
  color: var(--card-title);
  font-size: 11px;
}

.kpi-help-wrap {
  position: relative;
  display: inline-flex;
}

.kpi-help-label {
  cursor: help;
  text-decoration: underline;
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.kpi-help-label:focus-visible {
  outline: 2px solid #79a9d2;
  outline-offset: 2px;
  border-radius: 4px;
}

.kpi-help-tooltip {
  position: fixed;
  z-index: 50;
  left: 0;
  top: 0;
  transform: none;
  width: min(260px, 72vw);
  background: #143553;
  color: #f7fbff;
  border-radius: 8px;
  padding: 8px 9px;
  font-size: 11px;
  line-height: 1.35;
  box-shadow: 0 10px 22px rgba(5, 25, 44, 0.24);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.16s ease;
}

.kpi-help-wrap:hover .kpi-help-tooltip,
.kpi-help-wrap:focus-within .kpi-help-tooltip {
  opacity: 1;
}

.bundle-value {
  margin-top: 4px;
  font-size: 18px;
  font-family: "Sora", "Manrope", sans-serif;
}

.bundle-meta {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.pill {
  display: inline-block;
  border-radius: 999px;
  padding: 2px 7px;
  font-size: 11px;
  font-weight: 700;
}

.up {
  color: #0c8f63;
  background: rgba(13, 154, 108, 0.14);
}

.mid {
  color: #9a6809;
  background: rgba(185, 120, 8, 0.15);
}

.down {
  color: #b83a55;
  background: rgba(203, 61, 93, 0.15);
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  box-shadow: var(--shadow);
  padding: 11px;
  display: flex;
  flex-direction: column;
}

.skeleton-grid {
  margin-top: 10px;
}

.skeleton-card {
  overflow: hidden;
}

.skeleton-card .sk-card-title {
  height: 13px;
  margin-bottom: 7px;
}

.skeleton-card .sk-card-sub {
  height: 10px;
  margin-bottom: 10px;
  opacity: 0.9;
}

.skeleton-chart {
  width: 100%;
  min-height: 245px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--line) 70%, white);
  background-color: color-mix(in srgb, var(--surface) 86%, white);
}

.skeleton-card-tall .skeleton-chart {
  min-height: 300px;
}

.skeleton-card-map .skeleton-chart {
  min-height: 460px;
}

.skeleton-table {
  display: grid;
  gap: 8px;
  border: 1px solid color-mix(in srgb, var(--line) 80%, white);
  border-radius: 12px;
  padding: 10px;
  background: color-mix(in srgb, var(--surface) 88%, white);
}

.skeleton-table-head,
.skeleton-table-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.skeleton-table-head .sk-th {
  height: 10px;
  opacity: 0.9;
}

.skeleton-table-body {
  display: grid;
  gap: 7px;
}

.skeleton-table-row > span {
  display: block;
  height: 12px;
  border-radius: 999px;
}

.chart-fill-card {
  display: flex;
  flex-direction: column;
}

.card > .chart {
  flex: 1 1 auto;
}

.chart-fill-card .chart {
  flex: 1 1 auto;
  min-height: 320px;
}

.card h4 {
  font-size: 14px;
}

.card .sub {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin: 3px 0 8px;
}

.span-12 { grid-column: span 12; }
.span-8 { grid-column: span 8; }
.span-7 { grid-column: span 7; }
.span-6 { grid-column: span 6; }
.span-5 { grid-column: span 5; }
.span-4 { grid-column: span 4; }
.span-3 { grid-column: span 3; }

.chart {
  min-height: 245px;
  width: 100%;
}

.chart.map-chart {
  min-height: 460px;
}

.chart.tall {
  min-height: 300px;
}

.funnel-host {
  min-height: 320px;
}

.funnel-modern {
  display: grid;
  gap: 10px;
  align-content: start;
}

.funnel-summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  border: 1px solid color-mix(in srgb, var(--line) 82%, white);
  border-radius: 10px;
  background: linear-gradient(135deg, color-mix(in srgb, var(--surface) 88%, white), color-mix(in srgb, var(--surface-soft) 82%, white));
  padding: 8px 11px;
}

.funnel-summary-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--card-title);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.funnel-summary-value {
  font-family: "Sora", "Manrope", sans-serif;
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
}

.funnel-rows {
  display: grid;
  gap: 8px;
}

.funnel-row {
  border: 1px solid color-mix(in srgb, var(--line) 82%, white);
  border-radius: 10px;
  background: color-mix(in srgb, var(--surface) 86%, white);
  padding: 8px 10px;
}

.funnel-row-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.funnel-row-stage {
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
}

.funnel-row-number {
  font-family: "Sora", "Manrope", sans-serif;
  font-weight: 800;
  font-size: 15px;
  color: var(--text);
}

.funnel-track {
  margin-top: 6px;
  height: 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-soft) 78%, white);
  overflow: hidden;
}

.funnel-fill {
  height: 100%;
  border-radius: 999px;
}

.funnel-row-meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  font-weight: 700;
}

.chart-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.legend-gradient {
  display: inline-block;
  height: 12px;
  width: 190px;
  border-radius: 999px;
}

.legend-gradient-map {
  background: linear-gradient(90deg, #eaf1f7 0%, #7fb9de 55%, #0a5e8f 100%);
}

.legend-gradient-heat {
  background: linear-gradient(90deg, #e30613 0%, #f8fafc 50%, #0d9a6c 100%);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 23, 40, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 30;
}

.table-wrap {
  overflow-x: auto;
}

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

.table th,
.table td {
  text-align: left;
  padding: 8px 7px;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, white);
  white-space: nowrap;
}

.table th {
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-size: 11px;
}

.monthly-sales-table-wrap {
  margin-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--line) 78%, white);
  padding-top: 8px;
}

.monthly-sales-table th,
.monthly-sales-table td {
  padding-top: 6px;
  padding-bottom: 6px;
  padding-left: 5px;
  padding-right: 5px;
}

.monthly-sales-matrix {
  min-width: max-content;
}

.monthly-sales-matrix thead th {
  background: color-mix(in srgb, var(--surface) 86%, white);
  text-align: center;
  border-bottom: 1px solid color-mix(in srgb, var(--line) 78%, white);
}

.monthly-sales-matrix .year-total-col {
  background: color-mix(in srgb, var(--surface-soft) 80%, white);
  font-weight: 700;
}

.monthly-sales-matrix .row-label {
  position: sticky;
  left: 0;
  z-index: 1;
  background: color-mix(in srgb, var(--surface) 86%, white);
  text-align: left;
  min-width: 114px;
  font-weight: 800;
  color: var(--text);
}

.monthly-sales-matrix tbody td {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.monthly-sales-matrix tbody tr.is-ventas .row-label {
  color: color-mix(in srgb, var(--accent) 78%, var(--text));
}

.monthly-sales-matrix tbody tr.is-aa .row-label {
  color: var(--muted);
}

.monthly-sales-matrix tbody tr.is-objetivo .row-label {
  color: #ad7d1a;
}

.monthly-sales-matrix tbody tr.is-pct {
  background: color-mix(in srgb, var(--surface) 90%, white);
}

.monthly-sales-matrix tbody tr.is-pct .row-label {
  color: var(--card-title);
}

.monthly-sales-matrix tbody tr.is-pct-aa {
  background: color-mix(in srgb, var(--surface-soft) 76%, white);
}

.monthly-sales-matrix tbody tr.is-pct-aa .row-label {
  color: color-mix(in srgb, var(--card-title) 86%, var(--text));
}

.kpi-ok { color: var(--green); font-weight: 700; }
.kpi-mid { color: var(--amber); font-weight: 700; }
.kpi-bad { color: var(--red); font-weight: 700; }

:root[data-color-mode="dark"] .topbar,
:root[data-color-mode="dark"] .filter-row {
  background: rgba(17, 25, 35, 0.86);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.26);
}

:root[data-color-mode="dark"] .objective,
:root[data-color-mode="dark"] .score,
:root[data-color-mode="dark"] .card {
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
}

:root[data-color-mode="dark"] .objective {
  background: linear-gradient(140deg, rgba(21, 30, 42, 0.96), rgba(22, 33, 47, 0.96));
}

:root[data-color-mode="dark"] .score-bundle-item {
  background: #162130;
  border-color: #2b3b4d;
}

:root[data-color-mode="dark"] .clear-filter {
  background: #162130;
}

:root[data-color-mode="dark"] .filter-chip {
  background: #162130;
}

:root[data-color-mode="dark"] .filter-chip:hover {
  background: #1a2738;
}

:root[data-color-mode="dark"] .theme-popover {
  border-color: rgba(255, 255, 255, 0.1);
}

:root[data-color-mode="dark"] .theme-popover::after {
  border-color: rgba(255, 255, 255, 0.1);
}

:root[data-color-mode="dark"] .theme-option {
  background: #182332;
  border-color: #2a3a4d;
}

:root[data-color-mode="dark"] .theme-option:hover {
  background: #1b2838;
}

:root[data-color-mode="dark"] .theme-option.is-active {
  background: color-mix(in srgb, rgba(var(--accent-rgb), 0.18) 60%, #182332);
}

:root[data-color-mode="dark"] .theme-option-preview {
  background: #101825;
  border-color: #2a3a4d;
}

:root[data-color-mode="dark"] .mode-toggle {
  background: #101825;
  border-color: #2a3a4d;
}

:root[data-color-mode="dark"] .funnel-summary,
:root[data-color-mode="dark"] .funnel-row {
  background: #162130;
  border-color: #2a3a4d;
}

:root[data-color-mode="dark"] .funnel-track {
  background: #202d3d;
}

:root[data-color-mode="dark"] .table th,
:root[data-color-mode="dark"] .table td {
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

:root[data-color-mode="dark"] .monthly-sales-matrix thead th,
:root[data-color-mode="dark"] .monthly-sales-matrix .row-label {
  background: #162130;
  border-bottom-color: rgba(255, 255, 255, 0.07);
}

:root[data-color-mode="dark"] .monthly-sales-matrix .year-total-col {
  background: #1a2738;
}

:root[data-color-mode="dark"] .monthly-sales-matrix tbody tr.is-pct {
  background: rgba(255, 255, 255, 0.015);
}

:root[data-color-mode="dark"] .monthly-sales-matrix tbody tr.is-pct-aa {
  background: rgba(255, 255, 255, 0.03);
}

:root[data-color-mode="dark"] .sidebar-overlay {
  background: rgba(2, 8, 16, 0.62);
}

@media (max-width: 1300px) {
  .score-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .span-8,
  .span-7,
  .span-6,
  .span-5,
  .span-4,
  .span-3 { grid-column: span 12; }
}

@media (max-width: 768px) {
  .monthly-sales-matrix .row-label {
    min-width: 94px;
  }

  .monthly-sales-table th,
  .monthly-sales-table td {
    padding-left: 4px;
    padding-right: 4px;
  }
}

@media (max-width: 1024px) {
  body {
    overflow: auto;
  }

  body.sidebar-open {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(86vw, 320px);
    height: 100dvh;
    padding-top: 60px;
    transform: translateX(-104%);
    transition: transform 0.24s ease;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: 0 18px 40px rgba(10, 35, 58, 0.22);
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  body.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .floating-menu-btn,
  .sidebar-close-btn {
    display: grid;
  }

  body.sidebar-open .floating-menu-btn {
    opacity: 0;
    pointer-events: none;
  }

  .main {
    padding: 12px;
    padding-top: 68px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    width: 100%;
    flex-wrap: wrap;
    justify-content: stretch;
  }

  .top-actions .ghost {
    flex: 1 1 auto;
    min-width: 110px;
  }

  .top-control-range {
    max-width: none;
    flex-basis: 260px;
  }

  .ghost-date-range {
    min-width: 0;
  }

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

@media (max-width: 700px) {
  .main { padding: 10px; padding-top: 64px; gap: 10px; }
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 12px;
  }

  .topbar h2 {
    font-size: 21px;
  }

  .topbar-left {
    width: 100%;
  }

  .top-actions {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    align-items: end;
  }

  .top-control-range {
    grid-column: 1 / span 2;
    grid-row: 1;
    min-width: 0;
    max-width: none;
  }

  .top-actions .ghost,
  .top-actions .ghost-date-range {
    width: 100%;
    min-width: 0;
  }

  #filter-toggle-btn {
    grid-column: 1;
    grid-row: 2;
  }

  #export-btn {
    grid-column: 2;
    grid-row: 2;
  }

  .filter-row-inner {
    min-width: 0;
    width: 100%;
    flex-wrap: wrap;
    align-items: stretch;
  }

  .filter-group {
    min-width: calc(50% - 6px);
    flex: 1 1 calc(50% - 6px);
  }

  .clear-filter {
    width: 100%;
  }

  .filter-chip-value {
    max-width: 140px;
  }

  .score-grid { grid-template-columns: 1fr; }

  .score-bundle {
    grid-column: span 1;
  }

  .score-bundle-grid {
    grid-template-columns: 1fr;
  }

  .chart {
    min-height: 220px;
  }

  .chart-fill-card .chart {
    min-height: 240px;
  }

  .chart.tall {
    min-height: 260px;
  }

  .chart.map-chart {
    min-height: 340px;
  }

  .funnel-host {
    min-height: auto;
  }

  .legend-gradient {
    width: 136px;
  }
}

@media (max-width: 500px) {
  .filter-group {
    min-width: 100%;
    flex-basis: 100%;
  }

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

  #filter-toggle-btn {
    grid-column: 1;
    grid-row: 2;
  }

  #export-btn {
    grid-column: 2;
    grid-row: 2;
  }

  .kicker {
    font-size: 10px;
  }

  .funnel-row-head {
    flex-wrap: wrap;
  }
}
