:root { --grey:#6d6e71; --orange:#ee5a24; --ink:#222; --line:#e2e2e4; --bg:#f4f4f5; --calc:#f7f8fa; --sale:#fff4ef; }
* { box-sizing:border-box; }
[hidden] { display:none !important; }
body { margin:0; font:14px/1.4 system-ui, -apple-system, "Segoe UI", sans-serif; color:var(--ink); background:var(--bg); }
button, .button { font:inherit; padding:7px 12px; border:1px solid #cfcfd3; border-radius:6px; background:#fff; color:var(--ink); cursor:pointer; text-decoration:none; display:inline-block; white-space:nowrap; }
button:hover, .button:hover { border-color:var(--grey); }
.primary { background:var(--orange); border-color:var(--orange); color:#fff; font-weight:600; }
.danger { color:#b42318; }
.link { border:0; background:none; color:var(--grey); }
:focus-visible { outline:2px solid var(--orange); outline-offset:1px; }
input, textarea { font:inherit; width:100%; padding:7px 8px; border:1px solid #cfcfd3; border-radius:6px; background:#fff; }
label { display:flex; flex-direction:column; gap:4px; font-size:12px; color:var(--grey); font-weight:600; }
label input, label textarea { font-size:14px; color:var(--ink); font-weight:400; }
.card { background:#fff; border:1px solid var(--line); border-radius:10px; padding:16px; margin-bottom:14px; }

.login { min-height:100vh; display:grid; place-items:center; padding:16px; }
.login form { width:min(320px, 100%); display:flex; flex-direction:column; gap:12px; }
.login img { width:180px; align-self:center; }
.login h1 { margin:0; text-align:center; font-size:20px; }
.error { color:#b42318; margin:0; min-height:1.4em; }

.top { display:flex; align-items:center; gap:16px; flex-wrap:wrap; padding:10px 20px; background:#fff; border-bottom:3px solid var(--orange); }
.top img { width:110px; }
.top nav { display:flex; gap:6px; margin-right:auto; flex-wrap:wrap; }
.top nav button.active { background:var(--grey); border-color:var(--grey); color:#fff; }
.badge { background:var(--orange); color:#fff; border-radius:10px; padding:0 7px; margin-left:4px; font-size:12px; }
main { padding:18px 20px 120px; max-width:1500px; margin:0 auto; }
#search { max-width:420px; margin-bottom:12px; }

.table-wrap { overflow-x:auto; padding:0; }
table { width:100%; border-collapse:collapse; }
th { text-align:left; font-size:12px; color:var(--grey); padding:10px 8px; border-bottom:2px solid var(--line); }
td { padding:8px; border-bottom:1px solid var(--line); vertical-align:middle; }
.num { text-align:right; white-space:nowrap; font-variant-numeric:tabular-nums; }
.actions { display:flex; gap:6px; justify-content:flex-end; flex-wrap:wrap; }
.empty { text-align:center; color:var(--grey); padding:30px; margin:0; }

.editor-title { display:flex; justify-content:space-between; align-items:center; gap:12px; flex-wrap:wrap; margin-bottom:12px; }
.editor-title h2 { margin:0; font-size:19px; }
.editor-title h2 span { color:var(--orange); font-size:15px; }
.grid { display:grid; grid-template-columns:repeat(auto-fill, minmax(210px, 1fr)); gap:12px; }
.wide { grid-column:span 2; }
.coef { border-left:4px solid var(--orange); }
.hint { margin:0; font-size:12px; color:var(--grey); grid-column:1 / -1; }
.lines { min-width:1250px; }
.lines th, .lines td { padding:4px; }
.lines td:not(.desc) input { width:78px; text-align:right; }
.lines td.ut input { width:48px; text-align:left; }
.lines .desc { width:30%; min-width:260px; }
.lines .calc { background:var(--calc); color:var(--grey); }
.lines .sale { background:var(--sale); font-weight:600; }
.lines tr.chapter td input { width:100%; text-align:left; font-weight:700; color:var(--orange); }
.tools { white-space:nowrap; text-align:right; }
.tools button { padding:4px 7px; margin-left:2px; }
.add { display:flex; gap:8px; padding:10px; }

.totals { position:fixed; left:0; right:0; bottom:0; display:flex; justify-content:flex-end; flex-wrap:wrap; gap:8px; padding:10px 20px; background:#fff; border-top:1px solid var(--line); box-shadow:0 -4px 14px #0000000d; }
.totals div { display:flex; flex-direction:column; align-items:flex-end; padding:4px 12px; border-radius:6px; min-width:105px; }
.totals span { font-size:11px; color:var(--grey); }
.totals strong { font-size:16px; font-variant-numeric:tabular-nums; }
.totals .calc { background:var(--calc); }
.totals .bad { background:#fde8e6; color:#b42318; }
.totals .total { background:var(--orange); color:#fff; }
.totals .total span { color:#fff; }

dialog { width:min(900px, 96vw); height:94vh; max-height:94vh; padding:0; border:0; border-radius:10px; }
dialog[open] { display:flex; flex-direction:column; }
dialog::backdrop { background:#0008; }
dialog header { display:flex; gap:10px; align-items:center; padding:10px 14px; border-bottom:1px solid var(--line); }
dialog header strong { margin-right:auto; }
iframe { flex:1; border:0; width:100%; }
#toast { position:fixed; top:14px; right:14px; z-index:10; background:#1d6f42; color:#fff; padding:10px 16px; border-radius:8px; }
#toast.error { background:#b42318; min-height:0; }
@media (max-width:640px) { .wide { grid-column:auto; } main { padding:12px 10px 200px; } .totals { padding:8px; gap:4px; } .totals div { min-width:90px; padding:2px 8px; } }
