/* src/styles.css */
* {
  box-sizing: border-box;
}

:root {
  --buncss-light: initial;
  --buncss-dark: ;
  color-scheme: light;
  --bg: #f8faf9;
  --panel: #fff;
  --panel-soft: #fbfdfc;
  --line: #e4e9e7;
  --line-strong: #d6dfdc;
  --text: #101817;
  --muted: #66736f;
  --accent: #0f766e;
  --accent-dark: #0b655e;
  --accent-soft: #eef9f6;
  --hit: #0f8b5f;
  --hit-bg: #f1fbf7;
  --miss: #c56a11;
  --miss-bg: #fff8ea;
  --fail: #c73535;
  --fail-bg: #fff5f5;
  --info: #2f6db5;
  --info-bg: #f2f7ff;
  --shadow: 0 1px 2px #1018170d, 0 14px 32px #1018170a;
}

body {
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Noto Sans, Ubuntu, Cantarell, Helvetica Neue, sans-serif;
}

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

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

svg {
  display: block;
  width: 20px;
  height: 20px;
}

#app {
  max-width: 1800px;
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 28px 42px;
}

.appbar {
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items:  center;
  height: 58px;
  margin: 0 -28px;
  padding: 0 28px;
}

.brand {
  display: flex;
  align-items:  center;
  gap: 14px;
  font-size: 15px;
  font-weight: 760;
}

.brand-mark {
  color: #fff;
  display: grid;
  background: linear-gradient(135deg, #0b8378, #0f766e);
  border-radius: 8px;
  place-items:  center;
  width: 36px;
  height: 36px;
  box-shadow: inset 0 1px #ffffff2e;
}

.brand-mark svg {
  width: 23px;
  height: 23px;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 24px;
  padding: 30px 0 26px;
}

.domain-line {
  display: flex;
  flex-wrap: wrap;
  align-items:  center;
  gap: 14px;
}

h1, h2 {
  letter-spacing: 0;
  margin: 0;
}

h1 {
  font-size: clamp(31px, 3vw, 43px);
  line-height: 1;
}

h2 {
  display: flex;
  align-items:  center;
  gap: 9px;
  font-size: 17px;
  font-weight: 780;
}

.state-dot {
  background: #aebbb6;
  border-radius: 999px;
  width: 11px;
  height: 11px;
}

.state-dot.on {
  background: var(--accent);
  box-shadow: 0 0 0 5px #0f766e1f;
}

.state-text {
  color: #303b38;
  font-size: 15px;
}

.actions, .form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items:  center;
  gap: 12px;
}

.button, .icon-button, .tabs button {
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  min-height: 42px;
}

.button {
  background: var(--panel);
  color: var(--text);
  display: inline-flex;
  justify-content: center;
  align-items:  center;
  gap: 8px;
  padding: 0 23px;
  font-weight: 780;
}

.icon-button {
  aspect-ratio: 1;
  background: var(--panel);
  color: #17211f;
  display: grid;
  place-items:  center;
  width: 42px;
}

.button:hover, .icon-button:hover, .tabs button:hover {
  border-color: #b9c7c2;
}

.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.primary:hover {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

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

.danger {
  color: #fff;
  background: #b42318;
  border-color: #b42318;
}

.icon-text svg {
  width: 18px;
  height: 18px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 24px;
  margin-bottom: 30px;
}

.stat, .samples-panel, .side-panel, .logs-panel, .form-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  border-radius: 8px;
}

.stat {
  display: flex;
  align-items:  center;
  gap: 18px;
  min-height: 116px;
  padding: 22px;
}

.stat-icon, .section-icon {
  background: var(--accent-soft);
  color: var(--accent);
  display: grid;
  border-radius: 8px;
  flex: none;
  place-items:  center;
}

.stat-icon {
  width: 48px;
  height: 48px;
}

.section-icon {
  width: 22px;
  height: 22px;
}

.section-icon svg {
  width: 16px;
  height: 16px;
}

.stat span:not(.stat-icon), .stat small, .section-head span, .age-row span {
  color: var(--muted);
}

.stat span:not(.stat-icon), .stat small {
  display: block;
  font-size: 13px;
}

