/* Light theme based on https://www.itabol.it/risorse/.
   Brand greens, white surfaces and slate text follow the site's GeneratePress
   palette; the darker text accent keeps small labels readable on white. */
:root {
  --bg: #f7f8f9;
  --panel: #ffffff;
  --panel-2: #f0f0f0;
  --line: #dfe5e7;
  --line-strong: #b5c1c8;
  --text: #222222;
  --text-2: #536474;
  --muted: #536474;
  --brand: #74bc00;
  --brand-bright: #8fe307;
  --accent: #4b7607;
  --accent-strong: #5a8d09;
  --accent-soft: #eef6e3;
  --accent-ink: #222222;
  --ok: #3e6a07;
  --error: #b42318;
  --warning: #855600;
  --radius: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0; min-height: 100vh; display: flex; flex-direction: column;
  background: var(--bg); color: var(--text);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 24px; flex-wrap: wrap;
  padding: 14px 28px; border-top: 4px solid var(--brand); border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { width: 34px; height: 34px; flex: none; fill: none; stroke: var(--brand); stroke-width: 1.8;
        stroke-linecap: round; stroke-linejoin: round; }
.logo rect { fill: var(--accent-soft); }
.name { font-size: 19px; font-weight: 650; letter-spacing: 0.01em; }
.tagline { font-size: 12px; color: var(--muted); }
.powered {
  display: inline-flex; align-items: center; gap: 8px; padding: 4px 12px 4px 10px;
  border: 1px solid var(--line-strong); border-radius: 999px; color: var(--text-2);
  font-size: 12px; text-decoration: none; white-space: nowrap;
  transition: border-color .15s, color .15s, background .15s;
}
.powered:hover, .powered:focus-visible { border-color: var(--accent); color: var(--text); background: var(--accent-soft); }
.powered-label { color: var(--muted); }
.powered-logo {
  display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 28px;
  border-radius: 50%; background: var(--panel); box-shadow: 0 0 0 1px var(--line);
}
.powered-logo img { display: block; width: 22px; height: auto; }
.powered-name { font-weight: 600; color: var(--text); letter-spacing: 0.01em; }

/* Layout */
.page { flex: 1; width: 100%; max-width: 1400px; margin: 0 auto; padding: 20px 28px 24px;
        display: flex; flex-direction: column; gap: 18px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); min-width: 0; }
.card.disabled { background: var(--panel-2); }
.card-head { display: flex; align-items: center; min-height: 52px; padding: 10px 18px; border-bottom: 1px solid var(--line); }
h2 { margin: 0; font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
     color: var(--muted); display: flex; align-items: center; }
