:root {
  --ink: #17202a;
  --muted: #6f7b88;
  --line: #e7e9ec;
  --canvas: #f4f5f6;
  --surface: #ffffff;
  --charcoal: #1d252b;
  --coral: #e86f51;
  --coral-dark: #cf583e;
  --coral-soft: #fce9e4;
  --blue: #4976d1;
  --blue-soft: #e8eefb;
  --shadow: 0 16px 45px rgba(27, 35, 41, 0.08);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--canvas);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.is-hidden {
  display: none !important;
}

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

.eyebrow {
  margin: 0 0 8px;
  color: var(--coral-dark);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.button {
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 11px;
  cursor: pointer;
  font-weight: 750;
  transition: 150ms ease;
}

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

.button:focus-visible,
button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(73, 118, 209, 0.3);
  outline-offset: 2px;
}

.button-primary {
  background: var(--coral);
  color: #fff;
  box-shadow: 0 8px 20px rgba(232, 111, 81, 0.23);
}

.button-primary:hover {
  background: var(--coral-dark);
}

.button-secondary {
  background: var(--charcoal);
  color: #fff;
}

.button-quiet {
  min-height: 36px;
  background: #f1f2f3;
  color: #3b454d;
}

.button-wide {
  width: 100%;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 16px;
  background: var(--coral);
  color: #fff;
  font-size: 26px;
  font-weight: 900;
  box-shadow: 0 12px 24px rgba(232, 111, 81, 0.25);
}

.brand-mark-small {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  font-size: 20px;
  box-shadow: none;
}

.login-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 15% 10%, rgba(232, 111, 81, 0.16), transparent 28%),
    radial-gradient(circle at 86% 82%, rgba(73, 118, 209, 0.13), transparent 30%),
    #1c242a;
}

.login-shell {
  display: grid;
  min-height: 100vh;
  padding: 32px 20px;
  place-items: center;
}

.login-card {
  width: min(100%, 430px);
  padding: 42px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.97);
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
}

.login-card .brand-mark {
  margin-bottom: 28px;
}

.login-card h1 {
  margin: 0;
  font-size: clamp(30px, 6vw, 42px);
  letter-spacing: -0.04em;
}

.login-lead {
  margin: 12px 0 28px;
  color: var(--muted);
  line-height: 1.6;
}

.login-form {
  display: grid;
  gap: 18px;
}

.login-form label,
.date-fields label {
  display: grid;
  gap: 7px;
  color: #505a63;
  font-size: 13px;
  font-weight: 750;
}

.login-form input,
.date-fields input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  border: 1px solid #d9dde1;
  border-radius: 10px;
  background: #fff;
  color: var(--ink);
}

.secure-note {
  margin: 22px 0 0;
  color: #9098a0;
  font-size: 12px;
  text-align: center;
}

.topbar {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 max(24px, calc((100vw - 1280px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(14px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 16px;
}

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

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

.status-dot {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 12px;
}

.status-dot i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #36a66f;
  box-shadow: 0 0 0 4px rgba(54, 166, 111, 0.12);
}

.dashboard-shell {
  width: min(calc(100% - 40px), 1480px);
  margin: 0 auto;
  padding: 42px 0 70px;
}

.page-heading,
.card-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.page-heading {
  margin-bottom: 28px;
}

.page-heading h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 52px);
  letter-spacing: -0.045em;
}

.page-heading > div > p:last-child {
  margin: 10px 0 0;
  color: var(--muted);
}

.filter-panel {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 24px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: 0 8px 28px rgba(27, 35, 41, 0.04);
}

.quick-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.quick-filters button {
  min-height: 38px;
  padding: 0 14px;
  border: 1px solid #dde0e3;
  border-radius: 10px;
  background: #fff;
  color: #4f5962;
  cursor: pointer;
  font-weight: 700;
}

.quick-filters button.is-active {
  border-color: var(--coral);
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.manager-filter {
  position: relative;
  min-width: 210px;
}

.manager-filter summary {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 13px;
  border: 1px solid #dde0e3;
  border-radius: 10px;
  background: #fff;
  color: #4f5962;
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
  list-style: none;
}

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

.manager-filter summary::after {
  color: #8c969e;
  content: "⌄";
  font-size: 18px;
}

.manager-filter[open] summary {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(73, 118, 209, 0.12);
}

.manager-filter-menu {
  position: absolute;
  z-index: 20;
  top: calc(100% + 8px);
  left: 0;
  width: min(320px, 80vw);
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(24, 34, 42, 0.16);
}

.manager-filter-menu > button {
  width: 100%;
  padding: 9px 10px;
  border: 0;
  border-radius: 8px;
  background: #f3f5f6;
  color: #46515a;
  cursor: pointer;
  text-align: left;
  font-weight: 750;
}

.manager-filter-options {
  display: grid;
  max-height: 260px;
  gap: 4px;
  margin-top: 7px;
  overflow-y: auto;
}

.manager-filter-options label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
}

.manager-filter-options label:hover {
  background: var(--blue-soft);
}

.manager-filter-options input {
  width: 17px;
  height: 17px;
  accent-color: var(--blue);
}

.date-fields {
  display: flex;
  align-items: end;
  gap: 10px;
}

.date-fields input {
  width: 148px;
  height: 40px;
}

.date-separator {
  padding-bottom: 10px;
  color: #9ca3a9;
}

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 18px;
  margin: 24px 0;
}

.metric-card {
  display: flex;
  min-height: 188px;
  align-items: flex-start;
  gap: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 28px rgba(27, 35, 41, 0.045);
}

