/* KTE Service — "Service Line" design trial: one complaint (office complaint page and the field job page share these parts) */

/* ---------- header: number, status, customer, and the journey ---------- */
.case-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 16px 22px 18px; margin-bottom: 12px; }
.case-hero .back { margin-bottom: 6px; }
.case-top { display: flex; justify-content: space-between; gap: 24px; align-items: flex-start; }
.case-name { min-width: 0; }
.case-id { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 0 0 10px; }
.sr-big { font-size: 1.15rem; padding: 6px 10px; border-radius: 8px; }
.case-name h1 { font-size: 2.1rem; }
.case-eq { margin: 4px 0 0; font-weight: 700; color: var(--ink-2); letter-spacing: 0.01em; }
.case-summary { margin: 6px 0 0; color: var(--muted); max-width: 70ch; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.case-status { flex: none; display: grid; gap: 10px; justify-items: end; min-width: 250px; max-width: 42%; }
.case-kv { grid-template-columns: max-content minmax(0, auto); background: var(--bg); border-radius: 10px; padding: 10px 14px; gap: 5px 16px; }
.case-kv dd.is-late { color: var(--danger); }
.case-status .amc-link, .case-name .amc-link { display: inline-flex; margin-top: 8px; }
.linked-line { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.88rem; font-weight: 600; }
.amc-tag { display: inline-block; font: 800 0.7rem/1.3 var(--font-c); letter-spacing: 0.04em; padding: 1px 6px; border-radius: 5px; background: #0b6e8a; color: #fff; vertical-align: 1px; }
.amc-link { font-weight: 600; font-size: 0.88rem; text-decoration: none; align-items: center; gap: 6px; }

/* the journey along the Service Line */
.journey { list-style: none; display: flex; margin: 18px 0 0; padding: 14px 0 0; border-top: 1px solid var(--line); overflow-x: auto; scrollbar-width: thin; }
.journey li { flex: 1 0 118px; max-width: 200px; position: relative; display: grid; gap: 2px; padding: 22px 12px 0 0; min-width: 0; }
.journey li::before { content: ""; position: absolute; left: 0; right: 0; top: 7px; height: 4px; background: var(--c); border-radius: 2px; opacity: 0.9; }
.journey li:first-child::before { left: 2px; }
.j-dot { position: absolute; left: 0; top: 1px; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 4px solid var(--c); box-sizing: border-box; }
.journey b { font: 700 0.92rem/1.2 var(--font-c); color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.journey small { color: var(--muted); font-size: 0.78rem; }
.journey .is-now .j-dot { width: 22px; height: 22px; top: -2px; left: -3px; background: var(--c); border-color: var(--surface); box-shadow: 0 0 0 3px var(--c); }
.journey .is-now::before { right: auto; width: 16px; }
.journey .is-now b { font-size: 1rem; }
.journey .is-next { --c: var(--accent); }
.journey .is-next::before { background: repeating-linear-gradient(90deg, var(--line-strong) 0 6px, transparent 6px 11px); right: 12px; opacity: 1; display: none; }
.journey .is-next .j-dot { border-style: dashed; border-color: var(--accent-dark); border-width: 3px; }
.journey .is-next b { color: #8a5600; }
.journey .is-now:has(+ .is-next)::before { width: auto; right: 0; background: repeating-linear-gradient(90deg, var(--line-strong) 0 6px, transparent 6px 11px); opacity: 1; }

/* the action bar: pinned under the top bar on computers, above the bottom menu on phones */
.case-actions { position: sticky; top: calc(var(--top-h) + var(--safe-t)); z-index: 12; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 0; margin-bottom: 8px;
  background: var(--bg); }
.case-actions .next-btn { min-width: 200px; }
.act-note { flex: 1 1 180px; line-height: 1.35; }
.menu-wrap .more-toggle::after { content: ""; width: 7px; height: 7px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg) translateY(-2px); margin-left: 4px; }

/* ---------- body ---------- */
.case-grid { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; align-items: start; }
.case-grid > * { min-width: 0; }
.case-main .panel, .case-side .panel { margin-bottom: 14px; }
.case-side h2, .case-main h2 { font-size: 1.12rem; }
.qtn-banner { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin: 0 0 14px; padding: 12px 16px; border-radius: var(--r); background: var(--ok-soft); border: 1px solid #a9dcc3; color: #0b5c40; font-weight: 600; }
.qtn-banner-btns { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.qtn-banner.qtn-declined { background: #f5e8f6; border-color: #dcbbe0; color: #6b2a73; }
.refs-strip { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.ref-box { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: 10px 16px; display: flex; flex-direction: column; min-width: 160px; }
.ref-box span { font-size: 0.78rem; color: var(--muted); font-weight: 600; }
.ref-box b { font: 700 1.2rem var(--font-c); }
.ref-box.ref-quote { border-color: #cbbcf6; background: #f6f3ff; }
.ref-box.ref-quote b { color: #44279e; }
.clarify-box { border-color: #dcc4f3; background: #fbf7ff; }
.clarify-box h2 { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.pre { white-space: pre-wrap; font-weight: 500; }
.rec-panel { border-color: #f3d38f; background: #fffaf0; }
.owner-warn { color: #7a4c00; font-weight: 600; }
.alt-action { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 12px; margin-top: 4px; }
.qtn-no-row { display: grid; grid-template-columns: 1fr 110px; gap: 10px; }

/* visits */
.visit-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 10px; }
.visit-card { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; background: var(--surface); border-left: 4px solid var(--line-strong); }
.visit-card.result-rectified { border-left-color: #5aa330; }
.visit-card.result-revisit { border-left-color: #ee8a1c; }
.visit-card.result-need_parts { border-left-color: #a7713f; }
.visit-card.result-not_repairable { border-left-color: #cf5636; }
.visit-card header { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.visit-card header b { font: 700 1.02rem var(--font-c); }
.visit-who { display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; flex-wrap: wrap; font-size: 0.92rem; font-weight: 600; }
.visit-work { margin: 0; font-size: 0.94rem; white-space: pre-wrap; }
.visit-parts { margin: 8px 0 0; display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.result-tag { font: 700 0.76rem/1.3 var(--font); border-radius: 6px; padding: 2px 8px; background: var(--sunken); color: var(--ink-2); white-space: nowrap; }
.result-rectified { background: #e3f3d8; color: #285410; }
.result-revisit { background: #ffefd9; color: #83460a; }
.result-need_parts { background: #f2e9df; color: #5a3714; }
.result-not_repairable { background: #fbe6e0; color: #7a2410; }

/* activity (status history + comments), newest first */
.comment-box { display: flex; gap: 8px; align-items: flex-start; flex-wrap: wrap; margin: 0 0 14px; }
.comment-box .field { flex: 1 1 280px; margin: 0; }
.comment-box textarea { min-height: 44px; }
.comment-box .form-error { padding: 0; flex-basis: 100%; order: 3; }
.history { list-style: none; margin: 0 0 8px; padding: 0; }
.history > li { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.h-body { min-width: 0; }
.h-head { display: flex; flex-wrap: wrap; gap: 3px 10px; align-items: baseline; font-size: 0.84rem; color: var(--muted); }
.h-who { font-weight: 700; color: var(--ink); font-size: 0.92rem; }
.h-when { font-size: 0.8rem; }
.h-what { margin-top: 3px; }
.h-flow { display: inline-flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.h-arrow { color: var(--faint); }
.h-note { margin: 4px 0 0; color: var(--ink-2); font-size: 0.93rem; white-space: pre-wrap; }
.h-note.is-comment { background: var(--bg); border-radius: 4px 12px 12px 12px; padding: 9px 13px; margin-top: 6px; color: var(--ink); font-size: 0.96rem; }
.h-visit-head { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.h-kv { margin-top: 6px; max-width: 540px; }
.h-kv dd { white-space: normal; overflow: visible; }
.h-kv .chips-list { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.how { font: 700 0.7rem/1.3 var(--font); border-radius: 5px; padding: 1px 7px; }
.how-auto { background: var(--sunken); color: var(--ink-2); }
.how-next { background: var(--accent-soft); color: #7a4c00; }
.how-manual { background: #fbe6e0; color: #7a2410; }

/* side: details, contact, job cards, parts, people, status aging */
.side { margin: 0; }
.side-row { padding: 9px 0; border-bottom: 1px solid var(--line); min-width: 0; }
.side-row dt { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.side-row dd { margin: 2px 0 0; font-weight: 600; font-size: 0.94rem; overflow-wrap: anywhere; }
.facts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 18px; }
.details-grid .side-row:has(.pre) { grid-column: 1 / -1; }
.contact-main { margin: 0; font-size: 1.02rem; }
.tel { font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.tel-list li { padding: 6px 0; }
.sub-h { font-size: 0.95rem; margin: 14px 0 6px; }
.parts-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.parts-table th { text-align: left; font-size: 0.78rem; color: var(--muted); font-weight: 600; padding: 4px 8px 6px 0; border-bottom: 1px solid var(--line); }
.parts-table td { padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-scroll .parts-table { min-width: 520px; }
.parts-edit li { display: flex; justify-content: space-between; gap: 10px; }
.people { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.people li { display: grid; grid-template-columns: 36px minmax(0, 1fr); gap: 10px; align-items: start; }
.people .inv { margin-top: 5px; }
.tag-owner { background: var(--ink); color: #fff; }
.tag-current { background: #e4ecff; color: #1e3a8a; }
.tag-member { background: var(--sunken); color: var(--ink-2); }
.tag-visit { background: var(--link-soft); color: var(--link-dark); }
.member-by { margin: 4px 0 0; }
.aging { list-style: none; margin: 0; padding: 0; display: grid; gap: 9px; }
.aging li { display: grid; gap: 4px; font-size: 0.86rem; }
.aging li.is-current .ag-label { font-weight: 700; }
.ag-label { display: flex; justify-content: space-between; }
.ag-bar { height: 8px; border-radius: 4px; overflow: hidden; display: block; }
.ag-bar span { display: block; height: 100%; border-radius: 4px; }
.ag-val { color: var(--muted); font-size: 0.8rem; }
.qtn-card { border-color: #cbbcf6; }
.kv.qtn-kv { grid-template-columns: 170px minmax(0, 1fr); gap: 7px 12px; }
.reg-btns { display: flex; flex-wrap: wrap; gap: 6px; }
.qtn-card .reg-btns { margin-top: 12px; }
.reg-error { margin: 10px 0 0; padding: 9px 12px; border: 1px solid #f2b8b4; border-radius: var(--r-sm); background: var(--alert-soft); color: #7a1510; font-weight: 600; font-size: 0.88rem; }
.reg-error p { margin: 0 0 8px; }

/* other jobs at the same branch (site-jobs.js): folded bars */
.site-jobs-wrap { display: grid; gap: 8px; margin: 0 0 14px; }
.site-jobs { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); }
.site-jobs > summary { list-style: none; cursor: pointer; display: flex; align-items: center; gap: 8px; min-height: 50px; padding: 10px 16px; font-weight: 700; }
.site-jobs > summary::-webkit-details-marker { display: none; }
.site-jobs > summary::after { content: ""; margin-left: auto; width: 8px; height: 8px; border-right: 2px solid var(--muted); border-bottom: 2px solid var(--muted); transform: rotate(45deg); transition: transform 0.15s; }
.site-jobs[open] > summary::after { transform: rotate(225deg); }
.site-jobs.quiet { background: transparent; border-style: dashed; }
.site-jobs.quiet > summary { color: var(--muted); font-weight: 600; font-size: 0.94rem; min-height: 44px; }
.sj-cards { list-style: none; margin: 0; padding: 0 12px 12px; display: grid; gap: 8px; }
.sj-cards > li { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
.sj-card { flex: 1 1 220px; display: grid; gap: 3px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); text-decoration: none; min-width: 0; }
.sj-card:hover { border-color: var(--ink); }
.sj-card.is-static, .sj-card.is-static:hover { border-color: var(--line); cursor: default; }
.sj-card-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.sj-card-main { font-size: 0.92rem; overflow-wrap: anywhere; }
.sj-machine { font-weight: 600; }
.sj-people, .sj-parts { font-size: 0.84rem; color: var(--muted); }
.sj-report { flex: none; }

/* Email Customer (email-customer.js) */
.dialog.email-panel { width: min(820px, calc(100vw - 24px)); }
.email-body { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.email-list { display: flex; flex-direction: column; gap: 8px; }
.email-item { text-align: left; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px; padding: 11px 13px; font: inherit; color: var(--ink); cursor: pointer; }
.email-item[aria-selected="true"] { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); font-weight: 700; }
.email-suggested { margin-left: 6px; }
.email-preview textarea { width: 100%; min-height: 240px; resize: vertical; }
.email-copy-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

@media (max-width: 1100px) { .case-grid { grid-template-columns: minmax(0, 1fr) 320px; } .facts-grid.details-grid { grid-template-columns: 1fr; } }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  .case-hero { margin: -18px -16px 12px; border-radius: 0; border-width: 0 0 1px; padding: 12px 16px 16px; }
  .case-top { flex-direction: column; gap: 12px; }
  .case-name h1 { font-size: 1.7rem; }
  .case-status { justify-items: stretch; max-width: none; min-width: 0; width: 100%; }
  .journey { margin-right: -16px; padding-right: 16px; }
  .journey li { flex-basis: 104px; }
  /* thumb zone: the next step sits just above the bottom menu */
  .case-actions { position: fixed; left: 0; right: 0; top: auto; bottom: calc(var(--tab-h) + var(--safe-b)); z-index: 24; margin: 0; padding: 10px 12px; background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); border-top: 1px solid var(--line); flex-wrap: nowrap; }
  .case-actions .next-btn, .case-actions #claim { flex: 1 1 auto; min-width: 0; min-height: 48px; }
  .case-actions .act-note { display: none; }
  .case-actions #email-customer { display: none; }
  .case-actions .btn { min-height: 48px; }
  .case-actions .menu { left: auto; right: 0; top: auto; bottom: calc(100% + 8px); }
  main:has(.case-actions) { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 110px); }
  .case-grid { grid-template-columns: minmax(0, 1fr); }
  .facts-grid { grid-template-columns: 1fr; }
  .email-body { grid-template-columns: 1fr; }
  .email-list { flex-direction: row; flex-wrap: wrap; }
  .sj-report { width: 100%; min-height: 40px; }
  .history > li { grid-template-columns: 30px minmax(0, 1fr); gap: 10px; }
  .h-kv { grid-template-columns: 56px minmax(0, 1fr); }
}

/* ---------- compact complaint header (office): name and buttons | journey | Due, Owner, Technician ---------- */
.case-head { display: grid; grid-template-columns: minmax(450px, 1fr) minmax(0, 1fr) auto; gap: 8px 24px; align-items: center; }
.case-head .case-id { margin: 0 0 6px; gap: 8px; }
.case-head .case-id .back { margin: 0 4px 0 0; min-height: 0; font-size: 0.86rem; }
.case-head .sr-big { font-size: 1rem; padding: 4px 8px; }
.case-head h1 { font-size: 1.55rem; }
.case-head .case-eq { margin: 2px 0 0; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.case-head .case-summary { display: inline; margin: 0 0 0 6px; font-weight: 500; color: var(--muted); -webkit-line-clamp: unset; }
.case-head .case-actions { position: static; background: none; padding: 0; margin: 12px 0 0; flex-wrap: nowrap; }
.case-head .case-actions .next-btn { min-width: 0; min-height: 40px; padding: 8px 18px; font-size: 0.94rem; }
.case-head .case-status { max-width: none; min-width: 0; align-self: start; }
.case-mid { min-width: 0; align-self: center; }
.case-mid .journey { margin: 0; padding: 0; border-top: 0; }
.case-mid .journey li { flex-basis: 96px; padding-right: 8px; }
.case-mid .journey b { font-size: 0.86rem; white-space: nowrap; }
.case-mid .journey .is-next b { white-space: normal; }
.case-mid .journey .is-now b { font-size: 0.92rem; }
.case-hero:has(.case-head) { padding: 14px 20px 16px; }
/* computers with room: the compact header stays in view while scrolling (buttons at the top, pinned) */
@media (min-width: 821px) and (min-height: 700px) { .case-hero:has(.case-head) { position: sticky; top: calc(var(--top-h) + var(--safe-t) + 8px); z-index: 12; box-shadow: 0 6px 16px -12px rgba(13, 27, 42, 0.35); } }
@media (max-width: 1250px) { .case-head { grid-template-columns: minmax(0, 1fr) auto; } .case-mid { grid-column: 1 / -1; grid-row: 2; } }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) {
  .case-head { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .case-mid, .case-head .case-status { grid-column: 1; grid-row: auto; }
  .case-head .case-eq { white-space: normal; }
  .case-head .case-actions { position: fixed; margin: 0; padding: 10px 12px; background: rgba(255, 255, 255, 0.96); }
  .case-head h1 { font-size: 1.5rem; }
}

/* parts choice after an approved quotation: two large cards */
.choice-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.choice-card { position: relative; border: 2px solid var(--line-strong); border-radius: var(--r); padding: 14px 16px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; background: var(--surface); }
.choice-card input { position: absolute; opacity: 0; pointer-events: none; }
.choice-card b { font: 700 1.1rem var(--font-c); }
.choice-card small { color: var(--muted); }
.choice-card:hover { border-color: var(--ink); }
.choice-card:has(input:checked) { border-color: var(--ink); background: var(--sunken); box-shadow: inset 0 0 0 1px var(--ink); }
.choice-card.ok:has(input:checked) { border-color: #2f8f3a; background: #e3f3d8; box-shadow: inset 0 0 0 1px #2f8f3a; }
.choice-card.no:has(input:checked) { border-color: var(--danger); background: var(--alert-soft); box-shadow: inset 0 0 0 1px var(--danger); }
.choice-card:has(input:focus-visible) { outline: 3px solid color-mix(in srgb, var(--link) 55%, transparent); outline-offset: 2px; }
/* quotation number not in the Register yet */
.qtn-missing-line { margin: 8px 0 0; padding: 9px 12px; border-radius: var(--r-sm); background: var(--accent-soft); border: 1px solid #f3d38f; color: #6b4300; font-weight: 600; font-size: 0.92rem; }
/* people on other jobs at the same branch */
.sj-person { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9rem; color: var(--ink-2); }
.sj-people { display: flex; flex-wrap: wrap; gap: 6px 14px; margin-top: 6px; }
.sj-parts { display: grid; gap: 2px; margin-top: 6px; }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) { .branch-work li a, .amc-cases li a, .sj-main a { display: inline-flex; align-items: center; min-height: 40px; } }
.menu .menu-phone { display: none; }
@media (max-width: 820px), (pointer: coarse) and (max-height: 500px) { .menu .menu-phone { display: block; } }
