/* Сервисен центар – main stylesheet */

:root {
    --bg: #f4f6f9;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --border: #e2e7ee;
    --border-strong: #cfd6e0;
    --text: #1c2530;
    --text-2: #4b5664;
    --muted: #6b7684;
    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-soft: #e8efff;
    --focus: #93b4ff;

    --green: #15803d;   --green-soft: #e6f6ec;
    --blue: #1d4ed8;    --blue-soft: #e8efff;
    --orange: #c2410c;  --orange-soft: #fff1e6;
    --red: #b91c1c;     --red-soft: #fdeceb;
    --gray: #5b6573;    --gray-soft: #eef1f4;
    --amber: #92400e;   --amber-soft: #fef3c7;
    --indigo: #3730a3;  --indigo-soft: #e0e7ff;

    --radius: 8px;
    --radius-sm: 6px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
    --sidebar-w: 248px;
    --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .5rem; line-height: 1.25; font-weight: 650; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; }
p { margin: 0 0 .75rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-green { color: var(--green); }
.strong { font-weight: 600; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.hidden { display: none !important; }
.icon { width: 18px; height: 18px; flex: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w);
    background: #0f1b2d;
    color: #c9d3e1;
    display: flex;
    flex-direction: column;
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 40;
    overflow-y: auto;
}
.sidebar-brand {
    display: flex; align-items: center; gap: .6rem;
    padding: 1.1rem 1.1rem;
    color: #fff; font-weight: 650; font-size: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--primary); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
}
.brand-mark .icon { width: 18px; height: 18px; }
.sidebar-nav { padding: .6rem .5rem; flex: 1; }
.nav-group {
    margin: 1rem .75rem .35rem;
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: #7f8ea3;
}
.nav-link {
    display: flex; align-items: center; gap: .7rem;
    padding: .55rem .75rem; margin: 1px 0;
    border-radius: var(--radius-sm);
    color: #c9d3e1; font-size: .93rem;
}
.nav-link:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav-link.active { background: var(--primary); color: #fff; }
.sidebar-footer {
    padding: .9rem 1.1rem; font-size: .85rem;
    border-top: 1px solid rgba(255, 255, 255, .08); color: #e5ebf3;
}
.sidebar-footer .muted { color: #8b99ad; }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: .75rem;
    height: 60px; padding: 0 1.5rem;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar-search {
    flex: 1; max-width: 520px;
    display: flex; align-items: center; gap: .5rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 999px; padding: 0 .9rem; color: var(--muted);
}
.topbar-search input {
    border: 0; background: transparent; outline: none;
    height: 38px; width: 100%; font: inherit; color: var(--text);
}
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.icon-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 999px;
    border: 0; background: transparent; color: var(--text-2); cursor: pointer;
    list-style: none;
}
.icon-btn:hover { background: var(--gray-soft); text-decoration: none; }
.icon-btn .icon { width: 20px; height: 20px; }
.icon-btn::-webkit-details-marker { display: none; }
.bell-count {
    position: absolute; top: 3px; right: 1px;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 999px; background: var(--red); color: #fff;
    font-size: .7rem; font-weight: 700; line-height: 18px; text-align: center;
}
.menu-toggle { display: none; }
.user-menu { position: relative; }
.user-menu-panel {
    position: absolute; right: 0; top: 46px; min-width: 230px;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .4rem;
}
.user-menu-head { padding: .5rem .6rem .6rem; display: flex; flex-direction: column; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.user-menu-panel a, .user-menu-panel button {
    display: flex; align-items: center; gap: .5rem; width: 100%;
    padding: .5rem .6rem; border: 0; background: none; border-radius: var(--radius-sm);
    color: var(--text); font: inherit; cursor: pointer; text-align: left;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--gray-soft); text-decoration: none; }

.content { padding: 1.5rem; max-width: 1400px; width: 100%; }

/* ---------- Page header ---------- */
.page-head {
    display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem;
    flex-wrap: wrap; margin-bottom: 1.25rem;
}
.page-head h1 { margin: 0; }
.page-head .subtitle { color: var(--muted); margin-top: .2rem; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.breadcrumb { font-size: .85rem; color: var(--muted); margin-bottom: .3rem; }
.breadcrumb a { color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
    min-height: 40px; padding: .45rem 1rem;
    border-radius: var(--radius-sm); border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text);
    font: inherit; font-weight: 550; cursor: pointer; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--surface); border-color: #efb4b0; color: var(--red); }
.btn-danger:hover { background: var(--red-soft); }
.btn-success { background: var(--green); border-color: var(--green); color: #fff; }
.btn-success:hover { background: #116430; }
.btn-ghost { border-color: transparent; background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { min-height: 32px; padding: .25rem .65rem; font-size: .88rem; }
.btn-lg { min-height: 48px; padding: .6rem 1.3rem; font-size: 1.02rem; }
.btn-block { width: 100%; }
.btn .icon { width: 17px; height: 17px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.link-btn { border: 0; background: none; color: var(--primary); cursor: pointer; font: inherit; padding: 0; }
.link-btn:hover { text-decoration: underline; }
.inline-form { display: inline; }

/* ---------- Cards ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 1.25rem;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: .75rem;
    padding: .85rem 1.1rem; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.card-header h2, .card-header h3 { margin: 0; font-size: 1rem; display: flex; align-items: center; gap: .5rem; }
.card-body { padding: 1.1rem; }
.card-body.flush { padding: 0; }
.card-footer { padding: .75rem 1.1rem; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }
.card-red { border-left: 4px solid var(--red); }
.card-orange { border-left: 4px solid var(--orange); }
.card-blue { border-left: 4px solid var(--blue); }

.grid { display: grid; gap: 1.25rem; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-sidebar { grid-template-columns: minmax(0, 1fr) 360px; }
/* Calendar: side panel only on wide screens, otherwise below the calendar. */
.grid-calendar { grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1560px) { .grid-calendar { grid-template-columns: minmax(0, 1fr) 360px; } }
.grid > .card { margin-bottom: 0; }
.stack > * + * { margin-top: 1.25rem; }

/* ---------- KPI tiles ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .9rem; margin-bottom: 1.25rem; }
.kpi {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: .9rem 1rem; box-shadow: var(--shadow); color: var(--text); display: block;
}
a.kpi:hover { border-color: var(--border-strong); text-decoration: none; }
.kpi-label { font-size: .82rem; color: var(--muted); }
.kpi-value { font-size: 1.65rem; font-weight: 700; line-height: 1.2; margin-top: .15rem; }
.kpi-sub { font-size: .8rem; color: var(--muted); }
.kpi-red .kpi-value { color: var(--red); }
.kpi-orange .kpi-value { color: var(--orange); }
.kpi-blue .kpi-value { color: var(--blue); }
.kpi-green .kpi-value { color: var(--green); }

/* ---------- Quick actions ---------- */
.quick-actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-bottom: 1.25rem; }

/* ---------- Badges & tags ---------- */
.badge {
    display: inline-flex; align-items: center; gap: .3rem;
    padding: .12rem .55rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-blue { background: var(--blue-soft); color: var(--blue); }
.badge-orange { background: var(--orange-soft); color: var(--orange); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-gray { background: var(--gray-soft); color: var(--gray); }
.tag {
    display: inline-block; padding: 0 .38rem; border-radius: 4px;
    font-size: .7rem; font-weight: 700; letter-spacing: .02em; vertical-align: 1px;
}
.tag-company { background: var(--indigo-soft); color: var(--indigo); }
.tag-external { background: var(--amber-soft); color: var(--amber); }
.priority-urgent { color: var(--red); font-weight: 700; }
.priority-high { color: var(--orange); font-weight: 600; }
.row-urgent { background: #fff7f6; }
.row-urgent td:first-child { box-shadow: inset 3px 0 0 var(--red); }

/* ---------- Alerts ---------- */
.alert {
    padding: .75rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem;
    border: 1px solid transparent; display: flex; gap: .6rem; align-items: flex-start;
}
.alert-success { background: var(--green-soft); border-color: #b9e4c7; color: #0f5a2b; }
.alert-error { background: var(--red-soft); border-color: #f3c1bd; color: #8a1616; }
.alert-warning { background: var(--orange-soft); border-color: #fbd0b1; color: #8a300a; }
.alert-info { background: var(--blue-soft); border-color: #c4d5fb; color: #173a9e; }
.alert .icon { margin-top: 2px; }
.alert-strong { font-weight: 600; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th {
    text-align: left; font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
    color: var(--muted); background: var(--surface-2);
    padding: .6rem .9rem; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.table td { padding: .65rem .9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #fafbfd; }
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 700; background: var(--surface-2); border-top: 1px solid var(--border-strong); }
.table-compact td, .table-compact th { padding: .45rem .7rem; }
.cell-main { font-weight: 600; color: var(--text); }
.cell-sub { font-size: .82rem; color: var(--muted); }
.table a.cell-main:hover { color: var(--primary); }

/* ---------- Filters ---------- */
.filters { display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end; margin-bottom: 1rem; }
.filters .field { margin: 0; min-width: 150px; }
.filters .field-grow { flex: 1; min-width: 200px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; background: var(--surface); }
.segmented a { padding: .45rem .85rem; color: var(--text-2); font-size: .9rem; border-left: 1px solid var(--border); }
.segmented a:first-child { border-left: 0; }
.segmented a:hover { background: var(--surface-2); text-decoration: none; }
.segmented a.active { background: var(--primary); color: #fff; }

/* ---------- Forms ---------- */
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1.25rem; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
.field { margin-bottom: 1rem; }
.field label, .field-label { display: block; font-weight: 600; font-size: .88rem; margin-bottom: .3rem; color: var(--text); }
.field .req { color: var(--red); }
.input, select.input, textarea.input {
    width: 100%; min-height: 40px; padding: .45rem .7rem;
    border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: #fff; color: var(--text); font: inherit;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.input.is-invalid, .is-invalid .input { border-color: var(--red); }
.input-lg { min-height: 52px; font-size: 1.15rem; }
.field-error { color: var(--red); font-size: .84rem; margin-top: .25rem; }
.help { color: var(--muted); font-size: .83rem; margin-top: .25rem; }
.check { display: flex; align-items: flex-start; gap: .55rem; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; margin-top: 2px; flex: none; }
.check-list { display: grid; gap: .45rem; }
.form-actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .5rem; }
.form-actions .spacer { flex: 1; }
.fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem .2rem; margin: 0 0 1rem; }
.fieldset legend { font-weight: 650; padding: 0 .4rem; }
.confirm-box { background: var(--orange-soft); border: 1px solid #fbd0b1; border-radius: var(--radius-sm); padding: .75rem .9rem; margin-bottom: 1rem; }

/* ---------- Line editor (work order) ---------- */
.lines { width: 100%; border-collapse: collapse; }
.lines th { font-size: .78rem; color: var(--muted); text-align: left; font-weight: 600; padding: .3rem .35rem; white-space: nowrap; }
.lines td { padding: .25rem .35rem; vertical-align: top; }
.lines .input { min-height: 38px; }
.lines .col-qty { width: 90px; }
.lines .col-price { width: 130px; }
.lines .col-total { width: 130px; text-align: right; font-weight: 600; padding-top: .6rem; white-space: nowrap; }
.lines .col-remove { width: 44px; }
.totals { margin-left: auto; max-width: 360px; }
.totals-row { display: flex; justify-content: space-between; padding: .35rem 0; border-bottom: 1px solid var(--border); }
.totals-row.grand { font-size: 1.15rem; font-weight: 700; border-bottom: 0; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: .15rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a {
    padding: .65rem .8rem; color: var(--text-2); font-weight: 550; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs .count { font-size: .75rem; background: var(--gray-soft); color: var(--gray); border-radius: 999px; padding: 0 .45rem; margin-left: .3rem; }

/* ---------- Detail lists ---------- */
.details { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .9rem 1.25rem; margin: 0; }
.details dt { font-size: .8rem; color: var(--muted); }
.details dd { margin: .1rem 0 0; font-weight: 550; word-break: break-word; }

/* ---------- Simple rows list (dashboard) ---------- */
.rows { list-style: none; margin: 0; padding: 0; }
.rows li { display: flex; gap: .75rem; align-items: center; padding: .7rem 1.1rem; border-bottom: 1px solid var(--border); }
.rows li:last-child { border-bottom: 0; }
.rows .row-main { flex: 1; min-width: 0; }
.rows .row-title { font-weight: 600; }
.rows .row-sub { font-size: .84rem; color: var(--muted); }
.rows .row-side { text-align: right; white-space: nowrap; font-size: .88rem; }
.time-chip { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 48px; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 2rem 1rem; color: var(--muted); }
.empty p { margin-bottom: .9rem; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: .3rem; align-items: center; justify-content: space-between; flex-wrap: wrap; padding: .75rem 1.1rem; border-top: 1px solid var(--border); font-size: .88rem; color: var(--muted); }
.pagination .pages { display: flex; gap: .3rem; }
.pagination a, .pagination span.current {
    min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0 .5rem; color: var(--text-2); background: var(--surface);
}
.pagination span.current { background: var(--primary); border-color: var(--primary); color: #fff; }
.pagination a:hover { background: var(--surface-2); text-decoration: none; }

/* ---------- Timeline (history) ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 1.25rem 1.6rem; border-left: 2px solid var(--border); margin-left: .45rem; }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
    content: ""; position: absolute; left: -7px; top: .25rem;
    width: 12px; height: 12px; border-radius: 50%; background: var(--primary); border: 2px solid #fff; box-shadow: 0 0 0 1px var(--primary);
}
.timeline li.historical::before { background: var(--gray); box-shadow: 0 0 0 1px var(--gray); }
.timeline-date { font-weight: 700; }
.timeline-meta { color: var(--muted); font-size: .88rem; }

/* ---------- Calendar ---------- */
.cal-toolbar { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-bottom: 1rem; }
.cal-title { font-size: 1.15rem; font-weight: 650; margin: 0 .5rem; min-width: 180px; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); }
.cal-dow { padding: .45rem .5rem; font-size: .75rem; text-transform: uppercase; color: var(--muted); font-weight: 600; background: var(--surface-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); }
.cal-cell { min-height: 118px; padding: .3rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--surface); position: relative; }
.cal-cell.other { background: var(--surface-2); }
.cal-cell.other .cal-daynum { color: #a3acb8; }
.cal-cell.today { background: #f5f8ff; }
.cal-cell.today .cal-daynum { background: var(--primary); color: #fff; }
.cal-daynum {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 26px; height: 26px; border-radius: 999px; font-size: .85rem; font-weight: 600; color: var(--text-2);
}
.cal-add { position: absolute; top: .35rem; right: .35rem; opacity: 0; color: var(--muted); width: 24px; height: 24px; display: inline-flex; align-items: center; justify-content: center; border-radius: 4px; }
.cal-cell:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--gray-soft); }
.cal-add .icon { width: 15px; height: 15px; }
.cal-event {
    display: block; margin-top: 3px; padding: 2px 6px; border-radius: 4px;
    font-size: .78rem; line-height: 1.35; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    border-left: 3px solid var(--blue); background: var(--blue-soft);
}
.cal-event:hover { text-decoration: none; filter: brightness(.97); }
.cal-event.st-in_service { border-left-color: var(--orange); background: var(--orange-soft); }
.cal-event.st-completed { border-left-color: var(--green); background: var(--green-soft); }
.cal-event.st-no_show { border-left-color: var(--red); background: var(--red-soft); }
.cal-event.st-cancelled { border-left-color: var(--gray); background: var(--gray-soft); text-decoration: line-through; }
.cal-more { font-size: .75rem; color: var(--muted); padding: 2px 6px; display: block; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .6rem; }
.cal-week-day { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); min-height: 200px; display: flex; flex-direction: column; }
.cal-week-day.today { border-color: var(--primary); box-shadow: 0 0 0 1px var(--primary); }
.cal-week-head { padding: .5rem .6rem; border-bottom: 1px solid var(--border); font-weight: 650; font-size: .88rem; display: flex; justify-content: space-between; align-items: center; }
.cal-week-body { padding: .4rem; flex: 1; }
.cal-week-body .cal-event { white-space: normal; padding: 4px 7px; margin-top: 5px; }
.legend { display: flex; gap: 1rem; flex-wrap: wrap; font-size: .82rem; color: var(--muted); margin-top: .75rem; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .35rem; vertical-align: -1px; }
.legend .l-scheduled::before { background: var(--blue); }
.legend .l-in_service::before { background: var(--orange); }
.legend .l-completed::before { background: var(--green); }
.legend .l-no_show::before { background: var(--red); }
.legend .l-cancelled::before { background: var(--gray); }

/* ---------- Guest pages ---------- */
body.guest { background: linear-gradient(160deg, #0f1b2d 0%, #1d3a6e 100%); }
.guest-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.guest-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 12px; padding: 2rem; box-shadow: var(--shadow-lg); }
.guest-card-wide { max-width: 620px; }
.guest-brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 1.5rem; }
.guest-card h1 { font-size: 1.3rem; }

/* ---------- Misc ---------- */
.error-page { text-align: center; padding: 3rem 1rem; }
.error-code { font-size: 3.5rem; font-weight: 800; color: var(--border-strong); line-height: 1; }
.error-detail { text-align: left; background: #111; color: #eee; padding: 1rem; border-radius: 6px; overflow: auto; font-size: .8rem; max-width: 900px; margin: 1rem auto; }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .9rem; }
.doc {
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface);
    display: flex; flex-direction: column;
}
.doc-thumb { height: 120px; background: var(--surface-2); display: flex; align-items: center; justify-content: center; color: var(--muted); overflow: hidden; }
.doc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.doc-thumb .icon { width: 40px; height: 40px; }
.doc-body { padding: .5rem .6rem; font-size: .82rem; flex: 1; }
.doc-name { font-weight: 600; word-break: break-word; }
.doc-actions { display: flex; gap: .25rem; padding: 0 .5rem .5rem; }
.upload-box { border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 1rem; background: var(--surface-2); }
.preview-list { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .6rem; }
.preview-list img { width: 72px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.preview-list .file-chip { font-size: .8rem; padding: .3rem .6rem; background: var(--surface); border: 1px solid var(--border); border-radius: 999px; }
.status-steps { display: flex; gap: .4rem; flex-wrap: wrap; }
.code { font-family: Consolas, "Courier New", monospace; font-size: .85rem; background: var(--gray-soft); padding: .1rem .4rem; border-radius: 4px; }
pre.mail-preview { white-space: pre-wrap; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem; font-family: Consolas, "Courier New", monospace; font-size: .82rem; max-height: 420px; overflow: auto; }
.changes { margin: 0; padding: 0; list-style: none; font-size: .85rem; }
.changes li { margin-bottom: .15rem; }
.changes .old { color: var(--red); text-decoration: line-through; }
.changes .new { color: var(--green); }
.matrix th, .matrix td { text-align: center; }
.matrix th:first-child, .matrix td:first-child { text-align: left; }

/* ---------- Responsive ---------- */
@media (max-width: 1180px) {
    .grid-sidebar { grid-template-columns: minmax(0, 1fr); }
    .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15, 27, 45, .45); z-index: 35; }
    .main { margin-left: 0; }
    .menu-toggle { display: inline-flex; }
    .cal-week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
    body { font-size: 16px; }
    .content { padding: 1rem; }
    .topbar { padding: 0 .75rem; gap: .4rem; }
    .grid-2, .grid-3, .form-grid, .form-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .form-grid .span-2 { grid-column: auto; }
    .page-head { flex-direction: column; }
    .page-actions { width: 100%; }
    .page-actions .btn { flex: 1; }
    .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .btn { min-height: 44px; }
    .input { min-height: 44px; font-size: 16px; }
    .quick-actions { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
    .quick-actions .btn { font-size: .88rem; padding: .4rem .5rem; white-space: normal; text-align: center; }
    .quick-actions .btn:first-child { grid-column: 1 / -1; }
    .cal-week { grid-template-columns: minmax(0, 1fr); }
    .cal-cell { min-height: 64px; padding: .15rem; }
    .cal-event { font-size: 0; height: 7px; padding: 0; margin-top: 2px; border-left-width: 0; background: var(--blue); }
    .cal-event.st-in_service { background: var(--orange); }
    .cal-event.st-completed { background: var(--green); }
    .cal-event.st-no_show { background: var(--red); }
    .cal-event.st-cancelled { background: var(--gray); }
    .cal-more { display: none; }
    .cal-add { display: none; }

    /* Tables become stacked cards on phones */
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tr { border-bottom: 1px solid var(--border); padding: .6rem .9rem; }
    .table-cards td { border: 0; padding: .15rem 0; }
    .table-cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: .82rem; }
    .table-cards td.num { text-align: left; }
    .table-cards td.hide-mobile { display: none; }
    .table-cards tfoot { display: block; }

    .lines thead { display: none; }
    .lines, .lines tbody, .lines tr, .lines td { display: block; width: 100% !important; }
    .lines tr { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .5rem; margin-bottom: .6rem; position: relative; }
    .lines td { padding: .2rem 0; }
    .lines td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--muted); }
    .lines .col-total { text-align: left; }
    .lines .col-remove { position: absolute; top: .3rem; right: .3rem; width: auto !important; }
    .totals { max-width: none; }
}

/* ---------- Print ---------- */
@media print {
    .sidebar, .topbar, .page-actions, .no-print, .alert { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; font-size: 12px; }
    .card { box-shadow: none; border-color: #bbb; break-inside: avoid; }
}
