@font-face {
  font-family: Manrope;
  src: url("/manrope.ttf") format("truetype");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  color-scheme: light;
  --canvas: #f6f7fb;
  --surface: #fff;
  --ink: #171729;
  --muted: #595d73;
  --line: #e3e5ef;
  --accent: #4c39d9;
  --accent-hover: #3c2bbb;
  --accent-soft: #eeecff;
  --error: #a3253c;
  --focus: #6957ea;
  --shadow: 0 1px 2px #1f214009, 0 8px 24px #26264a05;
  --type: Manrope, "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; background: var(--canvas); color: var(--ink); font: 15px/1.55 var(--type); }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { overflow-wrap: anywhere; }
h1 { font-size: clamp(29px, 4vw, 43px); font-weight: 800; line-height: 1.12; letter-spacing: -.055em; }
h2 { font-size: 20px; font-weight: 800; line-height: 1.25; letter-spacing: -.035em; }
h3 { font-size: 17px; font-weight: 800; line-height: 1.35; letter-spacing: -.018em; }
a { color: inherit; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
button:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: 3px solid #6957ea26; }
input, select, textarea {
  width: 100%; min-width: 0; min-height: 46px; padding: 10px 12px;
  border: 1px solid #d7d9e7; border-radius: 10px; background: var(--surface); color: var(--ink);
}
input::placeholder, textarea::placeholder { color: #676b80; opacity: 1; }
textarea { resize: vertical; }
label { display: grid; gap: 6px; font-size: 13px; font-weight: 750; }
label input, label select, label textarea { font-size: 15px; font-weight: 550; }
small, .muted { color: var(--muted); }
.money { font-variant-numeric: tabular-nums; white-space: nowrap; font-weight: 800; }

.primary, .secondary, .quiet, .exit, .close, .danger {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 9px 14px; border: 1px solid transparent; border-radius: 10px;
  font-size: 13px; font-weight: 800; text-align: center; text-decoration: none; line-height: 1.3;
}
.primary { min-height: 46px; padding-inline: 16px; background: var(--accent); color: white; }
.primary:hover:not(:disabled) { background: var(--accent-hover); }
.secondary, .close { background: var(--surface); border-color: var(--line); color: var(--ink); }
.secondary:hover, .close:hover, .quiet:hover { background: var(--accent-soft); color: var(--accent-hover); }
.quiet { background: transparent; color: var(--accent-hover); }
.danger { background: #fcecf0; color: var(--error); }
.danger:hover { background: #f7dfe7; }
.form-error { padding: 10px 12px; border-radius: 9px; color: var(--error); background: #fcecf0; font-size: 13px; font-weight: 650; }
svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; }

.app { display: grid; grid-template-columns: 208px minmax(0, 1fr); }
.topbar { position: sticky; top: 0; z-index: 5; height: 100dvh; background: var(--surface); border-right: 1px solid var(--line); }
.top-inner { display: flex; flex-direction: column; gap: 33px; height: 100%; padding: 29px 15px 16px; }
.app-mark { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; background: var(--accent); color: #fff; text-decoration: none; }
.app-mark svg { width: 25px; height: 25px; }
.top-inner > .app-mark { margin-left: 9px; }
nav { display: grid; gap: 5px; }
nav a, .exit { display: flex; align-items: center; justify-content: flex-start; gap: 11px; min-height: 47px; padding: 9px 11px; border-radius: 10px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 750; white-space: nowrap; }
nav a:hover, .exit:hover { background: #f1f2f8; color: var(--ink); }
nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-hover); }
nav a[aria-current="page"] svg { stroke-width: 2; }
nav [data-nav="settings"] circle { fill: var(--surface); }
nav [data-nav="settings"][aria-current] circle { fill: var(--accent-soft); }
.exit { margin-top: auto; border: 0; background: transparent; }
.workspace { width: min(100% - 64px, 1180px); margin: 0 auto; padding: 40px 0 64px; }
.page-heading, .section-head, .row, .dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading { min-height: 56px; margin-bottom: 22px; }
.page-meta { margin-top: 7px; color: var(--muted); font-weight: 650; overflow-wrap: anywhere; }
.page-heading > :is(button, a) { flex: 0 0 auto; }
.panel { min-width: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); box-shadow: var(--shadow); overflow: hidden; }
.block { margin-top: 16px; }
.section-head { padding: 18px 22px; }
.section-head p { margin-top: 3px; color: var(--muted); }
.count { min-width: 28px; padding: 3px 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent-hover); text-align: center; font-size: 12px; font-weight: 800; }
.calc-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(225px, 285px); gap: 18px; align-items: start; }
.material-row {
  display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(66px, .6fr) minmax(80px, .55fr);
  align-items: center; gap: 10px; min-height: 67px; padding: 10px 22px; border-top: 1px solid var(--line);
}
.material-row:focus-within { background: #f8f7ff; }
.material-row.table-label { min-height: auto; background: #f6f7fc; color: var(--muted); font-size: 12px; font-weight: 800; }
.material-name, .entry-title { font-size: 16px; font-weight: 800; overflow-wrap: anywhere; }
.material-row small { display: block; font-weight: 650; }
.material-row input { padding-inline: 9px; max-width: 104px; text-align: end; font-variant-numeric: tabular-nums; }
.summary { position: sticky; top: 22px; padding: 22px; border-radius: 17px; background: #21213c; color: #fff; box-shadow: 0 10px 26px #21213c22; }
.summary h2 { color: #d8d9ef; font-size: 14px; font-weight: 750; letter-spacing: 0; }
.summary .total { margin: 6px 0 5px; font-size: clamp(26px, 3.3vw, 40px); line-height: 1.17; letter-spacing: -.045em; }
.summary .muted { color: #c9cce5; font-size: 13px; }
.summary button { width: 100%; margin-top: 21px; justify-content: space-between; background: #e9e5ff; color: #30239b; }
.summary button:hover:not(:disabled) { background: #fff; }
.summary .form-error { margin-top: 12px; }

.tabs { display: flex; gap: 4px; width: fit-content; padding: 4px; border: 1px solid var(--line); border-radius: 11px; background: #eeeef6; }
.tabs a { display: grid; place-items: center; min-height: 36px; padding: 5px 14px; border-radius: 8px; color: var(--muted); font-size: 13px; font-weight: 800; text-decoration: none; }
.tabs a[aria-current] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px #24244912; }
.filters { display: grid; gap: 11px; grid-template-columns: 1.5fr 1fr 1fr; align-items: end; padding: 17px 22px; border-bottom: 1px solid var(--line); }
.filter-dates { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 11px; grid-column: 1 / -1; max-width: 360px; }
.filters .filter-actions { display: flex; flex-wrap: wrap; gap: 5px; grid-column: 1 / -1; }
.entries { margin: 0; padding: 0; list-style: none; }
.entry, .detail-line { padding: 14px 22px; border-top: 1px solid var(--line); }
.entry:first-child { border-top: 0; }
.entry-meta { margin-top: 2px; color: var(--muted); font-size: 13px; overflow-wrap: anywhere; }
.entry-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 5px; }
.entry-actions .quiet { min-height: 39px; padding: 6px 10px; }
.entry-actions .remove { color: var(--muted); }
.entry-actions .remove:hover { color: var(--error); background: #fcecf0; }
.detail-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 10px; }
.detail-foot { padding: 15px 22px; border-top: 1px solid var(--line); background: #f6f5ff; }
.comment { margin-top: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.blank, .loading { padding: 23px 22px; color: var(--muted); }
.archive { margin-top: 16px; }
.archive > summary { width: fit-content; padding: 7px 0; color: var(--muted); cursor: pointer; font-weight: 750; }
.catalog-list { display: grid; gap: 9px; padding: 0 14px 14px; }
.archive .catalog-list { padding-top: 14px; }
.catalog-card { min-width: 0; padding: 14px 15px 7px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.catalog-card .entry-actions .secondary { min-height: 38px; }
.material-history { margin-top: 10px; padding-top: 3px; border-top: 1px solid #eeeff6; font-size: 12px; }
.material-history > summary { width: fit-content; min-height: 33px; padding: 7px 0; cursor: pointer; color: var(--accent-hover); font-weight: 750; }
.material-history ul { list-style: none; margin: 0 0 5px; padding: 0; }
.material-history li { color: var(--muted); padding-block: 4px; }
.material-history time { margin-right: 9px; font-variant-numeric: tabular-nums; }

dialog { width: min(590px, 100% - 24px); max-height: calc(100% - 24px); padding: 0; border: 1px solid var(--line); border-radius: 17px; background: var(--surface); color: var(--ink); box-shadow: 0 25px 80px #17172f4d; }
dialog::backdrop { background: #1b1a37a6; }
.dialog-head { position: sticky; top: 0; z-index: 2; padding: 14px 21px; border-bottom: 1px solid var(--line); background: var(--surface); }
.close { min-width: 42px; padding: 4px; font-size: 23px; font-weight: 650; }
.dialog-body { padding: 17px 21px 21px; display: grid; gap: 14px; }
.dialog-actions { flex-wrap: wrap; justify-content: flex-end; padding-top: 2px; }
.quote-lines { list-style: none; padding: 0; margin: 0 0 6px; }
.quote-lines li { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; }
.quote-total { background: var(--accent-soft); padding: 11px 13px; border-radius: 9px; }
.fields-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.suggestions { margin: 0; padding: 5px; list-style: none; border: 1px solid var(--line); border-radius: 9px; background: #f7f6ff; max-height: 170px; overflow: auto; }
.suggestions button { width: 100%; text-align: left; background: transparent; border: 0; color: var(--ink); border-radius: 6px; padding: 6px 8px; }
.suggestions button:hover, .suggestions button:focus-visible { background: var(--accent-soft); }
.picked { border-radius: 9px; padding: 6px 12px; background: var(--accent-soft); color: var(--accent-hover); font-size: 13px; }
.phone-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; margin-bottom: 8px; }
.edit-line { display: grid; grid-template-columns: minmax(0, 1fr) 78px auto; align-items: center; gap: 7px; border-top: 1px solid var(--line); padding: 8px 0; }
.toast { position: fixed; z-index: 6; right: 18px; bottom: 18px; padding: 12px 16px; border-radius: 10px; color: #fff; background: #21213c; box-shadow: 0 5px 20px #25254530; font-size: 13px; }

.login-area { display: grid; min-height: 100svh; place-items: center; padding: 20px; background: radial-gradient(ellipse at 50% 37%, #edeaff, transparent 65%), var(--canvas); }
.login-card { width: min(100%, 390px); padding: clamp(22px, 6vw, 34px); border: 1px solid var(--line); border-radius: 21px; background: var(--surface); box-shadow: 0 16px 52px #30276312; }
.login-card .app-mark { margin-bottom: 17px; }
.login-card h1 { font-size: 36px; }
.login-card form { display: grid; gap: 14px; margin-top: 22px; }
.login-card .primary { min-height: 48px; margin-top: 4px; }

@media (max-width: 1140px) {
  .app { grid-template-columns: 168px minmax(0, 1fr); }
  .workspace { width: calc(100% - 44px); }
}
@media (max-width: 850px) {
  .app { display: block; }
  .topbar { height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .top-inner { flex-direction: row; align-items: center; height: auto; min-height: 62px; padding: 7px 15px; gap: 9px; }
  .top-inner > .app-mark { margin-left: 0; width: 35px; height: 35px; border-radius: 9px; }
  .top-inner > .app-mark svg { width: 21px; height: 21px; }
  nav { display: flex; margin: 0 auto 0 0; gap: 2px; }
  nav a, .exit { min-height: 42px; gap: 6px; padding-inline: 8px; font-size: 13px; }
  nav a svg, .exit svg { width: 17px; height: 17px; }
  .exit { margin-top: 0; }
  .workspace { width: calc(100% - 36px); padding-top: 24px; }
  .summary { top: 80px; }
}
@media (max-width: 650px) {
  .top-inner { min-height: 57px; padding-inline: 7px; gap: 3px; }
  .top-inner > .app-mark { display: none; }
  nav a, .exit { padding-inline: 7px; }
  nav a svg { display: none; }
  .workspace { width: calc(100% - 26px); padding-top: 20px; }
  .page-heading { min-height: 0; margin-bottom: 15px; flex-wrap: wrap; }
  .page-heading > :is(button, a) { flex: 0 1 auto; }
  .calc-layout { display: block; padding-bottom: 77px; }
  .summary {
    position: fixed; z-index: 4; top: auto; right: 0; bottom: 0; left: 0;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
    padding: 10px 14px max(10px, env(safe-area-inset-bottom)); border-radius: 13px 13px 0 0;
  }
  .summary h2 { font-size: 12px; grid-column: 1; }
  .summary .total { margin: 0; font-size: clamp(19px, 5vw, 28px); grid-area: 2 / 1; }
  .summary .muted { display: none; }
  .summary button { width: auto; margin: 0; grid-area: 1 / 2 / 3 / 3; }
  .summary .form-error { grid-column: 1 / -1; margin-top: 2px; }
  .section-head, .entry, .detail-line, .detail-foot, .filters { padding: 12px 13px; }
  .material-row { grid-template-columns: minmax(0, 1.3fr) minmax(57px, .6fr) 73px; padding-inline: 12px; gap: 7px; }
  .material-name { font-size: 14px; }
  .material-row .money { font-size: 13px; }
  .catalog-list { padding-inline: 9px; }
  .catalog-card { padding-inline: 11px; }
  .filters { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filters > label:first-child { grid-column: 1 / -1; }
  .row.adapt { flex-wrap: wrap; align-items: flex-start; }
  .entry-actions { justify-content: flex-start; }
  .dialog-head, .dialog-body { padding: 12px; }
  .toast { bottom: 80px; }
}
@media (max-width: 385px) {
  .fields-2 { grid-template-columns: 1fr; }
  .exit svg { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  :is(button, nav a, .tabs a, input) { transition: background-color .14s ease, color .14s ease, border-color .14s ease; }
}
