/* Kitfiler Tax — tax.kitfiler.com. No inline styles anywhere (CSP style-src 'self'). */
:root {
    --ink: #1b2430;
    --ink-2: #4a5566;
    --muted: #6b7686;
    --line: #dde3ea;
    --line-2: #eef2f6;
    --bg: #f5f7fa;
    --card: #ffffff;
    --brand: #1f4e79;
    --brand-2: #163a5c;
    --brand-tint: #e8f0f8;
    --good: #1e7a46;
    --good-tint: #e7f5ec;
    --owe: #a35a00;
    --owe-tint: #fdf2e3;
    --bad: #b42318;
    --bad-tint: #fdecea;
    --info-tint: #eaf2fb;
    --warn-tint: #fff6db;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --focus: 0 0 0 3px rgba(31, 78, 121, .35);
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 15px;
    line-height: 1.5;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; display: flex; flex-direction: column; background: var(--bg); }
a { color: var(--brand); }
a:hover { color: var(--brand-2); }
h1 { font-size: 1.6rem; margin: 0 0 .75rem; line-height: 1.25; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
code { font-family: Consolas, "SFMono-Regular", monospace; font-size: .92em; background: var(--line-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.pad { padding: 2rem; }
.ok { color: var(--good); font-weight: 600; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: none; box-shadow: var(--focus); }

/* ---------- top bar ---------- */
.topbar {
    display: flex; align-items: center; justify-content: space-between; gap: 1rem;
    padding: .7rem 1.5rem; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: .55rem; font-size: 1.15rem; color: var(--ink); text-decoration: none; letter-spacing: -.01em; }
.brand b { color: var(--brand); }
.brand-mark {
    display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
    background: var(--brand); color: #fff; font-weight: 700; font-size: 1rem;
}
.topnav { display: flex; align-items: center; gap: 1.1rem; flex-wrap: wrap; }
.topnav a { text-decoration: none; color: var(--ink-2); font-weight: 500; }
.topnav a:hover, .topnav a.active { color: var(--brand); }
form.inline { display: inline; margin: 0; }
.linklike { background: none; border: 0; padding: 0; color: var(--ink-2); font: inherit; font-weight: 500; cursor: pointer; }
.linklike:hover { color: var(--brand); }

/* ---------- public pages ---------- */
.public-main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 2rem 1.25rem 3rem; }
.footer { display: flex; gap: 1.25rem; justify-content: center; flex-wrap: wrap; padding: 1.25rem; color: var(--muted); font-size: .86rem; border-top: 1px solid var(--line); background: var(--card); }
.footer a { color: var(--muted); }
.hero { text-align: center; padding: 2.5rem 1rem 2rem; }
.hero h1 { font-size: 2.2rem; letter-spacing: -.02em; }
.lead { font-size: 1.15rem; color: var(--ink-2); max-width: 640px; margin: 0 auto 1.5rem; }
.hero-actions { display: flex; gap: .75rem; justify-content: center; flex-wrap: wrap; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.grid-3 ul { padding-left: 1.1rem; margin: 0; }
.grid-3 li { margin-bottom: .35rem; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 460px; margin: 1rem auto; }
.card.narrow input:not([type=checkbox]):not([type=radio]) { width: 100%; }
.card.narrow label { display: block; font-weight: 600; margin: .9rem 0 .3rem; font-size: .92rem; }
.card.narrow label.check { font-weight: 400; display: flex; gap: .5rem; align-items: flex-start; }
.card.narrow label.check input { margin-top: .3rem; flex: none; width: 17px; height: 17px; accent-color: var(--brand); }
.card.narrow .btn-block { margin-top: 1.2rem; }
.card.narrow h2 { margin-top: 1.5rem; }
.prose { max-width: 760px; margin: 0 auto; }
.prose h2 { margin-top: 1.5rem; }
.links { margin-top: 1rem; font-size: .9rem; }
.hint { display: block; color: var(--muted); font-size: .84rem; margin-top: .25rem; }
.steps { padding-left: 1.2rem; }
.steps li { margin-bottom: .75rem; }
.qr { margin: .75rem 0; }
.qr img { border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 6px; }
.key { word-break: break-all; }
.codes { columns: 2; list-style: none; padding: 0; }
.codes li { margin: .25rem 0; }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1.25rem; margin: 0 0 1rem; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; }

/* ---------- forms ---------- */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=search], select, textarea {
    font: inherit; color: var(--ink); background: #fff; border: 1px solid #c7d0db; border-radius: 7px; padding: .5rem .65rem;
    min-height: 38px; width: 100%; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--brand); box-shadow: var(--focus); outline: none; }
