/* System fonts only: no font host (PRD Hosting). */
:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5d6878;
  --border: #dde2e8;
  --accent: #1f6feb;
  --accent-soft: #e8f0fe;
  --ok: #1a7f37;
  --error: #c62828;
  --error-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff4d6;
  --radius: 10px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

html, body { margin: 0; }

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 16px 24px;
  display: grid;
  gap: 14px;
}

.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}
.app-header h1 { font-size: 1.25rem; margin: 0; }
.row-count { margin: 0; color: var(--muted); }

.eyebrow {
  display: block;
  margin: 0 0 6px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

.config-error {
  padding: 12px 16px;
  border-radius: var(--radius);
  background: var(--error-soft);
  color: var(--error);
  border: 1px solid var(--error);
  font-weight: 600;
  overflow-wrap: anywhere;
}
.config-error.notice {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}
.config-error.notice[hidden] { display: none; }

.current {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.current-type {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3rem);
  font-weight: 700;
  line-height: 1.1;
  color: var(--accent);
  overflow-wrap: anywhere;
}
.current-type[data-empty="true"] { color: var(--muted); }
.current-split { margin: 4px 0 0; color: var(--muted); }

.type-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
}
.type-btn {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  text-align: left;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.type-btn:hover:not(:disabled) { border-color: var(--accent); }
.type-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--accent);
}
.type-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.type-btn kbd {
  grid-row: span 2;
  display: inline-grid;
  place-items: center;
  width: 2rem;
  height: 2rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  font: 600 1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.type-label { font-weight: 600; overflow-wrap: anywhere; }
.type-split { font-size: 0.8rem; color: var(--muted); }

.scan {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
}
.scan-field {
  width: 100%;
  padding: 12px 14px;
  font: 1.1rem ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  border: 2px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.scan-field:focus { outline: none; border-color: var(--accent); }
.scan-field:disabled { background: var(--bg); cursor: not-allowed; }
.scan-status { margin: 8px 0 0; min-height: 1.4em; }
.scan-status[data-kind="ok"] { color: var(--ok); }
.scan-status[data-kind="error"] { color: var(--error); font-weight: 600; }
/* FR15: accepted, but exported in an earlier batch. */
.scan-status[data-kind="exported"] { color: var(--warn); background: var(--warn-soft); font-weight: 600; }
.rows-table .exported-notice { display: block; margin-top: 2px; font-size: 0.85em; font-weight: 600; color: var(--warn); }
/* Issue #27: the not-ready banner keeps its box while hidden (visibility,
   not display), so showing or hiding it never moves the buttons below it
   between mousedown and mouseup. The status line above it stays visible. */
.not-ready[hidden] { display: block !important; visibility: hidden; }
.not-ready {
  margin: 8px 0 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--error);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
/* FR14: "Já aberto noutro separador" (and the other tab-blocked states), in place of the scan status. */
.tab-blocked {
  margin: 8px 0 0;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--error);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 700;
  text-align: center;
}
body[data-ready="false"] .scan-field { border-color: var(--error); }
.caps-lock {
  margin: 8px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 600;
}

.rows {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
}
.rows-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.rows-table th, .rows-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.rows-table th { color: var(--muted); font-weight: 600; background: var(--bg); }
.rows-table .num { text-align: right; }
.rows-table td.doc { white-space: normal; overflow-wrap: anywhere; }
.rows-table tr.highlight td { background: var(--warn-soft); }
.rows-table tr.empty td { color: var(--muted); text-align: center; padding: 20px; }

.rows-table th.actions-col, .rows-table td.actions-col { text-align: right; width: 1%; }
.rows-table tr.editing td { background: var(--accent-soft); }
.rows-table tr.editor-row td { background: var(--accent-soft); white-space: normal; }
.row-btn {
  padding: 4px 10px;
  margin-left: 6px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.row-btn.delete { color: var(--error); border-color: var(--error); }
.row-btn:disabled { color: var(--muted); border-color: var(--border); cursor: not-allowed; }

.row-editor { display: grid; gap: 12px; }
.editor-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px 14px; }
.editor-field { display: grid; gap: 4px; font-size: 0.8rem; color: var(--muted); }
.editor-field input, .editor-field select {
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text);
  background: var(--surface);
}
.editor-error {
  margin: 0;
  padding: 8px 12px;
  border-radius: 6px;
  background: var(--error-soft);
  color: var(--error);
}
.editor-buttons { display: flex; gap: 8px; }
.editor-buttons button:not(.primary) {
  padding: 10px 18px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  font: inherit;
  cursor: pointer;
}

.actions { display: flex; justify-content: flex-end; gap: 10px; }
button.danger {
  padding: 10px 18px;
  border: 1px solid var(--error);
  border-radius: 8px;
  background: var(--surface);
  color: var(--error);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.danger:disabled { border-color: var(--border); color: var(--muted); cursor: not-allowed; }
button.primary {
  padding: 10px 18px;
  border: none;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
button.primary:disabled { background: var(--border); color: var(--muted); cursor: not-allowed; }

[hidden] { display: none !important; }

@media (max-width: 640px) {
  .app { padding: 12px; }
  .type-buttons { grid-template-columns: repeat(2, 1fr); }
}

/* AC 15: a restored row whose type key is not in the config (blocks download). */
.rows-table tr.flagged td { background: var(--error-soft); }
.rows-table tr.flagged td:first-child { color: var(--error); font-weight: 600; }

/* FR10: "was the file saved?" dialog. */
.saved-dialog {
  max-width: 32rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 24px;
  background: var(--surface);
}
.saved-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.saved-dialog:focus { outline: none; }
.saved-dialog-title { font-size: 1.15rem; font-weight: 600; margin-top: 0; overflow-wrap: anywhere; }