h3 { margin: 4px 0 8px; font-size: 14px; font-weight: 600; }
.step {
  display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px;
  margin-right: 10px; border-radius: 50%; background: var(--accent-soft); color: var(--accent);
  font-size: 11px; letter-spacing: 0;
}
.card-body { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.lead { margin: 0; color: var(--text-2); font-size: 15px; }
.note { margin: 0; font-size: 12.5px; color: var(--muted); }
.muted { color: var(--muted); }
.status { margin: 0; min-height: 1.4em; color: var(--text-2); }
.status.ok { color: var(--ok); }
.status.error { color: var(--error); }

/* Inputs */
.input-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.file-button {
  position: relative; display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 7px; font-size: 13px; color: var(--text-2); cursor: pointer;
}
.file-button:hover { border-color: var(--accent); color: var(--accent); }
.file-button input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.file-button:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
#file-name { flex: 1; min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.config { display: flex; flex-direction: column; gap: 14px; }
fieldset { margin: 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
legend { padding: 0 6px; font-size: 13px; color: var(--text-2); }
.choice { display: flex; gap: 10px; align-items: baseline; margin: 6px 0; color: var(--text-2); cursor: pointer; }
.choice input { accent-color: var(--accent); }
.field-layers { display: block; color: var(--muted); font-size: 12px; }

/* Buttons and links */
button { cursor: pointer; }
.primary {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-width: 160px;
  padding: 10px 18px; border: 0; border-radius: 8px; background: var(--brand); color: var(--accent-ink);
  font-weight: 650; letter-spacing: 0.02em; text-decoration: none;
}
.primary:hover { background: var(--brand-bright); }
.primary:disabled {
  cursor: not-allowed; background: var(--panel-2); color: var(--text-2);
  box-shadow: inset 0 0 0 1px var(--line-strong);
}
.ghost {
  display: inline-flex; align-items: center; padding: 7px 12px; border: 1px solid var(--line-strong);
  border-radius: 7px; background: transparent; color: var(--text-2); font-size: 13px; text-decoration: none;
}
.ghost:hover { border-color: var(--accent); color: var(--accent); }
a.ghost.download::before { content: "↓"; margin-right: 6px; color: var(--accent); }
.downloads { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

/* Figures and tables */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); margin: 0;
        border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.kpis > div { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; min-width: 0;
              border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); margin: 0 -1px -1px 0; }
.kpi-label { font-size: 12px; color: var(--muted); }
.kpi-value { margin: 0; font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.kpi-value.small-value { font-size: 14px; }
.kpi-value.accent { color: var(--accent); }
.results { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 28px; }
.preview-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.table-wrap { overflow: auto; max-height: 60vh; border: 1px solid var(--line); border-radius: 8px; }
.table-wrap.tall { max-height: 70vh; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th {
  position: sticky; top: 0; z-index: 1; padding: 9px 12px; text-align: left;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted); background: var(--panel-2); border-bottom: 1px solid var(--line); white-space: nowrap;
}
td { padding: 8px 12px; border-bottom: 1px solid var(--line); vertical-align: top; color: var(--text-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
table.kv th { position: static; width: 62%; text-transform: none; letter-spacing: 0; font-size: 13px;
              font-weight: 400; color: var(--text-2); background: transparent; padding-left: 0; }
table.kv td { font-weight: 600; color: var(--text); }
.st-fill, .st-overwrite { color: var(--accent); font-weight: 600; }
.st-preserved, .st-unchanged, .st-formula_preserved { color: var(--text); }
.st-no_value, .st-invalid_coordinates { color: var(--muted); }
.st-conflict { color: var(--warning); font-weight: 600; }

.footer {
  padding: 14px 28px 20px; font-size: 12px; color: var(--bg); background: var(--text);
  border-bottom: 6px solid var(--brand-bright); text-align: center;
}

@media (max-width: 960px) {
  .topbar { padding: 12px 16px; }
  .page { padding: 16px; }
}
@media (max-width: 480px) {
  .powered-label { display: none; }
  .tagline { display: none; }
  .primary { width: 100%; }
  .footer { padding: 12px 16px 16px; }
}
fieldset.inactive { background: var(--panel-2); }
fieldset.inactive .choice { cursor: default; }

/* Review page: map, editable table, compliance colours.
   Okabe–Ito blue (#0072B2) = BOLD compliant, orange (#E69F00) = ItaBOL compliant,
   white = not compliant; every state also has a text badge. */
.review-link { align-self: flex-start; text-decoration: none; }
.review-nav { margin: 0; }
.review-nav a { color: var(--accent); }
.map-toolbar, .table-toolbar, .save-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  justify-content: space-between; }
.table-toolbar { justify-content: flex-start; }
.legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.swatch { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid #222222; display: inline-block; }
.swatch-none { background: #ffffff; }
.swatch-bold { background: #0072B2; }
.swatch-itabol { background: #E69F00; }
.map-buttons { display: flex; gap: 6px; }
.map-buttons .ghost { min-width: 38px; }
.map-wrap { position: relative; }
#map { display: block; width: 100%; height: 460px; border: 1px solid var(--line); border-radius: 8px;
  cursor: grab; touch-action: none; background: #eaf2f8; }
.map-tip { position: absolute; pointer-events: none; background: #222222; color: #ffffff; font-size: 12px;
  padding: 4px 8px; border-radius: 6px; white-space: nowrap; }
label.inline { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; }
label.inline select, label.inline input { padding: 5px 8px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--panel); }
.pager { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); }
.review-wrap { max-height: 70vh; }
#grid td { white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; color: var(--text); }
#grid td[contenteditable] { cursor: text; }
#grid td[contenteditable]:focus { outline: 2px solid var(--accent); outline-offset: -2px; background: #ffffff;
  white-space: pre-wrap; overflow: visible; }
#grid th:first-child, #grid td.badge-cell { position: sticky; left: 0; z-index: 1; }
#grid th { z-index: 2; }
#grid th:first-child { z-index: 3; background: var(--panel-2); }
#grid td.badge-cell { background: inherit; }
#grid tr.row-none { background: #ffffff; }
#grid tr.row-bold { background: #d9ebf6; }
#grid tr.row-itabol { background: #fbe9c6; }
#grid tr.row-selected td { box-shadow: inset 0 2px 0 #222222, inset 0 -2px 0 #222222; }
.badge { display: inline-block; min-width: 52px; text-align: center; font-size: 11.5px; font-weight: 700;
  padding: 2px 8px; border-radius: 999px; border: 1px solid #222222; }
.badge-none { background: #ffffff; color: #222222; }
.badge-bold { background: #0072B2; color: #ffffff; border-color: #0072B2; }
.badge-itabol { background: #E69F00; color: #222222; border-color: #b37a00; }
td.row-number { color: var(--muted) !important; }
td.cell-problem { outline: 2px dashed var(--error); outline-offset: -3px; }
td.cell-warning { outline: 2px dashed var(--warning); outline-offset: -3px; }
td.cell-enriched, .tag-enriched { background-image: linear-gradient(rgba(116, 188, 0, .22), rgba(116, 188, 0, .22)); }
td.cell-edited, .tag-edited { font-weight: 700; text-decoration: underline dotted; }
.tag-enriched, .tag-edited { padding: 0 4px; border-radius: 4px; }
td.cell-formula { color: var(--muted) !important; font-style: italic; }

/* Run button right under the validation results. */
.run-row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
/* Filled secondary action (dark brand green, white text: contrast 5.4:1, hover 6.4:1); orange is
   reserved for "ItaBOL compliant" in the review page. */
.secondary { display: inline-flex; align-items: center; gap: 6px; padding: 9px 18px; border-radius: 8px;
  background: var(--accent); color: #ffffff; font-weight: 600; text-decoration: none; border: 1px solid var(--accent); }
.secondary:hover { background: var(--ok); border-color: var(--ok); color: #ffffff; }
.st-case_fixed { color: var(--accent); font-weight: 600; }
