@font-face { font-family: "Manrope"; src: url(/fonts/Manrope-Regular.ttf) format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(/fonts/Manrope-SemiBold.ttf) format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Manrope"; src: url(/fonts/Manrope-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url(/fonts/Unbounded-Bold.ttf) format("truetype"); font-weight: 700; font-display: swap; }
@font-face { font-family: "Unbounded"; src: url(/fonts/Unbounded-ExtraBold.ttf) format("truetype"); font-weight: 800; font-display: swap; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 400 var(--fs-body)/1.45 var(--font-body); }
h1, h2, h3 { font-family: var(--font-display); font-weight: 800; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: var(--fs-h2); } h3 { font-size: 15px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand-ink); }
.muted { color: var(--muted); } .small { font-size: var(--fs-small); } .cap { font-size: var(--fs-caption); }
.hidden { display: none !important; }
.row { display: flex; gap: var(--sp-3); align-items: center; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.stack { display: grid; gap: var(--sp-3); } .stack-lg { display: grid; gap: var(--sp-5); }
.right { margin-left: auto; }

/* Каркас */
.shell { min-height: 100dvh; display: grid; grid-template-rows: auto 1fr; }
.top { position: sticky; top: 0; z-index: 20; background: rgba(250,246,240,.92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.top-in { max-width: 1120px; margin: 0 auto; padding: 10px 16px; display: flex; align-items: center; gap: 16px; }
.brand-mark { display: flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 800; font-size: 14px; text-decoration: none; color: var(--text); min-width: 0; }
.brand-mark img { height: 30px; max-width: 110px; object-fit: contain; border-radius: 6px; }
.brand-mark .dot { width: 30px; height: 30px; border-radius: 9px; background: var(--brand); flex: none; }
.brand-mark span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 180px; }
.nav { display: flex; gap: 4px; margin-left: 8px; overflow-x: auto; scrollbar-width: none; }
.nav a { padding: 9px 14px; border-radius: var(--r-pill); text-decoration: none; color: var(--text-2); font-weight: 600; white-space: nowrap; }
.nav a:hover { background: var(--sunken); }
.nav a.on { background: var(--brand-soft); color: var(--brand-ink); }
.userbox { margin-left: auto; display: flex; align-items: center; gap: 8px; }
main { max-width: 1120px; width: 100%; margin: 0 auto; padding: 24px 16px 120px; }
@media (max-width: 720px) {
  .top-in { flex-wrap: wrap; gap: 8px; } .nav { order: 3; width: 100%; margin: 0; } .userbox .who { display: none; }
  main { padding: 16px 12px 120px; }
}

/* Элементы */
.btn { min-height: var(--tap); padding: 0 18px; border-radius: var(--r-pill); border: 1px solid var(--line-strong); background: var(--surface); font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; color: var(--text); }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); box-shadow: var(--shadow-cta); }
.btn.primary:hover { filter: brightness(.95); }
.btn.soft { background: var(--brand-soft); color: var(--brand-ink); border-color: transparent; }
.btn.danger { color: var(--danger); } .btn.sm { min-height: 36px; padding: 0 14px; font-size: var(--fs-small); }
.btn.icon { width: var(--tap); padding: 0; } .btn[disabled] { opacity: .5; cursor: not-allowed; box-shadow: none; }
.btn.lg { min-height: var(--cta-h); padding: 0 26px; font-size: var(--fs-lead); }
.card { background: var(--surface); border-radius: var(--r-card); padding: 20px; box-shadow: var(--shadow-card); border: 1px solid var(--line); }
.card.flat { box-shadow: none; }
.field { display: grid; gap: 6px; } .field > label, .lbl { font-size: var(--fs-caption); font-weight: 700; color: var(--muted); letter-spacing: .04em; text-transform: uppercase; }
.input, .select, .textarea { width: 100%; min-height: var(--field-h); padding: 0 16px; border-radius: var(--r-field); border: 1px solid var(--line-strong); background: var(--surface); }
.textarea { padding: 12px 16px; min-height: 96px; resize: vertical; }
.input:focus, .select:focus, .textarea:focus { outline: 3px solid var(--brand-soft); border-color: var(--brand); }
.input.sm { min-height: 40px; border-radius: 12px; padding: 0 12px; }
.input.num { text-align: right; font-variant-numeric: tabular-nums; }
.input[readonly], .input:disabled { background: var(--bg); color: var(--muted); }
.check { display: flex; gap: 10px; align-items: center; min-height: 40px; }
.check input { width: 20px; height: 20px; accent-color: var(--brand); }
.err { color: var(--danger); font-size: var(--fs-small); font-weight: 600; }
.grid2, .grid3 { align-items: start; }
.grid2 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; } .grid3 { display: grid; gap: 12px; grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: var(--r-chip); background: var(--sunken); font-size: var(--fs-caption); font-weight: 700; color: var(--text-2); white-space: nowrap; }
.chip.draft { background: var(--sunken); } .chip.sent { background: var(--brand-soft); color: var(--brand-ink); }
.chip.accepted { background: #DDF3E6; color: var(--success); } .chip.rejected { background: #FBE3E0; color: var(--danger); }
.seg { display: inline-flex; background: var(--sunken); padding: 4px; border-radius: var(--r-pill); gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { border: 0; background: transparent; padding: 8px 16px; border-radius: var(--r-pill); font-weight: 700; color: var(--text-2); cursor: pointer; white-space: nowrap; min-height: 38px; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: 0 2px 8px rgba(27,22,18,.08); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.empty h3 { color: var(--text); margin-bottom: 6px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: var(--fs-caption); color: var(--muted); text-transform: uppercase; letter-spacing: .04em; padding: 8px 12px; }
.table td { padding: 12px; border-top: 1px solid var(--line); vertical-align: middle; }
.scroll-x { overflow-x: auto; }
.list-row { display: flex; gap: 14px; align-items: center; padding: 16px 18px; background: var(--surface); border-radius: var(--r-row); border: 1px solid var(--line); text-decoration: none; color: inherit; }
.list-row:hover { box-shadow: var(--shadow-card); }
.money { font-family: var(--font-display); font-weight: 800; white-space: nowrap; font-variant-numeric: tabular-nums; }
.num-sm { font-variant-numeric: tabular-nums; white-space: nowrap; }

/* Вход */
.auth { min-height: 100dvh; display: grid; place-items: center; padding: 20px; }
.auth .card { width: min(440px, 100%); padding: 28px; }
.auth h1 { margin-bottom: 6px; }

/* Окна и уведомления */
.overlay { position: fixed; inset: 0; background: rgba(27,22,18,.45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal { background: var(--surface); border-radius: var(--r-card); padding: 24px; width: min(520px, 100%); max-height: 90dvh; overflow: auto; }
.modal.wide { width: min(720px, 100%); }
.modal h2 { margin-bottom: 14px; }
.toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: 104px; z-index: 60; display: grid; gap: 8px; width: min(420px, calc(100% - 24px)); }
.toast { background: var(--text); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; box-shadow: var(--shadow-bar); }
.toast.bad { background: var(--danger); }

/* Конструктор */
.ed-head { display: grid; gap: 12px; margin-bottom: 16px; }
.savestate { font-size: var(--fs-caption); font-weight: 700; color: var(--muted); }
.savestate.err { color: var(--danger); }
.banner { background: #FFF4D6; color: #6B4A00; border-radius: var(--r-row); padding: 12px 16px; font-weight: 600; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.sect { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-card); overflow: hidden; }
.sect-h { display: flex; align-items: center; gap: 10px; padding: 10px 14px; background: var(--brand-faint); border-bottom: 1px solid var(--line); }
.sect-h .input { font-weight: 700; background: transparent; border-color: transparent; padding: 0 8px; }
.sect-h .input:hover, .sect-h .input:focus { background: var(--surface); }
.item { display: grid; grid-template-columns: minmax(0, 1fr) 70px 64px 110px 120px 40px; gap: 8px; align-items: center; padding: 10px 14px; border-top: 1px solid var(--line); }
.item .name { font-weight: 600; min-width: 0; display: flex; gap: 8px; align-items: center; } .item .name > div { flex: 1; min-width: 0; } .item .name .note { display: block; font-weight: 400; color: var(--muted); font-size: var(--fs-small); }
.item .sum { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.item-lbl { display: none; }
@media (max-width: 720px) {
  .item { grid-template-columns: 1fr 1fr 1fr; gap: 8px 10px; }
  .item .name { grid-column: 1 / -1; }
  .item .sum { grid-column: 1 / 3; text-align: left; font-size: var(--fs-lead); align-self: center; }
  .item .del { grid-column: 3; justify-self: end; }
  .item-lbl { display: block; font-size: 11px; color: var(--muted); font-weight: 700; margin-bottom: 2px; }
  .item .unit { display: grid; } .item .cell { display: grid; }
}
.item .unit { color: var(--muted); }
.adder { padding: 12px 14px; border-top: 1px solid var(--line); position: relative; }
.results { position: absolute; left: 14px; right: 14px; top: calc(100% - 6px); z-index: 15; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 16px; box-shadow: var(--shadow-bar); max-height: 320px; overflow: auto; }
.results button { display: flex; width: 100%; text-align: left; gap: 10px; padding: 12px 14px; border: 0; background: transparent; cursor: pointer; align-items: center; border-bottom: 1px solid var(--line); min-height: var(--tap); }
.results button:hover, .results button.act { background: var(--brand-faint); }
.results .cat { color: var(--muted); font-size: var(--fs-caption); }
.totalbar { position: sticky; bottom: 0; z-index: 15; margin-top: 20px; background: var(--text); color: #fff; border-radius: var(--r-card); padding: 14px 20px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; box-shadow: var(--shadow-bar); }
.totalbar .money { font-size: var(--fs-total); }
.totalbar small { color: rgba(255,255,255,.7); display: block; }
.disc { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.disc .input { width: 110px; }
.badge-lock { font-size: var(--fs-caption); color: var(--muted); }
.stat { display: grid; gap: 2px; } .stat b { font-family: var(--font-display); font-size: 22px; }
.swatch { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--line-strong); padding: 0; background: none; cursor: pointer; }
.preview { border-radius: var(--r-card); overflow: hidden; border: 1px solid var(--line); }
.preview .ph { padding: 18px; font-family: var(--font-display); font-weight: 800; }
.logo-box { width: 140px; height: 70px; border: 1px dashed var(--line-strong); border-radius: 14px; display: grid; place-items: center; background: var(--surface); overflow: hidden; }
.logo-box img { max-width: 100%; max-height: 100%; }
:where(button, a, input, select, textarea):focus-visible { outline: 3px solid var(--brand); outline-offset: 2px; }
.input:focus, .select:focus, .textarea:focus { outline-offset: 0; }

/* Импорт */
.dropzone { border: 2px dashed var(--line-strong); border-radius: var(--r-card); padding: 32px 16px; display: grid; gap: 6px; text-align: center; cursor: pointer; background: var(--brand-faint); }
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: var(--brand-soft); }
.preview-table table { font-size: 13px; }
.preview-table th, .preview-table td { padding: 6px 10px; white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; }
.preview-table td.mapped, .preview-table th.mapped { background: var(--brand-faint); }
.preview-table th.mapped { color: var(--brand-ink); }
.preview-table tr.hdr td { font-weight: 700; color: var(--muted); }
