:root {
  --bg: #f6f8fb;
  --surface: #fff;
  --muted-bg: #f8fafc;
  --text: #0f172a;
  --muted: #64748b;
  --line: #e3e8ef;
  --blue: #2563eb;
  --green: #059669;
  --amber: #d97706;
  --red: #dc2626;
  --control-height: 38px;
  --label-height: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  font-size: 14px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); line-height: 1.5; }
body:has(dialog[open]) { overflow: hidden; }
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button, a { transition: color 160ms ease, background 160ms ease, border-color 160ms ease; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .5; }
a { color: var(--blue); text-decoration: none; }
:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }
button svg, .brand svg { width: 17px; height: 17px; flex-shrink: 0; }
.skip-link { position: fixed; top: -60px; left: 16px; z-index: 10; padding: 10px; background: white; }
.skip-link:focus { top: 8px; }
.app-header { min-height: 66px; padding: 0 34px; display: flex; align-items: center; gap: 30px; border-bottom: 1px solid var(--line); background: white; position: sticky; top: 0; z-index: 4; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; white-space: nowrap; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; background: #eff6ff; color: var(--blue); border-radius: 7px; }
.brand-note { font-size: 11px; color: var(--muted); margin-left: 2px; font-weight: 400; }
.nav { display: flex; gap: 5px; align-self: stretch; align-items: center; flex: 1; }
.nav button { border: none; background: transparent; padding: 9px 14px; border-radius: 6px; color: #475569; white-space: nowrap; }
.nav button[aria-current="page"] { background: #eff6ff; color: var(--blue); font-weight: 600; }
.header-right { display: flex; align-items: center; gap: 14px; }
.project-picker { max-width: 180px; background: var(--muted-bg); }
.identity { font-size: 12px; color: #475569; white-space: nowrap; }
main { max-width: 1540px; margin: 0 auto; padding: 28px 34px 48px; }
h1 { font-size: 22px; letter-spacing: -.5px; margin: 0 0 8px; font-weight: 650; }
h2 { font-size: 15px; margin: 0; font-weight: 650; }
h3 { font-size: 13px; margin: 0 0 14px; font-weight: 650; }
p { line-height: 1.65; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 23px; }
.page-head p { margin: 0; color: var(--muted); font-size: 13px; }
.actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: var(--control-height); padding: 8px 14px; border: 1px solid #cbd5e1; background: white; border-radius: 7px; color: #334155; white-space: nowrap; font-size: 13px; line-height: 20px; }
.btn:hover { background: #f8fafc; border-color: #94a3b8; }
.btn.primary { background: var(--blue); color: white; border-color: var(--blue); }
.btn.primary:hover { background: #1d4ed8; }
.btn.danger { color: var(--red); }
.btn.small { min-height: 32px; font-size: 12px; padding: 5px 10px; }
.btn.icon-button { width: var(--control-height); height: var(--control-height); padding: 0; color: var(--muted); }
.btn.icon-button:hover { color: #b91c1c; background: #fef2f2; border-color: #fecaca; }
.link-button { background: none; border: none; color: var(--blue); padding: 3px 0; font-size: 13px; text-align: left; }
.link-button:hover { color: #1d4ed8; text-decoration: underline; }
.panel { background: white; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; padding: 17px 20px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 20px; }
.toolbar { display: flex; gap: 10px; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.toolbar .search { width: 280px; }
.toolbar select { width: 160px; flex-shrink: 0; }
.toolbar .count { margin-left: auto; color: var(--muted); font-size: 12px; white-space: nowrap; }
.bulk-toolbar { justify-content: space-between; flex-wrap: wrap; }
.table-filters { padding: 18px 20px; border-bottom: 1px solid var(--line); scroll-margin-top: 90px; }
.table-filter-grid { display: grid; grid-template-columns: minmax(190px, 1.4fr) minmax(190px, 1.4fr) repeat(4, minmax(110px, 1fr)); gap: 14px; align-items: start; }
.filter-footer, .table-pagination { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.filter-footer { margin-top: 14px; }
.filter-footer .actions { gap: 18px; }
.table-filters > .hint { margin-top: 10px; }
.table-pagination { padding: 14px 20px; border-top: 1px solid var(--line); }
.generation-filters { margin-bottom: 20px; }
.generation-filters .table-filters { border-bottom: 0; }
.selection-summary { margin: 10px 0 0; padding: 10px 12px; border-radius: 6px; background: #eff6ff; color: #1e40af; font-size: 12px; line-height: 1.7; }
.link-button[data-rule-tables] { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
input, select, textarea { width: 100%; border: 1px solid #cbd5e1; background: white; color: var(--text); border-radius: 6px; padding: 8px 10px; min-width: 0; font-size: 13px; }
input:not([type="checkbox"]):not([type="radio"]), select { height: var(--control-height); line-height: 20px; }
input:hover:not(:disabled), select:hover:not(:disabled), textarea:hover:not(:disabled) { border-color: #94a3b8; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); }
input::placeholder, textarea::placeholder { color: var(--muted); opacity: 1; font-weight: 400; }
input:disabled, select:disabled, textarea:disabled { color: #475569; background: var(--muted-bg); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 16px; height: 16px; margin: 0; accent-color: var(--blue); flex-shrink: 0; }
textarea { resize: vertical; min-height: 76px; line-height: 1.6; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { min-height: var(--label-height); line-height: var(--label-height); font-size: 12px; font-weight: 550; color: #334155; }
.template-field > label { font-size: 12px; font-weight: 550; color: #334155; }
.template-tokens { display: flex; flex-wrap: wrap; gap: 6px; }
.template-tokens .btn { gap: 5px; }
.template-token-status { font-size: 10px; color: var(--muted); }
.template-tokens .btn:disabled { opacity: 0.6; cursor: not-allowed; }
.template-field input[aria-invalid="true"] { border-color: var(--red); }
.template-example { background: var(--muted-bg); border: 1px solid var(--line); padding: 9px 11px; border-radius: 6px; min-width: 0; }
.template-example > code { display: block; margin-top: 4px; overflow-wrap: anywhere; font-size: 13px; }
.template-error { margin: 0; color: var(--red); font-size: 12px; line-height: 1.6; }
.hint, .muted { font-size: 12px; color: var(--muted); line-height: 1.65; }
.hint { margin: 0; font-weight: 400; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 18px; align-items: start; }
.span-2 { grid-column: 1 / -1; }
.form-section + .form-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.form-section + .note, .form-grid + .note { margin-top: 20px; }
.form-section > .actions { margin-bottom: 12px; }
.form-section > .actions h3 { margin-bottom: 0; }
.form-grid + .hint, .test-controls > .hint { margin-top: 12px; }
.test-controls > .hint + .form-grid { margin-top: 12px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; margin-bottom: 12px; }
.section-heading h3 { display: flex; align-items: center; gap: 10px; font-size: 14px; margin: 0; }
.section-heading .badge { font-weight: 400; }
.form-empty { padding: 18px; margin-top: 16px; border: 1px dashed #cbd5e1; border-radius: 8px; background: var(--muted-bg); font-size: 12px; color: var(--muted); }
.check { display: flex; align-items: center; gap: 8px; line-height: 1.6; font-size: 13px; cursor: pointer; min-width: 0; }
.check > span { min-width: 0; overflow-wrap: anywhere; }
.check-stack { display: grid; gap: 13px; }
.check-stack + .form-section { margin-top: 16px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th { font-size: 11px; color: var(--muted); background: var(--muted-bg); font-weight: 600; white-space: nowrap; }
th, td { padding: 15px 18px; border-bottom: 1px solid var(--line); }
td { font-size: 13px; vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fafcff; }
.table-title { display: block; font-weight: 600; margin-bottom: 4px; }
.table-sub { display: block; font-size: 11px; color: var(--muted); }
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11px; line-height: 1.5; padding: 3px 8px; border-radius: 4px; color: #475569; background: #f1f5f9; white-space: nowrap; }
.badge.blue { background: #eff6ff; color: #2563eb; }
.badge.green { background: #ecfdf5; color: #047857; }
.badge.amber { background: #fffbeb; color: #b45309; }
.badge.red { background: #fef2f2; color: #b91c1c; }
.badges { display: flex; gap: 5px; flex-wrap: wrap; }
.note { background: #eff6ff; border: 1px solid #dbeafe; color: #1e40af; border-radius: 7px; padding: 12px 15px; font-size: 12px; line-height: 1.7; margin-bottom: 18px; }
.note.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.note.error { background: #fef2f2; border-color: #fecaca; color: #b91c1c; }
.note.neutral { background: var(--muted-bg); border-color: var(--line); color: #475569; }
.note:last-child { margin-bottom: 0; }
.breadcrumb { display: flex; align-items: center; gap: 9px; color: var(--muted); margin-bottom: 15px; font-size: 12px; }
.editor-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr); align-items: start; gap: 20px; }
.tabs { display: flex; gap: 20px; padding: 0 20px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: none; background: transparent; color: var(--muted); font-size: 12px; padding: 15px 0; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { border-bottom-color: var(--blue); color: var(--blue); font-weight: 600; }
.preview-panel { position: sticky; top: 88px; }
.preview-heading { background: #fbfdff; }
.preview-heading span { font-size: 11px; color: var(--muted); }
.test-controls { padding: 18px 20px; border-bottom: 1px solid var(--line); }
.test-controls .form-grid { gap: 12px; }
.test-controls .actions { margin-top: 14px; }
.preview-empty { min-height: 230px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; color: var(--muted); gap: 9px; padding: 30px; }
.preview-empty svg { width: 30px; height: 30px; color: #94a3b8; }
.preview-empty strong { font-size: 13px; color: #475569; font-weight: 500; }
.preview-empty p { margin: 0; max-width: 270px; font-size: 12px; }
.preview-summary { display: flex; flex-wrap: wrap; gap: 15px; padding: 13px 20px; background: var(--muted-bg); border-bottom: 1px solid var(--line); color: #475569; font-size: 12px; }
.preview-summary strong { color: var(--text); font-size: 15px; margin-right: 4px; font-variant-numeric: tabular-nums; }
.coverage { padding: 19px 20px; }
.coverage-item + .coverage-item { margin-top: 23px; border-top: 1px solid var(--line); padding-top: 20px; }
.coverage-title { font-size: 12px; font-weight: 600; margin-bottom: 12px; }
.months { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 5px; }
.month { border-radius: 4px; padding: 8px 2px; text-align: center; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 10px; background: #f1f5f9; color: #94a3b8; border: 1px solid #e2e8f0; }
.month.early { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.month.night { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.legend { display: flex; gap: 14px; margin: 13px 0 0; font-size: 11px; color: var(--muted); }
.legend span { display: flex; align-items: center; gap: 5px; }
.legend i { width: 8px; height: 8px; border-radius: 2px; background: #a7f3d0; }
.legend .night-dot { background: #bfdbfe; }
.range-line { font-size: 11px; line-height: 1.9; color: #475569; margin-top: 10px; }
.file-select { padding: 13px 16px; border-bottom: 1px solid var(--line); }
.file-select select { max-width: 100%; }
.script-overview { padding: 16px 20px; border-bottom: 1px solid var(--line); }
.script-overview strong { display: block; font-size: 13px; }
.script-overview > div > span { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.script-overview .badges { margin-top: 12px; }
.script-overview p, .full-script-note p { margin: 10px 0 0; font-size: 12px; color: #475569; line-height: 1.8; }
.script-view-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px 20px; border-bottom: 1px solid var(--line); }
.script-view-switch button { border: 1px solid var(--line); background: white; border-radius: 5px; padding: 7px 12px; color: #475569; font-size: 12px; }
.script-view-switch button[aria-pressed="true"] { color: #1d4ed8; background: #eff6ff; border-color: #bfdbfe; font-weight: 600; }
.script-view-switch > span { color: var(--muted); font-size: 11px; }
.business-reading { padding: 18px 20px; }
.operation-picker { display: flex; gap: 12px; align-items: end; }
.operation-picker .field { flex: 1; min-width: 0; }
.operation-picker > span { white-space: nowrap; padding-bottom: 9px; font-size: 11px; }
.operation-context { display: flex; flex-wrap: wrap; gap: 7px 14px; margin: 12px 0 18px; color: #475569; font-size: 11px; }
.reading-steps { list-style: none; counter-reset: reading; padding: 0; margin: 0; }
.reading-steps > li { counter-increment: reading; border-top: 1px solid var(--line); padding: 15px 0; }
.reading-steps > li > h3 { display: flex; gap: 8px; align-items: center; font-size: 13px; margin: 0 0 10px; }
.reading-steps > li > h3::before { content: counter(reading); color: #2563eb; background: #eff6ff; padding: 3px 7px; border-radius: 4px; font-size: 11px; }
.reading-steps p { font-size: 12px; color: #475569; line-height: 1.8; margin: 8px 0; }
.table-flow { display: grid; gap: 7px; padding: 12px; background: var(--muted-bg); border: 1px solid var(--line); border-radius: 6px; }
.table-flow code { overflow-wrap: anywhere; font-size: 12px; }
.table-flow > span { color: var(--muted); font-size: 11px; }
.mapping-details { border: 1px solid var(--line); border-radius: 5px; margin-bottom: 12px; }
.mapping-details > summary { padding: 10px 12px; color: #475569; font-size: 12px; cursor: pointer; }
.condition-reading > div { display: grid; grid-template-columns: 75px minmax(0, 1fr); gap: 10px; margin: 9px 0; }
.condition-reading strong { color: #475569; font-size: 11px; font-weight: 500; }
.condition-reading code { font-size: 11px; color: #334155; white-space: pre-wrap; overflow-wrap: anywhere; }
.reading-steps pre { border: 1px solid var(--line); border-radius: 5px; padding: 13px 15px; font-size: 12px; }
.full-script-note { padding: 12px 20px 16px; }
.full-script-note p { margin: 0 0 10px; }
.code-view { display: grid; grid-template-columns: max-content max-content; max-height: 490px; overflow: auto; background: #f8fafc; }
.code-view pre { max-height: none; overflow: visible; padding: 16px 14px; }
.code-view .code-gutter { position: sticky; left: 0; color: #94a3b8; text-align: right; background: #f1f5f9; border-right: 1px solid var(--line); user-select: none; }
.code-view .code-content { min-width: 0; }
pre { margin: 0; white-space: pre; overflow: auto; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; line-height: 1.8; color: #334155; background: #f8fafc; padding: 18px 20px; max-height: 490px; tab-size: 2; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }
.implementation { padding: 16px; border: 1px solid var(--line); border-radius: 7px; }
.implementation + .implementation { margin-top: 12px; }
.implementation p { margin: 9px 0 0; }
.step-list { display: grid; gap: 0; }
.step { display: grid; grid-template-columns: 30px 1fr; gap: 12px; padding: 14px 0; }
.step + .step { border-top: 1px solid var(--line); }
.step-number { width: 25px; height: 25px; display: grid; place-items: center; color: var(--blue); background: #eff6ff; border-radius: 5px; font-size: 12px; }
.step strong { font-size: 13px; font-weight: 550; }
.step p { margin: 4px 0 0; }
.empty { padding: 48px 25px; text-align: center; color: var(--muted); font-size: 13px; }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.project-card { padding: 22px; }
.project-card > .panel-head { padding: 0 0 16px; align-items: flex-start; }
.project-card h2 { overflow-wrap: anywhere; }
.project-card p { color: var(--muted); font-size: 12px; min-height: 38px; overflow-wrap: anywhere; }
.project-card .counts { display: flex; flex-wrap: wrap; gap: 10px 18px; padding: 12px 0 20px; font-size: 12px; color: #475569; }
.generation-layout { display: grid; grid-template-columns: minmax(330px, .8fr) minmax(0, 1.5fr); gap: 20px; align-items: start; }
.selection-list { display: grid; gap: 9px; margin-top: 14px; max-height: min(42dvh, 440px); overflow-y: auto; overscroll-behavior: contain; scrollbar-gutter: stable; padding: 4px; }
.selection-item { display: flex; align-items: flex-start; gap: 9px; padding: 12px; border: 1px solid var(--line); border-radius: 6px; }
.selection-item input { margin-top: 3px; }
.selection-item > span { min-width: 0; overflow-wrap: anywhere; }
.selection-item:has(input:checked) { background: #f5f9ff; border-color: #93b4f7; }
.selection-item .table-sub { margin-top: 5px; }
.generation-actions { border-top: 1px solid var(--line); padding: 16px 20px; display: flex; gap: 8px; flex-wrap: wrap; }
.login { max-width: 420px; margin: 12vh auto; padding: 30px; }
.login .form-grid { grid-template-columns: 1fr; margin-top: 25px; }
#toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #0f172a; color: white; padding: 12px 18px; border-radius: 7px; max-width: min(90vw, 600px); z-index: 20; font-size: 13px; line-height: 1.6; box-shadow: 0 4px 20px #0f172a22; }
#toast.error { background: #991b1b; }
.form-error, #toast { overflow-wrap: anywhere; }
dialog { width: min(950px, calc(100vw - 36px)); max-height: 90dvh; padding: 0; border: 1px solid var(--line); border-radius: 12px; color: var(--text); overflow: hidden; box-shadow: 0 24px 80px #0f172a29; }
dialog::backdrop { background: #0f172a55; }
dialog #modal-form { display: flex; flex-direction: column; max-height: 90dvh; }
.dialog-head { flex-shrink: 0; background: white; display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 18px 24px; border-bottom: 1px solid var(--line); }
.dialog-head h2 { font-size: 17px; overflow-wrap: anywhere; }
.dialog-body { padding: 24px; overflow-y: auto; min-height: 0; overscroll-behavior: contain; scrollbar-gutter: stable; }
.dialog-footer { flex-shrink: 0; padding: 16px 24px; border-top: 1px solid var(--line); background: white; display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 10px; }
.project-editor-dialog { width: min(1120px, calc(100vw - 36px)); }
.project-editor-dialog .dialog-body { background: var(--muted-bg); }
.project-section { background: white; border: 1px solid var(--line); border-radius: 10px; padding: 20px; }
.project-section + .project-section { margin-top: 16px; padding-top: 20px; }
.project-overview .form-grid { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.project-overview textarea { min-height: 76px; }
.table-editor-dialog { width: min(1020px, calc(100vw - 36px)); overflow: hidden; }
.table-editor-dialog #modal-form { display: flex; flex-direction: column; height: min(800px, 90dvh); max-height: 90dvh; }
.table-editor-dialog .dialog-head, .table-editor-dialog .dialog-footer { position: static; flex-shrink: 0; }
.table-editor-dialog .dialog-body { overflow-y: auto; flex: 1; min-height: 0; }
.table-editor-dialog .dialog-footer { justify-content: space-between; align-items: center; flex-wrap: wrap; }
.table-editor-tabs { display: flex; flex-shrink: 0; gap: 8px; padding: 14px 22px; border-bottom: 1px solid var(--line); background: var(--muted-bg); overflow-x: auto; }
.table-editor-tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; flex: 1 0 auto; border: 1px solid transparent; border-radius: 7px; padding: 10px 12px; background: transparent; color: var(--muted); white-space: nowrap; font-size: 13px; }
.table-editor-tabs button[aria-selected="true"] { color: var(--blue); background: white; border-color: #bfdbfe; font-weight: 600; }
.table-editor-step-number { display: inline-flex; justify-content: center; align-items: center; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 50%; font-size: 11px; }
.table-editor-tabs button[aria-selected="true"] .table-editor-step-number { color: white; background: var(--blue); border-color: var(--blue); }
.table-editor-page-head { margin-bottom: 22px; }
.table-editor-page-head h3 { margin-bottom: 6px; font-size: 15px; }
.table-editor-page-head p { margin: 0; font-size: 12px; color: var(--muted); }
.table-editor-page > .form-grid + .form-section { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.table-editor-page > .form-section > .actions { margin-bottom: 12px; }
.table-editor-page > .form-section > h3, .table-editor-page > .form-section > .actions h3 { margin-bottom: 0; }
.table-editor-page > .form-section > h3 { margin-bottom: 14px; }
.table-editor-page .columns-head { margin-top: 12px; }
.table-editor-progress { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 12px; }
.table-editor-progress > span:first-child { color: var(--text); font-variant-numeric: tabular-nums; }
.table-editor-rule-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.form-error:empty { display: none; }
dialog #modal-error:not(:empty) { margin-bottom: 18px; padding: 10px 12px; background: #fef2f2; border: 1px solid #fecaca; border-radius: 6px; }
.table-editor-dialog [hidden] { display: none !important; }
.material-panel { margin-top: 20px; }
.material-panel summary, .material-notes summary { cursor: pointer; font-size: 12px; color: var(--muted); margin: 12px 0; }
.material-panel td, .material-panel .table-sub { overflow-wrap: anywhere; }
.material-notes { margin-top: 18px; }
.material-notes textarea { min-height: 200px; line-height: 1.7; }
.repeat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)) var(--control-height); grid-template-rows: auto var(--control-height) auto; gap: 6px 12px; align-items: start; margin-top: 16px; }
.repeat-row.city-row { grid-template-columns: repeat(3, minmax(0, 1fr)) var(--control-height); }
.repeat-row.group-row { grid-template-columns: repeat(3, minmax(0, 1fr)) var(--control-height); margin-top: 0; }
.repeat-row > .field { display: grid; grid-template-rows: subgrid; grid-row: 1 / 4; }
.repeat-row > .btn { grid-column: -2 / -1; grid-row: 2; }
.source-row + .source-row, .city-row + .city-row { padding-top: 16px; border-top: 1px solid var(--line); }
.source-group-list { display: grid; gap: 10px; margin-top: 12px; }
.source-group-card, .source-group-editor { border: 1px solid var(--line); border-radius: 8px; padding: 14px; min-width: 0; }
.source-group-card:has(input:checked) { border-color: var(--blue); background: #f5f9ff; }
.source-group-card .check { flex-wrap: wrap; }
.source-group-card details { margin: 8px 0 0 23px; }
.source-group-card summary, .source-exceptions summary { cursor: pointer; font-size: 12px; color: var(--muted); }
.source-group-card p { overflow-wrap: anywhere; margin-top: 6px; }
.source-group-editor { margin-top: 16px; padding: 16px; background: #fcfdff; }
.source-group-members { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.source-group-members .check { overflow-wrap: anywhere; min-width: 0; }
.group-city-mapping { margin-top: 16px; border-top: 1px solid var(--line); padding-top: 14px; }
.group-city-mapping summary { cursor: pointer; font-weight: 600; }
.group-city-mapping .form-grid { margin-top: 12px; }
.source-missing { color: #b45309; }
.source-exceptions { margin: 14px 0; }
.source-exceptions .actions, .source-exceptions .hint { margin-top: 8px; }
#t-source-summary { margin-top: 12px; overflow-wrap: anywhere; }
.columns-row { display: grid; grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr) repeat(3, minmax(0, 1fr)) var(--control-height); gap: 10px; align-items: center; margin-top: 8px; }
.column-field { display: block; min-width: 0; }
.column-field > span { display: none; }
.column-field input.duplicate-target { border-color: var(--red); background: #fff1f2; color: #991b1b; }
.column-field input.duplicate-target:focus { outline: 2px solid #fca5a5; outline-offset: 2px; }
.column-field input.missing-expression { border-color: #d97706; background: #fffbeb; }
.column-field input.missing-expression:focus { outline: 2px solid #fcd34d; outline-offset: 2px; }
.missing-expression-hint { display: block; margin-top: 5px; color: #92400e; font-size: 12px; line-height: 1.5; }
.missing-expression-hint[hidden] { display: none; }
.columns-row:has(.missing-expression) { align-items: start; }
.duplicate-target-summary { margin: 12px 0 0; padding: 10px 12px; border: 1px solid #fecaca; border-radius: 6px; background: #fef2f2; color: #b91c1c; font-size: 12px; line-height: 1.7; }
.columns-row + details { margin-top: 18px; padding: 12px 14px; background: var(--muted-bg); border: 1px solid var(--line); border-radius: 7px; }
.columns-row + details > summary { cursor: pointer; }
.columns-row + details[open] > summary { margin-bottom: 12px; }
.columns-row + details .btn { margin-top: 12px; }
.columns-head { margin-top: 15px; color: var(--muted); font-size: 11px; }
.wide-table td { padding-top: 11px; padding-bottom: 11px; }
.loading { padding: 60px; text-align: center; color: var(--muted); }
.form-error { padding: 12px 0 0; color: #b91c1c; font-size: 12px; line-height: 1.6; }
.overview-note { display: flex; gap: 8px; align-items: center; font-size: 12px; color: #475569; margin-bottom: 18px; }
.overview-note svg { width: 16px; height: 16px; color: var(--blue); }
@media (max-width: 1150px) {
  .table-filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .table-filter-search { grid-column: span 2; }
  .app-header { gap: 15px; padding: 0 20px; }
  .brand-note { display: none; }
  .identity { display: none; }
  main { padding: 24px 20px; }
  .nav button { padding: 9px 10px; }
  .editor-layout { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 14px; }
  .tabs { gap: 15px; padding: 0 15px; }
  .project-editor-dialog { width: calc(100vw - 36px); }
  .project-section { padding: 18px; }
  .project-section + .project-section { padding-top: 18px; }
}
@media (max-width: 850px) {
  .table-filter-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-header { flex-wrap: wrap; padding-top: 13px; gap: 10px; }
  .header-right { margin-left: auto; }
  .nav { order: 3; width: 100%; flex: auto; overflow-x: auto; padding-bottom: 10px; }
  .editor-layout, .generation-layout, .project-grid { grid-template-columns: 1fr; }
  .preview-panel { position: static; }
  .page-head { align-items: flex-start; }
  .repeat-row, .repeat-row.city-row, .repeat-row.source-row, .repeat-row.group-row { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: none; gap: 16px 12px; }
  .repeat-row > .field { display: flex; grid-row: auto; }
  .repeat-row > .btn { grid-column: -2 / -1; grid-row: auto; justify-self: end; align-self: end; }
  .columns-row { grid-template-columns: repeat(2, minmax(0, 1fr)) var(--control-height); border: 1px solid var(--line); border-radius: 8px; padding: 14px; gap: 12px; margin-top: 12px; background: #fcfdff; }
  .column-field { display: flex; flex-direction: column; gap: 6px; }
  .column-field > span { display: block; color: #475569; font-size: 12px; }
  .column-field:nth-child(3), .column-field:nth-child(4) { grid-row: 2; }
  .column-field:nth-child(5) { grid-row: 3; grid-column: 1 / 3; }
  .columns-row > .btn { grid-column: 3; grid-row: 1; align-self: end; }
  .columns-head { display: none; }
  .toolbar { flex-wrap: wrap; }
  .toolbar .search { width: 100%; }
  .panel-head .actions { flex-wrap: wrap; }
  .project-card .counts { gap: 10px 14px; }
}
@media (max-width: 520px) {
  .table-filter-grid { grid-template-columns: minmax(0, 1fr); }
  .table-filter-search { grid-column: auto; }
  .table-filters { padding: 16px; }
  main { padding: 20px 14px; }
  .app-header { padding-left: 14px; padding-right: 14px; }
  h1 { font-size: 20px; }
  .page-head { flex-direction: column; gap: 14px; }
  .form-grid, .project-overview .form-grid { grid-template-columns: 1fr; }
  .months { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .panel-body, .dialog-body { padding: 17px; }
  .project-picker { max-width: 160px; }
  .header-right { min-width: 0; }
  .brand { font-size: 15px; gap: 7px; }
  dialog, .table-editor-dialog, .project-editor-dialog { width: calc(100vw - 16px); max-height: 94dvh; }
  dialog #modal-form, .table-editor-dialog #modal-form { max-height: 94dvh; }
  .dialog-head { padding: 14px 16px; }
  .dialog-head h2 { font-size: 16px; }
  .dialog-footer { padding: 12px 16px; }
  .project-editor-dialog .dialog-body { padding: 12px; }
  .project-section { padding: 14px; }
  .project-section + .project-section { padding-top: 14px; margin-top: 12px; }
  .section-heading { gap: 10px; }
  .section-heading .actions { width: 100%; }
  .repeat-row, .repeat-row.city-row, .repeat-row.source-row, .repeat-row.group-row { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .repeat-row > .btn { grid-column: 1; }
  .source-group-editor { padding: 12px; }
  .source-group-members { flex-direction: column; align-items: flex-start; }
  .columns-row { grid-template-columns: minmax(0, 1fr) var(--control-height); }
  .column-field { grid-column: 1 / -1; }
  .column-field:first-child { grid-column: 1; }
  .column-field:nth-child(3), .column-field:nth-child(4), .column-field:nth-child(5) { grid-row: auto; }
  .columns-row > .btn { grid-column: 2; }
  .condition-reading > div { grid-template-columns: 1fr; gap: 4px; }
  .operation-picker { flex-wrap: wrap; }
  .operation-picker > span { padding-bottom: 0; }
  .table-editor-tabs { padding: 10px 12px; gap: 4px; }
  .table-editor-tabs button { padding: 8px; font-size: 12px; gap: 5px; }
  .table-editor-step-number { width: 19px; height: 19px; }
  .table-editor-dialog .dialog-footer { padding: 12px 17px; gap: 10px; }
  .table-editor-progress { width: 100%; justify-content: space-between; gap: 8px; }
  .table-editor-dialog .dialog-footer > .actions { width: 100%; justify-content: flex-end; gap: 6px; }
  .table-editor-dialog .dialog-footer .btn { padding: 7px 9px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; scroll-behavior: auto !important; }
}
