@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;500;600;700&display=swap');

:root {
  --bg: #f4f3ef;
  --surface: #ffffff;
  --border: #d9d6d0;
  --border-light: #eae8e4;
  --text: #1e1e1e;
  --text-muted: #71706c;
  --accent: #e17a00;
  --accent-bg: rgba(225, 122, 0, 0.08);
  --accent-border: rgba(225, 122, 0, 0.25);
  --green: #0f7533;
  --green-bg: rgba(15, 117, 51, 0.09);
  --red: #b82020;
  --red-bg: rgba(184, 32, 32, 0.09);
  --radius: 8px;
}

*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Outfit', system-ui, sans-serif;
  font-weight: 400;
  font-size: 15px;
  background: var(--bg);
  color: var(--text);
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
  line-height: 1.5;
}

h1 {
  font-size: 1.6rem;
  font-weight: 700;
  margin-bottom: 1.5rem;
  color: var(--accent);
}

/* ── Fieldsets ── */

fieldset {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  margin-bottom: 0.75rem;
}

legend {
  font-weight: 600;
  font-size: 1.05rem;
  color: var(--accent);
  padding: 0 0.4rem;
}

fieldset p {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin: 0.25rem 0;
}

/* ── Radio pills ── */

.radio-group {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--border-light);
  border-radius: 6px;
  padding: 3px;
  margin-bottom: 0.6rem;
  gap: 3px;
}

.radio-group label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.15s, background 0.2s, box-shadow 0.15s;
  margin: 0;
}

.radio-group label:hover {
  color: var(--text);
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 0 0 1px var(--border-light);
}

.radio-group label:has(input:checked) {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
  box-shadow: none;
}

.radio-group label:has(input:checked):hover {
  background: #cf7000;
}

.radio-group input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* ── Form labels ── */

label:not([hidden]) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.25rem;
  margin: 0.4rem 0;
  font-size: 0.88rem;
}

label > input[type="number"] {
  margin-left: auto;
}

label:has(input[type="checkbox"]) {
  cursor: pointer;
}

/* ── Form controls ── */

input[type="number"] {
  width: 140px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.88rem;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  transition: border-color 0.15s, box-shadow 0.15s;
  margin: 0;
}

input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.35rem 0.5rem;
  font-family: inherit;
  font-size: 0.82rem;
  color: var(--text);
  transition: border-color 0.15s;
  margin-top: 0.1rem;
}

select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-bg);
}

input[type="checkbox"] {
  accent-color: var(--accent);
  width: 1rem;
  height: 1rem;
}

/* ── Tooltips ── */

.tooltip {
  cursor: help;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 600;
  position: relative;
}

#results .tooltip {
  font-size: inherit;
  font-weight: inherit;
  color: inherit;
}

/* Image tooltip (CSS, centered on viewport) */
.tooltip-img {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: min(700px, 92vw);
  max-height: 90vh;
  object-fit: contain;
  border-radius: 6px;
  z-index: 200;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.25);
  pointer-events: none;
}

.tooltip:hover .tooltip-img {
  display: block;
}

/* JS tooltip popup */
.tooltip-popup {
  position: fixed;
  display: none;
  background: #2a2a2e;
  color: #eee;
  padding: 0.45rem 0.65rem;
  border-radius: 5px;
  font-family: inherit;
  font-size: 0.8rem;
  white-space: pre-line;
  max-width: min(340px, calc(100vw - 1rem));
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  line-height: 1.5;
}

/* ── Computed result boxes ── */

#est-result,
#miner-count-result {
  background: var(--accent-bg);
  border: 1px solid var(--accent-border);
  border-radius: 5px;
  padding: 0.5rem 0.85rem;
  margin-top: 0.5rem;
}

#est-result p,
#miner-count-result p {
  font-size: 0.88rem;
  color: var(--text);
  margin: 0;
}

/* ── Hashprice fetch status ── */

#hashprice-fetch-status:not(:empty) {
  background: rgba(180, 120, 0, 0.08);
  border: 1px solid rgba(180, 120, 0, 0.2);
  border-radius: 5px;
  padding: 0.45rem 0.7rem;
  margin-top: 0.4rem;
  font-size: 0.82rem;
}

/* ── Results ── */

#results {
  margin-top: 1.5rem;
  padding-top: 1.25rem;
  border-top: 2px solid var(--border);
}

#results h2 {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

#current-heating-cost p {
  font-size: 0.95rem;
  margin-bottom: 0.5rem;
}

/* ── Results table ── */

#results-table-container {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

#results table {
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  width: 100%;
  min-width: 680px;
  font-size: 0.88rem;
}

#results th,
#results td {
  padding: 0.5rem 0.6rem;
  text-align: right;
  border: 1px solid var(--border-light);
}

#results th {
  background: var(--bg);
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
}

#results td {
  background: var(--surface);
}

#results th:first-child,
#results td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
}

#results th:first-child { background: var(--bg); }
#results td:first-child { background: var(--surface); font-weight: 500; }

/* Color classes — scoped under #results for specificity */
#results .cell-positive { color: var(--green); background: var(--green-bg); }
#results .cell-negative { color: var(--red); background: var(--red-bg); }

.th-dates {
  display: block;
  font-size: 0.7rem;
  font-weight: 400;
  opacity: 0.5;
}

/* ── Responsive ── */

@media (max-width: 600px) {
  body { padding: 1.25rem 0.75rem; }
  fieldset { padding: 0.75rem; }
  input[type="number"] { width: 110px; }
  .radio-group { flex-direction: column; }
}
