* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  color: #1a1a1a;
  background: #f4f6f5;
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
}

[hidden] { display: none !important; }

.login-screen {
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #157347;
}

.login-card {
  width: 22rem;
  max-width: calc(100% - 2rem);
  background: #fff;
  padding: 1.5rem;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card h1 {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  color: #157347;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}

input, select {
  padding: 0.4rem 0.5rem;
  border: 1px solid #c5cdc8;
  border-radius: 4px;
  background: #fff;
}

button {
  padding: 0.4rem 0.7rem;
  border: 1px solid #157347;
  border-radius: 4px;
  background: #157347;
  color: #fff;
}

button.secondary {
  background: #fff;
  color: #157347;
}

button.secondary.is-active {
  background: #157347;
  color: #fff;
}

button.danger {
  background: #fff;
  color: #9b1c1c;
  border-color: #9b1c1c;
}

button:disabled {
  opacity: 0.55;
  cursor: default;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  background: #157347;
  color: #fff;
  padding: 0.7rem 1rem;
}

.topbar-title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 650;
  font-size: 1.1rem;
}

.topbar-title img {
  height: 1.75rem;
  width: auto;
  display: block;
}

.topbar-tenant {
  flex: 1;
  position: relative;
  min-width: 0;
}

.topbar .tenant-picker {
  background: transparent;
  color: #fff;
  border-color: transparent;
  text-decoration: underline;
  text-underline-offset: 0.15em;
  padding: 0.15rem 0.35rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .tenant-picker:hover,
.topbar .tenant-picker[aria-expanded="true"] {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.tenant-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  left: 0;
  z-index: 30;
  display: flex;
  flex-direction: column;
  min-width: 14rem;
  max-width: 22rem;
  max-height: 16rem;
  overflow: auto;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #e4ebe7;
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(16, 28, 22, 0.12);
  padding: 0.2rem;
}

.topbar .tenant-menu button {
  width: 100%;
  text-align: left;
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
  background: #fff;
  color: #1a1a1a;
  border-color: transparent;
}

.topbar .tenant-menu button:hover:not(:disabled) {
  background: #eef4f1;
  color: #1a1a1a;
}

.tenant-menu button.is-current {
  font-weight: 650;
}

.tenant-menu .note,
.tenant-menu .error {
  margin: 0.35rem 0.5rem;
}

.topbar-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar button {
  background: #fff;
  color: #157347;
  border-color: #fff;
}

.layout {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-footer {
  flex: none;
  padding: 0.35rem 1rem;
  font-size: 0.75rem;
  color: #6b7772;
  text-align: left;
  border-top: 1px solid #d8e0dc;
  background: #f4f6f5;
}

.nav {
  width: 11rem;
  flex: none;
  background: #fff;
  border-right: 1px solid #d8e0dc;
  padding: 0.75rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-btn {
  text-align: left;
  background: transparent;
  color: #1a1a1a;
  border-color: transparent;
}

.nav-btn.is-active {
  background: #157347;
  color: #fff;
  border-color: #157347;
}

.nav-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #1a1a1a;
  padding: 0.15rem 0.55rem 0.1rem;
  pointer-events: none;
}

.nav-label + .nav-btn {
  margin-top: 0;
}

.nav > .nav-label:not(:first-child) {
  margin-top: 1.75rem;
}

.tags-block {
  margin-top: 1.25rem;
}

.main {
  flex: 1;
  min-width: 0;
  padding: 1rem 1.25rem 2rem;
  overflow: auto;
}

.blade h2 {
  margin: 0 0 0.75rem;
  font-size: 1.2rem;
}

.panel {
  background: #fff;
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 0.85rem 1rem;
  margin-bottom: 1rem;
}

.form-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}

.form-row label { min-width: 10rem; }

.provider-type-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem 0.9rem;
  margin: 0 0 0.85rem;
}

.provider-type-caption {
  font-size: 0.85rem;
  color: #3d4a44;
}

.provider-type-option {
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
  font-size: 0.85rem;
}

.provider-type-option input {
  width: auto;
  margin: 0;
  accent-color: #157347;
}

.provider-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  gap: 0.6rem;
  align-items: end;
}

.provider-fields label {
  min-width: 0;
}

.provider-fields label.field-wide {
  grid-column: span 2;
}

.provider-fields input,
.provider-fields select {
  width: 100%;
  min-width: 0;
}

.provider-fields label.field-key {
  min-width: min(28rem, 100%);
}

.provider-fields .field-check,
.provider-fields > button {
  align-self: end;
}

