/* =============================================================================
   Saleh Group Platform: one stylesheet for English (LTR) and Arabic (RTL).
   Layout uses logical properties (inline-start/end). Brand colours in :root.
   No inline styles are used anywhere (the security policy blocks them).
   ========================================================================== */

:root {
    --navy:        #0a2a4d;
    --navy-2:      #0d3d70;
    --blue:        #0b63b6;
    --blue-dark:   #084f92;
    --blue-light:  #29a9f0;
    --text:        #1c2733;
    --muted:       #5f6b7a;
    --bg:          #f3f6f9;
    --surface:     #ffffff;
    --border:      #e1e7ee;
    --success:     #1f7a4d;
    --success-bg:  #e7f5ee;
    --error:       #b3261e;
    --error-bg:    #fdecea;
    --warning:     #8a5a00;
    --warning-bg:  #fff4dc;
    --info-bg:     #e8f3fd;

    --radius:      12px;
    --shadow:      0 4px 18px rgba(10, 42, 77, .07);
    --sidebar-w:   250px;
    --topbar-h:    64px;
    --font:        "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
:root[lang="ar"] { --font: "Cairo", "Segoe UI", Tahoma, 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.6; color: var(--text); background: var(--bg); }
a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }
h1, h2, h3 { color: var(--navy); line-height: 1.3; margin: 0 0 .5em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }
p { margin: 0 0 .8em; }
img { max-width: 100%; }
:focus-visible { outline: 3px solid var(--blue-light); outline-offset: 2px; border-radius: 4px; }
.icon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; inset-inline-start: 12px; top: -60px; z-index: 300; background: var(--blue); color: #fff; padding: 8px 14px; border-radius: 8px; }
.skip-link:focus { top: 10px; color: #fff; }

/* ---------- Buttons & links ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .45em;
    padding: .6em 1.15em; border-radius: 10px; border: 1px solid transparent;
    font: inherit; font-weight: 600; line-height: 1.4; cursor: pointer; text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}
.btn-primary { background: var(--blue); color: #fff; }
.btn-primary:hover { background: var(--blue-dark); color: #fff; }
.btn-light { background: var(--surface); color: var(--navy); border-color: var(--border); }
.btn-light:hover { border-color: var(--blue); color: var(--blue); }
.btn-sm { padding: .35em .8em; font-size: .88rem; }
.btn-block { width: 100%; }
.link { display: inline-flex; align-items: center; gap: .3em; font-weight: 600; }
:root[dir="rtl"] .link .icon, :root[dir="rtl"] .pagination .icon { transform: scaleX(-1); }
.icon-btn { display: inline-flex; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--navy); cursor: pointer; }
.icon-btn:hover { background: var(--bg); }
.icon-btn .icon { width: 22px; height: 22px; }

/* ---------- App shell: sidebar + top bar ---------- */
.sidebar {
    position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 200; width: var(--sidebar-w);
    display: flex; flex-direction: column; background: var(--navy); color: rgba(255, 255, 255, .8);
    overflow-y: auto; transition: transform .25s ease;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 18px 20px; min-height: var(--topbar-h); color: #fff; font-weight: 700; border-bottom: 1px solid rgba(255, 255, 255, .08); }
.sidebar-brand:hover { color: #fff; }
.brand-logo { height: 40px; width: auto; max-width: 190px; object-fit: contain; }
.brand-logo + .brand-text { display: none; }
.brand-logo.missing { display: none; }
.brand-logo.missing + .brand-text { display: inline; }
.sidebar-nav { padding: 12px 12px 24px; }
.nav-section { margin: 16px 10px 6px; font-size: .75rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: rgba(255, 255, 255, .45); }
:root[lang="ar"] .nav-section { letter-spacing: 0; font-size: .82rem; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.sidebar-nav a { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: rgba(255, 255, 255, .8); font-weight: 500; }
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.active { background: var(--blue); color: #fff; }
.sidebar-backdrop { display: none; }

.app-main { margin-inline-start: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 100; height: var(--topbar-h);
    display: flex; align-items: center; gap: 12px; padding-inline: 24px;
    background: rgba(255, 255, 255, .95); border-bottom: 1px solid var(--border); backdrop-filter: blur(6px);
}
.sidebar-toggle { display: none; }
.topbar-title { flex: 1; margin: 0; font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.lang-link { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; color: var(--navy); }
:root[lang="en"] .lang-link span { font-family: "Cairo", sans-serif; }

.user-menu { position: relative; }
.user-menu summary { display: flex; align-items: center; gap: 10px; cursor: pointer; list-style: none; padding: 4px 6px; border-radius: 10px; }
.user-menu summary::-webkit-details-marker { display: none; }
.user-menu summary:hover { background: var(--bg); }
.avatar { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 50%; background: var(--blue); color: #fff; font-weight: 700; }
.user-menu-name { display: flex; flex-direction: column; line-height: 1.2; font-weight: 600; font-size: .92rem; }
.user-menu-name small { color: var(--muted); font-weight: 500; }
.user-menu-panel {
    position: absolute; inset-inline-end: 0; top: calc(100% + 8px); min-width: 220px; padding: 6px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.user-menu-panel a, .user-menu-panel button {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; border: 0; border-radius: 8px;
    background: none; color: var(--text); font: inherit; text-align: start; cursor: pointer;
}
.user-menu-panel a:hover, .user-menu-panel button:hover { background: var(--bg); color: var(--blue); }
.user-menu-panel form { margin: 0; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

.content { flex: 1; padding: 24px; max-width: 1280px; width: 100%; }

@media (max-width: 960px) {
    .sidebar { transform: translateX(-100%); }
    :root[dir="rtl"] .sidebar { transform: translateX(100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; z-index: 150; background: rgba(10, 42, 77, .45); }
    .app-main { margin-inline-start: 0; }
    .sidebar-toggle { display: inline-flex; }
    .topbar { padding-inline: 12px; }
    .content { padding: 16px; }
    .user-menu-name, .lang-link span { display: none; }
}

/* ---------- Alerts ---------- */
.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; font-weight: 500; }
.alert-success { background: var(--success-bg); color: var(--success); }
.alert-error { background: var(--error-bg); color: var(--error); }
.alert-info { background: var(--info-bg); color: var(--navy); }
.alert-warning { background: var(--warning-bg); color: var(--warning); }

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.card-title { font-size: 1.1rem; margin-bottom: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-head h3 { margin: 0; }
.card-note { background: var(--info-bg); border-color: transparent; box-shadow: none; }
.meta p { margin: 0 0 6px; }
.panel-warning { border-color: #f2d49a; background: var(--warning-bg); }
.panel-warning h3 { display: flex; align-items: center; gap: 8px; color: var(--warning); }

/* ---------- Dashboard ---------- */
.welcome { margin-bottom: 20px; }
.welcome h2 { margin-bottom: 2px; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card { display: flex; align-items: center; gap: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.stat-icon { display: inline-flex; align-items: center; justify-content: center; width: 46px; height: 46px; border-radius: 12px; background: var(--info-bg); color: var(--blue); }
.stat-icon .icon { width: 24px; height: 24px; }
.stat-value { margin: 0; font: 700 1.6rem/1.1 "Inter", sans-serif; color: var(--navy); }
.stat-label { margin: 2px 0 0; color: var(--muted); font-size: .9rem; }
.dashboard-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; align-items: start; }
@media (max-width: 960px) { .dashboard-grid { grid-template-columns: 1fr; } }
.feed { list-style: none; margin: 0; padding: 0; }
.feed li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.feed li:last-child { border-bottom: 0; }
.feed time { white-space: nowrap; font-size: .85rem; }

/* ---------- Toolbar & filters ---------- */
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.search { position: relative; display: flex; align-items: center; }
.search .icon { position: absolute; inset-inline-start: 10px; color: var(--muted); }
.search input { padding-inline-start: 34px !important; min-width: 260px; }
.inline-field { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: .9rem; }

/* ---------- Forms ---------- */
input, select, textarea {
    font: inherit; color: var(--text); background: #fbfcfd;
    padding: 9px 12px; border: 1px solid var(--border); border-radius: 10px; min-height: 42px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(11, 99, 182, .15); background: #fff; }
input:disabled { background: var(--bg); color: var(--muted); }
:root[dir="rtl"] input[dir="ltr"] { text-align: right; }
.form { display: grid; gap: 16px; }
.form.narrow { max-width: 480px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }
.field { display: grid; gap: 6px; margin: 0; }
.field > span, .field > legend { font-weight: 600; font-size: .92rem; color: var(--navy); }
.field input, .field select { width: 100%; }
.help { color: var(--muted); font-size: .84rem; }
.is-invalid, .is-invalid input { border-color: var(--error) !important; }
.field-error { margin: 0; color: var(--error); font-size: .86rem; font-weight: 500; }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding-top: 4px; }
.form-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.form-layout > form:only-child { grid-column: 1 / -1; max-width: 860px; }
.side-panels { display: grid; gap: 16px; }
.side-panels h3 { font-size: 1rem; }
@media (max-width: 1080px) { .form-layout { grid-template-columns: 1fr; } }

fieldset.field { border: 0; padding: 0; }
.role-choice { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.role-choice legend { grid-column: 1 / -1; margin-bottom: 6px; }
.role-choice .field-error { grid-column: 1 / -1; }
@media (max-width: 760px) { .role-choice { grid-template-columns: 1fr; } }
.radio-card { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: #fbfcfd; }
.radio-card:has(input:checked) { border-color: var(--blue); background: var(--info-bg); }
.radio-card input { min-height: 0; margin-top: 4px; accent-color: var(--blue); }
.radio-card span { display: grid; gap: 2px; }
.radio-card small { color: var(--muted); font-size: .84rem; line-height: 1.45; }

/* ---------- Tables ---------- */
.table-card { padding: 0; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: start; font-weight: 600; color: var(--muted); font-size: .82rem; text-transform: uppercase; letter-spacing: .04em; background: #f8fafc; }
:root[lang="ar"] .table th { text-transform: none; letter-spacing: 0; font-size: .88rem; }
.table th, .table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #fafcfe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { text-align: end; white-space: nowrap; }
.table .details { max-width: 360px; color: var(--muted); font-size: .86rem; word-break: break-word; }
.empty { padding: 32px; text-align: center; color: var(--muted); margin: 0; }
@media screen and (max-width: 760px) {
    .table thead { display: none; }
    .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
    .table tr { padding: 10px 0; border-bottom: 1px solid var(--border); }
    .table td { border: 0; padding: 4px 16px; }
    .table td[data-label]::before { content: attr(data-label); display: block; font-size: .78rem; color: var(--muted); font-weight: 600; }
    .table .actions { text-align: start; padding-top: 8px; }
}

/* ---------- Badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--bg); color: var(--muted); }
.badge .icon { width: .95em; height: .95em; }
.badge-admin { background: #e6ecf5; color: var(--navy); }
.badge-staff { background: var(--info-bg); color: var(--blue); }
.badge-technician { background: #e9f6ef; color: var(--success); }
.badge-active { background: var(--success-bg); color: var(--success); }
.badge-inactive { background: #eef0f3; color: var(--muted); }
.badge-locked { background: var(--warning-bg); color: var(--warning); }
.badge-action-login_failed, .badge-action-account_locked, .badge-action-access_denied { background: var(--error-bg); color: var(--error); }
.badge-action-user, .badge-action-setup { background: var(--info-bg); color: var(--blue); }

/* ---------- Pagination ---------- */
.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; font-size: .9rem; }

/* ---------- Sign-in & error pages ---------- */
.auth-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px 16px;
    background: linear-gradient(135deg, var(--navy) 0%, var(--navy-2) 60%, var(--blue) 100%);
}
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 16px; padding: 32px 28px; box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.auth-brand { text-align: center; margin-bottom: 20px; }
.auth-brand .brand-logo { height: 70px; max-width: 260px; margin-inline: auto; display: block; }
.auth-brand .brand-text { font-weight: 700; font-size: 1.3rem; color: var(--navy); }
.auth-subtitle { margin: 8px 0 0; color: var(--muted); }
.auth-title { font-size: 1.3rem; text-align: center; margin-bottom: 16px; }
.auth-lang { text-align: center; margin: 18px 0 0; }
.auth-lang a { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.error-page { text-align: center; padding: 24px 0; }
.error-code { margin: 0; font: 700 3.5rem/1 "Inter", sans-serif; color: var(--blue); }
.content .error-page { max-width: 520px; margin: 40px auto; }

/* =============================================================================
   Fleet (Phase 3)
   ========================================================================== */
.check-inline { display: inline-flex; align-items: center; gap: 6px; font-size: .9rem; color: var(--navy); cursor: pointer; }
.check-inline input { min-height: 0; accent-color: var(--blue); }
.row-link { color: var(--navy); }
.row-link:hover { color: var(--blue); }
.small { font-size: .85rem; }
.plate {
    display: inline-block; padding: 1px 8px; border: 1px solid var(--navy); border-radius: 6px;
    font: 700 .85rem/1.5 "Inter", monospace; letter-spacing: .04em; color: var(--navy); background: #fff; white-space: nowrap;
}
.plate-sm { font-size: .75rem; padding: 0 6px; }
.detail-head h2 .plate { vertical-align: middle; margin-inline-start: 8px; }

.badge-due-overdue { background: var(--error-bg); color: var(--error); }
.badge-due-due_soon { background: var(--warning-bg); color: var(--warning); }
.badge-due-ok { background: var(--success-bg); color: var(--success); }
.badge-vehicle-active { background: var(--success-bg); color: var(--success); }
.badge-vehicle-maintenance { background: var(--warning-bg); color: var(--warning); }
.badge-vehicle-inactive, .badge-vehicle-sold { background: #eef0f3; color: var(--muted); }
.badge-mt { background: var(--info-bg); color: var(--blue); }
.badge-action-vehicle, .badge-action-maintenance { background: #e6ecf5; color: var(--navy); }

.detail-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.detail-title { display: flex; align-items: center; gap: 14px; }
.detail-title h2 { margin: 0 0 2px; }
.detail-title p { margin: 0; }
.detail-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-bottom: 16px; }
.detail-grid h3 { font-size: .95rem; color: var(--muted); font-weight: 600; margin-bottom: 8px; }
.big-value { margin: 0 0 6px; font: 700 1.35rem/1.3 "Inter", var(--font); color: var(--navy); }
.facts { margin: 0; display: grid; gap: 0; }
.facts > div { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.facts > div:last-child { border-bottom: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-weight: 600; text-align: end; }
.notes { margin: 10px 0 0; padding: 10px 12px; background: var(--bg); border-radius: 8px; font-size: .9rem; }
.inline-form { display: flex; gap: 8px; margin-top: 8px; }
.inline-form input { flex: 1; min-width: 0; }
.card-head-padded { padding: 16px 20px 4px; margin: 0; }

.form-wide { max-width: 1000px; }
.form-wide .card-title { margin: 8px 0 0; padding-top: 8px; border-top: 1px solid var(--border); }
.form-wide .card-title:first-of-type { border-top: 0; padding-top: 0; margin-top: 0; }
.form-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 900px) { .form-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 640px) { .form-grid-3 { grid-template-columns: 1fr; } }
textarea { width: 100%; resize: vertical; }
.total-output { display: flex; align-items: center; min-height: 42px; padding: 9px 12px; border-radius: 10px; background: var(--info-bg); font-weight: 700; color: var(--navy); }
.stat-money { font-size: 1.25rem; }

/* =============================================================================
   Customers, sites, equipment (Phase 4)
   ========================================================================== */
.site-list { list-style: none; margin: 0; padding: 0; }
.site-list li { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.site-list li:last-child { border-bottom: 0; }
.site-actions { display: flex; gap: 6px; flex-shrink: 0; }
.badge-eq-active { background: var(--success-bg); color: var(--success); }
.badge-eq-under_repair { background: var(--warning-bg); color: var(--warning); }
.badge-eq-inactive, .badge-eq-decommissioned { background: #eef0f3; color: var(--muted); }
.badge-action-customer, .badge-action-site, .badge-action-equipment { background: #e9f6ef; color: var(--success); }
optgroup { font-weight: 700; color: var(--navy); }

/* =============================================================================
   Service visits (Phase 5)
   ========================================================================== */
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tabs a {
    display: inline-flex; align-items: center; gap: 6px; padding: 10px 14px; margin-bottom: -1px;
    border-bottom: 3px solid transparent; color: var(--muted); font-weight: 600;
}
.tabs a:hover { color: var(--navy); }
.tabs a.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-count { min-width: 22px; padding: 0 7px; border-radius: 999px; background: var(--bg); color: var(--muted); font: 600 .78rem/1.6 "Inter", sans-serif; text-align: center; }
.tabs a.active .tab-count { background: var(--info-bg); color: var(--blue); }
.tab-count-alert { background: var(--error-bg) !important; color: var(--error) !important; }

.badge-visit-scheduled { background: var(--info-bg); color: var(--blue); }
.badge-visit-in_progress { background: var(--warning-bg); color: var(--warning); }
.badge-visit-completed { background: var(--success-bg); color: var(--success); }
.badge-visit-cancelled { background: #eef0f3; color: var(--muted); text-decoration: line-through; }
.badge-priority-high { background: var(--warning-bg); color: var(--warning); }
.badge-priority-urgent { background: var(--error); color: #fff; }
.badge-action-visit { background: var(--info-bg); color: var(--blue); }
.table .badge + .badge { margin-top: 4px; }
.detail-title p .badge { margin-inline-end: 4px; }

.detail-grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.detail-grid-2 h3 { display: flex; align-items: center; gap: 8px; color: var(--navy); font-size: 1.05rem; }
.detail-actions form { margin: 0; }
.btn-danger { color: var(--error); border-color: #f1c4c0; }
.btn-danger:hover { background: var(--error); color: #fff; border-color: var(--error); }
.dashboard-visits { margin-bottom: 16px; }

/* =============================================================================
   Service report (Phase 6)
   ========================================================================== */
.report-card { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.report-card h3 { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.report-card p { margin: 0; }
.report-card form { margin: 0; }
.badge-report-draft { background: var(--warning-bg); color: var(--warning); }
.badge-report-completed { background: var(--success-bg); color: var(--success); }
.badge-report-voided { background: var(--error-bg); color: var(--error); text-decoration: line-through; }
.badge-action-report { background: #e6ecf5; color: var(--navy); }

.report-form { display: grid; gap: 16px; margin-bottom: 16px; }
.report-form .card-title { margin: 0; }

/* Checklist: one row per item, big tap targets */
.check-group { border: 0; padding: 0; margin: 14px 0 0; }
.check-group legend { font-weight: 700; color: var(--navy); padding: 0 0 6px; font-size: .95rem; }
.check-row {
    display: grid; grid-template-columns: minmax(140px, 1fr) auto minmax(140px, .8fr); align-items: center; gap: 8px 12px;
    padding: 8px 0; border-bottom: 1px solid var(--border);
}
.check-row:last-child { border-bottom: 0; }
.check-row .field-error { grid-column: 1 / -1; }
.check-name { font-weight: 500; }
.check-remark { min-height: 38px; padding: 6px 10px; font-size: .9rem; }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: #fff; }
.seg { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; min-height: 0; }
.seg span { display: block; padding: 8px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); border-inline-start: 1px solid var(--border); white-space: nowrap; }
.seg:first-child span { border-inline-start: 0; }
.seg input:focus-visible + span { outline: 3px solid var(--blue-light); outline-offset: -3px; }
.seg-ok input:checked + span { background: var(--success); color: #fff; }
.seg-attention input:checked + span { background: #d97706; color: #fff; }
.seg-replaced input:checked + span { background: var(--blue); color: #fff; }
.seg-not_applicable input:checked + span { background: #6b7280; color: #fff; }
@media (max-width: 760px) {
    .check-row { grid-template-columns: 1fr; }
    .segmented { display: grid; grid-template-columns: repeat(4, 1fr); }
    .seg span { text-align: center; padding: 10px 4px; }
}

/* Measurements */
.measure-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.input-unit { display: flex; align-items: stretch; }
.input-unit input { flex: 1; min-width: 0; border-start-end-radius: 0; border-end-end-radius: 0; }
.input-unit .unit { display: inline-flex; align-items: center; padding: 0 10px; border: 1px solid var(--border); border-inline-start: 0; border-start-end-radius: 10px; border-end-end-radius: 10px; background: var(--bg); color: var(--muted); font-size: .85rem; }
.measure-remark { min-height: 36px; padding: 6px 10px; font-size: .88rem; }
.is-abnormal .input-unit input { border-color: var(--error); background: var(--error-bg); }
.row-abnormal td { background: #fff7f6; }

/* Parts */
.parts { display: grid; gap: 8px; }
.part-row { display: grid; grid-template-columns: 2fr 1.3fr .6fr .8fr auto; gap: 8px; align-items: center; }
.part-row input { width: 100%; min-width: 0; }
.part-head { font-size: .8rem; font-weight: 600; color: var(--muted); }
@media (max-width: 760px) {
    .part-head { display: none; }
    .part-row { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
    .part-row input:first-child { grid-column: 1 / -1; }
}

/* Save bar stays visible on long reports */
.sticky-actions {
    position: sticky; bottom: 0; z-index: 50; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px;
    padding: 12px 16px; background: rgba(255, 255, 255, .96); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 -6px 20px rgba(10, 42, 77, .08);
}
:root[dir="rtl"] .sticky-actions .icon { transform: scaleX(-1); }

/* Photos */
.photo-grid { list-style: none; margin: 0 0 14px; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.photo-grid li { position: relative; aspect-ratio: 1; border-radius: 10px; overflow: hidden; background: var(--bg); }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid form { position: absolute; top: 6px; inset-inline-end: 6px; margin: 0; }
.photo-delete { display: inline-flex; padding: 4px; border: 0; border-radius: 50%; background: rgba(10, 42, 77, .75); color: #fff; cursor: pointer; }
.photo-delete .icon { width: 16px; height: 16px; }
.upload-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.upload-form input[type="file"] { flex: 1; min-width: 220px; background: #fff; }

/* Signatures */
.signature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.signature-pad { display: grid; gap: 8px; }
.signature-pad canvas { width: 100%; height: auto; aspect-ratio: 600 / 220; border: 2px dashed #b9c4d0; border-radius: 10px; background: #fff; touch-action: none; cursor: crosshair; }
.signature-pad.is-invalid canvas { border-color: var(--error); }
.signature-pad button { justify-self: start; }
.signature-view img { width: 100%; max-width: 360px; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.summary-list { margin: 0 0 12px; padding-inline-start: 18px; }

/* Read-only checklist */
.checklist-read { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 24px; }
.checklist-read h3 { font-size: .95rem; margin: 10px 0 4px; }
.checklist-read ul { list-style: none; margin: 0; padding: 0; }
.checklist-read li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: .92rem; }
.badge-result-ok { background: var(--success-bg); color: var(--success); }
.badge-result-attention { background: #fdf0dc; color: #b45309; }
.badge-result-replaced { background: var(--info-bg); color: var(--blue); }
.badge-result-not_applicable { background: #eef0f3; color: var(--muted); }

/* Print links on the report page */
.print-bar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }

/* =============================================================================
   Summary reports (Phase 7)
   ========================================================================== */
.report-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.report-link { display: flex; gap: 14px; align-items: flex-start; color: var(--text); transition: border-color .15s, transform .15s; }
.report-link:hover { border-color: var(--blue); transform: translateY(-2px); color: var(--text); }
.report-link strong { display: block; color: var(--navy); margin-bottom: 4px; }
.report-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.period-line { font-weight: 600; color: var(--navy); }

/* Printing any platform page: only the content, with a small header */
.print-header { display: none; }
@media print {
    @page { size: A4; margin: 12mm; }
    html { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .sidebar, .sidebar-backdrop, .topbar, .no-print, .toolbar, .skip-link, .pagination,
    .detail-actions, .print-bar, .alert, .btn { display: none !important; }
    .app-main { margin: 0 !important; display: block; min-height: 0; }
    .content { padding: 0; max-width: none; }
    body { background: #fff; font-size: 10.5px; color: #111; }

    .print-header { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px;
                    padding-bottom: 6px; margin-bottom: 10px; border-bottom: 2px solid var(--navy); }
    .print-header img { height: 34px; width: auto; }
    .print-header h1 { margin: 0; font-size: 15px; }
    .print-header p { margin: 0; text-align: end; font-size: 10px; color: #444; }

    .card, .stat-card { box-shadow: none; border-color: #c9d1db; }
    .card { padding: 10px; }
    .stat-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 10px; }
    .stat-card { padding: 8px 10px; break-inside: avoid; }
    .stat-icon { display: none; }
    .stat-value { font-size: 16px; }
    .stat-money { font-size: 13px; }
    .detail-grid, .detail-grid-2, .dashboard-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

    .table-card { overflow: visible; }
    .table { font-size: 10px; }
    .table thead { display: table-header-group; }      /* repeat column titles on every page */
    .table th { background: #eef3f8 !important; color: #333; }
    .table th, .table td { padding: 4px 6px; border-bottom: 1px solid #d5dce4; }
    .table tr { break-inside: avoid; }
    .badge { border: 1px solid #c9d1db; padding: 0 6px; }
    .period-line { margin: 0 0 8px; }
    a { color: inherit; text-decoration: none; }
}

/* =============================================================================
   Settings (Phase 9)
   ========================================================================== */
.type-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.chip { padding: 5px 12px; border: 1px solid var(--border); border-radius: 999px; background: #fff; color: var(--navy); font-weight: 600; font-size: .9rem; }
.chip:hover { border-color: var(--blue); color: var(--blue); }
.chip.active { background: var(--blue); border-color: var(--blue); color: #fff; }
.chip-off { opacity: .55; }

.row-forms { display: grid; gap: 6px; margin: 8px 0; }
.row-form { display: grid; gap: 8px; align-items: center; margin: 0; }
.row-form input, .row-form select { min-width: 0; width: 100%; min-height: 38px; padding: 6px 10px; }
.row-form .check-inline input { width: auto; min-height: 0; }
.row-head { font-size: .78rem; font-weight: 600; color: var(--muted); }
.row-type { grid-template-columns: 1.4fr 1.4fr .7fr .5fr .7fr auto; }
.row-type .row-note { grid-column: 1 / -1; margin-top: -4px; }
.row-category { grid-template-columns: 1.5fr 1.5fr .5fr .7fr auto; }
.row-category .strong { font-weight: 700; color: var(--navy); }
.row-item { grid-template-columns: 1.5fr 1.5fr 1fr .5fr .7fr auto; padding-inline-start: 14px; }
.row-meas { grid-template-columns: 1.3fr 1.3fr .6fr .6fr .6fr .5fr .7fr auto; }
.row-off input { color: var(--muted); text-decoration: line-through; }
.row-add { margin-top: 6px; padding-top: 10px; border-top: 1px dashed var(--border); }
.row-new h3 { display: flex; align-items: center; gap: 8px; font-size: 1rem; }
.row-note { margin: 2px 0 0; }
@media (max-width: 900px) {
    .row-head { display: none; }
    .row-type, .row-category, .row-item, .row-meas { grid-template-columns: 1fr 1fr; padding: 10px; border: 1px solid var(--border); border-radius: 10px; }
    .row-add > span { display: none; }
}

/* ---------- Payment reminders ---------- */
.nav-badge { margin-inline-start: auto; min-width: 22px; padding: 0 7px; border-radius: 999px; background: #e5484d; color: #fff; font: 700 .75rem/1.6 "Inter", sans-serif; text-align: center; }
.sidebar-toggle { position: relative; }
.nav-dot { position: absolute; top: 6px; inset-inline-end: 6px; width: 9px; height: 9px; border-radius: 50%; background: #e5484d; box-shadow: 0 0 0 2px var(--surface); }
.link-button { margin-inline-start: 8px; padding: 0; border: 0; background: none; color: var(--blue); font: inherit; font-size: .85rem; text-decoration: underline; cursor: pointer; }
.side-panels .card.form form + form { margin-top: 8px; }
.badge-pay-mobile, .badge-pay-internet { background: var(--info-bg); color: var(--blue); }
.badge-pay-rent, .badge-pay-loan { background: #efe9fb; color: #5b3fa8; }
.badge-pay-salary { background: var(--success-bg); color: var(--success); }
.badge-pay-electricity, .badge-pay-water { background: var(--warning-bg); color: var(--warning); }
.badge-pay-tax { background: var(--error-bg); color: var(--error); }
.badge-action-payment { background: #efe9fb; color: #5b3fa8; }