.stat strong {
  display: block;
  overflow-wrap: anywhere;
  margin: 7px 0;
  font-size: 24px;
  line-height: 1.1;
}

.tabs {
  display: inline-flex;
  overflow: hidden;
  background: #f1f4f3;
  border: 1px solid #e7ecea;
  border-radius: 8px;
  align-items:  center;
  gap: 0;
  margin-bottom: 22px;
  padding: 2px;
}

.tabs button {
  color: #2f3a37;
  position: relative;
  background: none;
  border: 0;
  min-width: 104px;
  padding: 0 18px;
  font-weight: 760;
}

.tabs .active {
  background: var(--panel);
  color: var(--text);
  box-shadow: 0 1px 2px #1018170f;
}

.tabs .active:after {
  background: var(--accent);
  content: "";
  position: absolute;
  border-radius: 999px;
  height: 2px;
  bottom: 0;
  left: 14px;
  right: 14px;
}

.metrics-bottom {
  display: grid;
  grid-template-columns: minmax(320px, .8fr) minmax(420px, 1.2fr);
  align-items:  start;
  gap: 18px;
  margin-top: 18px;
}

.samples-panel, .side-panel, .logs-panel, .form-panel {
  overflow: hidden;
}

.section-head {
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 16px;
  min-height: 60px;
  padding: 0 20px;
}

.section-head span {
  flex: none;
  font-size: 14px;
}

.table-filters {
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(260px, 1.4fr) repeat(3, minmax(150px, .75fr));
  align-items:  end;
  gap: 14px;
  padding: 16px 20px;
}

.table-scroll {
  overflow: auto;
  max-height: 64vh;
}

.table-pagination {
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items:  center;
  gap: 14px;
  min-height: 58px;
  padding: 10px 20px;
}

.page-size-control {
  color: var(--muted);
  display: flex;
  flex: none;
  align-items:  center;
  gap: 8px;
  font-size: 13px;
  font-weight: 740;
}

.page-size-control select {
  width: 82px;
  min-height: 36px;
  padding-top: 7px;
  padding-bottom: 7px;
}

.pagination-range, .page-controls span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.page-controls {
  display: flex;
  align-items:  center;
  gap: 10px;
}

.icon-button.compact {
  width: 36px;
  min-height: 36px;
}

.icon-button.compact svg {
  width: 18px;
  height: 18px;
}

.sample-table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: 100%;
  min-width: 980px;
}

.sample-table th, .sample-table td {
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #eef2f0;
  padding: 13px 14px;
}

.sample-table thead th {
  background: var(--panel);
  color: #2e3936;
  letter-spacing: 0;
  position: sticky;
  text-transform: uppercase;
  z-index: 2;
  font-size: 12px;
  font-weight: 800;
  top: 0;
}

.sample-table tbody th, .sample-table td {
  font-size: 13px;
}

.sample-table tbody tr:hover {
  background: #fbfdfc;
}

.sample-table th:first-child {
  width: 32%;
}

.sample-table th:nth-child(2) {
  width: 13%;
}

.sample-table th:nth-child(3), .sample-table th:nth-child(4), .sample-table th:nth-child(5), .sample-table th:nth-child(6), .sample-table th:nth-child(7) {
  width: 9%;
}

.sample-table th:nth-child(8) {
  width: 10%;
}

.sample-table.metric-matrix {
  min-width: var(--matrix-min-width);
  width: var(--matrix-min-width);
}

.metric-matrix th:first-child, .metric-matrix th:nth-child(2), .metric-matrix tbody td:nth-child(2) {
  position: sticky;
  background: #fff;
}

.matrix-url-col {
  width: var(--matrix-url-width);
}

.matrix-country-col {
  width: var(--matrix-country-width);
}

.matrix-time-col {
  width: var(--matrix-time-width);
}

.metric-matrix th:first-child {
  z-index: 4;
  width: var(--matrix-url-width);
  left: 0;
}

.metric-matrix th:nth-child(2) {
  left: var(--matrix-url-width);
  z-index: 4;
  width: var(--matrix-country-width);
}

.metric-matrix tbody th:first-child {
  z-index: 3;
  left: 0;
}

