:root {
  color-scheme: only light;
  --bg: #f3f2ef;
  --card: #ffffff;
  --border: #e6e2da;
  --text: #141414;
  --muted: #6b6459;
  --ok: #1a1a1a;
  --error: #a4341c;
  --input-bg: #ffffff;
  --btn: #141414;
  --btn-text: #ffffff;
  --btn-hover: #2a2a2a;
  --focus: #141414;
  --code-bg: #f6f4ef;
  --gold: #b08d57;
  --shadow: 0 1px 2px rgba(20, 20, 20, .04), 0 12px 40px rgba(20, 20, 20, .06);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { color-scheme: only light; background: var(--bg); }
html, body { margin: 0; }
body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(ellipse 70% 45% at 50% -10%, #fdfcf9 0%, transparent 60%),
    var(--bg);
  color: var(--text);
  font: 15px/1.55 -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
.card {
  width: min(420px, 92vw);
  max-width: 100%;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 1.4rem;
  margin: 2rem 0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.card.wide { width: min(860px, 94vw); }
.card.xwide { width: min(1180px, 96vw); }
@media (max-width: 720px) {
  .card.wide, .card.xwide { width: min(820px, 94vw); }
  .cf-two-col { grid-template-columns: 1fr !important; }
}

/* Brand */
.brand {
  display: flex;
  align-items: center;
  margin: 0 0 1.4rem;
  padding-bottom: 1.1rem;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.brand-meta {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.3rem;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}
.brand-wordmark {
  display: block;
  height: 38px !important;
  width: auto !important;
  max-width: min(240px, 62vw) !important;
  max-height: 38px !important;
  object-fit: contain;
  object-position: left center;
}
.brand-sub {
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 600;
  line-height: 1;
}

h1 {
  font-size: 1.35rem;
  margin: 0 0 0.8rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}
h2 {
  font-size: 0.98rem;
  margin: 1.6rem 0 0.55rem;
  font-weight: 650;
  color: var(--text);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
h2::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.muted { color: var(--muted); font-size: 0.9rem; }
.error { color: var(--error); font-size: 0.9rem; font-weight: 600; }
.ok { color: var(--ok); font-weight: 650; }

form { display: grid; gap: 0.9rem; margin-top: 1rem; }
label { display: grid; gap: 0.35rem; font-size: 0.82rem; color: var(--muted); font-weight: 550; letter-spacing: .01em; }
input, textarea, select {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: 0.55rem 0.7rem;
  font-size: 0.95rem;
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
textarea {
  font: 13px/1.45 ui-monospace, "Cascadia Mono", Consolas, monospace;
  resize: vertical;
  min-height: 2.6em;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  field-sizing: content;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(20, 20, 20, 0.07);
}
button, .button {
  display: block;
  text-align: center;
  text-decoration: none;
  background: var(--btn);
  color: var(--btn-text);
  border: 0;
  border-radius: 8px;
  padding: 0.68rem 1rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: .01em;
  transition: transform .12s ease, background .15s, box-shadow .15s;
}
button:hover, .button:hover { background: var(--btn-hover); transform: translateY(-1px); box-shadow: 0 6px 18px rgba(20,20,20,.12); }
button:active { transform: translateY(0); }
button:disabled { opacity: 0.4; cursor: not-allowed; transform: none; box-shadow: none; }
button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 550;
}
button.secondary:hover { background: #f4f2ee; box-shadow: none; }

.qr { display: block; margin: 1rem auto; width: 220px; background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--border); }
.codes { columns: 2; padding-left: 1.2rem; }
.codes li { margin: 0.25rem 0; }
code {
  background: var(--code-bg);
  padding: 0.1em 0.35em;
  border-radius: 5px;
  font-size: 0.85em;
  border: 1px solid var(--border);
  color: var(--text);
}

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td {
  text-align: left;
  padding: 0.55rem 0.4rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
th {
  color: var(--muted);
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 650;
}
tbody tr { transition: background .12s; }
tbody tr:hover { background: #faf8f4; }

details { font-size: 0.85rem; color: var(--muted); margin-top: 0.6rem; }
details > summary {
  cursor: pointer;
  padding: 0.5rem 0.7rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #faf8f4;
  font-weight: 550;
  color: var(--text);
  list-style: none;
  user-select: none;
  transition: background .15s;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before { content: "▸ "; color: var(--gold); font-weight: 700; }
details[open] > summary::before { content: "▾ "; }
details > summary:hover { background: #f4f1ea; }

a { color: #141414; text-decoration: underline; text-underline-offset: 2px; text-decoration-color: #b9b2a6; transition: text-decoration-color .15s; }
a:hover { color: #000; text-decoration-color: #141414; }

.divider {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.85rem;
  margin: 1.2rem 0 0.8rem;
}
.divider::before, .divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }

.page-footer {
  margin-top: 1.6rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  overflow: hidden;
}
.page-footer img {
  height: 16px !important;
  width: auto !important;
  max-width: 140px !important;
  max-height: 16px !important;
  object-fit: contain;
  object-position: left center;
  opacity: 0.5;
  display: block;
}
.page-footer .muted { font-size: 0.75rem; }

.lang-switch {
  display: inline-flex;
  gap: 0.25rem;
  align-items: center;
  margin-left: 0.5rem;
  font-size: 0.78rem;
}
.lang-switch a {
  text-decoration: none;
  padding: 0.15rem 0.45rem;
  border: 1px solid var(--border);
  border-radius: 5px;
  color: var(--muted);
  font-weight: 600;
}
.lang-switch a.active { background: #141414; color: #fff; border-color: #141414; }
.topnav { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; }

/* ---- Cashflow chart ---- */
.cf-chart-wrap { position: relative; }
.cf-tooltip {
  position: absolute;
  pointer-events: none;
  background: #141414;
  color: #fff;
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  font-size: 0.78rem;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  opacity: 0;
  transform: translateY(4px);
  transition: opacity .12s, transform .12s;
  z-index: 5;
  min-width: 180px;
}
.cf-tooltip.on { opacity: 1; transform: translateY(0); }
.cf-tooltip .t-title { font-weight: 700; margin-bottom: 0.2rem; }
.cf-tooltip .t-row { display: flex; align-items: center; gap: 0.45rem; }
.cf-tooltip .t-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.cf-tooltip .t-val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 600; padding-left: .8rem; }
@keyframes cf-draw { to { stroke-dashoffset: 0; } }
@keyframes cf-fade { to { opacity: 1; } }

/* ---- Mobile ---- */
@media (max-width: 720px) {
  html, body { overflow-x: hidden; }
  .card { padding: 1.1rem 0.9rem 1rem; }
  h1 { font-size: 1.15rem; }
  form { gap: 0.7rem; }
  form[style*="grid-template-columns"] {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }
  table, thead, tbody, tr, td, th { display: block; }
  thead { display: none; }
  table { width: 100%; }
  tbody { display: block; width: 100%; }
  tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: 10px;
    margin: 0 0 0.6rem;
    padding: 0.55rem 0.7rem;
    background: #fff;
  }
  td {
    display: block;
    border: 0 !important;
    padding: 0.28rem 0;
    word-break: break-word;
    white-space: normal !important;
  }
  td::before {
    content: attr(data-label);
    display: block;
    font-size: 0.68rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    margin-bottom: 0.1rem;
  }
  td:empty::before { display: none; }
  td input, td textarea, td select { width: 100% !important; max-width: 100% !important; }
  td.desc-cell { min-width: 0; max-width: 100%; }
  td:has(> input[type="checkbox"]:only-child) {
    display: flex;
    align-items: center;
    gap: 0.5rem;
  }
  td:has(> input[type="checkbox"]:only-child)::before { margin-bottom: 0; }
  button { width: 100%; }
  form[style*="inline"] { display: block !important; margin: 0.4rem 0 !important; }
  .topnav { flex-direction: column; align-items: flex-start; }
  .lang-switch { margin-left: 0; }
}

/* —— Filax infrastructure status —— */
.fx-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-end;
  margin-bottom: 0.5rem;
}
.fx-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  align-items: flex-end;
}
.fx-env {
  display: grid;
  gap: 0.25rem;
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 550;
  min-width: 12rem;
}
.fx-env select { min-width: 14rem; }
.fx-controls button { width: auto; padding: 0.55rem 1rem; }
.fx-banner {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 1rem;
  margin: 0.8rem 0 1.1rem;
  background: #fff;
  line-height: 1.45;
}
.fx-banner.ok { border-color: #cfe4d6; background: #f4faf6; }
.fx-banner.warn { border-color: #f0dfc0; background: #fffaf0; }
.fx-banner.bad { border-color: #efc9c2; background: #fff6f4; }
.fx-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
}
.fx-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1rem 1rem;
  box-shadow: 0 1px 2px rgba(20,20,20,.03);
  min-width: 0;
}
.fx-card h2 { margin-top: 0.2rem; font-size: 0.95rem; }
.fx-card h2::after { display: none; }
.fx-span2 { grid-column: 1 / -1; }
.fx-sub {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 0.9rem 0 0.35rem;
  font-weight: 650;
}
.fx-kv {
  display: grid;
  grid-template-columns: 8.5rem 1fr;
  gap: 0.28rem 0.7rem;
  font-size: 0.88rem;
}
.fx-k { color: var(--muted); }
.fx-v { word-break: break-word; }
.fx-metrics {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
  margin-top: 0.85rem;
}
.fx-metric {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem 0.55rem;
  background: var(--code-bg);
}
.fx-m-label {
  display: block;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  font-weight: 650;
}
.fx-m-val {
  font-size: 1.05rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.fx-pills { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.55rem; }
.fx-pill {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 0.18rem 0.45rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: #f6f4ef;
  color: var(--text);
}
.fx-pill.ok { background: #eaf5ee; border-color: #c5dfce; color: #1a5c34; }
.fx-pill.warn { background: #fff6e8; border-color: #efd7a8; color: #8a5a10; }
.fx-pill.bad { background: #fdecea; border-color: #efc4bc; color: #8f2a1b; }
.fx-table-wrap { overflow-x: auto; margin-top: 0.25rem; }
.fx-card table { font-size: 0.84rem; }
.fx-card th { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
.fx-log {
  list-style: none;
  margin: 0.25rem 0 0;
  padding: 0;
  max-height: 220px;
  overflow: auto;
  font-size: 0.82rem;
}
.fx-log li {
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
  word-break: break-word;
}
.fx-log li:last-child { border-bottom: 0; }
@media (max-width: 900px) {
  .fx-grid { grid-template-columns: 1fr; }
  .fx-span2 { grid-column: auto; }
  .fx-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fx-kv { grid-template-columns: 1fr; }
  .fx-k { margin-top: 0.25rem; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }
}
