:root {
  color-scheme: light;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --ink: #111827;
  --text: #263241;
  --muted: #687386;
  --line: #d9e0e8;
  --line-strong: #bdc7d3;
  --teal: #006b5f;
  --teal-dark: #004f46;
  --blue: #1d4f91;
  --blue-soft: #e8f1ff;
  --green: #157347;
  --green-soft: #e8f6ef;
  --red: #a33b3b;
  --red-soft: #fff0f0;
  --amber: #9a6700;
  --amber-soft: #fff6db;
  --shadow: 0 10px 30px rgba(31, 41, 55, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

button,
input,
select {
  font: inherit;
}

button {
  min-height: 38px;
  border: 1px solid var(--teal);
  background: var(--teal);
  color: #fff;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 750;
  cursor: pointer;
}

button:hover {
  background: var(--teal-dark);
}

button.secondary {
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

button.secondary:hover {
  background: var(--panel-soft);
}

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

input,
select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(0, 107, 95, 0.18);
  outline-offset: 1px;
}

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

.login-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(245, 247, 250, 0.96)),
    repeating-linear-gradient(90deg, rgba(17, 24, 39, 0.035) 0 1px, transparent 1px 72px),
    repeating-linear-gradient(0deg, rgba(17, 24, 39, 0.03) 0 1px, transparent 1px 72px),
    var(--bg);
}

.login-shell {
  width: min(440px, calc(100vw - 28px));
}

.login-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 30px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: #fff;
  border-radius: 8px;
  font-weight: 850;
  margin-bottom: 18px;
}

.brand-mark.small {
  width: 36px;
  height: 36px;
  margin: 0;
  font-size: 12px;
}

.login-panel h1 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 24px;
  line-height: 1.15;
}

.login-panel p {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.45;
}

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

.login-form button {
  width: 100%;
  margin-top: 4px;
}

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

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.eyebrow {
  color: var(--teal);
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 2px 0 0;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.1;
}

.header-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-main {
  width: min(1760px, 100%);
  margin: 0 auto;
  padding: 18px 24px 28px;
}

.report-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.report-head h2 {
  margin: 0 0 4px;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.15;
}

.report-head p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.secure-note {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--green);
  padding: 7px 11px;
  font-size: 12px;
  font-weight: 800;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
}

.metric span,
.metric small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.25;
}

.metric strong {
  display: block;
  color: var(--ink);
  font-size: 22px;
  line-height: 1.05;
  margin: 4px 0;
}

.control-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(31, 41, 55, 0.04);
  padding: 12px;
  margin-bottom: 12px;
}

.segment-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.segment {
  min-height: 34px;
  background: #fff;
  color: var(--text);
  border-color: var(--line-strong);
}

.segment:hover {
  background: var(--panel-soft);
}

.segment.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fff;
}

.filter-grid {
  display: grid;
  grid-template-columns: minmax(240px, 1.4fr) minmax(135px, 0.75fr) minmax(145px, 0.8fr) minmax(160px, 0.9fr) 130px 100px 126px;
  align-items: end;
  gap: 10px;
}

.search-field input {
  padding-left: 12px;
}

.applied-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
  margin-top: 10px;
}

.filter-chip,
.muted-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel-soft);
  color: var(--muted);
  padding: 5px 9px;
  font-size: 12px;
  line-height: 1.2;
}

.filter-chip strong {
  color: var(--ink);
}

.data-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 390px;
  align-items: start;
  gap: 12px;
}

.table-card,
.detail-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(31, 41, 55, 0.04);
}

.table-toolbar {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

#resultCount {
  display: block;
  color: var(--ink);
  font-size: 14px;
}

.range-info {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-top: 2px;
}

.pager {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.pager button {
  min-height: 32px;
  height: 32px;
  padding: 0 10px;
}

.table-scroll {
  overflow: auto;
  max-height: calc(100vh - 312px);
  min-height: 420px;
}

table {
  width: 100%;
  min-width: 900px;
  border-collapse: separate;
  border-spacing: 0;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef3f8;
  color: #334155;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
  cursor: pointer;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover td,
tbody tr.selected td {
  background: #f3faf8;
}

tbody tr.selected td:first-child {
  box-shadow: inset 3px 0 0 var(--teal);
}

.client-cell {
  min-width: 220px;
}

.row-open,
.service-cell strong,
.capacity strong {
  display: block;
  color: var(--ink);
  line-height: 1.25;
}

.row-open {
  min-height: 0;
  width: 100%;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
  font-weight: 850;
  cursor: pointer;
}

.row-open:hover {
  background: transparent;
  color: var(--teal);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.client-cell span,
.service-cell span,
.capacity span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  margin-top: 3px;
}

.capacity {
  min-width: 130px;
}

.capacity strong {
  color: var(--blue);
  white-space: nowrap;
}

.service-cell {
  min-width: 260px;
}

.section-badge,
.status {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 850;
  line-height: 1.2;
  white-space: nowrap;
}

.section-badge {
  background: var(--blue-soft);
  color: var(--blue);
}

.status.neutral {
  background: var(--blue-soft);
  color: var(--blue);
}

.status.success {
  background: var(--green-soft);
  color: var(--green);
}

.status.danger {
  background: var(--red-soft);
  color: var(--red);
}

.detail-card {
  position: sticky;
  top: 76px;
  max-height: calc(100vh - 92px);
  overflow: auto;
  padding: 0;
}

.empty-detail {
  min-height: 420px;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
  gap: 6px;
  padding: 24px;
}

.empty-detail strong {
  color: var(--ink);
  font-size: 16px;
}

.detail-heading {
  padding: 16px 16px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-soft);
}

.detail-heading h2 {
  margin: 10px 0 4px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
}

.detail-heading p {
  margin: 0;
  color: var(--muted);
  line-height: 1.35;
}

.detail-section {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.detail-section:last-child {
  border-bottom: 0;
}

.detail-section h3 {
  margin: 0 0 10px;
  color: var(--ink);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.detail-grid {
  display: grid;
  gap: 9px;
}

.detail-item {
  display: grid;
  gap: 2px;
}

.detail-item span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.detail-item strong {
  color: var(--text);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

@media (max-width: 1320px) {
  .metrics {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .filter-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

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

  .detail-card {
    position: static;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
    padding: 12px 14px;
  }

  .header-actions,
  .header-actions button {
    width: 100%;
  }

  .app-main {
    padding: 14px;
  }

  .report-head {
    flex-direction: column;
  }

  .report-head h2 {
    font-size: 19px;
  }

  .secure-note {
    align-self: flex-start;
  }

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

  .segment-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .table-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .pager {
    width: 100%;
    justify-content: space-between;
  }

  .table-scroll {
    max-height: none;
    min-height: 360px;
  }

  table {
    min-width: 760px;
  }

  .login-panel {
    padding: 24px;
  }
}
