:root {
  --ink: #17212b;
  --muted: #65717e;
  --paper: #f5f7f8;
  --white: #fff;
  --brand: #3157d5;
  --brand-dark: #2341ab;
  --accent: #e3a857;
  --border: #dce3e6;
  --danger: #a33232;
  --danger-soft: #fff0f0;
  --success: #176b55;
  --success-soft: #e8f4f2;
  --shadow: 0 18px 55px rgba(23, 33, 43, .08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; color: var(--ink); background: var(--paper); font-family: Inter, sans-serif; line-height: 1.5; }
button, input, select, textarea { font: inherit; }
a { color: var(--brand); }
button, a { -webkit-tap-highlight-color: transparent; }
h1, h2, h3, p { overflow-wrap: anywhere; }
.skip-link { position: fixed; z-index: 100; top: 8px; left: 8px; padding: 12px 16px; color: var(--white); background: var(--ink); border-radius: 8px; transform: translateY(-150%); }
.skip-link:focus { transform: translateY(0); }
.site-header { display: flex; align-items: center; justify-content: space-between; gap: 28px; min-height: 72px; padding: 14px clamp(20px, 6vw, 80px); background: var(--white); border-bottom: 1px solid var(--border); }
.wordmark { color: var(--ink); font-size: 20px; font-weight: 700; text-decoration: none; }
.wordmark span { color: var(--brand); }
.header-actions, .primary-nav, .card-actions, .form-actions { display: flex; align-items: center; gap: 10px; }
.primary-nav a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 8px; color: var(--ink); font-weight: 600; text-decoration: none; }
.primary-nav a:hover { color: var(--brand); background: #f0f3fb; }
.primary-nav a[aria-current="page"] { color: var(--brand); background: #e9eefc; }
.page-content { width: min(1120px, calc(100% - 40px)); margin: 0 auto; padding: 54px 0 72px; }
.secondary-button, .primary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 0 20px; border-radius: 10px; font-weight: 600; cursor: pointer; }
.secondary-button { border: 1px solid var(--brand); color: var(--brand); background: transparent; }
.primary-button { border: 1px solid var(--brand); color: var(--white); background: var(--brand); }
.primary-button:hover { border-color: var(--brand-dark); background: var(--brand-dark); }
.danger-button { border: 1px solid var(--danger); color: var(--white); background: var(--danger); }
.compact-button { min-height: 40px; padding-inline: 15px; }
.button-link { text-decoration: none; }
.text-link, .card-link { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.messages { margin-bottom: 20px; }
.alert { padding: 13px 15px; border-radius: 10px; background: var(--success-soft); }
.alert-error, .alert-danger { color: #8d2424; background: var(--danger-soft); }
.simple-card, .dashboard-card { width: min(620px, 100%); padding: clamp(28px, 5vw, 52px); border: 1px solid var(--border); border-radius: 22px; background: var(--white); box-shadow: var(--shadow); }
.simple-card input { width: 100%; min-height: 48px; padding: 0 14px; border: 1px solid var(--border); border-radius: 10px; }
.eyebrow { margin: 0 0 12px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; }
.page-heading { margin-bottom: 28px; }
.page-heading h1 { max-width: 760px; margin: 0; font-size: clamp(30px, 5vw, 46px); line-height: 1.08; letter-spacing: -.035em; }
.page-heading > p:last-child, .page-heading > div > p:last-child { max-width: 720px; margin: 12px 0 0; color: var(--muted); font-size: 17px; }
.page-heading-actions, .section-heading, .title-with-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.detail-navigation { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px 20px; margin-bottom: 22px; }
.breadcrumb { color: var(--muted); font-size: 14px; }
.breadcrumb ol { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.breadcrumb a { color: var(--brand-dark); font-weight: 600; }
.detail-back-link { flex: 0 0 auto; }
.service-order-heading { margin-bottom: 22px; }
.heading-facts { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 16px 0 0; }
.heading-facts div { display: flex; gap: 7px; }
.heading-facts dt { color: var(--muted); }
.heading-facts dd { margin: 0; font-weight: 700; }
.title-with-status { justify-content: flex-start; flex-wrap: wrap; }
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.module-card { display: flex; min-height: 260px; flex-direction: column; justify-content: space-between; gap: 24px; padding: clamp(24px, 4vw, 38px); border: 1px solid var(--border); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.module-card h2 { margin: 0; font-size: 28px; }
.module-card p:not(.eyebrow) { color: var(--muted); }
.search-toolbar { display: flex; align-items: end; gap: 12px; margin-bottom: 24px; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--white); }
.filter-toolbar { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 24px; padding: 18px; border: 1px solid var(--border); border-radius: 16px; background: var(--white); }
.filter-wide { grid-column: span 2; }
.filter-actions { display: flex; align-items: center; gap: 14px; grid-column: 1 / -1; }
.filter-more { grid-column: 1 / -1; padding-top: 2px; border-top: 1px solid var(--border); }
.filter-more > summary { width: fit-content; padding-top: 14px; color: var(--brand-dark); cursor: pointer; font-weight: 700; }
.filter-more[open] > summary { margin-bottom: 14px; }
.filter-advanced-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.search-field { flex: 1; }
.search-field label, .form-field label { display: block; margin-bottom: 7px; font-weight: 600; }
.search-field input, .form-field input, .form-field select, .form-field textarea { width: 100%; min-height: 48px; padding: 10px 13px; color: var(--ink); border: 1px solid #b9c5ca; border-radius: 10px; background: var(--white); }
html input[type="checkbox"] { width: 18px; height: 18px; min-height: 18px; margin: 0; padding: 0; accent-color: var(--brand); cursor: pointer; vertical-align: middle; }
.form-field .checkbox-label { display: inline-flex; align-items: center; gap: 10px; margin-bottom: 0; cursor: pointer; }
.checkbox-label input[type="checkbox"] { flex: 0 0 18px; }
.form-field textarea { min-height: 120px; resize: vertical; }
[data-uppercase] { text-transform: uppercase; }
.record-list { display: grid; gap: 14px; }
.record-card { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 24px; padding: 22px 24px; border: 1px solid var(--border); border-radius: 16px; background: var(--white); transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease; }
.record-card:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49, 87, 213, .12); }
.record-main { min-width: 0; flex: 1; }
.record-title-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.record-title-row h2, .record-title-row h3 { margin: 0; font-size: 20px; }
.record-title-row a { color: var(--ink); text-decoration: none; }
.record-title-row a:hover { color: var(--brand); text-decoration: underline; }
.record-card-primary-link::after { position: absolute; inset: 0; content: ""; border-radius: 16px; cursor: pointer; }
.record-card a:not(.record-card-primary-link) { position: relative; z-index: 1; }
.record-subtitle { margin: 4px 0 0; color: var(--muted); }
.record-key-facts { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0 0; }
.record-key-facts div { min-width: 108px; padding: 7px 10px; border-radius: 10px; background: var(--paper); }
.record-key-facts dt { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; }
.record-key-facts dd { margin: 1px 0 0; color: var(--ink); font-size: 17px; font-weight: 700; }
.record-summary { display: -webkit-box; max-width: 820px; margin: 14px 0 0; overflow: hidden; color: var(--ink); -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.record-summary strong { color: var(--muted); font-size: 13px; }
.record-meta { display: flex; flex-wrap: wrap; gap: 10px 28px; margin: 14px 0 0; }
.record-meta div { display: flex; min-width: 0; flex-wrap: wrap; gap: 6px; }
.record-meta dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.record-meta dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.record-meta a { overflow-wrap: anywhere; }
.record-meta-wide { flex: 1 1 320px; }
.card-link { flex: 0 0 auto; text-decoration: none; }
.status-badge { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 10px; color: var(--success); background: var(--success-soft); border-radius: 999px; font-size: 13px; font-weight: 700; }
.status-inactive { color: #705b29; background: #f7efd9; }
.status-order-cancelled { color: var(--danger); background: var(--danger-soft); }
.status-order-paused, .status-order-awaiting_approval { color: #705b29; background: #f7efd9; }
.status-order-completed, .status-order-delivered { color: var(--success); background: var(--success-soft); }
.status-order-draft { color: var(--muted); background: #edf0f2; }
.status-order-open, .status-order-in_progress, .status-order-inspecting { color: var(--brand-dark); background: #eef1ff; }
.status-order-approved { color: var(--success); background: var(--success-soft); }
.status-inspection-not_started { color: var(--muted); background: #edf0f2; }
.status-inspection-in_progress, .status-inspection-reopened { color: var(--brand-dark); background: #eef1ff; }
.status-inspection-completed { color: var(--success); background: var(--success-soft); }
.status-inspection-cancelled { color: #705b29; background: #f7efd9; }
.empty-state { padding: clamp(34px, 7vw, 64px); text-align: center; border: 1px dashed #b9c5ca; border-radius: 18px; background: var(--white); }
.empty-state h2, .empty-state h3 { margin-top: 0; }
.empty-state p { color: var(--muted); }
.empty-state-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.empty-state-actions form { margin: 0; }
.compact-empty { padding: 30px; }
.list-pagination-summary { margin-top: 24px; }
.list-results-count { margin: 0; color: var(--muted); text-align: center; font-size: 14px; font-weight: 600; }
.pagination { display: flex; align-items: center; justify-content: center; gap: 18px; margin-top: 28px; }
.list-pagination-summary .pagination { margin-top: 12px; }
.pagination a { display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px; font-weight: 600; }
.entity-form { padding: clamp(22px, 5vw, 40px); border: 1px solid var(--border); border-radius: 20px; background: var(--white); box-shadow: var(--shadow); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.form-field-wide { grid-column: 1 / -1; }
.required-label { color: var(--muted); font-size: 12px; font-weight: 500; }
.help-text, .field-error, .field-feedback { margin: 7px 0 0; font-size: 13px; }
.help-text { color: var(--muted); }
.field-error, .has-error label { color: var(--danger); }
.field-feedback { min-height: 20px; color: var(--muted); }
.field-feedback.is-error { color: var(--danger); }
.field-feedback.is-success { color: var(--success); }
.has-error input, .has-error select, .has-error textarea { border-color: var(--danger); }
.form-field[hidden] { display: none; }
.primary-button:disabled { cursor: wait; opacity: .72; }
.inspection-form .primary-button:disabled, .entity-form .primary-button:disabled { cursor: not-allowed; }
.form-error-summary { margin-bottom: 24px; padding: 18px 20px; color: #702020; border: 1px solid #efc1c1; border-radius: 12px; background: var(--danger-soft); }
.form-error-summary h2 { margin: 0; font-size: 18px; }
.form-error-summary ul { margin-bottom: 0; }
.form-actions { margin-top: 28px; flex-wrap: wrap; }
.form-section { min-width: 0; margin: 0; padding: 24px 0; border: 0; border-bottom: 1px solid var(--border); }
.form-section:first-of-type { padding-top: 0; }
.form-section legend { margin-bottom: 18px; padding: 0; font-size: 20px; font-weight: 700; }
.company-logo-settings { align-items: center; display: grid; gap: 24px; grid-template-columns: minmax(160px, 220px) 1fr; }
.company-logo-preview { align-items: center; background: #f7f9fa; border: 1px dashed var(--border); border-radius: 10px; display: flex; justify-content: center; min-height: 120px; padding: 16px; }
.company-logo-preview img { display: block; height: auto; max-height: 96px; max-width: 100%; object-fit: contain; }
@media (max-width: 640px) { .company-logo-settings { grid-template-columns: 1fr; } }
.detail-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.detail-card { padding: clamp(22px, 4vw, 32px); border: 1px solid var(--border); border-radius: 18px; background: var(--white); }
.detail-card-wide { grid-column: 1 / -1; }
.detail-card h2 { margin: 0 0 20px; font-size: 21px; }
.detail-card h3 { margin: 24px 0 8px; font-size: 16px; }
.operational-summary { margin-bottom: 28px; }
.hub-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.hub-panel { min-width: 0; }
.compact-attachment-gallery { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.compact-timeline { max-width: 900px; }
.operational-summary .section-heading { margin-bottom: 8px; }
.operational-summary .section-heading h2 { font-size: 21px; }
.operational-alerts { margin: 30px 0 0; }
.operational-alerts ul, .inspection-list { display: grid; gap: 12px; margin: 0; padding: 0; list-style: none; }
.operational-alerts li { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 16px 18px; border: 1px solid #e4d39b; border-radius: 14px; background: #fffaf0; }
.operational-alerts li p { margin: 4px 0 0; color: var(--muted); }
.operational-alerts li form { flex: 0 0 auto; margin: 0; }
.service-narrative { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px 32px; }
.service-narrative > div { min-width: 0; }
.service-narrative h3, .detail-card > h3:first-child { margin-top: 0; }
.service-narrative > a { grid-column: 1 / -1; justify-self: start; }
.progress-summary { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 22px; }
.progress-summary div { display: grid; gap: 5px; }
.progress-summary > span { color: var(--muted); font-size: 24px; }
.inspection-list { margin-bottom: 14px; }
.inspection-list .detail-card { padding: 20px 22px; }
.inspection-list h3 { margin: 0; }
.inspection-list p { margin: 7px 0 0; }
.page-heading .card-actions, .section-heading .card-actions { flex-wrap: wrap; }
.contextual-action-bar { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: -10px 0 28px; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--white); }
.contextual-action-visible { display: flex; align-items: center; min-width: 0; gap: 10px; }
.contextual-action-visible form, .contextual-action-menu-panel form { margin: 0; }
.contextual-action-menu { position: relative; flex: 0 0 auto; }
.contextual-action-menu summary { list-style: none; user-select: none; }
.contextual-action-menu summary::-webkit-details-marker { display: none; }
.contextual-action-menu summary::after { margin-left: 8px; content: "▾"; }
.contextual-action-menu[open] summary::after { content: "▴"; }
.contextual-action-menu-panel { position: absolute; z-index: 10; top: calc(100% + 8px); right: 0; display: grid; width: min(280px, calc(100vw - 40px)); gap: 8px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.contextual-action-menu-panel a, .contextual-action-menu-panel button { width: 100%; justify-content: flex-start; text-align: left; }
.contextual-action-menu-panel .secondary-button { color: var(--ink); border-color: transparent; }
.contextual-action-menu-panel .secondary-button:hover { color: var(--brand); background: #f0f3fb; }
.contextual-action-destructive { margin-top: 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.contextual-action-mobile-items { display: none; gap: 8px; }
.contextual-action-menu-mobile-only { display: none; }
.operational-metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0; margin: 0; }
.operational-metrics div { min-width: 0; padding: 12px 18px; border-left: 1px solid var(--border); }
.operational-metrics div:first-child { padding-left: 0; border-left: 0; }
.operational-metrics dt { color: var(--muted); font-size: 13px; }
.operational-metrics dd { min-width: 0; margin: 4px 0 0; overflow-wrap: anywhere; font-size: 17px; font-weight: 700; word-break: break-word; }
.detail-list { margin: 0; }
.detail-list div { display: grid; grid-template-columns: minmax(120px, .7fr) 1.3fr; gap: 16px; padding: 11px 0; border-bottom: 1px solid var(--border); }
.detail-list div:last-child { border-bottom: 0; }
.detail-list dt { color: var(--muted); font-size: 14px; }
.detail-list dd { margin: 0; font-weight: 500; }
.detail-emphasis { font-size: 20px; font-weight: 700; }
.address-block { font-style: normal; line-height: 1.7; }
.preserve-lines { white-space: pre-line; }
.muted-text { color: var(--muted); }
.related-section { margin-top: 38px; }
.section-heading { margin-bottom: 18px; }
.section-heading h2 { margin: 0; font-size: 26px; }
.compact-list .record-card { box-shadow: none; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 24px; margin-top: 38px; padding: 22px 24px; border: 1px solid #e6c6c6; border-radius: 16px; background: var(--danger-soft); }
.danger-zone h2 { margin: 0; font-size: 18px; }
.danger-zone p { margin: 5px 0 0; color: #704747; }
.status-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.status-actions form { display: flex; flex-wrap: wrap; gap: 8px; }
.status-actions input { min-height: 44px; padding: 8px 12px; border: 1px solid #b9c5ca; border-radius: 10px; }
.timeline { margin: 0; padding: 0; list-style: none; }
.timeline li { position: relative; display: grid; grid-template-columns: 20px 1fr; gap: 14px; padding-bottom: 22px; }
.timeline li::before { position: absolute; top: 18px; bottom: 0; left: 7px; width: 2px; content: ""; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline-marker { z-index: 1; width: 16px; height: 16px; margin-top: 5px; border: 4px solid var(--white); border-radius: 50%; background: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.timeline-content { padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--white); }
.timeline-content p { margin: 6px 0 0; }
.timeline-title { color: var(--ink); font-weight: 700; }
.timeline-meta { color: var(--muted); font-size: 13px; }
.history-filter { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; margin-bottom: 22px; }
.history-filter label { width: 100%; font-weight: 600; }
.history-filter select { min-width: min(280px, 100%); min-height: 44px; padding: 8px 12px; border: 1px solid #b9c5ca; border-radius: 10px; background: var(--white); }
.history-changes { margin: 14px 0 0; padding-top: 10px; border-top: 1px solid var(--border); }
.history-changes div { display: grid; grid-template-columns: minmax(140px, .6fr) 1.4fr; gap: 12px; padding: 6px 0; }
.history-changes dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.history-changes dd { margin: 0; }
.visually-hidden { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.inspection-order-card { display: flex; align-items: center; justify-content: space-between; gap: 24px; }
.inspection-order-card h3 { margin-top: 0; }
.inspection-progress { display: grid; gap: 8px; margin-bottom: 22px; padding: 18px 20px; border: 1px solid var(--border); border-radius: 14px; background: var(--white); }
.inspection-progress progress { width: 100%; height: 14px; accent-color: var(--brand); }
.inspection-vehicle-summary { display: flex; justify-content: space-between; gap: 16px; margin: 20px 0; padding: 16px 18px; border-radius: 12px; background: #f5f7f8; }
.inspection-sections { display: grid; gap: 24px; margin-top: 24px; }
.inspection-section { min-width: 0; padding: clamp(18px, 4vw, 28px); border: 1px solid var(--border); border-radius: 16px; }
.inspection-section > legend { padding: 0 8px; font-size: 20px; font-weight: 700; }
.inspection-item { display: grid; grid-template-columns: minmax(180px, .8fr) minmax(260px, 1.2fr); gap: 14px 24px; padding: 22px 0; border-bottom: 1px solid var(--border); }
.inspection-item { min-width: 0; margin: 0; border-top: 0; border-right: 0; border-left: 0; }
.inspection-item > legend { padding: 0; font-weight: 700; }
.inspection-item:last-child { border-bottom: 0; }
.inspection-question label { font-weight: 700; }
.choice-grid > div { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.choice-grid > div > div > label { display: flex; align-items: center; gap: 9px; min-height: 48px; padding: 10px 12px; border: 1px solid #b9c5ca; border-radius: 10px; cursor: pointer; }
.choice-grid input[type="radio"] { width: 20px; height: 20px; min-height: 20px; margin: 0; }
.inspection-notes { grid-column: 2; }
.inspection-notes label { display: block; margin-bottom: 6px; color: var(--muted); font-size: 13px; }
.readonly-banner { display: grid; gap: 6px; margin-bottom: 24px; padding: 18px 20px; border: 1px solid #b9c5ca; border-radius: 14px; background: #f5f7f8; }
.inspection-readonly { display: grid; gap: 18px; }
.inspection-readonly .section-heading { margin-bottom: 0; }
.inspection-readonly-section h3 { margin-top: 0; }
.readonly-response { display: grid; grid-template-columns: minmax(180px, 1fr) 1fr; gap: 12px 24px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.readonly-response:last-child { border-bottom: 0; }
.readonly-response p { margin: 0; }
.readonly-response-note { grid-column: 2; }
.attachment-section .section-heading p { margin: 5px 0 0; }
.attachment-gallery { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin: 0; padding: 0; list-style: none; }
.attachment-card { min-width: 0; border: 1px solid var(--border); border-radius: 16px; background: var(--white); }
.attachment-image-link { display: block; overflow: hidden; aspect-ratio: 4 / 3; border-radius: 15px 15px 0 0; background: #e8ecee; }
.attachment-image-link img { display: block; width: 100%; height: 100%; object-fit: cover; transition: transform .18s ease; }
.attachment-image-link:hover img { transform: scale(1.025); }
.attachment-card-body { display: grid; gap: 9px; padding: 16px; }
.attachment-card-body p { margin: 0; }
.attachment-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.order-badge { flex: 0 0 auto; padding: 2px 8px; color: var(--muted); border-radius: 999px; background: var(--paper); font-size: 12px; }
.attachment-context { color: var(--brand-dark); font-size: 13px; font-weight: 600; }
.attachment-meta { color: var(--muted); font-size: 12px; }
.attachment-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 14px; padding-top: 3px; }
.delete-confirmation { position: relative; }
.delete-confirmation summary { color: var(--danger); font-weight: 600; cursor: pointer; }
.delete-confirmation form { position: absolute; z-index: 4; right: 0; width: min(280px, 80vw); padding: 14px; border: 1px solid #e6c6c6; border-radius: 12px; background: var(--white); box-shadow: var(--shadow); }
.delete-confirmation form p { margin: 0 0 10px; }
.image-viewer { width: min(1000px, calc(100% - 32px)); max-height: calc(100vh - 32px); padding: 18px; border: 0; border-radius: 18px; background: var(--white); }
.image-viewer::backdrop { background: rgba(13, 20, 27, .78); }
.image-viewer-close { position: absolute; z-index: 2; top: 12px; right: 12px; width: 44px; height: 44px; color: var(--white); border: 0; border-radius: 50%; background: rgba(13, 20, 27, .8); font-size: 28px; cursor: pointer; }
.image-viewer figure { display: grid; gap: 12px; margin: 0; }
.image-viewer figure img { display: block; max-width: 100%; max-height: calc(100vh - 190px); margin: 0 auto; object-fit: contain; }
.image-viewer figcaption { display: flex; justify-content: space-between; gap: 16px; color: var(--muted); }
.image-viewer figcaption strong { color: var(--ink); }
.image-viewer-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 16px; }
.attachment-edit-layout { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(420px, 1.2fr); align-items: start; gap: 24px; }
.attachment-edit-preview { overflow: hidden; margin: 0; border: 1px solid var(--border); border-radius: 18px; background: var(--white); }
.attachment-edit-preview img { display: block; width: 100%; height: auto; }
.attachment-edit-preview figcaption { padding: 12px 16px; color: var(--muted); font-size: 13px; }
.file-preview { margin-top: 18px; color: var(--muted); }
.file-preview-list, .upload-results ul { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.file-preview-item { display: grid; grid-template-columns: 72px minmax(0, 1fr) auto; align-items: center; gap: 14px; padding: 10px; border: 1px solid var(--border); border-radius: 12px; }
.file-preview-item.is-error { color: var(--danger); border-color: #e6a9a9; background: var(--danger-soft); }
.file-preview-item img { width: 72px; height: 58px; border-radius: 8px; object-fit: cover; background: var(--paper); }
.file-preview-item div { display: grid; min-width: 0; }
.file-preview-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-preview-item span { font-size: 13px; }
.upload-status { display: flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--muted); }
.upload-status.is-error { color: var(--danger); }
.upload-status progress { width: min(240px, 40%); }
.upload-results { margin-bottom: 24px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; }
.upload-results h2 { margin: 0 0 12px; font-size: 18px; }
.upload-results li { display: grid; padding: 10px 0; border-bottom: 1px solid var(--border); }
.upload-results li:last-child { border-bottom: 0; }
.upload-results .is-success { color: var(--success); }
.upload-results .is-error { color: var(--danger); }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible, [tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}

@media (hover: hover) {
  .record-card:hover { border-color: #b9c5ca; box-shadow: 0 12px 32px rgba(23, 33, 43, .07); transform: translateY(-1px); }
}

@media (max-width: 760px) {
  .hub-grid { grid-template-columns: 1fr; gap: 0; }
  .site-header { align-items: flex-start; flex-direction: column; gap: 8px; }
  .header-actions { width: 100%; justify-content: space-between; }
  .primary-nav { max-width: 100%; overflow-x: auto; }
  .page-heading-actions, .section-heading { align-items: flex-start; flex-direction: column; }
  .operational-alerts li { align-items: flex-start; flex-direction: column; }
  .service-narrative { grid-template-columns: 1fr; }
  .service-narrative > a { grid-column: auto; }
  .module-grid, .detail-layout, .form-grid, .filter-toolbar { grid-template-columns: 1fr; }
  .filter-wide { grid-column: auto; }
  .filter-advanced-grid { grid-template-columns: 1fr; }
  .detail-card-wide, .form-field-wide { grid-column: auto; }
  .operational-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .operational-metrics div, .operational-metrics div:first-child { padding: 12px 0; border-bottom: 1px solid var(--border); border-left: 0; }
  .record-card { align-items: flex-start; flex-direction: column; gap: 8px; }
  .card-link { width: 100%; justify-content: flex-end; }
  .danger-zone { align-items: flex-start; flex-direction: column; }
  .inspection-order-card { align-items: flex-start; flex-direction: column; }
  .inspection-item, .readonly-response { grid-template-columns: 1fr; }
  .inspection-notes { grid-column: auto; }
  .readonly-response-note { grid-column: auto; }
  .inspection-vehicle-summary { flex-direction: column; }
  .attachment-gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attachment-edit-layout { grid-template-columns: 1fr; }
  .contextual-action-secondary { display: none; }
  .contextual-action-mobile-items { display: grid; }
  .contextual-action-menu-mobile-only { display: block; }
}

@media (max-width: 560px) {
  .page-content { width: min(100% - 28px, 1120px); padding: 32px 0 52px; }
  .site-header { padding-inline: 14px; }
  .header-actions { align-items: flex-start; flex-direction: column; }
  .primary-nav { width: 100%; }
  .primary-nav a { padding-inline: 10px; }
  .search-toolbar { align-items: stretch; flex-direction: column; }
  .search-toolbar .secondary-button { width: 100%; }
  .record-card, .entity-form, .detail-card { padding: 20px; }
  .record-key-facts div { flex: 1 1 108px; }
  .detail-navigation { align-items: stretch; flex-direction: column; }
  .detail-back-link { width: 100%; }
  .record-meta, .record-meta div { flex-direction: column; gap: 3px; }
  .form-actions, .form-actions .button-link, .form-actions button { width: 100%; }
  .empty-state-actions, .empty-state-actions .button-link, .empty-state-actions form, .empty-state-actions button { width: 100%; }
  .detail-list div { grid-template-columns: 1fr; gap: 2px; }
  .heading-facts { display: grid; gap: 6px; }
  .progress-summary { grid-template-columns: 1fr; }
  .progress-summary > span { transform: rotate(90deg); justify-self: start; }
  .operational-alerts li .button-link, .operational-alerts li form, .operational-alerts li button { width: 100%; }
  .history-changes div { grid-template-columns: 1fr; gap: 2px; }
  .pagination { flex-wrap: wrap; gap: 8px; }
  .danger-zone form, .danger-zone button { width: 100%; }
  .attachment-gallery { grid-template-columns: 1fr; }
  .file-preview-item { grid-template-columns: 58px minmax(0, 1fr); }
  .file-preview-item img { width: 58px; height: 52px; }
  .file-preview-item button { grid-column: 1 / -1; width: 100%; }
  .image-viewer { width: calc(100% - 16px); padding: 10px; }
  .image-viewer figcaption, .image-viewer-actions { align-items: stretch; flex-direction: column; }
  .image-viewer-actions > * { width: 100%; }
  .delete-confirmation form { right: auto; left: 0; }
  .contextual-action-bar { align-items: stretch; }
  .contextual-action-visible, .contextual-action-primary, .contextual-action-primary > *, .contextual-action-primary a, .contextual-action-primary button { min-width: 0; width: 100%; }
  .contextual-action-menu { flex: 0 0 auto; }
  .contextual-action-menu > summary { padding-inline: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .record-card { transition: none; }
  .record-card:hover { transform: none; }
}

.quote-items { display: grid; gap: 16px; }
.quote-item-row { align-items: end; border: 1px solid var(--border); border-radius: 12px; display: grid; gap: 12px; grid-template-columns: minmax(220px, 2fr) minmax(110px, .7fr) minmax(140px, .9fr) minmax(130px, .8fr); padding: 16px; }
.quote-item-row[hidden] { display: none; }
.quote-item-catalog { grid-column: 1 / -1; }
.quote-item-catalog[hidden] { display: none; }
.quote-item-unit-price { grid-column: 1 / -2; }
.quote-item-row output { align-items: center; background: var(--paper); border: 1px solid var(--border); border-radius: 10px; display: flex; font-weight: 700; min-height: 44px; padding: 8px 12px; }
.quote-item-remove { justify-self: end; }
.catalog-tabs { border-bottom: 1px solid var(--border); display: flex; gap: 24px; margin-bottom: 28px; }
.catalog-tab { border-bottom: 3px solid transparent; color: var(--muted); font-size: 14px; font-weight: 600; margin-bottom: -1px; padding: 10px 2px; text-decoration: none; }
.catalog-tab:hover { color: var(--brand); }
.catalog-tab[aria-current="page"] { border-bottom-color: var(--brand); color: var(--brand); }
.catalog-card-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 8px; }
.catalog-card-actions form { margin: 0; }
.quote-items-actions, .quote-actions { align-items: center; display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; margin-top: 18px; }
.quote-live-total { display: flex; flex-direction: column; text-align: right; }
.quote-live-total span { color: var(--muted); font-size: 13px; }
.quote-live-total strong { font-size: 1.5rem; }
.table-scroll { overflow-x: auto; }
.quote-table { border-collapse: collapse; min-width: 680px; width: 100%; }
.quote-table th, .quote-table td { border-bottom: 1px solid var(--border); padding: 14px 12px; text-align: right; vertical-align: top; }
.quote-table th:first-child, .quote-table td:first-child { text-align: left; }
.quote-table td small { color: var(--muted); display: block; margin-top: 4px; }
.quote-table tfoot th, .quote-table tfoot td { border-top: 2px solid var(--ink); font-size: 1.05rem; font-weight: 700; }
@media (max-width: 900px) { .quote-item-row { grid-template-columns: 1fr 1fr; } .quote-item-unit-price { grid-column: 1 / -1; } }
@media (max-width: 560px) { .quote-item-row { grid-template-columns: 1fr; } .quote-item-unit-price { grid-column: auto; } .quote-item-remove, .quote-item-remove button { justify-self: stretch; width: 100%; } }
