:root {
  --ink: #191c2b;
  --ink-soft: #6b7080;
  --bg: #f5f6f8;
  --panel: #ffffff;
  --border: #e3e5ea;
  --accent: #24306b;
  --accent-hover: #1b2452;
  --sebes: #157a3d;
  --kp: #1d4fbf;
  --danger: #b3261e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(20, 22, 35, 0.06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background-color: var(--bg);
  color: var(--ink);
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* Fixed background layer (a pseudo-element, not background-attachment:fixed
   on body directly, since that property is unreliable on mobile Safari).
   Sits behind everything and never scrolls with the page content. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.15)),
    url("background.jpg");
  background-repeat: no-repeat;
  background-size: cover;
  background-position: center;
}

.page {
  max-width: 720px;
  margin: 0 auto;
  padding: 40px 20px 80px;
}

.page-header {
  margin-bottom: 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
}
.logo {
  width: 76px;
  height: 76px;
  border-radius: 16px;
  box-shadow: 0 2px 8px rgba(20, 22, 35, 0.18);
  margin-bottom: 14px;
}
.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}
.subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 16px;
}

.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
  margin-bottom: 10px;
}

/* Segmented control */
.segmented {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.segmented-option {
  flex: 1;
  border: none;
  background: transparent;
  padding: 10px 8px;
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
  cursor: pointer;
  border-right: 1px solid var(--border);
  transition: background-color 0.12s ease;
}
.segmented-option:last-child { border-right: none; }
.segmented-option:hover { background: #f0f1f4; }
.segmented-option.active {
  background: var(--accent);
  color: #fff;
}

/* Form fields */
.field { margin-bottom: 18px; }
.field:last-of-type { margin-bottom: 0; }
.field label {
  display: block;
  font-size: 13.5px;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--ink);
}
.field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14.5px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fbfbfc;
  color: var(--ink);
  transition: border-color 0.12s ease;
}
.field input[type="text"]:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
}
.field input[readonly] { color: var(--ink-soft); background: #f0f1f4; }
.field input:disabled { color: var(--ink-soft); background: #eceef1; }

.hint {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.hint a { color: var(--kp); }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  cursor: pointer;
}
.checkbox-row input { width: 16px; height: 16px; }

.button-row { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

.btn {
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 11px 20px;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: #f0f1f4; }
.btn-secondary { background: #eef0f6; color: var(--ink); }
.btn-secondary:hover { background: #e3e6ee; }
.btn-small { font-size: 13px; padding: 7px 14px; margin-top: 10px; background: #eef0f6; color: var(--ink); }
.link-btn {
  background: none; border: none; padding: 0; font: inherit;
  color: var(--kp); text-decoration: underline; cursor: pointer;
}

/* Results */
.headline {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
}
.headline-item { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.headline-label { font-size: 14px; font-weight: 600; }
.headline-value { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
.headline-name { color: var(--ink-soft); font-size: 14px; }
.sebes-color { color: var(--sebes); }
.kp-color { color: var(--kp); }
.kp-input {
  font-family: inherit;
  font-size: 20px;
  font-weight: 700;
  width: 130px;
  padding: 4px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
}
.kp-input:focus { outline: none; border-color: var(--kp); }

.results-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.results-table td {
  padding: 8px 4px;
  border-bottom: 1px solid #f0f1f4;
  font-variant-numeric: tabular-nums;
}
.results-table td:first-child { color: var(--ink); }
.results-table td:last-child { text-align: right; }
.results-table tr.bold-row td { font-weight: 700; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

#formula-output { margin-top: 14px; }
#formula-output pre {
  background: #f5f6f8;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
  font-family: "SF Mono", "Consolas", monospace;
}

/* Google Sheets */
.signed-in-status { font-size: 14px; margin-bottom: 14px; }
#sheet-status { margin-top: 12px; font-size: 14px; }
#sheet-status.success { color: var(--sebes); }
#sheet-status.error { color: var(--danger); }

/* Instructions disclosure */
.disclosure-toggle {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: none;
  border: none;
  padding: 0;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.disclosure-toggle .chevron { transition: transform 0.15s ease; color: var(--ink-soft); }
.disclosure-toggle.open .chevron { transform: rotate(180deg); }
.disclosure-body { margin-top: 16px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 14px; }
.tab-btn {
  background: none; border: none; padding: 8px 4px; margin-right: 16px;
  font-family: inherit; font-size: 14px; font-weight: 500;
  color: var(--ink-soft); cursor: pointer; border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--ink); border-bottom-color: var(--accent); font-weight: 600; }
.tab-content h3 { font-size: 15px; margin: 0 0 8px; }
.tab-content p { font-size: 13.5px; color: var(--ink-soft); margin: 0 0 10px; }
.tab-content ol { padding-left: 20px; font-size: 13.5px; }
.tab-content li { margin-bottom: 6px; }

@media (max-width: 480px) {
  .page { padding: 24px 14px 60px; }
  .logo { width: 60px; height: 60px; }
  .page-header h1 { font-size: 23px; }
  .segmented-option { font-size: 12px; padding: 9px 4px; }
  .headline { gap: 20px; }
}