input:disabled, select:disabled { background: var(--line-2); color: var(--ink-2); }
input.upper { text-transform: uppercase; }
.narrow-input { max-width: 190px; }
.input-group { display: flex; gap: .4rem; align-items: center; }
.input-group > input, .input-group > select { flex: 1; min-width: 0; }
.input-group.money { position: relative; }
.input-group.money .prefix { position: absolute; left: .65rem; color: var(--muted); pointer-events: none; }
.input-group.money input { padding-left: 1.5rem; text-align: right; font-variant-numeric: tabular-nums; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .9rem 1.1rem; margin-bottom: .5rem; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .narrow { max-width: 160px; }
.field { display: flex; flex-direction: column; min-width: 0; }
.field > label { font-weight: 600; font-size: .88rem; margin-bottom: .3rem; color: var(--ink-2); }
.field.check { flex-direction: row; align-items: flex-start; margin: .35rem 0; }
.field.check label { font-weight: 400; color: var(--ink); display: flex; gap: .55rem; align-items: flex-start; cursor: pointer; }
.field.check input { margin-top: .25rem; width: 17px; height: 17px; accent-color: var(--brand); flex: none; }
.field .error { color: var(--bad); font-size: .84rem; margin-top: .25rem; }
.field.has-error input, .field.has-error select { border-color: var(--bad); }
.req { color: var(--bad); }
label.radio { display: flex; gap: .5rem; align-items: center; margin: .3rem 0; cursor: pointer; }
label.radio input { accent-color: var(--brand); width: 16px; height: 16px; }

/* ---------- buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font: inherit; font-weight: 600;
    padding: .5rem 1rem; min-height: 38px; border-radius: 7px; border: 1px solid #c7d0db; background: #fff; color: var(--ink);
    cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s;
}
.btn:hover { background: var(--line-2); color: var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); color: #fff; }
.btn-danger { color: var(--bad); border-color: #f0b6b0; }
.btn-danger:hover { background: var(--bad-tint); color: var(--bad); }
.btn-quiet { border-color: transparent; color: var(--ink-2); }
.btn-small { padding: .25rem .6rem; min-height: 30px; font-size: .86rem; }
.btn-large { padding: .75rem 1.5rem; font-size: 1.05rem; }
.btn-block { width: 100%; }
.icon-btn { background: none; border: 0; font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); padding: .1rem .4rem; border-radius: 6px; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }

/* ---------- alerts ---------- */
.alert { border-radius: 8px; padding: .75rem 1rem; margin: 0 0 1rem; border: 1px solid transparent; }
.alert ul { margin: .25rem 0 0; padding-left: 1.2rem; }
.alert p { margin: 0; }
.alert-error { background: var(--bad-tint); border-color: #f4c7c2; color: #7a1a12; }
.alert-info { background: var(--info-tint); border-color: #c9dcf0; }
.alert-warning { background: var(--warn-tint); border-color: #f1df9d; }
.alert-success { background: var(--good-tint); border-color: #b9e1c8; color: #14532d; }

/* ---------- app shell ---------- */
.app-main { flex: 1; width: 100%; }
.page { max-width: 1180px; margin: 0 auto; padding: 1.75rem 1.5rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.welcome { max-width: 680px; }
.return-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.return-card {
    display: block; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.25rem;
    text-decoration: none; color: var(--ink); box-shadow: var(--shadow); transition: border-color .15s, transform .15s;
}
.return-card:hover { border-color: var(--brand); transform: translateY(-1px); color: var(--ink); }
.rc-name { font-weight: 700; font-size: 1.05rem; }
.rc-meta { color: var(--muted); font-size: .86rem; margin: .2rem 0 .6rem; }
.rc-amount .good { color: var(--good); font-weight: 700; }
.rc-amount .owe { color: var(--owe); font-weight: 700; }

/* ---------- return editor ---------- */
.editor { display: grid; grid-template-columns: 250px minmax(0, 1fr); min-height: calc(100vh - 57px); }
.side-nav { background: var(--card); border-right: 1px solid var(--line); padding: 1rem .75rem 2rem; position: sticky; top: 57px; height: calc(100vh - 57px); overflow-y: auto; }
.side-nav .back { display: inline-block; font-size: .88rem; text-decoration: none; margin: 0 .5rem .6rem; }
.return-name { font-weight: 700; margin: 0 .5rem .75rem; overflow-wrap: anywhere; }
.side-nav ul { list-style: none; margin: 0; padding: 0; }
.side-nav li a { display: block; padding: .42rem .7rem; border-radius: 7px; text-decoration: none; color: var(--ink-2); font-size: .93rem; }
.side-nav li a:hover { background: var(--line-2); color: var(--ink); }
.side-nav li a.active { background: var(--brand-tint); color: var(--brand); font-weight: 600; }
.side-nav li.lvl-1 a { padding-left: 1.7rem; font-size: .9rem; }
.side-nav li.divider { border-top: 1px solid var(--line); margin-top: .5rem; padding-top: .5rem; }

.editor-main { padding: 1.25rem 2rem 2rem; max-width: 1200px; width: 100%; }
.editor-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.editor-head h1 { margin: 0 0 .25rem; }
.pill { display: inline-block; font-size: .78rem; font-weight: 600; padding: .12rem .55rem; border-radius: 999px; background: var(--line-2); color: var(--ink-2); }
.pill.accepted { background: var(--good-tint); color: var(--good); }
.pill.rejected { background: var(--bad-tint); color: var(--bad); }
.pill.readytofile, .pill.transmitted { background: var(--info-tint); color: var(--brand); }
.headline { display: flex; flex-direction: column; align-items: flex-end; padding: .4rem 1rem; border-radius: 8px; background: var(--line-2); min-width: 170px; }
.headline span { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.headline b { font-size: 1.35rem; font-variant-numeric: tabular-nums; }
.headline.good { background: var(--good-tint); }
.headline.good b { color: var(--good); }
.headline.owe { background: var(--owe-tint); }
.headline.owe b { color: var(--owe); }
.save-area { display: flex; align-items: center; gap: .75rem; }
.save-status { color: var(--muted); font-size: .86rem; }

.section-body { min-height: 300px; }
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.25rem 1.4rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.panel > h2 { margin-bottom: .5rem; }
h2.sub { margin: 1.5rem 0 .5rem; }
h2.sub:first-child { margin-top: 0; }
.intro { color: var(--ink-2); margin: 0 0 .9rem; max-width: 820px; }
.empty { padding: 1.5rem; text-align: center; color: var(--muted); background: var(--card); border: 1px dashed #c7d0db; border-radius: var(--radius); }
.editor-foot { display: flex; justify-content: space-between; margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--line); }

/* ---------- lists / tables ---------- */
.record-list { margin-bottom: 1rem; }
.list-toolbar { display: flex; align-items: center; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; }
.list-toolbar .search { max-width: 320px; }
.list-toolbar .btn-primary { margin-left: auto; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
table.grid { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.grid th { text-align: left; font-weight: 600; color: var(--ink-2); background: #f9fafb; padding: .6rem .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.grid td { padding: .55rem .8rem; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.grid tbody tr:hover { background: #fafbfd; }
table.grid tfoot td { font-weight: 700; background: #f9fafb; border-top: 1px solid var(--line); border-bottom: 0; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.grid td.actions { text-align: right; white-space: nowrap; }
table.grid .confirm { display: inline-flex; gap: .4rem; align-items: center; font-size: .86rem; color: var(--bad); white-space: normal; }
table.lines td:first-child { color: var(--muted); width: 70px; }

.diagnostics { list-style: none; padding: 0; margin: 0 0 .75rem; }
.diagnostics li { padding: .45rem .7rem; border-radius: 7px; margin-bottom: .35rem; background: var(--line-2); }
.diagnostics li.error { background: var(--bad-tint); }
.diagnostics li.warning { background: var(--warn-tint); }
.diagnostics li b { margin-right: .35rem; }

.summary-tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .75rem; margin: .75rem 0 1rem; }
.summary-tiles > div { background: var(--line-2); border-radius: 8px; padding: .7rem .9rem; display: flex; flex-direction: column; }
.summary-tiles span { font-size: .8rem; color: var(--muted); }
.summary-tiles b { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.summary-tiles .good { background: var(--good-tint); }
.summary-tiles .good b { color: var(--good); }
.summary-tiles .owe { background: var(--owe-tint); }
.summary-tiles .owe b { color: var(--owe); }

fieldset.signer { border: 1px solid var(--line); border-radius: var(--radius); padding: .5rem 1.1rem 1rem; margin: 0 0 1rem; }
fieldset.signer legend { font-weight: 700; padding: 0 .4rem; }
fieldset.signer .field { max-width: 360px; margin-bottom: .6rem; }
.verify .label { font-weight: 600; font-size: .88rem; color: var(--ink-2); margin: .5rem 0 .25rem; }
.jurat { background: #fbfcfe; border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1.1rem; margin: 1rem 0; font-size: .92rem; }
.jurat h3 { margin-top: 0; }
.status-panel.accepted { border-left: 4px solid var(--good); }
.status-panel.rejected { border-left: 4px solid var(--bad); }
.status-panel.pending { border-left: 4px solid var(--brand); }
.status-line { font-size: 1.02rem; margin: 0 0 .25rem; }

/* ---------- modal ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); display: grid; place-items: center; z-index: 100; padding: 1rem; }
.modal { background: var(--card); border-radius: 12px; width: min(560px, 100%); max-height: calc(100vh - 2rem); display: flex; flex-direction: column; box-shadow: 0 20px 50px rgba(0, 0, 0, .25); }
.modal-wide { width: min(860px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem .5rem; }
.modal-head h2 { margin: 0; }
.modal-body { padding: .5rem 1.25rem 1rem; overflow-y: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: .5rem; padding: .85rem 1.25rem; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 12px 12px; }
.code-list { max-height: 50vh; overflow-y: auto; margin: .75rem 0; border: 1px solid var(--line); border-radius: 8px; }
.code-group { position: sticky; top: 0; background: #f3f6f9; font-weight: 600; font-size: .82rem; padding: .35rem .75rem; color: var(--ink-2); }
.code-item { display: flex; gap: .75rem; width: 100%; text-align: left; background: none; border: 0; border-bottom: 1px solid var(--line-2); padding: .5rem .75rem; font: inherit; cursor: pointer; }
.code-item:hover, .code-item:focus-visible { background: var(--brand-tint); }

/* ---------- staff ---------- */
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--line); margin-bottom: 1.25rem; flex-wrap: wrap; }
.tabs a { padding: .55rem .9rem; text-decoration: none; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; font-weight: 500; }
.tabs a.active { color: var(--brand); border-bottom-color: var(--brand); }
pre.log { background: #0f172a; color: #e2e8f0; padding: .75rem 1rem; border-radius: 8px; max-height: 240px; overflow: auto; font-size: .84rem; }

/* ---------- reconnect + idle ---------- */
.reconnect { display: none; }
.reconnect.components-reconnect-show, .reconnect.components-reconnect-failed, .reconnect.components-reconnect-rejected {
    display: grid; place-items: center; position: fixed; inset: 0; background: rgba(15, 23, 42, .35); z-index: 200;
}
.reconnect-box { background: var(--card); padding: 1.25rem 1.5rem; border-radius: 10px; box-shadow: var(--shadow); }
.reconnect-box p { display: none; margin: 0; }
.components-reconnect-show .reconnect-show-text,
.components-reconnect-failed .reconnect-failed-text,
.components-reconnect-rejected .reconnect-rejected-text { display: block; }
.idle-warning { position: fixed; bottom: 1rem; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: .75rem 1.25rem; border-radius: 8px; z-index: 300; box-shadow: var(--shadow); }

/* ---------- small screens ---------- */
@media (max-width: 860px) {
    .editor { grid-template-columns: 1fr; }
    .side-nav { position: static; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .side-nav ul { display: flex; flex-wrap: wrap; gap: .25rem; }
    .side-nav li.lvl-1 a { padding-left: .7rem; }
    .side-nav li.divider { border-top: 0; margin: 0; padding: 0; }
    .editor-main { padding: 1rem; }
    .form-grid .span-2 { grid-column: auto; }
    .topbar { padding: .6rem 1rem; }
}
@media print {
    .topbar, .side-nav, .editor-foot, .save-area, .btn { display: none !important; }
    .editor { display: block; }
}

/* Headings receive focus after navigation (screen readers); no visible ring needed there. */
h1:focus, h1:focus-visible { box-shadow: none; outline: none; }
