body { min-height: 100vh; background: #f4f7fb; }

.preview-bar { background: #e9eff7; border-bottom: 1px solid #d5dfee; }
.preview-inner { display: flex; align-items: center; gap: 12px; min-height: 38px; padding-block: 5px; }
.preview-title { color: var(--brand-ink); font-size: .88rem; font-weight: 720; }
.preview-tools { display: flex; flex-wrap: wrap; gap: 2px 12px; margin-left: auto; color: var(--brand-muted); font-size: .8rem; }
.preview-tools a { font-weight: 670; }

.account-main { padding-block: 19px 48px; }
.crumbs { display: flex; align-items: center; gap: 7px; color: var(--brand-muted); font-size: .81rem; }
.crumbs .icon { width: 12px; height: 12px; color: #6c809c; }
.page-intro { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin: 18px 0 23px; }
.page-intro form { margin-top: 5px; }
.account-logout { min-width: 104px; min-height: 42px; padding-inline: 16px; font-size: .9rem; }
.page-intro h1 { font-size: clamp(1.68rem, 4vw, 2.35rem); letter-spacing: -.04em; line-height: 1.13; }
.page-intro p { margin-top: 7px; color: var(--brand-muted); }
.page-intro p span[data-legal-only] { margin-inline: 3px; }
.text-button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 3px 0; border: 0; background: transparent; color: var(--brand-blue);
  font-size: .875rem; font-weight: 680; line-height: 1.35; text-align: left;
}
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.dashboard {
  display: grid; gap: 15px; align-items: start; align-content: start;
  grid-template-columns: minmax(0, 1fr) minmax(245px, 295px);
  grid-template-rows: auto auto auto auto 1fr;
  grid-template-areas: "menu menu" "finance manager" "orders company" "orders garage" "orders offers-summary";
}
.dashboard:not([data-view="overview"]) { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto; grid-template-areas: "menu" "content"; }
.account-menu {
  grid-area: menu; display: flex; flex-wrap: wrap; gap: 4px; min-width: 0; padding: 7px;
}
.account-menu a {
  display: flex; align-items: center; gap: 9px; min-height: 42px; padding: 8px 9px;
  border-radius: 7px; color: #344968; font-size: .9rem; font-weight: 650; white-space: nowrap;
}
.account-menu a .icon { color: #4b6b93; }
.account-menu a:hover { background: #f0f5fc; text-decoration: none; }
.account-menu a[aria-current] { color: #064895; background: #e9f2ff; }
.account-menu a[aria-current] .icon { color: #064895; }
.panel, .account-menu {
  min-width: 0; border: 1px solid var(--brand-line); border-radius: 11px; background: #fff;
  box-shadow: 0 1px 2px #12356306;
}
.panel { padding: 17px 18px; }
.buyer-login { width: min(100%, 490px); margin: 25px auto; }
.buyer-login h1 { font-size: clamp(1.35rem, 4vw, 1.8rem); }
.buyer-login p { margin: 6px 0 16px; color: var(--brand-muted); }
.login-credentials { display: grid; gap: 13px; margin-top: 19px; }
.login-field { display: grid; gap: 5px; }
.login-field label, .login-test h2 { font-size: .92rem; font-weight: 680; }
.login-field input { width: 100%; min-height: 42px; padding: 8px 11px; border: 1px solid #c8d7e8; border-radius: 7px; color: var(--brand-ink); background: #fff; }
.login-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.login-actions .button { min-height: 36px; }
.login-recovery { justify-self: start; color: var(--brand-blue); text-decoration: underline; }
.buyer-login .login-credentials + .login-actions { margin-top: 13px; }
.login-credentials .errorlist { color: #a51a33; font-size: .88rem; }
.login-test { margin-top: 18px; padding-top: 13px; border-top: 1px solid #e2eaf3; }
.login-test h2 { margin-bottom: 9px; color: var(--brand-muted); }
.panel-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 6px 12px; margin-bottom: 12px; }
.panel-heading h2 { display: flex; align-items: center; gap: 8px; font-size: 1.08rem; line-height: 1.2; letter-spacing: -.018em; }
.panel-heading h2 .icon { font-size: .93rem; color: var(--brand-blue); }

.finance {
  grid-area: finance; align-self: stretch; position: relative; isolation: isolate; overflow: hidden;
  padding: 19px 22px 21px; border-color: #0d345f; color: #fff; background: linear-gradient(115deg, #081e37, #0d345f);
}
.finance::before {
  content: ""; position: absolute; z-index: -1; inset: 0;
  background: linear-gradient(125deg, #0a61ad, #064583); clip-path: polygon(84% 0, 100% 0, 100% 100%, 69% 100%);
}
.finance :is(dt, .text-button, .panel-heading .icon) { color: #e1efff; }
.finance :focus-visible { outline-color: #fff; }
.finance-heading { margin-bottom: 16px; }
.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 15px; margin: 0; }
.metrics:has(> [hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.metrics > div + div { padding-left: 16px; border-left: 1px solid #91b8e455; }
.metrics dt { font-size: .875rem; }
.metrics dd { margin: 4px 0 0; font-size: clamp(1.3rem, 3vw, 1.8rem); font-weight: 760; letter-spacing: -.042em; font-variant-numeric: tabular-nums; white-space: nowrap; }
.metrics dd small { font-size: .62em; font-weight: 660; letter-spacing: 0; }
.metrics .has-debt { color: #ffbac5; }

.orders { grid-area: orders; }
.dashboard[data-view="orders"] .orders { grid-area: content; }
.orders, .ledger-register { padding: 0; }
.order-heading { margin: 0; padding: 17px 18px 14px; }
.dashboard[data-view="orders"] .order-heading h2 { font-size: clamp(1.35rem, 4vw, 1.65rem); }
.order-footer { display: grid; justify-items: center; gap: 8px; padding: 13px 18px 16px; border-top: 1px solid #e2eaf3; }
.order-footer p { color: var(--brand-muted); font-size: .85rem; }
.order-footer .button { min-height: 36px; }
.order-table { width: 100%; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.order-table th { color: var(--brand-muted); background: #f0f5fb; font-weight: 630; text-align: left; }
.order-table :is(th, td) { padding: 10px 9px; border-top: 1px solid #e2eaf3; }
.order-table :is(th, td):first-child { padding-left: 18px; }
.order-table :is(th, td):last-child { padding-right: 18px; text-align: right; white-space: nowrap; }
.order-table td:last-child { font-weight: 680; }
.order-table tr:focus-within td, .order-table tbody tr:hover td { background: #f8fbff; }
.order-table td time { white-space: nowrap; color: var(--brand-muted); }
.order-mobile-date { display: none; }
.order-number { display: grid; justify-items: start; gap: 1px; padding: 0; }
.order-number span { color: var(--brand-muted); font-size: .77rem; font-weight: 500; }
.status {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%; padding: 3px 8px; border-radius: 5px;
  color: #20558a; background: #eaf3ff; font-size: .82rem; font-weight: 650;
}
.status::before { content: ""; width: 5px; height: 5px; flex: none; border-radius: 50%; background: currentColor; }
.status-ready { color: #81540d; background: #fff4db; }
.status-done, .status-paid, .status-received { color: #196147; background: #e8f5ed; }
.status-cancelled { color: #56627a; background: #edf0f5; }

.company { grid-area: company; }
.company-name { display: block; font-size: 1rem; }
.company-fields { display: grid; gap: 6px; margin: 8px 0; font-size: .875rem; }
.company-fields div { display: flex; justify-content: space-between; gap: 7px; }
.company-fields dt { color: var(--brand-muted); }
.company-fields dd { margin: 0; font-weight: 630; text-align: end; font-variant-numeric: tabular-nums; }
.company-detail { margin-top: 3px; }

.garage { grid-area: garage; }
.quiet-count { display: grid; place-items: center; min-width: 20px; height: 20px; border-radius: 5px; color: #225b96; background: #e9f2fc; font-size: .75rem; }
.vehicle-card {
  position: relative; isolation: isolate; overflow: hidden; display: flex; align-items: center;
  width: 100%; min-height: 91px; padding: 10px; border: 0; border-radius: 7px;
  color: #fff; background: linear-gradient(110deg, #0a223e, #143c67); text-align: left;
}
.vehicle-card:hover { background: linear-gradient(110deg, #0b3058, #184575); text-decoration: none; }
.vehicle-copy { display: grid; gap: 3px; overflow-wrap: anywhere; }
.vehicle-with-photo .vehicle-copy { max-width: 58%; }
.vehicle-copy strong { font-size: .97rem; }
.vehicle-copy span { color: #dfebfa; font-size: .81rem; }
.vehicle-card img { position: absolute; z-index: -1; inset: auto 0 0 auto; width: 53%; height: 100%; object-fit: cover; object-position: right; mask-image: linear-gradient(to right, transparent, #000 24%); }

.manager { grid-area: manager; align-self: stretch; }
.manager-profile { display: flex; align-items: center; gap: 11px; margin-bottom: 7px; }
.manager-profile div { display: grid; gap: 2px; }
.manager-profile strong { font-size: .96rem; }
.manager-profile div span { color: var(--brand-muted); font-size: .82rem; }
.avatar { display: grid; flex: none; place-items: center; width: 43px; height: 43px; border-radius: 50%; color: #124f8b; background: #e8f1fc; font-size: .88rem; font-weight: 760; }
.manager-contact { margin-left: 54px; }

.offers-summary { grid-area: offers-summary; align-self: end; }
.offer-list { display: grid; }
.offer-list li + li { margin-top: 10px; padding-top: 10px; border-top: 1px solid #e3ebf5; }
.offer-list button { display: grid; gap: 2px; padding: 0; border: 0; background: transparent; color: var(--brand-ink); text-align: left; }
.offer-list button:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.offer-list span { color: var(--brand-muted); font-size: .78rem; }
.offer-list strong { font-size: .87rem; font-weight: 660; }

.tab-content { grid-area: content; display: grid; gap: 15px; min-width: 0; }
.section-heading-inline { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 11px 20px; }
.section-heading-inline h2 { font-size: clamp(1.35rem, 4vw, 1.75rem); line-height: 1.15; letter-spacing: -.028em; }
.account-button { background: var(--brand-blue); min-height: 39px; }

.ledger-intro { padding: 19px 21px; background: linear-gradient(115deg, #fff 58%, #e9f3ff); }
.ledger-intro p { margin-top: 6px; color: var(--brand-muted); font-size: .94rem; font-weight: 600; }
.ledger-source { display: inline-flex; align-items: center; gap: 6px; color: var(--brand-muted); font-size: .82rem; font-weight: 620; }
.ledger-source .icon { color: var(--brand-blue); }
.ledger-company { display: grid; grid-template-columns: 1.05fr 1.2fr .8fr; gap: 16px; margin-top: 14px; padding-top: 13px; border-top: 1px solid #dce6f1; }
.ledger-company section { min-width: 0; }
.ledger-company section + section { border-left: 1px solid #dce6f1; padding-left: 14px; }
.ledger-company h3 { font-size: .93rem; }
.ledger-company .company-fields { margin-bottom: 0; }
.ledger-company .company-fields dt { flex: none; max-width: 49%; }
.ledger-company .company-fields dd { overflow-wrap: anywhere; }
.ledger-types { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 12px; }
.ledger-type {
  display: flex; align-items: center; gap: 10px; padding: 11px 13px; min-height: 62px;
  color: var(--brand-ink); font-size: .94rem; font-weight: 680;
}
.ledger-type:hover { border-color: #92b5db; background: #f7fbff; text-decoration: none; }
.ledger-type[aria-current] { border-color: #5388c3; background: #eff6ff; color: var(--brand-blue); }
.ledger-type-icon {
  display: grid; place-items: center; flex: none; width: 35px; height: 35px; border-radius: 7px;
  color: var(--brand-blue); background: #e9f2fc;
}
.ledger-type[aria-current] .ledger-type-icon { color: #fff; background: var(--brand-blue); }
.ledger-type .quiet-count { margin-left: auto; }
.register-sum { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 9px; font-size: .85rem; color: var(--brand-muted); }
.register-sum strong { color: var(--brand-ink); font-size: 1rem; font-variant-numeric: tabular-nums; }
.ledger-table .order-number span { font-size: .82rem; }
.ledger-table .status { white-space: nowrap; }
.ledger-table tr:last-child td:first-child { border-bottom-left-radius: 11px; }
.ledger-table tr:last-child td:last-child { border-bottom-right-radius: 11px; }
.status-due { color: #805411; background: #fff2d9; }
.ledger-empty { color: var(--brand-muted); font-size: .875rem; padding: 14px 18px; border-top: 1px solid #e2eaf3; }

.vehicle-list, .offer-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px; }
.garage-vehicle { display: grid; grid-template-rows: auto 1fr auto; row-gap: 11px; }
.vehicle-heading { display: flex; align-items: center; gap: 10px; }
.vehicle-heading h3 { font-size: 1.06rem; overflow-wrap: anywhere; }
.garage-vehicle-icon { display: grid; place-items: center; flex: none; width: 38px; height: 38px; border-radius: 8px; color: var(--brand-blue); background: #e9f2fc; }
.garage-vehicle .company-fields { align-self: start; margin: 0; padding-block: 10px 1px; border-top: 1px solid #e3ebf5; }
.garage-vehicle .company-fields dt { flex: none; }
.garage-vehicle .company-fields dd { overflow-wrap: anywhere; }
.garage-vehicle .text-button, .offer-card .text-button { justify-self: start; }
.offer-card { display: grid; gap: 8px; }
.offer-card h3 { font-size: 1.12rem; line-height: 1.25; }
.offer-card p { color: var(--brand-muted); font-size: .9rem; }
.offer-date { color: var(--brand-blue); font-size: .81rem; font-weight: 650; }

.detail-dialog { width: min(530px, calc(100% - 28px)); padding: 0; border: 1px solid #ccdbed; border-radius: 12px; color: var(--brand-ink); box-shadow: 0 18px 64px #081e373b; }
.detail-dialog::backdrop { background: #071b385c; }
.dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 19px; border-bottom: 1px solid #e3ebf5; }
.dialog-heading h2 { font-size: 1.25rem; letter-spacing: -.02em; }
.dialog-heading h2:focus { outline: none; }
.detail-heading-title { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 12px; min-width: 0; }
.dialog-close { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 6px; color: var(--brand-blue); background: #eaf2fc; }
.detail-actions { display: flex; flex: none; align-items: center; gap: 8px; }
.detail-actions .dialog-close, .detail-actions .detail-download { min-height: 36px; }
.detail-actions .dialog-close { width: 36px; }
.detail-download { padding-inline: 12px; white-space: nowrap; }
.dialog-body { display: grid; gap: 12px; padding: 17px 19px 21px; }
.dialog-body .status { justify-self: start; }
.dialog-body .company-fields { margin: 0; }
.dialog-body > .company-fields div + div { padding-top: 6px; border-top: 1px solid #e3ebf5; }

.detail-dialog:has(.document-items) { width: min(890px, calc(100% - 28px)); max-height: calc(100dvh - 28px); }
.detail-dialog:has(.document-items) .dialog-heading { position: sticky; top: 0; z-index: 1; background: #fff; }
.detail-dialog:has(.document-items) .dialog-heading h2 { font-size: clamp(1.2rem, 4vw, 1.5rem); }
.document-meta {
  display: flex; align-items: start; justify-content: space-between; flex-wrap: wrap; gap: 10px 20px;
  padding: 12px 13px; border: 1px solid #e0e9f5; border-radius: 8px; background: #f6f9fd;
}
.document-meta .company-fields { display: flex; flex-wrap: wrap; gap: 9px 22px; }
.document-meta .company-fields div { display: grid; gap: 3px; justify-content: start; }
.document-meta .company-fields dd { text-align: start; }
.document-meta .order-number { font-size: inherit; }

.document-items { display: grid; gap: 11px; min-width: 0; }
.document-items h3 { font-size: 1.04rem; }
.document-table-frame { overflow: hidden; border: 1px solid #dce6f2; border-radius: 8px; }
.document-table { width: 100%; table-layout: fixed; border-collapse: collapse; font-size: .875rem; font-variant-numeric: tabular-nums; }
.document-brand-col, .document-article-col { width: 16%; }
.document-quantity-col { width: 15%; }
.document-amount-col { width: 19%; }
.document-table :is(th, td) { padding: 10px clamp(8px, 1.3vw, 12px); vertical-align: middle; text-align: start; }
.document-table thead th { color: var(--brand-muted); background: #edf4fc; font-weight: 650; }
.document-table tbody :is(th, td) { border-top: 1px solid #e1eaf5; }
.document-table tbody td { overflow-wrap: anywhere; }
.document-table td:last-child { white-space: nowrap; font-weight: 680; }
.document-product { font-weight: 680; }
.document-mobile-label { display: none; }
.document-totals { justify-self: end; padding: 11px 12px; border-radius: 8px; background: #f0f6fe; }
.document-totals .company-fields div { justify-content: start; gap: 16px; }
.document-totals .company-fields :is(dt, dd) { color: var(--brand-blue); font-size: 1.02rem; font-weight: 740; }

.vehicle-dialog { width: min(550px, calc(100% - 28px)); }
.vehicle-form-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.vehicle-form-fields label { display: grid; gap: 5px; color: var(--brand-ink); font-size: .88rem; font-weight: 640; }
.vehicle-form-fields .wide-field { grid-column: 1 / -1; }
.vehicle-form-fields input { width: 100%; min-height: 40px; padding: 7px 10px; border: 1px solid #c8d7e8; border-radius: 7px; color: var(--brand-ink); background: #fff; font-size: 1rem; font-weight: 450; }
.vehicle-form-fields input::placeholder { color: var(--brand-muted); }
.form-actions { display: flex; justify-content: end; align-items: center; gap: 8px; padding-top: 4px; }
.form-actions .button { min-height: 39px; }
.form-error { font-size: .88rem; color: #a51a33; }

@media (max-width: 800px) {
  .dashboard {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: none;
    grid-template-areas: "menu" "finance" "manager" "orders" "company" "garage" "offers-summary";
  }
  .vehicle-card img { width: min(47%, 280px); }
  .ledger-company { grid-template-columns: 1fr; gap: 10px; }
  .ledger-company section + section { border-left: 0; border-top: 1px solid #dce6f1; padding: 10px 0 0; }
}

@media (max-width: 650px) {
  .detail-dialog:has(.document-items) .dialog-heading { padding: 12px; }
  .detail-dialog:has(.document-items) .dialog-body { padding: 12px; }
  .detail-download { padding-inline: 8px; font-size: .79rem; }
  .document-table colgroup { display: none; }
  .document-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .document-table tbody tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 7px; padding: 10px; }
  .document-table tbody tr + tr { border-top: 1px solid #e1eaf5; }
  .document-table tbody :is(th, td) { padding: 0; border-top: 0; }
  .document-table tbody th { grid-column: 1 / -1; }
  .document-table tbody td { font-size: .8rem; }
  .document-mobile-label { display: block; color: var(--brand-muted); font-size: .75rem; font-weight: 500; }
}

@media (max-width: 600px) {
  .preview-inner { flex-wrap: wrap; gap: 1px 9px; }
  .preview-tools { font-size: .73rem; }
  .preview-title { font-size: .79rem; }
  .account-main { padding-top: 13px; }
  .page-intro { margin: 12px 0 16px; }
  .page-intro p { font-size: .89rem; }
  .account-menu { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 3px; padding: 5px; }
  .account-menu a { justify-content: center; min-height: 36px; padding: 4px; font-size: .78rem; white-space: normal; text-align: center; }
  .account-menu a .icon { display: none; }
  .panel { padding: 13px 12px; }
  .orders, .ledger-register { padding: 0; }
  .order-heading { padding: 13px 12px 11px; }
  .metrics { gap: 7px; }
  .metrics > div + div { padding-left: 7px; }
  .metrics dt { font-size: .75rem; }
  .metrics dd { font-size: clamp(1rem, 4.4vw, 1.5rem); }
  .order-table, .order-number { font-size: .79rem; }
  .order-table :is(th, td) { padding-inline: 5px; }
  .order-table :is(th, td):first-child { padding-left: 8px; }
  .order-table :is(th, td):last-child { padding-right: 8px; }
  .status { padding: 3px 5px; font-size: .75rem; }
  .status::before { display: none; }
  .order-number span { font-size: .7rem; }
  .ledger-types { gap: 6px; }
  .ledger-type { gap: 6px; padding: 8px 6px; font-size: .8rem; min-height: 48px; }
  .ledger-type-icon { width: 27px; height: 27px; }
  .ledger-register .order-heading { align-items: start; }
  .ledger-table .order-number span { font-size: .73rem; }
  .vehicle-list, .offer-cards { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 360px) {
  .account-main, .preview-inner { width: calc(100% - 22px); }
  .account-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ledger-type-icon { display: none; }
}

@media (max-width: 480px) {
  .order-table :is(th, td):nth-child(2) { display: none; }
  .order-mobile-date { display: block; margin-top: 2px; font-size: .73rem; }
}