tr.provider-edit-row > td {
  padding-top: 0.75rem;
}

.inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.error {
  color: #9b1c1c;
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.warn {
  color: #8a5a00;
  margin: 0.35rem 0 0;
  font-size: 0.9rem;
}

.note {
  color: #3d4a44;
  margin: 0 0 0.75rem;
}

.empty {
  padding: 1.25rem;
  background: #fff;
  border: 1px dashed #b7c4bd;
  border-radius: 6px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 0.9rem;
}

th, td {
  text-align: left;
  padding: 0.4rem 0.5rem;
  border-bottom: 1px solid #e4ebe7;
  vertical-align: top;
}

th {
  background: #eef4f1;
  font-weight: 600;
  white-space: nowrap;
}

th button.sort {
  background: transparent;
  color: inherit;
  border: 0;
  padding: 0;
  font-weight: 600;
}

th button.sort.is-sortable {
  color: #157347;
}

tr.is-active td { background: #e7f5ee; }

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.actions button {
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
}

.provider-actions {
  position: relative;
}

.provider-action-menu {
  position: fixed;
  z-index: 20;
  display: flex;
  flex-direction: column;
  min-width: 7.5rem;
  background: #fff;
  border: 1px solid #e4ebe7;
  border-radius: 4px;
  box-shadow: 0 6px 16px rgba(16, 28, 22, 0.12);
  padding: 0.2rem;
}

.provider-action-menu button {
  width: 100%;
  text-align: left;
  padding: 0.2rem 0.45rem;
  font-size: 0.8rem;
  background: #fff;
  color: #1a1a1a;
  border-color: transparent;
}

.provider-action-menu button:hover:not(:disabled) {
  background: #eef4f1;
}

.provider-action-menu button:disabled {
  opacity: 0.55;
  cursor: default;
}

.kv {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.5rem 1rem;
  margin: 0;
}

.kv div { margin: 0; }

.kv dt {
  font-size: 0.75rem;
  color: #5c6b64;
}

.kv dd {
  margin: 0.1rem 0 0;
  font-variant-numeric: tabular-nums;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.swatch {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 4px;
  border: 2px solid transparent;
  padding: 0;
}

.swatch.is-selected {
  border-color: #1a1a1a;
  outline: 2px solid #fff;
  outline-offset: -4px;
}

.swatch-label {
  font-size: 0.75rem;
  color: #5c6b64;
}

.tag-chip {
  display: inline-block;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  font-size: 0.8rem;
}

.mark {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0 0.3rem;
  border-radius: 3px;
  background: #f3e8e8;
  color: #9b1c1c;
  font-size: 0.75rem;
}

.pager {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-top: 0.75rem;
}

.blade-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.blade-head h2 {
  margin: 0;
}

.filter-panel .filter-actions {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
}

.copy, .file-btn, .file-link {
  background: #fff;
  color: #157347;
  border: 1px solid #157347;
  padding: 0.1rem 0.3rem;
  line-height: 0;
}

.copy.is-copied {
  line-height: 1.2;
  font-size: 0.75rem;
  padding: 0.15rem 0.35rem;
}

.file-link {
  line-height: 1.2;
  font-size: 0.8rem;
  padding: 0.15rem 0.4rem;
  white-space: nowrap;
}

.copy-cell, .file-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  position: relative;
}

.file-cell {
  align-items: flex-start;
}

.icon {
  display: inline-flex;
  width: 14px;
  height: 14px;
}

.file-list {
  position: absolute;
  z-index: 5;
  top: 1.6rem;
  left: 0;
  min-width: 14rem;
  width: max-content;

  background: #fff;
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  box-shadow: 0 6px 16px rgba(16, 28, 22, 0.12);
}

.info-cell {
  position: relative;
  display: inline-flex;
}

.info-btn {
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border-radius: 999px;
  border: 1px solid #157347;
  background: #fff;
  color: #157347;
  font-size: 0.75rem;
  font-style: italic;
  font-weight: 700;
  line-height: 1.2rem;
}

.info-pop {
  display: none;
  position: absolute;
  z-index: 6;
  top: 1.6rem;
  right: 0;
  min-width: 12rem;
  max-width: 28rem;
  max-height: 16rem;
  overflow-y: auto;
  overflow-wrap: anywhere;
  background: #fff;
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 0.45rem 0.55rem;
  box-shadow: 0 6px 16px rgba(16, 28, 22, 0.12);
  font-size: 0.8rem;
  white-space: normal;
}

.info-cell:hover .info-pop,
.info-cell:focus-within .info-pop {
  display: block;
}

.file-items {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  min-width: 0;
}

.file-row-label {
  flex: 0 0 auto;
  white-space: nowrap;
  font-size: 0.8rem;
}

button.file-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  background: #fff;
  color: #157347;
  border: 1px solid #157347;
  padding: 0.2rem;
  line-height: 1;
}

.absent {
  color: #5c6b64;
  font-size: 0.8rem;
}

.scroll {
  overflow-x: auto;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(16, 28, 22, 0.45);
}

.modal-panel {
  width: 100%;
  max-width: 28rem;
  max-height: calc(100vh - 2rem);
  overflow: auto;
  background: #fff;
  border-radius: 6px;
  padding: 1.25rem 1.35rem;
  box-shadow: 0 12px 32px rgba(16, 28, 22, 0.22);
}

.modal-panel.is-wide {
  max-width: 40rem;
}

.modal-panel.is-provider {
  max-width: 56rem;
}

.provider-head .blade-head-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
  flex: none;
}

