:root {
  color-scheme: light;
  font-family: "Inter", "Segoe UI", Arial, sans-serif;
  color: #18283d;
  background: #f2f5f9;
  font-synthesis: none;
  --muted: #55667c;
  --line: #e1e7ef;
  --blue: #2357ad;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.wrap { width: min(1120px, calc(100% - 64px)); margin-inline: auto; }
.topbar { color: #fff; background: #14243b; }
.topbar-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 750; letter-spacing: -.025em; }
.brand-mark { display: grid; place-items: center; width: 36px; height: 36px; color: #fff; background: #2c60b5; border-radius: 8px; }
.topbar-label { color: #c7d4e6; font-size: 13px; }
.page-heading { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: end; gap: 14px; padding: 33px 0 24px; }
h1 { margin: 0; font-size: clamp(30px, 4vw, 41px); line-height: 1.12; letter-spacing: -.045em; }
.page-heading p { margin: 9px 0 0; color: var(--muted); line-height: 1.45; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.page-actions a { text-decoration: none; }
.dashboard { display: grid; grid-template-columns: minmax(0, 1.85fr) minmax(300px, 1fr); gap: 22px; align-items: start; }
.panel { background: #fff; border: 1px solid var(--line); border-radius: 13px; box-shadow: 0 2px 6px #18283d05; min-width: 0; }
.panel-header { display: flex; align-items: center; gap: 11px; padding: 15px 22px; border-bottom: 1px solid var(--line); }
.section-icon { display: grid; place-items: center; width: 34px; height: 34px; color: var(--blue); background: #ebf2fd; border-radius: 8px; flex-shrink: 0; }
.section-icon svg { width: 19px; height: 19px; }
h2 { margin: 0; font-size: 17px; letter-spacing: -.015em; }
form { padding: 19px 22px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; column-gap: 15px; row-gap: 13px; }
.catalog-field { position: relative; min-width: 0; }
.catalog-field label { display: block; }
.catalog-source { margin: 8px 0 0; color: var(--muted); font-size: 12px; }
.catalog-source a { color: var(--blue); text-underline-offset: 2px; }
.catalog-options { position: absolute; z-index: 2; inset-inline: 0; top: calc(100% + 4px); max-height: 220px; overflow: auto; overscroll-behavior: contain; margin: 0; padding: 4px; list-style: none; background: #fff; border: 1px solid #cbd8ea; border-radius: 7px; box-shadow: 0 8px 20px #14243b22; }
.catalog-options li { padding: 8px 9px; border-radius: 4px; overflow-wrap: anywhere; font-size: 14px; cursor: pointer; }
.catalog-options li:hover, .catalog-options [aria-selected=true] { background: #edf4ff; color: #234674; }
label, legend { font-size: 13px; font-weight: 650; }
label { min-width: 0; }
input:not([type=radio]):not([type=checkbox]), textarea, select { display: block; margin-top: 5px; width: 100%; border: 1px solid #d7e0ec; border-radius: 6px; min-height: 39px; padding: 8px 10px; background: #fbfcfe; color: #18283d; font-size: 14px; font-weight: 400; }
textarea { resize: vertical; min-height: 59px; }
::placeholder { color: #687990; opacity: 1; }
:focus-visible { outline: 2px solid #3170cc; outline-offset: 2px; }
.required { color: #a6273c; }
fieldset { margin: 17px 0 0; padding: 0; border: 0; min-width: 0; }
legend { padding: 0; margin-bottom: 8px; }
.quality-options, .operation-options { display: flex; flex-wrap: wrap; gap: 7px; }
.chip { position: relative; cursor: pointer; }
.chip input { position: absolute; opacity: 0; }
.chip span, .quality-tag { display: inline-flex; align-items: center; gap: 6px; border-radius: 5px; padding: 6px 9px; background: var(--surface); color: var(--tone); }
.chip span { border: 1px solid var(--edge); }
.chip input:checked + span { border-color: var(--tone); box-shadow: inset 0 0 0 1px var(--tone); }
.chip input:focus-visible + span { outline: 2px solid #3170cc; outline-offset: 2px; }
.chip i, .quality-tag i { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.green { --surface: #eef8f2; --tone: #17613d; --edge: #d1e8da; }
.yellow { --surface: #fff7e4; --tone: #795006; --edge: #f1e2b8; }
.red { --surface: #fceef0; --tone: #9e2940; --edge: #f2d5db; }
.comment, .margin-field { display: block; margin-top: 11px; }
.operation { display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 9px; border: 1px solid #d7e0ec; border-radius: 6px; cursor: pointer; }
.operation:has(:checked) { border-color: #7a9fd4; background: #edf4ff; }
.operation input { accent-color: var(--blue); width: 15px; height: 15px; margin: 0; }
.operation small { color: var(--muted); font-size: 12px; font-weight: 500; }
.event-fields:has(label:not([hidden])) { margin-top: 12px; }
.sale-field { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 10px; margin-top: 12px; }
.sale-field small { color: var(--muted); font-size: 12px; }
.listing-fields { display: flex; align-items: end; flex-wrap: wrap; gap: 8px 12px; margin-top: 12px; }
.listing-fields > label:first-child { flex: 1 1 240px; }
.form-footer { display: flex; justify-content: flex-end; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.required-note { margin-right: auto; color: var(--muted); font-size: 12px; }
.primary, .secondary { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 12px; font-size: 13px; font-weight: 650; border-radius: 6px; }
.primary { color: #fff; background: var(--blue); border: 1px solid var(--blue); }
.primary:hover { background: #19458c; }
.primary svg { width: 17px; height: 17px; }
.secondary { color: #234674; border: 1px solid #d7e0ec; background: #fff; }
.secondary:hover { background: #edf4ff; }
.history-button svg { width: 17px; height: 17px; }
.total { margin: 17px 18px 2px; padding: 16px; background: #edf4ff; border-radius: 8px; color: #234674; }
.total span { display: block; margin-bottom: 5px; font-size: 13px; font-weight: 650; }
.total strong { font-size: clamp(27px, 3.5vw, 39px); line-height: 1.1; letter-spacing: -.04em; }
.breakdown { margin: 0; padding: 4px 18px 0; }
.breakdown div, .margin-total { display: flex; align-items: center; justify-content: space-between; column-gap: 12px; }
.breakdown div { border-bottom: 1px solid var(--line); padding: 12px 0; }
.breakdown dt { font-size: 14px; font-weight: 650; }
.breakdown dt small { display: block; color: var(--muted); margin-top: 3px; font-size: 12px; font-weight: 400; }
.breakdown dd { margin: 0; font-size: 15px; font-weight: 700; text-align: right; }
.margin-total { margin: 0 18px; padding: 14px 0; color: var(--muted); font-size: 13px; }
.margin-total strong { color: #18283d; text-align: right; }
.total strong, .breakdown dd, .margin-total strong { overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.journal { margin-top: 21px; }
.count { border-radius: 20px; background: #edf2f8; color: #475b72; padding: 2px 8px; font-size: 12px; font-weight: 700; }
.empty { color: var(--muted); margin: 0; padding: 23px 22px; font-size: 14px; }
.record { display: flex; align-items: start; justify-content: space-between; gap: 18px; padding: 15px 22px; border-bottom: 1px solid var(--line); }
.record:last-child { border-bottom: 0; }
.record-info { min-width: 0; overflow-wrap: anywhere; }
.record h3 { font-size: 15px; margin: 0 0 4px; }
.record-heading { display: flex; align-items: center; flex-wrap: wrap; gap: 5px 8px; }
.record-heading h3 { margin: 0; }
.record-listing { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 8px 0; font-size: 13px; }
.record-listing a { color: var(--blue); text-underline-offset: 2px; }
.listing-close, .listing-pending { min-height: 31px; font-size: 12px; }
.listing-pending { padding: 4px 8px; border: 1px solid #e9d099; border-radius: 6px; background: #fff4d8; color: #745009; font-weight: 700; }
.listing-pending:hover { background: #ffebba; }
.listing-state { color: var(--muted); }
.stock-status { border-radius: 5px; background: #edf4ff; color: #234674; padding: 3px 7px; font-size: 11px; font-weight: 650; }
.stock-status.sold { background: #eef8f2; color: #17613d; }
.record p { margin: 5px 0 0; color: var(--muted); font-size: 13px; white-space: pre-wrap; }
.quality-tag { margin-top: 5px; font-size: 12px; font-weight: 650; }
.record-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.record-side { display: flex; flex-wrap: wrap; align-items: start; justify-content: end; gap: 9px 22px; }
.record-earnings { display: grid; gap: 3px; min-width: 120px; text-align: right; }
.record-earnings span, .record-earnings small { color: var(--muted); font-size: 12px; }
.record-earnings strong { font-size: 18px; font-variant-numeric: tabular-nums; }
.stock-record { align-items: center; }
.stock-record button { flex-shrink: 0; }
.delete { color: #9e2940; }
.delete:hover { background: #fceef0; }
footer { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 12px; padding: 15px 0 22px; }
footer svg { width: 15px; height: 15px; }
.field-error, .warning { color: #9e2940; font-size: 13px; }
.field-error { margin: 8px 0 0; }
.warning { padding: 10px; background: #fceef0; border-radius: 6px; }
.record ul { margin: 7px 0 0; padding-left: 17px; color: var(--muted); font-size: 13px; }
.record li + li { margin-top: 3px; }
.vehicle-gallery { margin-top: 11px; }
.photo-strip, .photo-thumbnails { display: flex; flex-wrap: wrap; gap: 7px; }
.photo-thumbnails:empty { display: none; }
.photo-thumb, .photo-add { display: grid; place-items: center; width: 76px; height: 58px; padding: 0; border-radius: 7px; overflow: hidden; }
.photo-thumb { border: 1px solid var(--line); background: #edf2f8; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-add { border: 1px dashed #9eb1ca; color: var(--blue); background: #f5f8fc; font-size: 26px; }
.photo-add:hover { background: #edf4ff; }
.photo-add:disabled { opacity: .6; cursor: wait; }
dialog { width: min(530px, calc(100% - 24px)); max-height: calc(100dvh - 28px); padding: 0; border: 1px solid var(--line); border-radius: 13px; color: inherit; background: #fff; box-shadow: 0 20px 70px #14243b40; }
dialog::backdrop { background: #14243b70; }
#photo-viewer { width: min(720px, calc(100% - 24px)); }
#photo-image { display: block; width: 100%; max-height: 68dvh; object-fit: contain; background: #edf2f8; }
.photo-footer { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: end; padding: 12px 18px; }
.history-header { justify-content: space-between; position: sticky; top: 0; z-index: 1; background: #fff; }
.history-header form { padding: 0; }
.history-body { padding-bottom: 16px; }
.month-picker { display: block; max-width: 230px; margin: 14px 18px 0; }
.history-events { margin: 0 18px; padding-top: 12px; border-top: 1px solid var(--line); }
.history-events h3 { margin: 0 0 8px; font-size: 14px; }
.history-empty { margin: 0; color: var(--muted); font-size: 13px; }
.history-records { list-style: none; margin: 0; padding: 0; }
.history-records li { padding: 8px 0; display: flex; align-items: baseline; justify-content: space-between; gap: 10px; font-size: 13px; }
.history-records li + li { border-top: 1px solid var(--line); }
.history-records strong { overflow-wrap: anywhere; }
.history-records span { color: var(--muted); text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (max-width: 790px) {
  .wrap { width: calc(100% - 36px); }
  .dashboard { grid-template-columns: 1fr; gap: 16px; }
  .page-heading { padding-top: 25px; }
}
@media (max-width: 480px) {
  .wrap { width: calc(100% - 24px); }
  .panel-header, form, .record { padding-inline: 14px; }
  .topbar-inner { min-height: 56px; }
  .fields { column-gap: 9px; }
  .record { flex-direction: column; gap: 10px; }
  .record-side { justify-content: start; }
  .record-earnings { text-align: left; }
  .stock-record { align-items: start; }
}
