:root {
  color-scheme: light;
  --bg: #f8fcfe;
  --rail: #ffffff;
  --surface: #ffffff;
  --ink: #432918;
  --graphite: #432918;
  --muted: #7d6f68;
  --line: #d4edfc;
  --soft: #fff6d8;
  --green: #3d6827;
  --yellow: #fbbb10;
  --orange: #e94e1b;
  --pink: #fff1ec;
  --blue: #d4edfc;
  --red: #c9361b;
  --focus: rgba(233, 78, 27, 0.18);
  --shadow: 0 8px 24px rgba(67, 41, 24, 0.06);
  --shadow-strong: 0 16px 40px rgba(67, 41, 24, 0.11);
  --radius: 14px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

*,
*::before,
*::after {
  min-width: 0;
}

strong,
span,
small,
p,
h1,
h2,
h3,
label,
button {
  overflow-wrap: anywhere;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "TT Runs", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.demo-mode::before {
  content: "ДЕМО-РЕЖИМ";
  position: fixed;
  z-index: 95;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  height: 24px;
  place-items: center;
  background: var(--yellow);
  color: var(--ink);
  font-size: 12px;
  font-weight: 800;
}

body.demo-mode .app {
  padding-top: 24px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

.user-gate {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(248, 252, 254, 0.96);
}

.user-gate.hidden {
  display: none;
}

.user-gate-panel {
  display: grid;
  width: min(560px, 100%);
  gap: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
}

.user-gate-panel h1 {
  font-size: 26px;
}

.user-gate-panel p {
  color: var(--muted);
  line-height: 1.45;
}

.login-error {
  min-height: 18px;
  color: var(--red);
  font-size: 13px;
  font-weight: 720;
}

.user-choice-grid {
  display: grid;
  gap: 10px;
}

.user-choice {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  font-weight: 780;
  text-align: left;
  padding: 0 14px;
}

.user-choice:hover {
  border-color: rgba(233, 78, 27, 0.3);
  background: #fff1ec;
  color: var(--orange);
}

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

input,
select,
textarea {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  font-size: 16px;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled,
input:disabled,
select:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

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

.rail {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-right: 1px solid var(--line);
  padding: 22px;
  background: #ffffff;
}

.brand,
.nav-item,
.topbar,
.top-actions,
.surface-head,
.card-head,
.density-card {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand-logo {
  display: block;
  width: 86px;
  height: auto;
  object-fit: contain;
}

.login-logo {
  display: block;
  width: min(260px, 70vw);
  height: auto;
  object-fit: contain;
}

.brand strong,
.brand span,
td small,
.card-head span,
.density-card span {
  display: block;
}

.brand span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 6px;
}

.nav-item {
  gap: 10px;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 0 12px;
  background: transparent;
  color: var(--ink);
  font-weight: 720;
  text-align: left;
}

.nav-item.active,
.nav-item:hover {
  border-color: rgba(233, 78, 27, 0.18);
  background: #fff1ec;
  color: var(--orange);
}

.rail-field {
  margin-top: auto;
}

.rail-demo-toggle {
  display: none;
  width: 100%;
}

label {
  display: grid;
  gap: 7px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

select[multiple] {
  min-height: 114px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--orange);
  box-shadow: 0 0 0 3px var(--focus);
}

button:focus-visible,
.sort-head:focus-visible,
.combo-option:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.workspace {
  min-width: 0;
  padding: 26px;
}

.topbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.topbar p,
h1,
h2,
p {
  margin: 0;
}

.topbar p {
  margin-bottom: 5px;
  color: var(--orange);
  font-size: 12px;
  font-weight: 820;
  text-transform: uppercase;
}

h1 {
  font-size: 28px;
  line-height: 1.15;
}

h2 {
  font-size: 16px;
}

.top-actions {
  gap: 10px;
}

.menu-toggle {
  display: none !important;
}

.sync-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-width: 148px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px 0 42px;
  background: #ffffff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 760;
  white-space: nowrap;
  box-shadow: 0 8px 18px rgba(67, 41, 24, 0.05);
  transition: background 200ms ease, border-color 200ms ease, color 200ms ease, box-shadow 200ms ease;
}

.sync-status::before {
  content: "";
  position: absolute;
  left: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: inset 0 0 0 6px #ffffff, 0 3px 8px rgba(67, 41, 24, 0.14);
  transition: transform 220ms ease, background 220ms ease;
}

.sync-status.demo-active {
  border-color: rgba(251, 187, 16, 0.56);
  background: #fff8dc;
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(251, 187, 16, 0.12);
}

.sync-status.demo-active::before {
  background: var(--yellow);
  transform: scale(1.08);
}

button.sync-status {
  cursor: pointer;
  touch-action: manipulation;
}

body.is-viewer .delete-button {
  display: none;
}

.row-action {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0 9px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.row-action.danger:hover {
  border-color: rgba(233, 78, 27, 0.28);
  background: #fff2f0;
  color: var(--orange);
}

.icon-button,
.primary-button,
.quiet-button,
.submit-button,
.delete-button {
  min-height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
}

.icon-button {
  display: grid;
  width: 40px;
  place-items: center;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.primary-button,
.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 15px;
  background: var(--orange);
  color: #ffffff;
  font-weight: 700;
  box-shadow: none;
}

.quiet-button {
  padding: 0 12px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.icon-button,
.primary-button,
.quiet-button,
.submit-button,
.delete-button,
.nav-item {
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.icon-button:hover,
.quiet-button:hover {
  border-color: rgba(233, 78, 27, 0.28);
  background: #fff1ec;
  color: var(--orange);
  box-shadow: none;
}

.primary-button:hover,
.submit-button:hover {
  transform: translateY(-1px);
  background: #d94316;
  box-shadow: none;
}

.primary-button:active,
.submit-button:active,
.quiet-button:active,
.icon-button:active,
.nav-item:active {
  transform: scale(0.98);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpis article,
.surface {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
  animation: surfaceIn 360ms ease both;
}

.kpis article {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.kpis article.clickable-kpi {
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
}

.kpis article.clickable-kpi:hover {
  transform: translateY(-2px);
  border-color: rgba(233, 78, 27, 0.24);
  box-shadow: var(--shadow-strong);
}

.kpis article::after {
  content: none;
}

.kpis span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.kpis strong {
  display: block;
  margin-top: 7px;
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.kpis small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.view {
  display: none;
}

.view.active {
  display: block;
}

.data-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px);
  gap: 16px;
  align-items: start;
}

.plan-settings-grid {
  grid-template-columns: minmax(280px, 0.65fr) minmax(0, 1.35fr);
}

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

.data-kpis article {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: #ffffff;
}

.data-kpis span,
.data-kpis strong {
  display: block;
}

.data-kpis span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.data-kpis strong {
  margin-top: 5px;
  font-size: 24px;
}

.data-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.bulk-form {
  display: grid;
  gap: 12px;
}

.backup-panel {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.backup-panel h3 {
  margin: 0;
  font-size: 15px;
}

.backup-list {
  display: grid;
  gap: 8px;
}

.backup-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #ffffff;
}

.plan-target-grid,
.plan-card-list,
.planner-plan-progress,
.plan-dashboard,
.plan-dashboard-grid {
  display: grid;
  gap: 10px;
}

.plan-target-row,
.plan-card,
.plan-progress-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
}

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

.plan-target-row label {
  min-width: 0;
}

.plan-target-row h3,
.plan-card h3,
.plan-progress-card h3 {
  margin: 0;
  font-size: 14px;
}

.plan-card {
  display: grid;
  gap: 9px;
}

.plan-card-head,
.plan-progress-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.plan-card-head span,
.plan-progress-head span,
.plan-progress-caption {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.plan-meter {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: #edf7fd;
  overflow: hidden;
}

.plan-meter i {
  display: block;
  height: 100%;
  width: min(100%, var(--progress, 0%));
  border-radius: inherit;
  background: var(--orange);
  transition: width 260ms ease;
}

.plan-meter b {
  position: absolute;
  top: -3px;
  bottom: -3px;
  left: min(100%, var(--expected, 0%));
  width: 2px;
  border-radius: 999px;
  background: var(--ink);
  opacity: 0.35;
}

.plan-meter-pair {
  display: grid;
  gap: 9px;
}

.plan-meter-pair > div {
  display: grid;
  gap: 5px;
}

.plan-meter-pair span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.plan-meter.green i {
  background: var(--green);
}

.plan-meter.yellow i {
  background: var(--yellow);
}

.plan-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(118px, 1fr));
  gap: 8px;
}

.plan-stats span {
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px;
  color: var(--muted);
  font-size: 12px;
}

.plan-stats b {
  display: block;
  margin-top: 3px;
  color: var(--ink);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.plan-dashboard-grid {
  grid-template-columns: minmax(0, 3fr) minmax(220px, 1fr);
  align-items: start;
}

.plan-owner-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}

.plan-dashboard .plan-hints {
  align-content: start;
  max-height: 520px;
  overflow: auto;
}

.plan-hints {
  display: grid;
  gap: 8px;
}

.plan-hint {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.4;
}

.plan-hint.priority-high {
  border-color: rgba(61, 104, 39, 0.32);
  background: #f3f8ef;
}

.plan-hint.priority-medium {
  border-color: rgba(251, 187, 16, 0.48);
  background: #fff8dc;
}

.plan-hint.priority-low {
  background: #f8fcfe;
}

.plan-hint strong,
.plan-hint span {
  display: block;
}

.plan-hint span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.compact-leaderboard .leader-row {
  grid-template-columns: 28px minmax(120px, 1fr) minmax(90px, 0.6fr) 38px;
}

.agent-touch-row {
  grid-template-columns: minmax(130px, 200px) minmax(100px, 1fr) 54px;
}

.backup-card strong,
.backup-card span {
  display: block;
}

.backup-card span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.logout-button {
  width: 100%;
}

.split {
  display: grid;
  grid-template-columns: minmax(350px, 440px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.activity-layout {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
}

.activity-editor {
  position: sticky;
  top: 22px;
  min-width: 0;
  overflow: visible;
}

.activity-layout > *,
.split > * {
  min-width: 0;
}

.compact-left {
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
}

.surface {
  padding: 18px;
  min-width: 0;
}

.form-surface {
  display: grid;
  gap: 14px;
}

.combo {
  position: relative;
}

.combo-menu {
  position: absolute;
  z-index: 30;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 260px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  box-shadow: var(--shadow-strong);
  padding: 6px;
}

.combo-menu.open {
  display: grid;
  gap: 4px;
}

.combo-option {
  min-height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: #ffffff;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
  text-align: left;
}

.combo-option:hover,
.combo-option:focus {
  background: #fff1ec;
  color: var(--orange);
}

.combo-create {
  border: 1px solid rgba(233, 78, 27, 0.18);
  background: #fff1ec;
  color: var(--orange);
}

.date-popover {
  position: fixed;
  z-index: 120;
  left: 50%;
  top: 50%;
  width: min(330px, calc(100vw - 28px));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
  box-shadow: var(--shadow-strong);
  transform: translate(-50%, -50%);
}

.date-popover-head {
  display: grid;
  grid-template-columns: 38px 1fr 38px;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.date-popover-head button,
.date-grid button {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #ffffff;
  color: var(--ink);
  font-weight: 780;
}

.date-popover-head strong {
  text-align: center;
  text-transform: capitalize;
}

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

.date-weekdays {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-align: center;
}

.date-grid button.active {
  border-color: var(--orange);
  background: var(--orange);
  color: #ffffff;
}

.planner-agency-create {
  margin-top: -6px;
}

.planner-tools {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(170px, 1fr) auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}

.planner-card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.combo-empty {
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
}

.surface-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.surface-head span {
  color: var(--muted);
  font-size: 12px;
}

.helper-text {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.form-grid,
.filters {
  display: grid;
  gap: 10px;
  min-width: 0;
}

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

.form-grid > label,
.filters > label,
.agent-tools > *,
.inline-add > * {
  min-width: 0;
}

.filters {
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  margin-bottom: 12px;
}

.compact-filters {
  grid-template-columns: repeat(auto-fit, minmax(170px, 220px));
}

.submit-button {
  width: 100%;
}

.agent-picker {
  display: grid;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
}

.agent-picker-head,
.agent-tools {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.agent-picker h3 {
  margin: 0 0 4px;
  font-size: 14px;
}

.agent-picker p {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
}

.checkline {
  display: inline-flex;
  grid-template-columns: none;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  color: var(--ink);
  font-size: 13px;
  font-weight: 760;
}

.checkline input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.inline-add {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  min-width: 0;
  width: 100%;
}

.agent-checklist {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
}

.agent-option {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr);
  align-items: start;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px;
  background: #ffffff;
}

.agent-option input {
  width: 16px;
  min-height: 16px;
  margin-top: 2px;
}

.agent-option strong,
.agent-option small {
  display: block;
}

.agent-option small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.compact {
  padding: 12px;
}

.activity-list,
.density-list,
.planner-list,
.bars {
  display: grid;
  gap: 10px;
}

.activity-list {
  max-height: calc(100vh - 250px);
  overflow: auto;
  padding-right: 3px;
}

.activity-card,
.density-card,
.planner-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
  background: #ffffff;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.density-card {
  width: 100%;
  color: var(--ink);
  text-align: left;
}

.activity-card:hover,
.density-card:hover,
.planner-card:hover {
  transform: translateY(-2px);
  border-color: rgba(233, 78, 27, 0.22);
  box-shadow: var(--shadow);
}

.activity-card {
  display: grid;
  gap: 9px;
}

.card-head,
.density-card {
  justify-content: space-between;
  gap: 12px;
}

.card-head strong {
  font-size: 15px;
}

.card-head span,
.activity-card small,
.density-card span,
.planner-card span,
td small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.activity-card p {
  font-size: 14px;
  line-height: 1.45;
}

.planner-card {
  display: grid;
  gap: 5px;
}

.planner-card time {
  color: var(--orange);
  font-size: 12px;
  font-weight: 840;
}

.planner-card p {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.45;
}

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

.chips span,
.status,
.density {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: var(--blue);
  color: var(--ink);
  font-size: 12px;
  font-weight: 820;
  white-space: nowrap;
}

.chips .danger,
.density.red {
  background: #fff1ec;
  color: var(--red);
}

.density.green {
  background: #eef6e9;
  color: var(--green);
}

.density.yellow {
  background: var(--soft);
  color: var(--ink);
}

.delete-button {
  width: 32px;
  min-height: 32px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--muted);
  font-size: 22px;
  line-height: 1;
}

.delete-button:hover {
  color: var(--orange);
  border-color: rgba(233, 78, 27, 0.24);
  background: #fff2f0;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

table {
  width: 100%;
  min-width: 680px;
  border-collapse: collapse;
}

tbody tr {
  transition: background 150ms ease;
}

tbody tr:hover {
  background: #f8fcfe;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 12px 11px;
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--ink);
  font-size: 12px;
  font-weight: 860;
  text-transform: uppercase;
  background: var(--blue);
  position: sticky;
  top: 0;
  z-index: 1;
}

.sort-head {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: left;
  text-transform: inherit;
}

.sort-head:hover {
  color: var(--orange);
}

.sort-head[aria-sort="ascending"]::after,
.sort-head[aria-sort="descending"]::after {
  margin-left: 5px;
  color: var(--orange);
  font-size: 10px;
}

.sort-head[aria-sort="ascending"]::after {
  content: "↑";
}

.sort-head[aria-sort="descending"]::after {
  content: "↓";
}

td {
  font-size: 13px;
}

.bi-hero {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
  overflow: hidden;
  background: #ffffff;
}

.bi-hero span {
  color: var(--orange);
  font-size: 12px;
  font-weight: 860;
  text-transform: uppercase;
}

.bi-hero h2 {
  margin-top: 5px;
  font-size: 26px;
}

.analytics-controls {
  display: grid;
  grid-template-columns: 170px 145px 145px;
  gap: 10px;
  align-content: center;
}

.bi-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  align-items: stretch;
  grid-auto-flow: row dense;
}

.wide {
  grid-column: span 7;
}

.full-width {
  grid-column: 1 / -1;
}

.bi-kpis {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  grid-column: 1 / -1;
  box-shadow: none;
  background: transparent;
  border: 0;
  padding: 0;
}

.bi-kpis article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.bi-kpis span,
.bi-kpis small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.bi-kpis strong {
  display: block;
  margin: 6px 0 4px;
  color: var(--ink);
  font-size: 28px;
  font-variant-numeric: tabular-nums;
}

.chart-card {
  grid-column: span 5;
  min-height: 220px;
  align-content: start;
}

.chart-card.wide {
  grid-column: span 7;
}

.chart-card.agent-touch-dashboard,
.chart-card.touch-depth-dashboard,
.chart-card.type-panel,
.chart-card.recommendation-panel,
.chart-card.leader-panel,
.chart-card.density-panel {
  grid-column: span 6;
}

.chart-card.matrix-panel {
  grid-column: 1 / -1;
}

.chart-card.full-width {
  grid-column: 1 / -1;
}

.chart-card.compact-chart {
  min-height: 0;
}

.analytics-combo-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.85fr);
  gap: 18px;
  align-items: start;
}

.combo-panel {
  min-width: 0;
}

.subhead {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.subhead h3 {
  font-size: 15px;
}

.subhead span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 760;
}

.trend-chart {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: 10px;
  align-items: end;
  height: 178px;
  padding: 14px 6px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.trend-column {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  height: 100%;
  min-width: 0;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 6px 4px 5px;
  background: transparent;
  align-items: end;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.trend-column:hover {
  background: #fff1ec;
  color: var(--ink);
}

.trend-column i {
  display: block;
  width: 100%;
  min-height: 10px;
  flex: 0 0 auto;
  border-radius: 8px 8px 2px 2px;
  background: linear-gradient(180deg, var(--orange), #b63b16);
  animation: barGrow 700ms ease both;
}

.trend-column strong {
  color: var(--ink);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.leaderboard {
  display: grid;
  gap: 9px;
}

.chart-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.toggle-button {
  min-height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 11px;
  background: #ffffff;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.toggle-button.active,
.toggle-button:hover {
  border-color: rgba(233, 78, 27, 0.28);
  background: #fff1ec;
  color: var(--orange);
}

.leader-row {
  display: grid;
  grid-template-columns: 28px minmax(160px, 1fr) minmax(120px, 0.8fr) 42px;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.leader-row:hover,
.bar-row:hover,
.matrix-cell:hover {
  border-color: rgba(233, 78, 27, 0.22);
  box-shadow: var(--shadow);
}

.leader-row b {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border-radius: 999px;
  background: #fff1ec;
  color: var(--orange);
  font-size: 12px;
}

.leader-row span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.leader-meter {
  height: 9px;
  border-radius: 999px;
  background: #edf7fd;
  overflow: hidden;
}

.leader-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  animation: barGrow 700ms ease both;
}

.bar-row {
  display: grid;
  grid-template-columns: minmax(140px, 220px) minmax(120px, 1fr) minmax(42px, auto);
  gap: 10px;
  align-items: center;
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px;
  background: transparent;
  color: var(--ink);
  text-align: left;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.bar-row.has-reach {
  grid-template-columns: minmax(150px, 240px) minmax(120px, 1fr) 68px 68px;
}

.bar-header {
  display: grid;
  grid-template-columns: minmax(150px, 240px) minmax(120px, 1fr) 68px 68px;
  gap: 10px;
  padding: 0 8px 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
  text-align: right;
}

.bar-row span {
  font-variant-numeric: tabular-nums;
  font-weight: 820;
  text-align: right;
}

.bar-row strong {
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf7fd;
  overflow: hidden;
}

.bar-track div {
  height: 100%;
  border-radius: inherit;
  background: var(--orange);
  animation: barGrow 700ms ease both;
}

.density-legend {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.density-legend span {
  display: flex;
  align-items: center;
  gap: 8px;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
}

.dot.green {
  background: var(--green);
}

.dot.yellow {
  background: var(--yellow);
}

.dot.red {
  background: var(--red);
}

.matrix-table {
  overflow-x: visible;
}

.matrix-table table {
  min-width: 100%;
}

.matrix-table th:not(:first-child),
.matrix-table td:not(:first-child) {
  width: 118px;
  text-align: center;
}

.matrix-cell {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(233, 78, 27, 0.12);
  border-radius: var(--radius-sm);
  background: rgba(212, 237, 252, calc(0.45 + var(--heat) * 0.42));
  color: var(--ink);
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.insight-drawer {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  justify-content: flex-end;
  background: rgba(19, 35, 29, 0.42);
  backdrop-filter: blur(3px);
}

.insight-drawer.open {
  display: flex;
}

.insight-panel {
  width: min(680px, 100%);
  height: 100%;
  overflow-y: auto;
  padding: 22px;
  background: #ffffff;
  box-shadow: -18px 0 40px rgba(67, 41, 24, 0.12);
  animation: panelIn 240ms ease both;
}

.insight-panel > .delete-button {
  float: right;
}

.insight-panel h2 {
  margin: 6px 42px 18px 0;
  font-size: 22px;
}

.insight-panel h3 {
  margin: 18px 0 8px;
  font-size: 14px;
}

.insight-charts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

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

.insight-kpis article,
.mini-list span,
.insight-list article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.insight-kpis article {
  padding: 12px;
}

.insight-kpis span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
}

.insight-kpis strong {
  display: block;
  margin-top: 5px;
  font-size: 24px;
}

.mini-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.mini-bars {
  display: grid;
  gap: 7px;
}

.mini-bars div {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(90px, 0.8fr) 28px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 12px;
}

.mini-bars i {
  display: block;
  height: 8px;
  border-radius: 999px;
  background: var(--orange);
}

.mini-bars b {
  color: var(--ink);
}

.mini-list span {
  padding: 7px 9px;
  color: var(--muted);
  font-size: 12px;
}

.mini-list b {
  color: var(--ink);
}

.insight-list {
  display: grid;
  gap: 8px;
}

.insight-list article {
  padding: 11px;
}

.insight-list span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.insight-list p {
  margin-top: 7px;
  font-size: 13px;
  line-height: 1.45;
}

.recommendation-list,
.planner-recommendations {
  display: grid;
  gap: 8px;
}

.planner-recommendations {
  margin-bottom: 12px;
}

.planner-recommendation-head {
  display: grid;
  gap: 3px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px 11px;
  background: #fff8dc;
}

.planner-recommendation-head strong,
.planner-recommendation-head span {
  display: block;
}

.planner-recommendation-head span {
  color: var(--muted);
  font-size: 12px;
}

.recommendation-card {
  display: grid;
  gap: 4px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 11px;
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.recommendation-card.priority-high {
  border-color: rgba(61, 104, 39, 0.32);
  background: #f3f8ef;
}

.recommendation-card.priority-medium {
  border-color: rgba(251, 187, 16, 0.48);
  background: #fff8dc;
}

.recommendation-card.priority-low {
  background: #f8fcfe;
}

.planner-recommendation {
  position: relative;
  padding-left: 14px;
}

.planner-recommendation::before {
  content: "";
  position: absolute;
  inset: 10px auto 10px 0;
  width: 4px;
  border-radius: 999px;
  background: var(--green);
}

.planner-recommendation.red {
  border-color: rgba(233, 78, 27, 0.22);
  background: #fff1ec;
}

.planner-recommendation.red::before {
  background: var(--red);
}

.planner-recommendation.yellow {
  border-color: rgba(245, 158, 11, 0.28);
  background: #fff8dc;
}

.planner-recommendation.yellow::before {
  background: var(--yellow);
}

.planner-recommendation.green {
  border-color: rgba(61, 104, 39, 0.18);
  background: #f3f8ef;
}

.recommendation-card:hover {
  border-color: rgba(233, 78, 27, 0.22);
  box-shadow: var(--shadow);
}

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 120;
  max-width: min(360px, calc(100vw - 32px));
  border: 1px solid rgba(233, 78, 27, 0.24);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: #ffffff;
  color: var(--ink);
  box-shadow: var(--shadow-strong);
  transform: translateY(16px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast strong,
.toast span {
  display: block;
}

.toast strong {
  font-size: 13px;
}

.toast span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
}

.recommendation-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.empty {
  padding: 26px 12px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1120px) {
  .app {
    grid-template-columns: 1fr;
  }

  .rail {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .split,
  .compact-left,
  .activity-layout,
  .plan-settings-grid,
  .plan-dashboard-grid,
  .plan-owner-list,
  .bi-grid {
    grid-template-columns: 1fr;
  }

  .chart-card,
  .chart-card.agent-touch-dashboard,
  .chart-card.touch-depth-dashboard,
  .chart-card.type-panel,
  .chart-card.recommendation-panel,
  .chart-card.leader-panel,
  .chart-card.density-panel,
  .wide,
  .full-width {
    grid-column: 1 / -1;
  }

  .activity-editor {
    position: static;
  }

  .inline-add {
    min-width: 0;
  }

  .analytics-combo-grid {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 760px) {
  body {
    overscroll-behavior: contain;
  }

  .app {
    display: block;
  }

  .menu-toggle {
    display: grid !important;
    flex: 0 0 40px;
  }

  .rail {
    position: fixed;
    z-index: 40;
    inset: 0 auto 0 0;
    width: min(82vw, 310px);
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform 220ms ease;
    border-right: 1px solid var(--line);
    border-bottom: 0;
    box-shadow: var(--shadow-strong);
  }

  .rail-demo-toggle {
    display: inline-flex;
  }

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

  body.nav-open::after {
    content: "";
    position: fixed;
    z-index: 35;
    inset: 0;
    background: rgba(31, 43, 36, 0.34);
  }

  .workspace {
    padding: 12px;
  }

  .planner-tools {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: sticky;
    z-index: 20;
    top: 0;
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr);
    align-items: center;
    margin: -12px -12px 12px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--line);
    background: rgba(244, 247, 242, 0.96);
    backdrop-filter: blur(10px);
  }

  .topbar > div:first-of-type {
    display: none;
  }

  .topbar p,
  .topbar h1 {
    display: none;
  }

  .top-actions {
    grid-column: 2;
    grid-row: 1;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-content: stretch;
    gap: 8px;
    margin-top: 0;
    padding-bottom: 0;
  }

  .top-actions .icon-button {
    display: none;
  }

  .top-actions .sync-status {
    display: none;
  }

  .top-actions .primary-button {
    width: 100%;
    min-height: 48px;
    font-size: 15px;
  }

  .card-head,
  .density-card {
    align-items: stretch;
    flex-direction: column;
  }

  .kpis,
  .data-kpis,
  .bi-kpis,
  .plan-stats,
  .plan-target-row,
  .plan-dashboard-grid,
  .form-grid,
  .filters,
  .agent-tools,
  .agent-picker-head,
  .inline-add {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .kpis {
    display: none;
  }

  .kpis article,
  .surface {
    padding: 12px;
  }

  .kpis strong {
    font-size: 22px;
  }

  .activity-editor {
    max-height: none;
    overflow: visible;
  }

  .activity-list {
    max-height: none;
    overflow: visible;
    padding-right: 0;
  }

  .table-wrap {
    margin-inline: -2px;
  }

  .activity-card,
  .density-card,
  .planner-card {
    padding: 10px;
  }

  .agent-picker {
    padding: 10px;
  }

  .agent-checklist {
    grid-template-columns: 1fr;
  }

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

  .data-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .user-gate {
    align-items: start;
    padding: 14px;
  }

  .user-gate-panel {
    margin-top: 28px;
    padding: 18px;
  }

  h1 {
    overflow: hidden;
    font-size: 19px;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .insight-kpis,
  .insight-charts,
  .analytics-controls {
    grid-template-columns: 1fr;
  }

  .bi-hero {
    flex-direction: column;
  }

  .analytics-combo {
    overflow: hidden;
  }

  .trend-chart {
    grid-template-columns: repeat(var(--trend-count), minmax(42px, 1fr));
    gap: 8px;
    height: 176px;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 8px 6px;
    -webkit-overflow-scrolling: touch;
  }

  .trend-column {
    min-width: 42px;
    padding: 5px 2px 4px;
    font-size: 11px;
  }

  .trend-column strong {
    font-size: 12px;
  }

  .trend-column span {
    white-space: nowrap;
  }

  .toast {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 460px) {
  .kpis {
    grid-template-columns: 1fr;
  }

  .primary-button {
    flex: 1;
  }
}

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

@keyframes surfaceIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes barGrow {
  from {
    transform: scaleY(0.15);
    transform-origin: bottom;
    opacity: 0.2;
  }
  to {
    transform: scaleY(1);
    transform-origin: bottom;
    opacity: 1;
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}
