:root {
    --fm-pink: #b82d61;
    --fm-pink-dark: #a52555;
    --fm-pink-soft: #f0a8c1;
    --fm-pink-pale: #fff0f5;
    --fm-ink: #26211f;
    --fm-ink-soft: #514944;
    --fm-muted: #6b605a;
    --fm-canvas: #f5f1ed;
    --fm-surface: #fffdfb;
    --fm-line: #e5ddd7;
    --fm-green: #246a48;
    --fm-green-pale: #e8f6ee;
    --fm-amber: #80500c;
    --fm-amber-pale: #fff4df;
    --fm-blue: #256479;
    --fm-blue-pale: #e9f5f8;
    --fm-red: #b03f4c;
    --fm-red-pale: #fdecee;
    --fm-shadow-sm: 0 7px 24px rgba(45, 35, 30, .055);
    --fm-shadow-lg: 0 20px 60px rgba(45, 35, 30, .13);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--fm-ink);
    background: var(--fm-canvas);
    font-synthesis: none;
}

* { box-sizing: border-box; }
html { min-height:100%; background:var(--fm-canvas); scroll-padding-block:100px; -webkit-text-size-adjust:100%; }
body { min-height: 100%; margin: 0; color: var(--fm-ink); background: var(--fm-canvas); -webkit-font-smoothing: antialiased; }
button, input, textarea, select { font: inherit; }
a { color: var(--fm-pink-dark); }
h1, h2, h3, p { margin-top: 0; }
h1:focus, main:focus { outline:none; }
:focus-visible { outline:3px solid #176d92; outline-offset:3px; }
button, a, input, textarea, select, summary { scroll-margin-block:110px; }
.skip-link { position:fixed; left:12px; top:12px; z-index:3000; transform:translateY(-160%); padding:12px 18px; border-radius:8px; background:#fff; color:#26211f; font-weight:800; }
.skip-link:focus { transform:none; }
summary { cursor:pointer; min-height:44px; padding-block:10px; font-weight:700; }
.sr-only { position:absolute; width:1px; height:1px; padding:0; margin:-1px; overflow:hidden; clip-path:inset(50%); white-space:nowrap; border:0; }

.app-version {
    display: block;
    color: #8f8580;
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .04em;
    line-height: 1.2;
    white-space: nowrap;
}

.app-version-sidebar {
    margin: 12px 13px 0;
}

.app-version-anonymous {
    position: fixed;
    left: 16px;
    bottom: 12px;
    z-index: 20;
    color: #756b66;
}

.page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-heading h1 { margin: 0; font-size: clamp(1.65rem, 2.4vw, 2.25rem); letter-spacing: -.045em; line-height: 1.05; font-weight: 820; }
.page-heading p { max-width: 680px; margin: 9px 0 0; color: var(--fm-muted); font-size: .9rem; line-height: 1.55; }
.page-eyebrow { display: block; margin-bottom: 8px; color: var(--fm-pink-dark); font-size: .68rem; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.heading-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.fm-button,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-outline-secondary {
    min-height: 44px;
    padding: 10px 17px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid transparent;
    border-radius: 11px;
    color: #fff;
    background: var(--fm-pink);
    font-size: .94rem;
    font-weight: 760;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
}

.fm-button:hover, .btn-primary:hover { color: #fff; background: var(--fm-pink-dark); transform: translateY(-1px); box-shadow: 0 7px 20px rgba(165,37,85,.18); }
.fm-button.secondary, .btn-secondary, .btn-outline-secondary { color: var(--fm-ink-soft); background: #fff; border-color: var(--fm-line); }
.fm-button.secondary:hover, .btn-secondary:hover, .btn-outline-secondary:hover { color: var(--fm-ink); background: #faf6f3; border-color: #d1c5bd; box-shadow: none; }
.fm-button.small { min-height:44px; padding:8px 12px; border-radius:9px; font-size:.875rem; }
.fm-button.ghost { color: var(--fm-pink-dark); background: transparent; }
.fm-button.ghost:hover { background: var(--fm-pink-pale); box-shadow: none; }
.fm-button:disabled, button:disabled { opacity: .52; pointer-events: none; }
.fm-button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.metric-grid { display: grid; grid-template-columns: repeat(5, minmax(150px, 1fr)); gap: 14px; margin-bottom: 28px; }
.metric-card { position: relative; min-height: 126px; padding: 20px; overflow: hidden; border: 1px solid var(--fm-line); border-radius: 16px; background: var(--fm-surface); box-shadow: var(--fm-shadow-sm); }
.metric-card::after { content: ''; position: absolute; width: 70px; height: 70px; right: -28px; top: -27px; border-radius: 50%; background: var(--metric-tint, var(--fm-pink-pale)); }
.metric-label { display: block; padding-right: 20px; color: var(--fm-muted); font-size: .73rem; font-weight: 730; line-height: 1.3; }
.metric-value { display: block; margin-top: 12px; font-size: 2rem; font-weight: 830; letter-spacing: -.055em; }
.metric-foot { display: flex; align-items: center; gap: 6px; margin-top: 6px; color: var(--fm-muted); font-size: .67rem; }
.metric-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--metric-color, var(--fm-pink)); }

.dashboard-grid { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, .78fr); gap: 20px; align-items: start; }
.stack { display: grid; gap: 20px; }
.panel { border: 1px solid var(--fm-line); border-radius: 17px; background: var(--fm-surface); box-shadow: var(--fm-shadow-sm); overflow: hidden; }
.panel-header { min-height:66px; padding:16px 20px; display:flex; align-items:center; justify-content:space-between; flex-wrap:wrap; gap:12px; border-bottom:1px solid var(--fm-line); }
.panel-header h2, .panel-header h3 { margin: 0; font-size: .98rem; font-weight: 800; letter-spacing: -.02em; }
.panel-header p { margin: 3px 0 0; color: var(--fm-muted); font-size: .7rem; }
.panel-body { padding: 20px; }
.panel-body.flush { padding: 0; }

.order-list { display: grid; }
.order-row { min-height: 74px; padding: 13px 20px; display: grid; grid-template-columns: 124px minmax(175px, 1.15fr) minmax(150px, 1fr) 145px 46px; align-items: center; gap: 14px; color: inherit; border-bottom: 1px solid #eee7e2; text-decoration: none; transition: background .14s ease; }
.order-row:last-child { border-bottom: 0; }
.order-row:hover { color: inherit; background: #fcf8f6; }
.order-number { color: var(--fm-pink-dark); font-size: .76rem; font-weight: 850; font-variant-numeric: tabular-nums; }
.order-person strong, .device-summary strong { display: block; overflow: hidden; color: var(--fm-ink); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.order-person small, .device-summary small, .order-time small { display: block; margin-top: 4px; overflow: hidden; color: var(--fm-muted); font-size: .68rem; text-overflow: ellipsis; white-space: nowrap; }
.row-chevron { width: 31px; height: 31px; display: grid; place-items: center; justify-self: end; border: 1px solid var(--fm-line); border-radius: 9px; color: var(--fm-muted); background: #fff; }

.status-badge { width: fit-content; min-height: 27px; padding: 0 9px; display: inline-flex; align-items: center; gap: 6px; border-radius: 99px; color: var(--fm-ink-soft); background: #f1ece8; font-size: .64rem; font-weight: 800; white-space: nowrap; }
.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .72; }
.status-badge.ready, .status-badge.collected { color: var(--fm-green); background: var(--fm-green-pale); }
.status-badge.waiting, .status-badge.awaiting-approval, .status-badge.awaiting-parts { color: var(--fm-amber); background: var(--fm-amber-pale); }
.status-badge.repair, .status-badge.diagnosing, .status-badge.quality-check { color: var(--fm-blue); background: var(--fm-blue-pale); }
.status-badge.cancelled { color: var(--fm-red); background: var(--fm-red-pale); }

.quick-actions { display: grid; gap: 10px; }
.quick-action { min-height: 66px; padding: 11px 13px; display: flex; align-items: center; gap: 12px; border: 1px solid var(--fm-line); border-radius: 13px; color: var(--fm-ink); background: #fff; text-decoration: none; transition: .15s ease; }
.quick-action:hover { color: var(--fm-ink); border-color: #e8a9bf; background: var(--fm-pink-pale); transform: translateY(-1px); }
.quick-action-icon { width: 39px; height: 39px; display: grid; place-items: center; flex: 0 0 auto; border-radius: 11px; color: var(--fm-pink-dark); background: var(--fm-pink-pale); font-size: 1.08rem; }
.quick-action strong { display: block; font-size: .78rem; }
.quick-action small { display: block; margin-top: 3px; color: var(--fm-muted); font-size: .65rem; }

.filters { margin-bottom: 16px; padding: 12px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; border: 1px solid var(--fm-line); border-radius: 14px; background: var(--fm-surface); }
.search-box { position: relative; flex: 1 1 280px; }
.search-box input { padding-left: 38px; }
.search-box::before { content: '⌕'; position: absolute; left: 14px; top: 50%; z-index: 1; color: var(--fm-muted); font-size: 1.2rem; transform: translateY(-54%); }

.form-control, .form-select, input:not([type]), input[type="text"], input[type="password"], input[type="email"], input[type="tel"], input[type="search"], input[type="number"], input[type="date"], input[type="datetime-local"], textarea, select {
    min-height: 44px;
    width: 100%;
    padding: 10px 13px;
    border: 1px solid #93877f;
    border-radius: 10px;
    color: var(--fm-ink);
    background: #fff;
    font-size: 1rem;
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea { min-height: 104px; resize: vertical; }
.search-box input[type], .search-box input:not([type]) { padding-left:38px; }
.form-control:focus, .form-select:focus, input:focus, textarea:focus, select:focus { border-color:#176d92; outline:2px solid #176d92; outline-offset:2px; box-shadow:none; }
.form-label, label.field-label { display: block; margin: 0 0 7px; color: var(--fm-ink-soft); font-size: .72rem; font-weight: 760; }
.field-help { display: block; margin-top: 6px; color: var(--fm-muted); font-size: .66rem; line-height: 1.45; }
.field-hint { display: block; margin-top: 7px; color: var(--fm-amber); font-size: .68rem; line-height: 1.45; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 17px; }
.form-grid .full { grid-column: 1 / -1; }
.input-group-inline { display: flex; gap: 10px; }

.wizard-shell { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 20px; align-items: start; }
.wizard-steps { position: sticky; top: 96px; padding: 12px; border: 1px solid var(--fm-line); border-radius: 16px; background: var(--fm-surface); }
.wizard-step { min-height: 54px; padding: 9px; display: flex; align-items: center; gap: 11px; border-radius: 11px; color: var(--fm-muted); }
.wizard-step-number { width: 29px; height: 29px; display: grid; place-items: center; flex: 0 0 auto; border: 1px solid var(--fm-line); border-radius: 9px; background: #faf7f4; font-size: .68rem; font-weight: 850; }
.wizard-step strong { display: block; color: inherit; font-size: .73rem; }
.wizard-step small { display: block; margin-top: 2px; font-size: .59rem; }
.wizard-step.active { color: var(--fm-pink-dark); background: var(--fm-pink-pale); }
.wizard-step.active .wizard-step-number { color: #fff; border-color: var(--fm-pink); background: var(--fm-pink); }
.wizard-step.complete { color: var(--fm-green); }
.wizard-card { min-height: 480px; padding: 26px; border: 1px solid var(--fm-line); border-radius: 17px; background: var(--fm-surface); box-shadow: var(--fm-shadow-sm); }
.wizard-card h2 { margin-bottom: 7px; font-size: 1.18rem; letter-spacing: -.025em; }
.wizard-card > p { margin-bottom: 24px; color: var(--fm-muted); font-size: .8rem; line-height: 1.55; }
.wizard-actions { margin-top: 25px; padding-top: 18px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-top: 1px solid var(--fm-line); }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(300px, .62fr); gap: 20px; align-items: start; }
.definition-list { display: grid; gap: 0; }
.definition-row { padding: 12px 0; display: flex; justify-content: space-between; gap: 20px; border-bottom: 1px solid #eee7e2; }
.definition-row:last-child { border-bottom: 0; }
.definition-row dt { color: var(--fm-muted); font-size: .71rem; font-weight: 650; }
.definition-row dd { margin: 0; color: var(--fm-ink); font-size: .75rem; font-weight: 750; text-align: right; }
.timeline { display: grid; }
.timeline-item { position: relative; padding: 0 0 19px 28px; }
.timeline-item::before { content: ''; position: absolute; left: 7px; top: 7px; bottom: -4px; width: 1px; background: var(--fm-line); }
.timeline-item:last-child::before { display: none; }
.timeline-dot { position: absolute; left: 2px; top: 3px; width: 11px; height: 11px; border: 2px solid #fff; border-radius: 50%; background: var(--fm-pink); box-shadow: 0 0 0 1px #dfa0b7; }
.timeline-item strong { display: block; font-size: .75rem; }
.timeline-item p { margin: 4px 0 0; color: var(--fm-muted); font-size: .69rem; line-height: 1.5; }
.timeline-item time { display:block; margin-top:4px; color:var(--fm-muted); font-size:.8rem; }

.empty-state { min-height: 220px; padding: 35px; display: grid; place-items: center; text-align: center; }
.empty-state-icon { width: 52px; height: 52px; margin: 0 auto 13px; display: grid; place-items: center; border-radius: 15px; color: var(--fm-pink-dark); background: var(--fm-pink-pale); font-size: 1.35rem; }
.empty-state h3 { margin: 0 0 7px; font-size: .9rem; }
.empty-state p { max-width: 380px; margin: 0 auto 16px; color: var(--fm-muted); font-size: .74rem; line-height: 1.5; }

.alert { padding: 13px 15px; border: 1px solid #efc3d2; border-radius: 11px; color: #7e2648; background: #fff2f6; font-size: .77rem; }
.alert-success { border-color: #bfe0cd; color: #256a49; background: #eff9f3; }
.validation-message, .text-danger { color: var(--fm-red); font-size: .69rem; }
.valid.modified:not([type=checkbox]) { border-color: #58a97d; }
.invalid { border-color: #cf5965 !important; }
.darker-border-checkbox.form-check-input { border-color: #929292; }
.blazor-error-boundary { padding: 1rem; border-radius: 10px; color: #fff; background: #9d2d3a; }
.blazor-error-boundary::after { content: "Ett fel inträffade."; }

@media (max-width: 1220px) {
    .metric-grid { grid-template-columns: repeat(3, 1fr); }
    .order-row { grid-template-columns: 112px minmax(160px, 1fr) minmax(130px, .85fr) 135px 34px; }
}

@media (max-width: 900px) {
    .dashboard-grid, .detail-grid { grid-template-columns: 1fr; }
    .wizard-shell { grid-template-columns: 1fr; }
    .wizard-steps { position: static; display: grid; grid-template-columns: repeat(5, 1fr); overflow-x: auto; }
    .wizard-step { min-width: 100px; flex-direction: column; text-align: center; }
    .wizard-step small { display: none; }
    .order-row { grid-template-columns: 108px 1fr 135px 30px; }
    .order-row .device-summary { grid-column:2; grid-row:2; }
}

@media (max-width: 620px) {
    .page-heading { align-items: flex-start; flex-direction: column; margin-bottom: 21px; }
    .heading-actions, .heading-actions .fm-button { width: 100%; }
    .metric-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .metric-card { min-height: 108px; padding: 16px; }
    .metric-value { font-size: 1.65rem; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .full { grid-column: auto; }
    .wizard-card { padding: 19px 16px; }
    .wizard-steps { grid-template-columns: repeat(5, 96px); margin: 0 -16px; border-radius: 0; border-inline: 0; }
    .order-row { min-height: 83px; padding: 13px 15px; grid-template-columns: 1fr auto; gap: 7px 12px; }
    .order-number { grid-column: 1; }
    .order-person { grid-column: 1; }
    .order-row .device-summary { grid-column:1; grid-row:auto; }
    .order-time { grid-column:1; }
    .order-row .status-badge { grid-column: 2; grid-row: 1 / span 2; }
    .row-chevron { display: none; }
    .panel-header { padding-inline: 16px; }
}

/* Shared readable defaults; page components can still establish hierarchy. */
.form-label, label.field-label, .field-help, .field-hint, .panel-header p,
.metric-label, .metric-foot, .quick-action small, .definition-row dt,
.timeline-item p, .empty-state p, .validation-message, .text-danger { font-size:.875rem; line-height:1.5; }
.order-number, .order-person strong, .device-summary strong, .quick-action strong,
.definition-row dd, .timeline-item strong, .alert { font-size:.95rem; }
.order-person small, .device-summary small, .order-time small { font-size:.85rem; }
.status-badge { min-height:30px; font-size:.8rem; }
.definition-row dt, .definition-row dd, .order-person, .device-summary, .stack, .panel, .form-grid > * { min-width:0; }
.definition-row dd { overflow-wrap:anywhere; }
.order-person strong, .order-person small, .device-summary strong, .device-summary small { white-space:normal; overflow-wrap:anywhere; }
.filters select { max-width:100%; }
.input-group-inline { flex-wrap:wrap; }
input[type="checkbox"], input[type="radio"] { width:20px; height:20px; flex:0 0 auto; accent-color:var(--fm-pink); }
label:has(> input[type="checkbox"]), label:has(> input[type="radio"]) { min-height:44px; display:flex; align-items:center; gap:9px; }
@media(max-width:720px) {
    .fm-button, .btn-primary, .btn-secondary, .fm-button.small { min-height:46px; }
    .panel-body { padding:16px; }
    .filters { align-items:stretch; }
    .filters select, .filters .search-box { flex:1 1 100%; }
    .wizard-step, .wizard-step strong { min-width:0; }
    .page-heading p { font-size:1rem; }
    .definition-row { gap:12px; }
    .order-row .status-badge { max-width:145px; white-space:normal; }
}
@media(prefers-reduced-motion:reduce) {
    *, *::before, *::after { scroll-behavior:auto !important; transition:none !important; }
    .fm-button:hover, .quick-action:hover { transform:none; }
}