.provider-group {
  margin: 1.1rem 0 0.55rem;
  font-size: 1rem;
  color: #157347;
}

.provider-table {
  max-width: 100%;
  overflow-x: hidden;
}

.provider-table table {
  table-layout: fixed;
  width: 100%;
}

.provider-table th,
.provider-table td {
  white-space: normal;
  overflow-wrap: anywhere;
}

.provider-table th:nth-child(1),
.provider-table td:nth-child(1) { width: 14%; }

.provider-table th:nth-child(2),
.provider-table td:nth-child(2) { width: 9%; }

.provider-table th:nth-child(3),
.provider-table td:nth-child(3) { width: 11%; }

.provider-table th:nth-child(4),
.provider-table td:nth-child(4) { width: 22%; }

.provider-table th:nth-child(5),
.provider-table td:nth-child(5) { width: 8%; }

.provider-table th:nth-child(6),
.provider-table td:nth-child(6) { width: 8%; }

.provider-table th:nth-child(7),
.provider-table td:nth-child(7) { width: 16%; }

.provider-table th:nth-child(8),
.provider-table td:nth-child(8) { width: 4.5%; }

.provider-table th:nth-child(9),
.provider-table td:nth-child(9) { width: 4.5%; }

.provider-table th:nth-child(10),
.provider-table td:nth-child(10) { width: 3%; }

.blade-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.blade-head h2 {
  margin: 0;
}

.spec-info-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: #fff;
  color: #157347;
  flex: none;
}

.spec-info-btn svg {
  display: block;
}

.spec-block + .spec-block {
  margin-top: 0.9rem;
  padding-top: 0.9rem;
  border-top: 1px solid #e4ebe7;
}

.spec-block h4 {
  margin: 0 0 0.3rem;
  font-size: 0.95rem;
  color: #157347;
}

.spec-block p {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.45;
}

.spec-key-note {
  margin: 1rem 0 0;
  font-size: 0.9rem;
}

.modal-panel h3 {
  margin: 0 0 0.9rem;
  font-size: 1.1rem;
  color: #157347;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.modal-form > label {
  font-weight: 600;
}

.modal-readonly {
  font-weight: 400;
  padding: 0.4rem 0.5rem;
  border: 1px solid #e4ebe7;
  border-radius: 4px;
  background: #f4f6f5;
  color: #1a1a1a;
}

.modal-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.suggest-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.suggest-row input {
  flex: 1;
  min-width: 0;
}

.session-id.is-deleted {
  color: #9b1c1c;
}

.session-actions {
  position: relative;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
}

.session-more {
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
}

.session-menu {
  position: absolute;
  z-index: 6;
  top: 1.6rem;
  right: 0;
  min-width: 8rem;
  background: #fff;
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 0.25rem;
  box-shadow: 0 6px 16px rgba(16, 28, 22, 0.12);
}

.session-menu-item,
.session-menu-replay {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 0.3rem 0.45rem;
  font-size: 0.85rem;
}

.session-menu-item {
  color: #9b1c1c;
}

.session-menu-replay {
  color: #1f3d32;
}

.replay-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

button.replay-pill {
  padding: 0.15rem 0.45rem;
  font-size: 0.78rem;
  line-height: 1.3;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #c5cdc8;
  border-radius: 4px;
}

button.replay-pill.is-active {
  background: #157347;
  color: #fff;
  border-color: #157347;
}

.replay-sep {
  width: 1px;
  align-self: stretch;
  min-height: 1.2rem;
  background: #d8e0dc;
  margin: 0 0.15rem;
}

