:root {
  color-scheme: dark;
  --bg: #101214;
  --panel: #171d24;
  --panel-2: #202832;
  --panel-3: #121820;
  --border: #344252;
  --text: #eef6ff;
  --muted: #9ec8f0;
  --blue: #58adff;
  --green: #22d889;
  --yellow: #f2bd4d;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button,
input,
select {
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #101720;
  color: var(--text);
}

button {
  cursor: pointer;
  padding: 8px 12px;
  background: #184f85;
  border-color: #2f75b8;
  font-weight: 700;
}

button:hover {
  border-color: var(--blue);
}

input,
select {
  min-height: 36px;
  padding: 7px 9px;
}

.topbar {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--border);
  background: #111820;
}

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

.home-link {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: #101720;
  color: var(--yellow);
  text-decoration: none;
}

.home-link:hover {
  border-color: var(--blue);
}

.home-link svg {
  width: 19px;
  height: 19px;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  fill: none;
}

h1 {
  margin: 0;
  font-size: 20px;
  line-height: 1.1;
}

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

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

.toolbar label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.toolbar select {
  min-width: 128px;
}

.login-panel {
  position: fixed;
  inset: 58px 0 0;
  display: grid;
  place-items: center;
  background: rgba(16, 18, 20, 0.94);
  z-index: 20;
  padding: 18px;
}

.login-panel[hidden] {
  display: none;
}

.login-box {
  width: min(360px, 100%);
  display: grid;
  gap: 12px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.login-box h2 {
  margin: 0;
  font-size: 18px;
}

.login-box label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

.page {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(8, minmax(135px, 1fr));
  gap: 10px;
}

.metric-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
}

.metric-card {
  min-height: 96px;
  padding: 11px 12px;
}

.metric-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

.metric-value {
  margin: 7px 0 3px;
  font-size: 28px;
  line-height: 1;
  font-weight: 900;
}

.metric-sub {
  color: var(--muted);
  font-size: 12px;
}

.split-grid {
  display: grid;
  grid-template-columns: minmax(520px, 1.25fr) minmax(430px, 1fr);
  gap: 14px;
}

.lower {
  grid-template-columns: minmax(520px, 1fr) minmax(520px, 1fr);
}

.panel-title {
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  background: var(--panel-2);
  font-weight: 800;
}

.panel-body {
  padding: 12px;
}

.range-chart {
  overflow-x: auto;
}

.day-axis {
  display: grid;
  grid-template-columns: 150px minmax(520px, 1fr) 118px;
  gap: 8px;
  align-items: end;
  min-width: 850px;
  padding: 0 0 9px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(88, 173, 255, 0.22);
}

.day-axis-track {
  position: relative;
  height: 30px;
  border-left: 1px solid rgba(158, 200, 240, 0.42);
  border-right: 1px solid rgba(158, 200, 240, 0.42);
  background-image: repeating-linear-gradient(
    to right,
    rgba(158, 200, 240, 0.32) 0,
    rgba(158, 200, 240, 0.32) 1px,
    transparent 1px,
    transparent calc(100% / 24)
  );
}

.day-axis-label {
  position: absolute;
  top: 0;
  transform: translateX(2px);
  color: var(--muted);
  font-size: 8px;
  line-height: 1;
  white-space: nowrap;
}

.day-axis-label:first-child {
  transform: translateX(2px);
}

.day-axis-label:last-child {
  transform: translateX(2px);
}

.range-row {
  display: grid;
  grid-template-columns: 150px minmax(520px, 1fr) 118px;
  gap: 8px;
  align-items: center;
  min-width: 850px;
  padding: 7px 0;
  border-bottom: 1px solid rgba(52, 66, 82, 0.75);
}

.range-time {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
  overflow: hidden;
}

.range-time span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.range-row:last-child {
  border-bottom: 0;
}

.agent-name strong {
  display: block;
}

.track {
  height: 20px;
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  background-color: #0e1620;
  background-image: repeating-linear-gradient(
    to right,
    rgba(158, 200, 240, 0.2) 0,
    rgba(158, 200, 240, 0.2) 1px,
    transparent 1px,
    transparent calc(100% / 24)
  );
  border: 1px solid #263343;
}

.range-bar {
  position: absolute;
  top: 3px;
  height: 6px;
  border-radius: 2px;
  min-width: 3px;
  background: var(--blue);
}

.range-bar.outbound {
  top: 11px;
  background: var(--green);
}

.empty {
  padding: 26px;
  text-align: center;
  color: var(--muted);
}

.table-wrap {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(52, 66, 82, 0.8);
  text-align: left;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}

.week-grid {
  display: grid;
  grid-template-columns: 112px repeat(7, minmax(72px, 1fr));
  gap: 6px;
  overflow: auto;
}

.week-label {
  display: flex;
  align-items: center;
  color: var(--muted);
  font-weight: 800;
}

.day-box {
  min-height: 64px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel-3);
  padding: 7px;
}

.day-box strong {
  display: block;
  font-size: 18px;
}

.heatmap {
  overflow: auto;
}

.heat-head,
.heat-row {
  display: grid;
  grid-template-columns: 122px repeat(24, minmax(18px, 1fr));
  gap: 2px;
  align-items: center;
}

.heat-head {
  color: var(--muted);
  font-size: 10px;
  margin-bottom: 6px;
}

.heat-row {
  margin: 5px 0;
  font-size: 11px;
}

.heat-cell {
  height: 22px;
  border-radius: 2px;
  background: #172334;
}

.heat-1 { background: #183a5f; }
.heat-2 { background: #235c93; }
.heat-3 { background: #2f82cc; }
.heat-4 { background: #22d889; }

@media (max-width: 1320px) {
  .summary-grid {
    grid-template-columns: repeat(4, minmax(135px, 1fr));
  }

  .split-grid,
  .lower {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .toolbar {
    justify-content: stretch;
  }

  .toolbar label,
  .toolbar button {
    width: 100%;
  }

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

  .range-row {
    grid-template-columns: 1fr;
    min-width: 0;
  }

  .day-axis {
    grid-template-columns: minmax(520px, 1fr);
    min-width: 520px;
  }

  .day-axis-spacer {
    display: none;
  }
}