.metric-matrix tbody td:nth-child(2) {
  left: var(--matrix-url-width);
  z-index: 3;
}

.metric-matrix tbody tr:hover th:first-child, .metric-matrix tbody tr:hover td:nth-child(2) {
  background: #fbfdfc;
}

.metric-matrix th:nth-child(2), .metric-matrix tbody td:nth-child(2) {
  box-shadow: 8px 0 12px -12px #11181673;
}

.metric-time-heading, .metric-matrix .status-cell {
  text-align: center;
  width: var(--matrix-time-width);
}

.metric-time-heading strong, .metric-time-heading span {
  display: block;
}

.metric-time-heading strong {
  color: #111816;
  text-transform: none;
  font-size: 13px;
  line-height: 1.1;
}

.metric-time-heading span {
  color: var(--muted);
  text-transform: none;
  margin-top: 4px;
  font-size: 11px;
  font-weight: 700;
}

.recheck-heading {
  box-shadow: inset 0 3px 0 var(--info);
  background: #f5fbff;
}

.recheck-heading strong {
  color: var(--info);
}

.sample-table td span, .url-cell span {
  color: var(--muted);
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 4px;
  font-size: 12px;
}

.url-cell {
  overflow-wrap: anywhere;
  line-height: 1.25;
}

.url-cell strong {
  display: block;
  font-size: 14px;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  height: 90px;
}

.status-pill {
  display: inline-flex;
  border-radius: 5px;
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
}

.status-button {
  cursor: pointer;
  font: inherit;
  border: 0;
  justify-content: center;
  min-width: 48px;
}

.status-button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.status-pill.hit {
  color: var(--hit);
  background: #dff5ea;
}

.status-pill.miss {
  color: var(--miss);
  background: #ffe5bd;
}

.status-pill.fail {
  color: var(--fail);
  background: #ffe1e1;
}

.status-pill.other {
  color: var(--info);
  background: #dcecff;
}

.status-cell {
  overflow: visible;
  position: relative;
}

.empty-status {
  color: var(--muted);
  font-weight: 700;
}

.sample-details {
  border: 1px solid var(--line);
  color: var(--text);
  position: absolute;
  text-align: left;
  z-index: 5;
  background: #fff;
  border-radius: 8px;
  min-width: 260px;
  padding: 10px 12px;
  top: calc(100% - 4px);
  right: 10px;
  box-shadow: 0 20px 45px #131e1b29;
}

.sample-details dl {
  display: grid;
  gap: 8px;
  margin: 0;
}

.sample-details div {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  align-items:  start;
  gap: 12px;
}

.sample-details dt {
  color: var(--muted);
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 800;
}

.sample-details dd {
  overflow-wrap: anywhere;
  margin: 0;
  font-size: 12px;
  font-weight: 700;
}

.age-list {
  display: grid;
  gap: 15px;
  padding: 18px 18px 20px;
}

.age-row {
  display: grid;
  gap: 8px;
}

.age-row div:first-child {
  display: flex;
  justify-content: space-between;
  align-items:  center;
  gap: 12px;
}

.age-row strong {
  overflow-wrap: anywhere;
  font-size: 13px;
  line-height: 1.25;
}

.age-row span {
  flex: none;
  font-size: 12px;
}

.bar {
  overflow: hidden;
  background: #edf1ef;
  border-radius: 999px;
  height: 8px;
}

.bar i {
  background: var(--accent);
  border-radius: inherit;
  display: block;
  height: 100%;
}

pre {
  color: #d9eee8;
  overflow: auto;
  white-space: pre-wrap;
  background: #111817;
  max-height: 360px;
  margin: 0;
  padding: 16px;
  font-size: 12px;
  line-height: 1.5;
}

.form-panel {
  display: grid;
  gap: 16px;
  max-width: 1080px;
  padding: 20px;
}

.config-panel {
  gap: 0;
  max-width: 1180px;
  padding: 0;
}

.proxy-panel {
  gap: 0;
  max-width: none;
  padding: 0;
}

.proxy-panel textarea, .proxy-panel .form-actions {
  margin: 20px;
}

