:root {
  --bg: #f8f3e8; --card: #fff; --panel: #efe3cc; --panel-line: #d8c9a8; --field: #fff; --text: #1d2430; --muted: #5d6676; --line: #d9dde4;
  --accent: #1f5fbf; --accent-text: #fff; --err: #b3261e;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171c; --card: #1d2229; --panel: #1d2229; --panel-line: #333b47; --field: #14171c; --text: #e8ebf0; --muted: #9aa3b2; --line: #333b47; --accent: #5b9bff; --accent-text: #0b1220; --err: #ff8a80; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.6 "Segoe UI", Arial, sans-serif; }
.top, main { max-width: 820px; margin: 0 auto; padding: 0 16px; }
.top { padding-top: 24px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
.top p { margin: 0 0 16px; color: var(--muted); }
main { padding-bottom: 48px; }
fieldset { background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; margin: 0 0 16px; padding: 12px 16px 16px; }
legend { font-weight: 700; padding: 0 6px; }
label { display: block; margin-top: 12px; font-weight: 600; }
input, textarea, select { display: block; width: 100%; margin-top: 4px; padding: 8px 10px; font: inherit; color: var(--text); background: var(--field); border: 1px solid var(--panel-line); border-radius: 6px; }
input:focus-visible, textarea:focus-visible, select:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hint { color: var(--muted); font-size: .9rem; margin: 6px 0; }
.error { color: var(--err); font-weight: 600; }
button { font: inherit; border-radius: 8px; padding: 10px 20px; cursor: pointer; border: 1px solid var(--line); background: var(--card); color: var(--text); }
button.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }
button:disabled { opacity: .5; cursor: not-allowed; }
.run-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.run-head h2 { margin: 0; flex: 1; font-size: 1.2rem; }
.badge { padding: 2px 10px; border-radius: 999px; background: var(--line); font-size: .85rem; }
.steps { list-style: none; padding: 0; margin: 16px 0; max-height: 260px; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 10px; }
.steps li { padding: 6px 14px; border-bottom: 1px solid var(--line); font-size: .92rem; color: var(--muted); overflow-wrap: anywhere; }
.steps li:last-child { color: var(--text); }
.msg { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 16px; margin: 12px 0; white-space: pre-wrap; }
.msg.user { border-color: var(--accent); }
.msg.err { border-color: var(--err); color: var(--err); }
fieldset.tabu-box { border: 2px solid var(--accent); }
#sim-frame { width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: 10px; background: #eef2f6; }
.dropzone { display: flex; flex-direction: column; align-items: center; gap: 4px; margin-top: 12px; padding: 32px 16px; text-align: center; font-weight: 400; border: 2px dashed var(--accent); border-radius: 10px; background: var(--field); cursor: pointer; }
.addr-row { display: flex; gap: 8px; align-items: flex-end; margin-top: 8px; }
.addr-row label { flex: 1; margin-top: 0; }
.addr-row .num { flex: 0 0 38%; }
.addr-row button { padding: 8px 12px; }
.dropzone.small { padding: 18px 16px; }
.dropzone strong { font-size: 1.2rem; }
.dropzone span { color: var(--muted); }
.dropzone.over { background: var(--line); }
details.more { margin: 0 0 16px; }
details.more > summary { cursor: pointer; font-weight: 600; padding: 8px 0; }
.file-list { padding-inline-start: 20px; color: var(--muted); }
.doc-bar { display: flex; gap: 8px; flex-wrap: wrap; margin: 16px 0; }
#doc { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 24px; overflow-x: auto; }
#doc table { border-collapse: collapse; width: 100%; margin: 12px 0; font-size: .93rem; }
#doc th, #doc td { border: 1px solid var(--line); padding: 6px 8px; text-align: start; vertical-align: top; }
#doc th { background: var(--bg); }
#doc a { color: var(--accent); overflow-wrap: anywhere; }
.disclaimer { color: var(--muted); font-size: .85rem; }
@media print {
  .no-print, .top, .disclaimer { display: none !important; }
  body { background: #fff; color: #000; }
  #doc { border: 0; padding: 0; }
  #doc th { background: #eee; }
  #doc th, #doc td { border-color: #999; }
}
[hidden] { display: none !important; }

.combo { position: relative; }
.combo input { padding-inline-end: 40px; }
.combo-toggle { position: absolute; inset-inline-end: 4px; top: 8px; width: 34px; height: calc(100% - 8px); padding: 0; border: 0; background: transparent; font-size: 1.1rem; color: var(--muted); cursor: pointer; border-radius: 6px; }
.combo-toggle:hover { background: var(--line); }
.combo-list { position: absolute; z-index: 30; inset-inline: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none; max-height: 280px; overflow-y: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 28px rgba(0, 0, 0, .18); }
.combo-list li { padding: 10px 14px; border-radius: 8px; cursor: pointer; font-weight: 600; }
.combo-list li:hover, .combo-list li.on { background: var(--accent); color: var(--accent-text); }
.combo-list li.empty { color: var(--muted); cursor: default; font-weight: 400; }
.combo-list li.empty:hover { background: transparent; color: var(--muted); }

.extract { background: var(--card); border: 2px solid var(--accent); border-radius: 12px; padding: 14px 18px; margin: 0 0 16px; }
.extract p { margin: 6px 0; }
.extract ul { margin: 6px 0; padding-inline-start: 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.chip { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--panel-line); background: var(--field); color: var(--text); cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); font-weight: 700; }

.history { margin-top: 32px; }
.history h2 { font-size: 1.15rem; margin: 0 0 4px; }
.history ul { list-style: none; padding: 0; margin: 8px 0; display: flex; flex-direction: column; gap: 8px; }
.history li { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; padding: 8px 12px; }
.history li span { flex: 1; overflow-wrap: anywhere; }
.history li button { padding: 6px 14px; }