.replay-utt-stepper {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.replay-utt-input {
  width: 4.5rem;
  padding: 0.15rem 0.35rem;
  font-size: 0.78rem;
}

.replay-sort {
  padding: 0.15rem 0.35rem;
  font-size: 0.78rem;
}

.replay-regex {
  flex: 1;
  min-width: 8rem;
  max-width: 18rem;
  padding: 0.15rem 0.35rem;
  font-size: 0.78rem;
}

.replay-body {
  margin: 0;
  font-family: SFMono-Regular, Consolas, Menlo, monospace;
  font-size: 11.5px;
  line-height: 1.45;
  background: #1e1e2e;
  color: #cdd6f4;
  padding: 0.75rem;
  overflow: auto;
  white-space: pre;
  min-height: 16rem;
  max-height: calc(100vh - 16rem);
  border-radius: 4px;
}

.replay-body.is-wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  overflow-x: hidden;
}

.stats-kpi {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.stats-kpi-tile {
  flex: 1 1 9.5rem;
  min-width: 8.5rem;
  background: #fff;
  border: 1px solid #d8e0dc;
  border-radius: 6px;
  padding: 0.65rem 0.8rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.stats-kpi-label {
  font-size: 0.75rem;
  color: #5c6b64;
}

.stats-kpi-value {
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1a1a1a;
}

.stats-kpi-sub {
  font-size: 0.75rem;
  color: #5c6b64;
  font-variant-numeric: tabular-nums;
}

.stats-window {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 0.85rem;
  margin: 0 0 1rem;
  font-size: 0.85rem;
  color: #3d4a44;
}

.stats-window-clear {
  min-height: 2.25rem;
}

.stats-bands {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  min-width: 0;
  margin-bottom: 1rem;
}

.stats-bands > .panel,
.stats-split > .panel {
  margin-bottom: 0;
}

.stats-split {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  min-width: 0;
}

.stats-inspector {
  margin-bottom: 1rem;
}

.stats-inspector h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.stats-inspector-date {
  margin: 0 0 0.55rem;
  font-size: 0.85rem;
  color: #3d4a44;
}

.stats-inspector-actions {
  margin-top: 0.75rem;
}

button.linkish {
  padding: 0;
  border: 0;
  background: transparent;
  color: #157347;
  font-weight: 600;
  text-align: left;
  min-height: 2.25rem;
}

.stats-chart-panel {
  min-width: 0;
}

.stats-chart-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 0.95rem;
}

.stats-chart-sub {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: #5c6b64;
}

.stats-chart-caption {
  margin: 0.45rem 0 0;
  font-size: 0.78rem;
  color: #5c6b64;
}

.stats-chart-empty {
  margin: 0.5rem 0 0;
  padding: 2.5rem 0.75rem;
  text-align: center;
  color: #5c6b64;
  background: #f4f6f5;
  border-radius: 4px;
}

.stats-chart-host {
  position: relative;
  width: 100%;
  min-width: 0;
  touch-action: pan-y;
}

.stats-chart-host.is-brushing {
  touch-action: none;
}

.stats-chart-svg {
  display: block;
  width: 100%;
  height: auto;
  outline: none;
}

.stats-plot-hit {
  fill: transparent;
  cursor: crosshair;
}

.stats-brush {
  fill: #157347;
  opacity: 0.12;
  pointer-events: none;
}

.is-pinned {
  fill: none;
  stroke: #157347;
  stroke-width: 1.5;
  pointer-events: none;
}

.stats-guide {
  stroke: #5c6b64;
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.stats-tooltip {
  position: fixed;
  z-index: 40;
  max-width: 18rem;
  padding: 0.45rem 0.6rem;
  background: #1a1a1a;
  color: #fff;
  border-radius: 4px;
  font-size: 0.75rem;
  line-height: 1.35;
  pointer-events: none;
  font-variant-numeric: tabular-nums;
}

.stats-tooltip-date {
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.stats-tooltip-note {
  margin-top: 0.25rem;
  color: #c5cdc8;
}

button.stats-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.15rem 0.35rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: #3d4a44;
  font-size: 0.78rem;
  font-weight: 400;
}

.stats-legend-item.is-hidden {
  opacity: 0.4;
  text-decoration: line-through;
}

.stats-toggle {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.55rem;
}

.stats-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem 0.85rem;
  margin: 0.5rem 0 0;
  font-size: 0.78rem;
  color: #3d4a44;
}

.stats-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.stats-legend-swatch {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 2px;
  flex: 0 0 auto;
}

@media (max-width: 720px) {
  .stats-split {
    grid-template-columns: minmax(0, 1fr);
  }
}