.proxy-panel .form-actions {
  margin-top: 0;
}

.proxy-scroll {
  border-bottom: 1px solid var(--line);
  max-height: 360px;
}

.proxy-table {
  min-width: 900px;
}

.proxy-table th:first-child {
  width: 38%;
}

.proxy-table th:nth-child(2), .proxy-table th:nth-child(3), .proxy-table th:nth-child(4), .proxy-table th:nth-child(5), .proxy-table th:nth-child(6) {
  width: auto;
}

.empty-state {
  color: var(--muted);
  text-align: center;
  min-height: 120px;
  padding: 34px 20px;
}

.config-body {
  display: grid;
  gap: 0;
}

.form-section {
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 16px;
  padding: 20px;
}

.form-section-title {
  display: flex;
  align-items:  center;
  gap: 10px;
}

h3 {
  letter-spacing: 0;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.config-grid {
  display: grid;
  gap: 14px;
}

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

.config-grid.compact {
  grid-template-columns: repeat(5, minmax(120px, 1fr));
}

.config-panel .form-actions {
  background: var(--panel-soft);
  justify-content: flex-end;
  padding: 16px 20px;
}

label {
  color: #34403d;
  display: grid;
  gap: 8px;
  font-size: 13px;
  font-weight: 740;
}

input, select, textarea {
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  color: var(--text);
  border-radius: 8px;
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: 3px solid #0f766e29;
  outline-offset: 1px;
}

button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid #0f766e29;
  outline-offset: 1px;
}

textarea {
  resize: vertical;
  min-height: 140px;
  line-height: 1.45;
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, #0000 50%, #66736f 50%), linear-gradient(135deg, #66736f 50%, #0000 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px;
  background-repeat: no-repeat;
  background-size: 5px 5px;
  padding-right: 34px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(120px, 1fr));
  gap: 14px;
}

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

.check {
  background: var(--panel-soft);
  display: flex;
  border: 1px solid #dce5e0;
  border-radius: 8px;
  align-items:  center;
  gap: 12px;
  min-height: 46px;
  padding: 0 12px;
}

.check input {
  appearance: none;
  accent-color: var(--accent);
  position: relative;
  background: #d5dedb;
  border: 0;
  border-radius: 999px;
  flex: none;
  width: 38px;
  height: 22px;
  min-height: auto;
  padding: 0;
}

.check input:after {
  content: "";
  position: absolute;
  background: #fff;
  border-radius: 999px;
  width: 18px;
  height: 18px;
  transition: transform .16s;
  top: 2px;
  left: 2px;
  box-shadow: 0 1px 3px #1018172e;
}

.check input:checked {
  background: var(--accent);
}

.check input:checked:after {
  transform: translateX(16px);
}

.check span {
  overflow-wrap: anywhere;
}

.fatal {
  background: var(--fail-bg);
  border: 1px solid #f4b1ab;
  border-radius: 8px;
  max-width: 760px;
  margin: 40px auto;
  padding: 18px;
}

@media (width <= 1280px) {
  .status-strip {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (width <= 760px) {
  #app {
    padding: 0 14px 28px;
  }

  .appbar {
    margin: 0 -14px;
    padding: 0 14px;
  }

  .hero, .actions {
    flex-direction: column;
    align-items: stretch;
  }

  .domain-line {
    display: grid;
    grid-template-columns: auto 1fr;
    align-items:  flex-start;
  }

  .domain-line h1 {
    grid-column: 1 / -1;
  }

  .status-strip, .field-grid, .config-grid.two, .config-grid.compact, .table-filters, .switches {
    grid-template-columns: 1fr;
  }

  .config-panel .form-actions {
    justify-content: stretch;
  }

  .config-panel .form-actions .button {
    width: 100%;
  }

  .table-pagination {
    flex-direction: column;
    align-items: stretch;
  }

  .page-controls {
    justify-content: space-between;
  }

  .tabs {
    display: flex;
    overflow-x: auto;
    width: 100%;
  }

  .tabs button {
    flex: 1 0 auto;
  }

  .section-head {
    flex-direction: column;
    justify-content: center;
    align-items:  flex-start;
    padding: 12px 16px;
  }
}
