:root { --accent:#2a6f9e; --ink:#1d2730; --muted:#6b7780; --line:#e3e7ea; --bg:#f6f7f8; --card:#fff; --ok:#2e7d4f; --warn:#b4541a; --bad:#b3261e; }
* { box-sizing:border-box; }
body { margin:0; font:15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif; color:var(--ink); background:var(--bg); }
a { color:var(--accent); text-decoration:none; cursor:pointer; } a:hover { text-decoration:underline; }
header { position:sticky; top:0; z-index:5; background:var(--card); border-bottom:1px solid var(--line); }
header .top { padding:12px 24px 8px; display:flex; gap:20px; align-items:center; }
header .brand { font-weight:600; color:var(--ink); white-space:nowrap; }
header .brand small { display:block; font-weight:400; color:var(--muted); font-size:12px; }
header input[type=search] { flex:1; max-width:640px; }
nav { display:flex; gap:2px; padding:0 18px; overflow-x:auto; }
nav a { padding:7px 10px 9px; color:var(--muted); font-size:14px; border-bottom:2px solid transparent; white-space:nowrap; }
nav a:hover { color:var(--ink); text-decoration:none; } nav a.on { color:var(--accent); border-color:var(--accent); }
main { max-width:1240px; margin:0 auto; padding:24px; }
h1 { font-size:24px; margin:0 0 4px; } h2 { font-size:15px; margin:0; } h3 { font-size:13px; margin:18px 0 8px; color:var(--muted); text-transform:uppercase; letter-spacing:.04em; font-weight:500; }
.sub { color:var(--muted); margin-bottom:18px; }
.titlebar { display:flex; justify-content:space-between; align-items:flex-start; gap:16px; flex-wrap:wrap; }
.actions { display:flex; gap:8px; flex-wrap:wrap; align-items:center; }

input, select, textarea { font:inherit; color:inherit; padding:8px 11px; border:1px solid var(--line); border-radius:8px; outline:none; background:#fff; max-width:100%; }
input:focus, select:focus, textarea:focus { border-color:var(--accent); box-shadow:0 0 0 3px rgba(42,111,158,.15); }
.btn { font:inherit; font-size:14px; padding:6px 12px; border:1px solid var(--line); border-radius:8px; background:#fff; color:var(--ink); cursor:pointer; white-space:nowrap; display:inline-block; }
.btn:hover { border-color:#c5ccd1; text-decoration:none; } .btn.primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn.danger { color:var(--bad); } .btn.small { font-size:12px; padding:3px 8px; }
.x { border:0; background:none; color:var(--muted); cursor:pointer; font-size:16px; line-height:1; padding:2px 6px; border-radius:6px; } .x:hover { color:var(--bad); background:#f6e9e8; }

.card { background:var(--card); border:1px solid var(--line); border-radius:10px; margin-bottom:18px; overflow:hidden; }
.card > .head { padding:10px 16px; border-bottom:1px solid var(--line); display:flex; justify-content:space-between; align-items:center; gap:12px; }
.card > .head .n { color:var(--muted); font-size:13px; font-weight:400; margin-left:6px; }
.card > .body { padding:14px 16px; } .card > .body.note { border-top:1px solid var(--line); }
table { width:100%; border-collapse:collapse; font-size:14px; }
th { text-align:left; font-weight:500; color:var(--muted); font-size:12px; text-transform:uppercase; letter-spacing:.03em; padding:8px 16px; border-bottom:1px solid var(--line); white-space:nowrap; }
th a { color:inherit; } th a.sorted { color:var(--accent); }
td { padding:8px 16px; border-bottom:1px solid var(--line); vertical-align:top; }
tr:last-child td { border-bottom:0; }
tr.click { cursor:pointer; } tr.click:hover td { background:#f1f6fa; }
td.num, th.num { text-align:right; font-variant-numeric:tabular-nums; white-space:nowrap; }
td.nowrap { white-space:nowrap; } td.tools { text-align:right; white-space:nowrap; width:1%; }
tr.total td { font-weight:600; background:#fafbfb; }
.neg { color:var(--bad); }
.badge { display:inline-block; font-size:12px; padding:1px 8px; border-radius:20px; background:#eef1f3; color:var(--muted); white-space:nowrap; }
.badge.ok { background:#e5f3ea; color:var(--ok); } .badge.k { background:#e6f0f7; color:var(--accent); } .badge.warn { background:#fbeee3; color:var(--warn); }
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:10px 24px; }
.field label { display:block; font-size:12px; color:var(--muted); } .field div { white-space:pre-wrap; word-break:break-word; }
.stats { display:grid; grid-template-columns:repeat(auto-fill, minmax(150px, 1fr)); gap:14px; margin-bottom:22px; }
.stat { background:var(--card); border:1px solid var(--line); border-radius:10px; padding:14px 16px; color:inherit; display:block; }
.stat:hover { border-color:var(--accent); text-decoration:none; }
.stat b { display:block; font-size:24px; font-weight:600; } .stat span { color:var(--muted); font-size:13px; }
.cols { display:grid; grid-template-columns:1fr 1fr; gap:18px; align-items:start; }
.muted { color:var(--muted); } .empty { padding:14px 16px; color:var(--muted); }
details.raw summary { cursor:pointer; color:var(--muted); padding:12px 16px; font-size:13px; }
details.raw table td:first-child { color:var(--muted); width:260px; }
.letter { white-space:pre-wrap; font-family:Georgia, serif; line-height:1.55; }
.crumb { font-size:13px; margin-bottom:10px; color:var(--muted); }
.more { padding:10px 16px; font-size:13px; color:var(--muted); border-top:1px solid var(--line); }
.filters { display:flex; gap:10px; flex-wrap:wrap; align-items:center; margin-bottom:14px; }
.filters input, .filters select { padding:6px 10px; font-size:14px; } .filters label { font-size:14px; color:var(--muted); display:flex; gap:6px; align-items:center; }
.pager { display:flex; gap:10px; align-items:center; justify-content:flex-end; padding:10px 16px; border-top:1px solid var(--line); font-size:13px; color:var(--muted); }
.bars { display:flex; gap:6px; align-items:flex-end; height:120px; padding:14px 16px 6px; }
.bars div { flex:1; background:var(--accent); border-radius:4px 4px 0 0; min-height:2px; position:relative; opacity:.85; }
.bars div:hover { opacity:1; } .barlabels { display:flex; gap:6px; padding:0 16px 12px; font-size:11px; color:var(--muted); } .barlabels span { flex:1; text-align:center; }
.tabs { display:flex; gap:6px; flex-wrap:wrap; margin-bottom:14px; }
.tabs a { padding:5px 11px; border:1px solid var(--line); border-radius:20px; background:#fff; color:var(--ink); font-size:13px; } .tabs a.on { background:var(--accent); border-color:var(--accent); color:#fff; } .tabs a:hover { text-decoration:none; }

.menu { position:relative; margin-left:auto; }
.drop { display:none; position:absolute; right:0; top:calc(100% + 6px); background:#fff; border:1px solid var(--line); border-radius:10px; box-shadow:0 8px 24px rgba(0,0,0,.12); min-width:180px; padding:6px; z-index:10; }
.drop.open { display:block; } .drop a { display:block; padding:7px 10px; border-radius:6px; color:var(--ink); } .drop a:hover { background:#f1f6fa; text-decoration:none; }

dialog { border:0; border-radius:12px; padding:0; width:min(860px, calc(100vw - 32px)); max-height:calc(100vh - 48px); box-shadow:0 20px 60px rgba(0,0,0,.3); color:var(--ink); }
dialog::backdrop { background:rgba(20,30,40,.45); }
dialog form { display:flex; flex-direction:column; max-height:calc(100vh - 48px); }
dialog .dhead { padding:14px 20px; border-bottom:1px solid var(--line); font-weight:600; font-size:17px; display:flex; justify-content:space-between; align-items:center; }
dialog .dbody { padding:16px 20px; overflow:auto; }
dialog .dfoot { padding:12px 20px; border-top:1px solid var(--line); display:flex; gap:8px; justify-content:flex-end; align-items:center; }
dialog .dfoot .left { margin-right:auto; }
.fgrid { display:grid; grid-template-columns:repeat(auto-fill, minmax(230px, 1fr)); gap:12px 16px; }
.fgrid .f { display:flex; flex-direction:column; gap:3px; min-width:0; } .fgrid .f.wide { grid-column:1 / -1; }
.fgrid label { font-size:12px; color:var(--muted); } .fgrid label b { color:var(--bad); font-weight:400; }
.fgrid input, .fgrid select, .fgrid textarea { width:100%; } .fgrid textarea { min-height:90px; resize:vertical; } .fgrid textarea.big { min-height:340px; font-family:Georgia, serif; }
.picker { position:relative; } .picker .res { position:absolute; left:0; right:0; top:100%; background:#fff; border:1px solid var(--line); border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,.12); z-index:20; max-height:240px; overflow:auto; }
.picker .res a { display:block; padding:6px 10px; color:var(--ink); font-size:14px; } .picker .res a:hover { background:#f1f6fa; text-decoration:none; } .picker .res small { color:var(--muted); }
.picker .chosen { display:flex; justify-content:space-between; align-items:center; gap:6px; padding:7px 11px; border:1px solid var(--line); border-radius:8px; background:#f6f9fb; }
.lines td { padding:4px 6px; border:0; } .lines th { padding:4px 6px; } .lines input { width:100%; padding:6px 8px; } .lines input.amt { text-align:right; }
.err { color:var(--bad); font-size:14px; }
#toast { position:fixed; bottom:20px; left:50%; transform:translateX(-50%); background:var(--ink); color:#fff; padding:10px 16px; border-radius:8px; font-size:14px; opacity:0; pointer-events:none; transition:opacity .2s; z-index:100; max-width:80vw; }
#toast.show { opacity:1; } #toast.bad { background:var(--bad); }

@media (max-width:800px) { header .top { flex-wrap:wrap; padding:10px 14px 6px; } main { padding:14px; } .card { overflow-x:auto; } .cols { grid-template-columns:1fr; } }
@media print { header, .actions, .crumb, .card:not(.print), #toast, .more { display:none !important; } body { background:#fff; } main { padding:0; max-width:none; } .card.print { border:0; } h1, .sub { display:none; } }
