:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #17201b;
  --muted: #607268;
  --line: #d9e2dc;
  --panel: #ffffff;
  --field: #f7faf8;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --gold: #d99a22;
  --rose: #c2415d;
  --shadow: 0 18px 55px rgba(32, 49, 42, 0.13);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(120deg, rgba(15, 118, 110, 0.12), rgba(217, 154, 34, 0.10)),
    #f4f7f5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
}

.workspace {
  display: grid;
  gap: 16px;
}

.topbar,
.input-panel,
.chart-panel,
.side-panel,
.table-panel {
  background: rgba(255, 255, 255, 0.93);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 22px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(1.9rem, 4vw, 3.4rem);
  line-height: 1;
}

h2 {
  font-size: 1rem;
}

.summary-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.summary-strip div {
  min-width: 0;
  padding: 11px 14px;
  background: var(--field);
  border-right: 1px solid var(--line);
}

.summary-strip div:last-child {
  border-right: 0;
}

.summary-strip span,
.summary-strip small {
  display: block;
}

.summary-strip span {
  font-size: 1.35rem;
  font-weight: 850;
}

.summary-strip small {
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
}

.input-panel {
  padding: 18px;
}

.live-controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
}

.status-line {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status-line.error {
  color: var(--rose);
  font-weight: 800;
}

.window-buttons {
  display: inline-grid;
  grid-template-columns: repeat(4, minmax(54px, 1fr));
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.window-buttons button {
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-right: 1px solid var(--line);
  color: var(--muted);
  background: var(--field);
  font-weight: 850;
}

.window-buttons button:last-child {
  border-right: 0;
}

.window-buttons button.active {
  color: #fff;
  background: var(--accent);
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  color: #fff;
  background: var(--accent);
  font-weight: 850;
}

.refresh-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.window-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.window-meta span {
  padding: 8px 10px;
  color: var(--muted);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: 750;
}

.manual-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.manual-panel summary {
  color: var(--accent-strong);
  cursor: pointer;
  font-weight: 850;
}

.manual-panel[open] summary {
  margin-bottom: 14px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.toolbar button,
.file-action,
.export-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 14px;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 750;
}

.toolbar button:hover,
.file-action:hover,
.export-button:hover:not(:disabled) {
  border-color: var(--accent);
}

.file-action input {
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  opacity: 0;
  pointer-events: none;
}

.input-panel > label,
.settings-grid label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

textarea {
  display: block;
  width: 100%;
  min-height: 190px;
  margin-top: 8px;
  padding: 14px;
  resize: vertical;
  color: var(--ink);
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.45;
}

textarea:focus,
input:focus {
  outline: 3px solid rgba(15, 118, 110, 0.18);
  border-color: var(--accent);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.settings-grid label {
  display: grid;
  gap: 6px;
}

.settings-grid input[type="number"] {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-row {
  grid-template-columns: 18px 1fr;
  align-content: center;
  align-items: center;
  padding: 10px 12px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.checkbox-row input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.results-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 16px;
}

.chart-panel,
.side-panel,
.table-panel {
  overflow-x: auto;
  padding: 18px;
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.segmented {
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-width: 72px;
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--field);
  color: var(--muted);
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  color: #fff;
  background: var(--accent);
}

.chart {
  display: grid;
  gap: 8px;
  min-height: 260px;
}

.empty-state {
  place-items: center;
  color: var(--muted);
  background: var(--field);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
}

.bar-row {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) 58px;
  align-items: center;
  gap: 10px;
}

.ball {
  display: inline-grid;
  place-items: center;
  width: 42px;
  aspect-ratio: 1;
  border-radius: 50%;
  color: #111814;
  background: radial-gradient(circle at 32% 28%, #fff8d6 0 18%, #f7c34e 45%, #be7814 100%);
  border: 1px solid rgba(105, 73, 15, 0.28);
  font-weight: 900;
  box-shadow: inset -5px -6px 12px rgba(80, 46, 0, 0.17);
}

.bar-track {
  height: 20px;
  overflow: hidden;
  background: #edf3ef;
  border-radius: 999px;
}

.bar-fill {
  height: 100%;
  min-width: 3px;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--gold));
}

.hit-count {
  color: var(--muted);
  font-weight: 800;
  text-align: right;
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 18px;
}

.rank-list {
  display: grid;
  gap: 8px;
  margin: 12px 0 0;
  padding-left: 24px;
}

.rank-list li {
  padding: 8px 10px;
  background: var(--field);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 800;
}

.rank-list span {
  color: var(--muted);
  font-weight: 700;
}

.export-button {
  width: 100%;
  color: #fff;
  background: var(--accent);
  border-color: var(--accent);
}

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

table {
  min-width: 560px;
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 8px;
}

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

th {
  color: var(--muted);
  background: var(--field);
  font-size: 0.8rem;
  text-transform: uppercase;
}

tbody tr:hover {
  background: #fbfcfb;
}

@media (max-width: 860px) {
  .topbar,
  .live-controls,
  .results-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

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

  .refresh-button {
    width: 100%;
  }

  .results-layout {
    display: grid;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100% - 20px, 1180px);
    padding: 10px 0;
  }

  .topbar,
  .input-panel,
  .chart-panel,
  .side-panel,
  .table-panel {
    padding: 14px;
  }

  h1 {
    font-size: 1.75rem;
    line-height: 1.08;
  }

  .status-line {
    font-size: 0.86rem;
  }

  .window-meta {
    display: grid;
  }

  .summary-strip,
  .settings-grid,
  .panel-heading {
    display: grid;
    grid-template-columns: 1fr;
  }

  .window-buttons {
    width: 100%;
  }

  .summary-strip div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .summary-strip div:last-child {
    border-bottom: 0;
  }

  .segmented {
    width: 100%;
  }

  .bar-row {
    grid-template-columns: 40px minmax(86px, 1fr) 42px;
    gap: 8px;
  }

  .ball {
    width: 36px;
    font-size: 0.88rem;
  }

  th,
  td {
    padding: 10px 8px;
  }
}