.metric-card > div:last-child {
  display: flex;
  min-width: 0;
  height: 100%;
  flex: 1;
  flex-direction: column;
  align-self: stretch;
}

.metric-card-accent {
  border-color: #f0b7a8;
  background: linear-gradient(135deg, #fff 45%, #fef1ed);
}

.metric-card-warning {
  border-color: #f2d9a8;
  background: linear-gradient(135deg, #fff 45%, #fff8e8);
}

.metric-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 13px;
  background: var(--coral-soft);
  color: var(--coral-dark);
  font-size: 22px;
  font-weight: 900;
}

.metric-icon-blue {
  background: var(--blue-soft);
  color: var(--blue);
}

.metric-icon-slate {
  background: #edf0f2;
  color: #57636c;
}

.metric-icon-warning {
  background: #fff0cf;
  color: #b56a00;
}

.metric-card p {
  display: flex;
  min-height: 36px;
  align-items: flex-start;
  margin: 1px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

.metric-card strong {
  display: block;
  margin-bottom: 12px;
  font-size: 38px;
  letter-spacing: -0.04em;
}

.metric-card small {
  display: block;
  margin-top: auto;
  color: #8b949b;
  font-size: 11px;
  line-height: 1.4;
}

.content-card {
  margin-top: 18px;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: 0 10px 32px rgba(27, 35, 41, 0.05);
}

.card-heading {
  align-items: center;
  margin-bottom: 24px;
}

.card-heading h2 {
  margin: 0;
  font-size: 23px;
  letter-spacing: -0.025em;
}

.chart-legend {
  display: flex;
  gap: 18px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.chart-legend span {
  display: flex;
  align-items: center;
  gap: 7px;
}

.chart-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 3px;
}

.legend-dialogs {
  background: var(--coral);
}

.legend-incoming {
  background: var(--blue);
}

.legend-unanswered {
  border-radius: 50% !important;
  background: #d9911e;
}

.chart-wrap {
  position: relative;
  min-height: 310px;
  overflow-x: auto;
}

#activity-chart {
  display: block;
  width: 100%;
  height: 310px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

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

th {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  color: #7d8790;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-align: left;
  text-transform: uppercase;
  vertical-align: bottom;
}

td {
  padding: 17px 14px;
  border-bottom: 1px solid #eff0f2;
  color: #3e4850;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.manager-row {
  cursor: pointer;
  transition: background 120ms ease;
}

.manager-row:hover {
  background: #faf6f4;
}

.manager-name {
  display: flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-weight: 800;
}

.avatar {
  display: grid;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--charcoal);
  color: #fff;
  font-size: 12px;
}

.number-cell {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.managers-table {
  min-width: 900px;
  table-layout: fixed;
}

.managers-table th:first-child,
.managers-table td:first-child {
  width: 34%;
}

.managers-table th:last-child,
.managers-table td:last-child {
  width: 14%;
  white-space: nowrap;
}

.managers-table th:not(:first-child):not(:last-child),
.managers-table td:not(:first-child):not(:last-child) {
  width: 13%;
}

.row-action {
  border: 0;
  background: transparent;
  color: var(--coral-dark);
  cursor: pointer;
  font-weight: 800;
}

.loading-cell,
.empty-state {
  padding: 36px 20px;
  color: var(--muted);
  text-align: center;
}

.updated-at {
  color: #91999f;
  font-size: 12px;
}

.alert {
  margin: 16px 0;
  padding: 13px 15px;
  border-radius: 11px;
  font-size: 13px;
  line-height: 1.5;
}

.alert-error {
  border: 1px solid #f0b8ae;
  background: #fff0ed;
  color: #9a382b;
}

.alert-warning {
  border: 1px solid #ead49b;
  background: #fff9e9;
  color: #755d1d;
}

.dialog-modal {
  width: min(calc(100% - 32px), 1120px);
  max-height: min(86vh, 850px);
  padding: 0;
  border: 0;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 100px rgba(0, 0, 0, 0.3);
}

.dialog-modal::backdrop {
  background: rgba(18, 24, 28, 0.68);
  backdrop-filter: blur(4px);
}

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

.dialog-header h2 {
  margin: 0;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: #fff;
  color: #56616a;
  cursor: pointer;
  font-size: 24px;
}

.dialog-table-wrap {
  max-height: 62vh;
  padding: 10px 26px 26px;
}

.crm-links {
  display: flex;
  gap: 8px;
}

.crm-links a {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}

@media (max-width: 900px) {
  .filter-panel,
  .date-fields {
    align-items: stretch;
    flex-direction: column;
  }

  .manager-filter {
    width: 100%;
  }

  .date-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .date-fields input {
    width: 100%;
  }

  .date-separator {
    display: none;
  }

  .date-fields .button {
    grid-column: 1 / -1;
  }

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

  .metric-card {
    min-height: auto;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 0 16px;
  }

  .status-dot {
    display: none;
  }

  .dashboard-shell {
    width: min(calc(100% - 24px), 1480px);
    padding-top: 28px;
  }

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

  .page-heading,
  .card-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-heading .button {
    width: 100%;
  }

  .date-fields {
    grid-template-columns: 1fr;
  }

  .date-fields .button {
    grid-column: auto;
  }

  .content-card,
  .metric-card {
    padding: 20px;
  }

  .chart-legend {
    flex-wrap: wrap;
  }

  .login-card {
    padding: 30px 24px;
  }
}
