/* NeuroConverse Finance - modern, plain, square UI (no rounded corners), sans-serif */
:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --ink: #111827;
    --ink-2: #374151;
    --muted: #6b7280;
    --line: #dcdfe4;
    --line-2: #eceef1;
    --accent: #1f4fd1;
    --accent-ink: #ffffff;
    --accent-soft: #e8eefc;
    --pos: #0f7a4a;
    --neg: #b42318;
    --warn: #a15c07;
    --side: #111827;
    --side-ink: #d1d5db;
    --income: #1f9d63;
    --expense: #d64545;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
    --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--bg); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .6em; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; margin-top: 1.2em; }
code { font-family: var(--mono); font-size: .88em; background: var(--line-2); padding: .05em .3em; }
p { margin: 0 0 1em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .84rem; }
.block { display: block; }
.nowrap { white-space: nowrap; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.center { text-align: center; }
.inline { display: inline; }

/* ---------- app shell */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 16px; height: 56px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); font-weight: 650; }
.brand:hover { text-decoration: none; }
.brand-mark { display: inline-grid; place-items: center; width: 30px; height: 30px; background: var(--ink); color: #fff; font-size: .78rem; font-weight: 700; letter-spacing: .04em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.topbar-user { color: var(--ink-2); font-weight: 500; }
.nav-toggle { display: none; background: none; border: 1px solid var(--line); width: 38px; height: 38px; font-size: 18px; cursor: pointer; }
.shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); min-height: calc(100vh - 56px); }
.sidebar { background: var(--side); color: var(--side-ink); padding: 18px 0; display: flex; flex-direction: column; }
.sidebar ul { list-style: none; margin: 0; padding: 0; }
.sidebar a { display: block; padding: 9px 22px; color: var(--side-ink); border-left: 3px solid transparent; }
.sidebar a:hover { background: #1f2937; color: #fff; text-decoration: none; }
.sidebar a.active { background: #1f2937; color: #fff; border-left-color: #6c8cff; font-weight: 600; }
.sidebar-heading { margin: 22px 22px 6px; font-size: .72rem; text-transform: uppercase; letter-spacing: .1em; color: #9ca3af; }
.sidebar-footer { margin-top: auto; padding-top: 20px; border-top: 1px solid #1f2937; }
.sidebar-footer a { font-size: .84rem; padding: 6px 22px; color: #9ca3af; }
.content { padding: 28px 32px 60px; max-width: 1400px; width: 100%; min-width: 0; overflow-wrap: break-word; }

.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; margin-bottom: 20px; }
.page-head h1 { margin: 0; }
.page-head > p { margin: 0; flex-basis: 100%; order: 3; }
.page-head .actions { margin-left: auto; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cal-title { min-width: 140px; text-align: center; }

/* ---------- panels, grids */
.panel { background: var(--surface); border: 1px solid var(--line); padding: 20px 22px; margin-bottom: 20px; }
.panel.narrow { max-width: 760px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.grid-2 > .panel { margin-bottom: 0; }
.grid-2 + * { margin-top: 20px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); margin-bottom: 20px; }
.kpi { background: var(--surface); padding: 16px 18px; display: flex; flex-direction: column; gap: 2px; }
.kpi-label { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.45rem; font-weight: 650; font-variant-numeric: tabular-nums; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpis-compact .kpi-value { font-size: 1.15rem; }
.panel .kpis { margin-bottom: 14px; }

/* ---------- buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 15px; font: inherit; font-size: .9rem; font-weight: 550; line-height: 1.3; color: var(--ink); background: var(--surface); border: 1px solid #c4c9d1; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.btn:hover { background: #f1f3f6; border-color: #9aa1ac; }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1a43b3; border-color: #1a43b3; }
.btn-danger { color: var(--neg); border-color: #e3a9a3; }
.btn-danger:hover { background: #fdf0ef; border-color: var(--neg); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--line-2); border-color: transparent; }
.btn-sm { padding: 5px 10px; font-size: .82rem; }
.btn-block { width: 100%; }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font: inherit; cursor: pointer; }
button.link:hover { text-decoration: underline; }
.button-row { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------- forms */
.form label { display: flex; flex-direction: column; gap: 5px; margin-bottom: 14px; font-size: .86rem; font-weight: 550; color: var(--ink-2); }
input, select, textarea { font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid #c4c9d1; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
input[disabled] { background: var(--line-2); color: var(--muted); }
input[type="checkbox"] { width: auto; accent-color: var(--accent); }
textarea { resize: vertical; }
.form label.check, label.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 450; }
.form .row, .row { display: flex; flex-wrap: wrap; gap: 0 16px; }
.row > label { flex: 1 1 160px; }
.row > label.grow, .filters label.grow { flex: 3 1 260px; }
.hint { font-size: .8rem; font-weight: 400; color: var(--muted); }
fieldset { border: 1px solid var(--line); padding: 14px 16px 4px; margin: 0 0 16px; }
legend { padding: 0 6px; font-weight: 650; font-size: .9rem; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.form-inline { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 12px; }
.form-inline label { flex: 1 1 140px; }
.form-inline .btn { margin-bottom: 14px; }
.input-code { font-family: var(--mono); font-size: 1.3rem; letter-spacing: .25em; text-align: center; }
.calc-preview { flex-basis: 100%; font-size: .85rem; color: var(--muted); margin: -6px 0 14px; min-height: 1.2em; font-variant-numeric: tabular-nums; }
.danger-zone { margin-top: -6px; margin-bottom: 20px; }

.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 12px; background: var(--surface); border: 1px solid var(--line); padding: 14px 16px; margin-bottom: 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .78rem; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; flex: 1 1 140px; }
.filters input, .filters select { text-transform: none; letter-spacing: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.export-form { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.export-form input[type="password"] { width: 200px; padding: 5px 8px; font-size: .85rem; }

/* ---------- tables */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); margin-bottom: 16px; }
.panel .table-wrap { border: 0; margin-bottom: 0; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th, .table td { padding: 9px 12px; text-align: left; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.table thead th { background: #f8f9fb; font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table tfoot th, .table tfoot td { border-top: 1px solid var(--line); border-bottom: 0; font-weight: 600; }
.table tbody tr:hover { background: #fafbfc; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-compact th, .table-compact td { padding: 6px 8px; }
.table tr.inactive td { color: var(--muted); }
.table tr.group th { background: var(--line-2); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.table .empty { text-align: center; color: var(--muted); padding: 28px; }
.row-actions { white-space: nowrap; text-align: right; }
.row-actions a + a { margin-left: 10px; }
.matrix td.yes { color: var(--pos); font-weight: 700; }
.matrix td.no { color: #c0c4cb; }
.items input { padding: 6px 8px; }
.items td { vertical-align: middle; }
.bar-cell { width: 35%; }
.hbar { width: 100%; height: 8px; display: block; }
.hbar-bg { fill: var(--line-2); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: 6px 18px; margin: 0; }
.dl dt { color: var(--muted); }
.dl dd { margin: 0; }

/* ---------- tags, status */
.tag { display: inline-block; padding: 1px 7px; font-size: .74rem; font-weight: 600; background: var(--line-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; vertical-align: middle; }
.tag-income, .tag-receivable { background: #e3f4ec; color: var(--pos); }
.tag-expense, .tag-payable { background: #fbe9e7; color: var(--neg); }
.status { display: inline-block; padding: 2px 8px; font-size: .78rem; font-weight: 600; border: 1px solid currentColor; }
.status-open, .status-pending { color: var(--accent); }
.status-paid, .status-active { color: var(--pos); }
.status-overdue, .status-disabled { color: var(--neg); }
.status-draft, .status-cancelled, .status-unverified { color: var(--muted); }

/* ---------- alerts */
.alert { padding: 11px 14px; margin-bottom: 16px; border: 1px solid; border-left-width: 4px; font-size: .92rem; }
.alert-success { background: #edf8f2; border-color: #a7d9bf; border-left-color: var(--pos); }
.alert-error { background: #fdf0ef; border-color: #f0b9b3; border-left-color: var(--neg); }
.alert-warning { background: #fff7e8; border-color: #f2d39b; border-left-color: var(--warn); }
.alert-info { background: var(--accent-soft); border-color: #c3d1f6; border-left-color: var(--accent); }

/* ---------- chart */
.chart { margin: 0 0 12px; }
.chart svg { width: 100%; height: auto; display: block; }
.chart .grid { stroke: var(--line-2); stroke-width: 1; }
.chart .baseline { stroke: var(--ink-2); stroke-width: 1; }
.chart .axis { font-size: 11px; fill: var(--muted); font-family: var(--font); }
.bar-income { fill: var(--income); }
.bar-expense { fill: var(--expense); }
.chart figcaption { font-size: .82rem; color: var(--muted); display: flex; align-items: center; gap: 8px; }
.legend { display: inline-block; width: 12px; height: 12px; }
.legend-income { background: var(--income); }
.legend-expense { background: var(--expense); margin-left: 12px; }

/* ---------- events & calendar */
.event-list { list-style: none; margin: 0 0 12px; padding: 0; }
.event { display: grid; grid-template-columns: 130px 1fr auto; gap: 2px 12px; padding: 8px 0 8px 10px; border-bottom: 1px solid var(--line-2); border-left: 3px solid var(--muted); font-size: .9rem; }
.event-date { color: var(--ink-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.event-src { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.event-desc { grid-column: 2 / 4; font-size: .82rem; color: var(--muted); }
.event-statutory, .cal-statutory { border-left-color: #7c3aed !important; }
.event-deadline, .cal-deadline { border-left-color: var(--neg) !important; }
.event-reminder, .event-meeting, .event-other, .cal-reminder, .cal-meeting, .cal-other { border-left-color: var(--accent) !important; }
.event-invoice, .cal-invoice { border-left-color: var(--warn) !important; }
.event-recurring, .cal-recurring { border-left-color: var(--income) !important; }
.calendar { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--line); gap: 1px; border: 1px solid var(--line); margin-bottom: 20px; }
.cal-head { background: #f8f9fb; padding: 8px; font-size: .76rem; font-weight: 650; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.cal-day { background: var(--surface); min-height: 112px; padding: 6px; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cal-day.other { background: #fafbfc; }
.cal-day.other .cal-num { color: #b0b5bd; }
.cal-day.today { box-shadow: inset 0 0 0 2px var(--accent); }
.cal-num { font-size: .82rem; font-weight: 650; color: var(--ink-2); }
.cal-num a { color: inherit; }
.cal-item { display: block; font-size: .74rem; line-height: 1.3; padding: 2px 5px; background: #f3f4f6; color: var(--ink); border-left: 3px solid var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-item:hover { background: var(--accent-soft); text-decoration: none; }
.legend-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-bottom: 10px; color: var(--muted); }
.dot { display: inline-block; width: 10px; height: 10px; margin-right: -8px; }
.dot-statutory { background: #7c3aed; } .dot-deadline { background: var(--neg); } .dot-reminder { background: var(--accent); }
.dot-invoice { background: var(--warn); } .dot-recurring { background: var(--income); }

/* ---------- misc */
.pagination { display: flex; flex-wrap: wrap; gap: 4px; }
.pagination a { padding: 5px 11px; border: 1px solid var(--line); background: var(--surface); }
.pagination a.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.tabs { display: flex; flex-wrap: wrap; border-bottom: 1px solid var(--line); margin-bottom: 20px; }
.tabs a { padding: 10px 16px; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.active { border-bottom-color: var(--accent); color: var(--ink); font-weight: 600; }
.tabs a:hover { text-decoration: none; background: var(--line-2); }
.option { border: 1px solid var(--line); padding: 16px; }
.option-active { border-color: var(--accent); background: #f8faff; }
.option h3 { margin-top: 0; }
.qr { display: inline-block; border: 1px solid var(--line); padding: 8px; background: #fff; margin: 8px 0 12px; }
.qr svg { display: block; width: 220px; height: 220px; }
.secret { font-size: 1rem; letter-spacing: .08em; word-break: break-all; }
.codes { display: grid; grid-template-columns: repeat(2, max-content); gap: 8px 28px; list-style: none; padding: 0; margin: 0 0 18px; }
.codes code { font-size: 1.05rem; letter-spacing: .08em; padding: 4px 8px; }
.steps { padding-left: 20px; }
.toc ol { columns: 2; margin: 8px 0 0; padding-left: 20px; }
.link-list li { margin-bottom: 4px; }
.logo-preview { border: 1px solid var(--line); padding: 14px; margin-bottom: 12px; background: #fff; display: inline-block; }
.logo-preview img { max-width: 260px; max-height: 110px; display: block; }
.release .version { font-family: var(--mono); background: var(--ink); color: #fff; padding: 2px 8px; font-size: .9rem; margin-right: 6px; }
.change-security { color: var(--neg); }
.change-added { color: var(--pos); }
.debug { white-space: pre-wrap; font-size: .8rem; background: var(--line-2); padding: 10px; }

/* ---------- auth pages */
body.auth { background: var(--bg); }
.auth-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 32px 16px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--ink); padding: 30px 32px; }
.auth-card-wide { max-width: 720px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; margin-bottom: 26px; }
.auth-card h1 { font-size: 1.35rem; }
.auth-links { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-top: 18px; font-size: .88rem; }
.auth-foot { font-size: .78rem; color: var(--muted); margin-top: 16px; }
details summary { cursor: pointer; color: var(--accent); margin: 12px 0 6px; }

/* ---------- responsive */
@media (max-width: 1100px) {
    .grid-2 { grid-template-columns: 1fr; }
    .grid-2 > .panel + .panel { margin-top: 0; }
}
@media (max-width: 860px) {
    .nav-toggle { display: inline-grid; place-items: center; }
    .shell { grid-template-columns: minmax(0, 1fr); }
    .panel { overflow-x: auto; padding: 16px; }
    .panel > .table { min-width: 520px; }
    .dl { grid-template-columns: minmax(0, 1fr); gap: 0 0; }
    .dl dd { margin-bottom: 8px; }
    h1 { font-size: 1.35rem; overflow-wrap: anywhere; }
    .filters label { flex-basis: 100%; }
    .export-form input[type="password"] { width: 100%; }
    .sidebar { position: fixed; top: 56px; bottom: 0; left: 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .15s ease; overflow-y: auto; }
    .sidebar.open { transform: none; }
    .content { padding: 20px 16px 48px; }
    .topbar { padding: 0 16px; }
    .topbar-user { display: none; }
    .cal-day { min-height: 70px; padding: 3px; }
    .cal-item { font-size: .66rem; padding: 1px 3px; }
    .event { grid-template-columns: 1fr; }
    .event-desc { grid-column: auto; }
    .toc ol { columns: 1; }
    .page-head .actions { margin-left: 0; }
}
@media (max-width: 520px) {
    .brand { font-size: .92rem; }
    .auth-card { padding: 24px 20px; }
    .codes { grid-template-columns: 1fr; }
}
@media print {
    .topbar, .sidebar, .filters, .toolbar, .actions, .danger-zone, .btn { display: none !important; }
    .shell { display: block; }
    body { background: #fff; }
    .panel { border: 0; padding: 0; }
}
