/* Gestione Cantieri - green theme on top of Bootstrap 5.3 (dark mode). */

/* Text font: Plus Jakarta Sans (SIL Open Font License, see fonts/PlusJakartaSans-OFL.txt), served from our own server */
@font-face {
    font-family: 'Plus Jakarta Sans';
    src: url('../fonts/plus-jakarta-sans-latin.woff') format('woff');
    font-weight: 200 800;
    font-style: normal;
    font-display: swap;
}

:root {
    /* "Bosco refinado": the same forest green, darker and calmer, with ONE accent (amber) for the main actions */
    --bosco-bg-main: #151b13;
    --bosco-bg-card: #1d251a;
    --bosco-bg-header: #11160f;
    --bosco-bg-raised: #243020;
    --bosco-cream: #eef1e3;
    --bosco-muted: #a3ae95;
    --bosco-border: #33402d;
    --bosco-line: #2a3525;
    --bosco-accent: #e8a33d;
    --bosco-accent-hover: #f0b65c;
    --bosco-accent-ink: #1a1406;
    --bosco-info: #8cc7f0;
    --bosco-warn: #f2c46b;
    --bosco-ok: #86d39b;
    --bosco-danger: #f4a197;
    --bosco-expense: #f3a582;
    --app-sidebar-w: 240px;
}

/* Bootstrap dark theme variables, re-colored with our palette */
[data-bs-theme="dark"] {
    --bs-body-bg: var(--bosco-bg-main);
    --bs-body-color: var(--bosco-cream);
    --bs-body-font-family: 'Plus Jakarta Sans', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --bs-border-color: var(--bosco-border);
    --bs-secondary-color: #cbd5e1;
    --bs-emphasis-color: #ffffff;
}

body {
    background-color: var(--bosco-bg-main);
    color: var(--bosco-cream);
}

.text-cream { color: var(--bosco-cream) !important; }

/* ---------- Navigation bar ---------- */
.navbar-custom {
    background-color: var(--bosco-bg-header);
    border-bottom: 1px solid var(--bosco-border);
}
.navbar-custom .navbar-brand { color: #f8fafc; }
.navbar-custom .navbar-user { color: #f8fafc; }
/* Just above the phone/tablet breakpoint the menu has many items: tighten the buttons a little. */
@media (min-width: 1200px) and (max-width: 1319.98px) {
    .navbar-custom .btn-sm { padding: .25rem .4rem; font-size: .78rem; }
    .navbar-custom .btn-sm i { margin-right: .15rem !important; }
}

/* ---------- Cards ---------- */
.card-bosco {
    background-color: var(--bosco-bg-card);
    border: 1px solid var(--bosco-border);
    color: var(--bosco-cream);
}
.card-stat {
    background-color: var(--bosco-bg-card);
    border: 1px solid var(--bosco-border);
    border-radius: 8px;
    padding: 15px;
    color: #f8fafc;
}
.card-stat .small { font-weight: 600; }

/* ---------- Tables ---------- */
.table {
    --bs-table-bg: var(--bosco-bg-card);
    --bs-table-color: var(--bosco-cream);
    --bs-table-border-color: var(--bosco-border);
    --bs-table-hover-bg: rgba(240, 243, 220, 0.06);
    --bs-table-hover-color: var(--bosco-cream);
}
.table > thead > tr > th {
    background-color: var(--bosco-bg-header);
    color: #ffffff;
    border-bottom: 2px solid var(--bosco-border);
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
}

/* ---------- Forms ---------- */
.form-control,
.form-select,
.input-group-text {
    background-color: var(--bosco-bg-header);
    border-color: var(--bosco-border);
    color: var(--bosco-cream);
}
.form-control:focus,
.form-select:focus {
    background-color: var(--bosco-bg-header);
    border-color: var(--bosco-cream);
    color: var(--bosco-cream);
    box-shadow: none;
}
.form-control::placeholder { color: #94a3b8; opacity: 1; }
.form-select option { background-color: var(--bosco-bg-card); color: var(--bosco-cream); }

/* Browser autofill would otherwise paint a light background */
.form-control:-webkit-autofill,
.form-control:-webkit-autofill:focus {
    -webkit-text-fill-color: var(--bosco-cream);
    -webkit-box-shadow: 0 0 0 1000px var(--bosco-bg-header) inset;
    caret-color: var(--bosco-cream);
}

/* ---------- Buttons and badges ---------- */
.btn-bosco {
    background-color: #f0f3dc;
    color: #34432b;
    font-weight: 600;
    border: none;
}
.btn-bosco:hover,
.btn-bosco:focus {
    background-color: #e0e5c1;
    color: #24301d;
}
.badge-material { background-color: #d97706; color: #fff; font-size: 0.75rem; font-weight: 600; }
.badge-mano     { background-color: #9a6b40; color: #fff; font-size: 0.75rem; font-weight: 600; }

/* Site status colors (used on the status selector and badges) */
.status-preventivo { background-color: #6c757d !important; color: #fff !important; }
.status-in-corso   { background-color: #0d6efd !important; color: #fff !important; }
.status-in-attesa  { background-color: #d97706 !important; color: #fff !important; }
.status-concluso   { background-color: #198754 !important; color: #fff !important; }

/* ---------- Modals ---------- */
.modal-content {
    --bs-modal-bg: var(--bosco-bg-card);
    --bs-modal-color: var(--bosco-cream);
    --bs-modal-border-color: var(--bosco-border);
    --bs-modal-header-border-color: var(--bosco-border);
    --bs-modal-footer-border-color: var(--bosco-border);
}

/* ---------- Login and error pages ---------- */
.page-login,
.page-center {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.page-login { background-color: var(--bosco-bg-main); }
.card-login {
    width: 100%;
    max-width: 400px;
    background-color: var(--bosco-bg-card);
    border: 1px solid var(--bosco-border);
    border-radius: 10px;
}
.card-login .text-muted { color: var(--bosco-muted) !important; }

/* Two-factor page */
.card-2fa { max-width: 440px; }
.qr-box { width: 220px; max-width: 100%; background: #fff; padding: 4px; border-radius: 6px; }
.qr-box svg { display: block; width: 100%; height: auto; }
.secret-key { font-size: 1.05rem; letter-spacing: 1px; color: var(--bosco-cream); word-break: break-all; }
.backup-codes {
    font-size: 1.15rem; line-height: 1.9; text-align: center; letter-spacing: 2px;
    background: var(--bosco-bg-header); border: 1px dashed var(--bosco-border); border-radius: 6px; padding: 10px; color: var(--bosco-cream);
}
@media print {
    .no-print, #toast-box { display: none !important; }
    .page-login { background: #fff !important; }
    .card-login { background: #fff !important; border: 0 !important; color: #000 !important; }
    .backup-codes { background: #fff !important; color: #000 !important; border-color: #000 !important; }
}

/* ---------- Additions for the working screens ---------- */
.clickable { cursor: pointer; }
.status-select { font-size: 0.8rem; }
.status-select option { background-color: var(--bosco-bg-card); color: var(--bosco-cream); }
.check-list { max-height: 160px; overflow-y: auto; background-color: var(--bosco-bg-header); border-color: var(--bosco-border) !important; }

/* Tabs in the details window */
.nav-tabs {
    --bs-nav-tabs-border-color: var(--bosco-border);
    --bs-nav-tabs-link-hover-border-color: var(--bosco-border);
    --bs-nav-tabs-link-active-bg: var(--bosco-bg-header);
    --bs-nav-tabs-link-active-color: #ffffff;
    --bs-nav-tabs-link-active-border-color: var(--bosco-border) var(--bosco-border) var(--bosco-bg-header);
    --bs-nav-link-color: var(--bosco-muted);
    --bs-nav-link-hover-color: #ffffff;
}

/* Text helpers used on dark cards */
.card-bosco .text-muted,
.modal-content .text-muted { color: var(--bosco-muted) !important; }
.form-text { color: var(--bosco-muted); }
dt { color: var(--bosco-muted); font-weight: 600; }

/* ---------- Photos ---------- */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.photo-thumb { position: relative; aspect-ratio: 1 / 1; border: 1px solid var(--bosco-border); border-radius: 6px; overflow: hidden; background: var(--bosco-bg-header); padding: 0; cursor: pointer; }
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb .photo-delete { position: absolute; top: 4px; right: 4px; line-height: 1; }
.photo-viewer { position: fixed; inset: 0; z-index: 2000; background: rgba(0, 0, 0, 0.92); display: flex; align-items: center; justify-content: center; }
.photo-viewer[hidden] { display: none; }
.photo-viewer img { max-width: 100%; max-height: 88vh; object-fit: contain; }
.photo-viewer-btn { position: absolute; background: rgba(0, 0, 0, 0.55); color: #fff; border: 1px solid rgba(255, 255, 255, 0.4); border-radius: 50%; width: 48px; height: 48px; font-size: 1.1rem; }
.photo-viewer-close { top: 12px; right: 12px; }
.photo-viewer-prev { left: 8px; top: 50%; transform: translateY(-50%); }
.photo-viewer-next { right: 8px; top: 50%; transform: translateY(-50%); }
.photo-viewer-caption { position: absolute; bottom: 10px; left: 0; right: 0; text-align: center; color: #ddd; font-size: 0.85rem; padding: 0 70px; }

/* ---------- Phone layout ---------- */
.status-select { padding-right: 1.6rem !important; min-width: 7.5rem; }

@media (max-width: 767.98px) {
    main.container { padding-left: 12px; padding-right: 12px; }
    .card-stat { padding: 10px 12px; }
    .card-stat h3, .card-stat h4 { font-size: 1.15rem; }

    /* Wide tables become one card per row. data-label (set by app.js) is the column title. */
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack thead { display: none; }
    .table-stack tbody tr {
        background-color: var(--bosco-bg-card);
        border: 1px solid var(--bosco-border);
        border-radius: 8px;
        margin: 0 0 10px;
        padding: 6px 0;
    }
    .table-responsive:has(.table-stack) { overflow-x: visible; }
    .card-body:has(.table-stack) { padding: 10px !important; }
    .card:has(.table-stack) { background: transparent; border: 0; }
    .table-stack td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        border: 0;
        padding: 0.3rem 0.85rem !important;
        text-align: right;
        background: transparent;
    }
    .table-stack td::before {
        content: attr(data-label);
        flex: 0 0 38%;
        text-align: left;
        font-weight: 600;
        font-size: 0.8rem;
        color: var(--bosco-muted);
        text-transform: uppercase;
    }
    .table-stack td[data-label=""]::before { display: none; }
    .table-stack td[data-label=""] { display: block; text-align: left; }
    .table-stack td.text-end { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; padding-top: 0.6rem !important; }
    .table-stack td.text-end::before { display: none; }

    /* Fingers need bigger targets than mouse pointers */
    .table-stack td .btn { min-width: 44px; min-height: 44px; display: inline-flex; align-items: center; justify-content: center; margin: 0 !important; }
    .modal-body .btn-sm, .modal-body .form-control-sm, .modal-body .form-select-sm { min-height: 40px; }
    .photo-grid { grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); }
    .photo-thumb .photo-delete { padding: 6px 8px !important; }
}

/* Modals whose body and footer sit inside a <form>: Bootstrap's scrolling needs the form to be part
   of the flex column, otherwise the content is cut off and cannot be scrolled (seen on phones). */
.modal-dialog-scrollable .modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}
.modal-dialog-scrollable .modal-content > form > .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.plan-amount { max-width: 140px; }

/* Expenses (spese) are always this orange, so they cannot be mistaken for the money collected (blue). */
.text-expense { color: var(--bosco-expense) !important; }

/* ---------- Searchable drop-down (App.combo) ---------- */
.combo { position: relative; }
.combo-list {
    position: absolute; left: 0; right: 0; z-index: 1060;
    max-height: 260px; overflow-y: auto;
    margin: 2px 0 0; padding: 0; list-style: none;
    background-color: var(--bosco-bg-card);
    border: 1px solid var(--bosco-cream);
    border-radius: 6px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.combo-list[hidden] { display: none; }
.combo-list li { padding: 6px 10px; cursor: pointer; border-bottom: 1px solid var(--bosco-border); }
.combo-list li:last-child { border-bottom: 0; }
.combo-list li.active, .combo-list li:hover { background-color: rgba(240, 243, 220, 0.14); }
.combo-list li[aria-disabled="true"] { opacity: 0.45; cursor: not-allowed; }
.combo-list li.combo-more { cursor: default; text-align: center; }
@media (max-width: 767.98px) { .combo-list li { padding: 10px 12px; } }

/* Phone numbers and addresses in the list are links */
.contact-link { color: inherit; text-decoration: underline dotted; text-underline-offset: 3px; }
.contact-link:hover { color: var(--bosco-cream); text-decoration: underline; }

/* Logo (square and compasses) */
.brand-logo { height: 32px; width: 32px; vertical-align: middle; }
.login-logo { height: 96px; width: 96px; }

/* Labels (etichette): the label is drawn in real millimetres */
.label-sheet { display: flex; flex-wrap: wrap; gap: 14px; }
.label-item { margin: 0; }
.label-item > svg { display: block; max-width: 100%; height: auto; background: #fff; border: 1px dashed #8a9a7a; }
@media print {
    body { background: #fff !important; }
    nav, .navbar, .no-print, footer { display: none !important; }
    main.container { max-width: none !important; margin: 0 !important; padding: 0 !important; }
    .card-bosco, .card-bosco .card-body { background: #fff !important; border: 0 !important; box-shadow: none !important; padding: 0 !important; }
    .label-sheet { display: block; gap: 0; }
    .label-item { page-break-after: always; break-after: page; }
    .label-item:last-child { page-break-after: auto; break-after: auto; }
    .label-item > svg { border: 0; max-width: none; }
}

/* In-app guide (guida.php) */
.guide-toc { columns: 2; column-gap: 2rem; padding-left: 1.4rem; }
.guide-toc li { margin-bottom: 4px; break-inside: avoid; }
.guide-steps li { margin-bottom: 8px; }
.guide-shot { text-align: center; }
.guide-shot img { max-width: 100%; box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35); }
.guide-page section { scroll-margin-top: 12px; }
@media (max-width: 767.98px) { .guide-toc { columns: 1; } }

/* Calendar button next to date fields (dateinputs.js): the native field is invisible and only anchors the calendar */
.date-native { position: absolute; opacity: 0; pointer-events: none; border: 0; padding: 0; margin: 0; }
.date-pick-btn { flex: 0 0 auto; }
.min-w-0 { min-width: 0; }

/* Calendar (calendario.php) */
.cal-title { display: inline-block; min-width: 9rem; }
.cal-title::first-letter { text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 2px; }
.cal-head { text-align: center; font-size: .75rem; color: #adb5bd; padding: .25rem 0; text-transform: capitalize; }
.cal-cell { min-height: 5.5rem; padding: .2rem; border: 1px solid rgba(255,255,255,.08); border-radius: .35rem; cursor: pointer; overflow: hidden; }
.cal-cell:hover, .cal-cell:focus { border-color: #ffc107; outline: none; }
.cal-other { opacity: .45; }
.cal-today { border-color: #ffc107; }
.cal-selected { background: rgba(255,193,7,.15); }
.cal-num { font-size: .75rem; font-weight: 600; }
.cal-chip { display: block; font-size: .65rem; line-height: 1.2; padding: .1rem .25rem; margin-top: 2px; border-radius: .25rem; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-legend .cal-chip { display: inline-block; font-size: .75rem; }
.cal-start { background: #198754; }
.cal-end { background: #0d6efd; }
.cal-inst { background: #6f42c1; }
.cal-paid { background: #6c757d; }
.cal-overdue { background: #dc3545; }
@media (max-width: 576px) {
    .cal-cell { min-height: 3.5rem; }
    .cal-cell .cal-chip { height: .45rem; padding: 0; font-size: 0; }
}

/* Progress of the works */
.progress-thin { height: .45rem; }

/* Site health light (semaforo) */
.health-dot { font-size: .7rem; vertical-align: middle; }
.health-green { color: #198754; }
.health-yellow { color: #ffc107; }
.health-red { color: #dc3545; }

/* Site diary */
.diary-notes { white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Cash forecast ---------- */
.fc-chart-wrap { position: relative; }
.fc-svg { width: 100%; height: auto; display: block; }
.fc-grid { stroke: rgba(240, 243, 220, .16); stroke-width: 1; }
.fc-zero { stroke: rgba(240, 243, 220, .55); stroke-width: 1; }
.fc-axis { fill: var(--bosco-muted); font-size: 11px; }
.fc-val { fill: var(--bosco-cream); font-size: 12px; font-weight: 600; }
.fc-bar-pos { fill: var(--bosco-info); }
.fc-bar-neg { fill: #ef6b5e; }
.fc-hit { fill: transparent; }
.fc-hit:hover { fill: rgba(240, 243, 220, .06); }
.fc-tip { position: absolute; z-index: 5; pointer-events: none; background: var(--bosco-bg-header); border: 1px solid var(--bosco-border); border-radius: 8px; padding: 8px 10px; font-size: .8rem; white-space: nowrap; }
.fc-sc { cursor: pointer; border: 1px solid var(--bosco-border); color: inherit; }
.fc-sc-on { border-color: var(--bosco-accent) !important; box-shadow: 0 0 0 1px var(--bosco-accent) inset; }
.fc-neg { color: var(--bosco-danger); }
.fc-ok { color: var(--bosco-ok); }

/* Capacity: usage bar of a week (a <progress>, the percentage and the status word are always written next to it) */
.cap-bar { appearance: none; -webkit-appearance: none; width: 6.5rem; height: .6rem; border: 0; border-radius: 4px; background: rgba(240, 243, 220, .16); overflow: hidden; }
.cap-bar::-webkit-progress-bar { background: rgba(240, 243, 220, .16); border-radius: 4px; }
.cap-bar::-webkit-progress-value { border-radius: 4px; background: var(--bosco-info); }
.cap-bar::-moz-progress-bar { border-radius: 4px; background: var(--bosco-info); }
.cap-bar-over::-webkit-progress-value { background: #ef6b5e; }
.cap-bar-over::-moz-progress-bar { background: #ef6b5e; }
.cap-bar-tight::-webkit-progress-value { background: #e8c23d; }
.cap-bar-tight::-moz-progress-bar { background: #e8c23d; }
.cap-bar-ok::-webkit-progress-value { background: #6cc58a; }
.cap-bar-ok::-moz-progress-bar { background: #6cc58a; }


/* =====================================================================
   New look (step 6.32): side menu / tab bar, calmer colors, one accent.
   Everything below overrides the older rules above.
   ===================================================================== */

body { font-variant-numeric: tabular-nums; -webkit-font-smoothing: antialiased; }
h1, h2, h3, h4, h5, .h1, .h2, .h3, .h4, .h5 { letter-spacing: -0.01em; }
a { color: var(--bosco-accent); }
a:hover { color: var(--bosco-accent-hover); }
:focus-visible { outline: 2px solid var(--bosco-accent); outline-offset: 2px; }

/* ---- Navigation: side menu (wide screens) ---- */
.app-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1030;
    width: var(--app-sidebar-w);
    display: none; flex-direction: column; gap: 18px;
    padding: 18px 14px;
    background: var(--bosco-bg-header);
    border-right: 1px solid var(--bosco-line);
    overflow-y: auto;
}
.app-brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; color: var(--bosco-cream); text-decoration: none; font-weight: 800; font-size: 1rem; letter-spacing: -0.01em; }
.app-brand:hover { color: #fff; }
.app-brand img { width: 34px; height: 34px; border-radius: 9px; flex: none; }
.app-nav { display: flex; flex-direction: column; gap: 16px; flex: 1 1 auto; }
.app-nav-group { display: flex; flex-direction: column; gap: 2px; }
.app-nav-bottom { margin-top: auto; }
.app-nav-title { font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: #8e9a80; padding: 0 10px 6px; }
.app-nav-link {
    display: flex; align-items: center; gap: 10px;
    min-height: 40px; padding: 8px 10px; border-radius: 8px;
    color: #c4ceb4; text-decoration: none; font-size: .92rem; font-weight: 500;
}
.app-nav-link i { color: #8e9a80; }
.app-nav-link:hover { background: #1b2318; color: var(--bosco-cream); }
.app-nav-link.active { background: var(--bosco-bg-raised); color: var(--bosco-cream); font-weight: 700; }
.app-nav-link.active i { color: var(--bosco-accent); }
.app-count { margin-left: auto; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; font-size: .72rem; font-weight: 800; }
.app-count-alert { background: #ef6b5e; color: #1a0705; }
.app-user { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 10px; background: #1b2318; border: 1px solid var(--bosco-line); }
.app-avatar { width: 34px; height: 34px; flex: none; border-radius: 50%; background: var(--bosco-border); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: .8rem; color: var(--bosco-cream); }
.app-user-text { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.app-user-text strong { font-size: .85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-user-text small { font-size: .72rem; color: var(--bosco-muted); }
.app-icon-btn {
    width: 34px; height: 34px; flex: none; border-radius: 8px;
    border: 1px solid var(--bosco-border); background: transparent; color: #c4ceb4;
    display: inline-flex; align-items: center; justify-content: center; text-decoration: none;
}
.app-icon-btn:hover { background: var(--bosco-bg-raised); color: var(--bosco-cream); }
.app-icon-btn-lg { width: 44px; height: 44px; border-radius: 12px; background: var(--bosco-bg-card); }
.app-icon-btn .app-count { position: absolute; top: -6px; right: -6px; margin: 0; }

/* ---- Navigation: top bar + tab bar (phones and tablets) ---- */
.app-topbar {
    position: sticky; top: 0; z-index: 1030;
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; padding-top: max(10px, env(safe-area-inset-top));
    background: rgba(17, 22, 15, 0.94);
    border-bottom: 1px solid var(--bosco-line);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
}
.app-topbar .app-brand { padding: 0; }
.app-tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030;
    display: flex; align-items: center; justify-content: space-around;
    min-height: 64px; padding: 6px 6px max(8px, env(safe-area-inset-bottom));
    background: var(--bosco-bg-header);
    border-top: 1px solid var(--bosco-line);
}
.app-tab {
    flex: 1 1 0; min-width: 0; min-height: 50px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    border: 0; background: transparent; color: var(--bosco-muted);
    font-size: .7rem; font-weight: 600; text-decoration: none;
}
.app-tab i { font-size: 1.15rem; }
.app-tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-tab.active { color: var(--bosco-accent); font-weight: 700; }
.app-tab:hover { color: var(--bosco-cream); }
.app-tab-add {
    flex: 0 0 auto; width: 54px; height: 54px; margin: -22px 6px 0;
    border: 0; border-radius: 16px; background: var(--bosco-accent); color: var(--bosco-accent-ink);
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.3rem;
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45); text-decoration: none;
}
.app-tab-add:hover { background: var(--bosco-accent-hover); color: var(--bosco-accent-ink); }
.app-offcanvas { --bs-offcanvas-bg: var(--bosco-bg-header); --bs-offcanvas-color: var(--bosco-cream); --bs-offcanvas-width: 300px; border-left: 1px solid var(--bosco-line) !important; }
.app-offcanvas .app-nav { margin-bottom: 16px; }
.app-offcanvas .app-nav-link { min-height: 46px; }

body.has-app-nav { padding-bottom: 84px; }
@media (min-width: 1200px) {
    .app-sidebar { display: flex; }
    .app-topbar, .app-tabbar { display: none; }
    body.has-app-nav { padding-left: var(--app-sidebar-w); padding-bottom: 0; }
}
@media print {
    .app-sidebar, .app-topbar, .app-tabbar, .app-offcanvas { display: none !important; }
    body.has-app-nav { padding: 0 !important; }
}

/* ---- Page header ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 18px; }
.page-head h1 { margin: 0; font-size: 1.6rem; font-weight: 800; }
.page-head .page-sub { color: var(--bosco-muted); font-size: .85rem; }
.page-head .page-actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }

/* ---- Cards ---- */
.card-bosco { background-color: var(--bosco-bg-card); border: 1px solid var(--bosco-line); border-radius: 12px; }
.card-bosco.shadow-sm { box-shadow: none !important; }
.card-stat { background-color: var(--bosco-bg-card); border: 1px solid var(--bosco-line); border-radius: 12px; padding: 16px 18px; color: var(--bosco-cream); }
.card-stat .small { font-weight: 600; color: var(--bosco-muted); }
.card-stat h3 { font-weight: 800 !important; letter-spacing: -0.02em; }

/* ---- Buttons ---- */
.btn { border-radius: 10px; font-weight: 600; }
.btn-sm { border-radius: 8px; }
.btn-bosco { background-color: var(--bosco-accent); color: var(--bosco-accent-ink); font-weight: 800; border: 0; }
.btn-bosco:hover, .btn-bosco:focus, .btn-bosco:active { background-color: var(--bosco-accent-hover) !important; color: var(--bosco-accent-ink) !important; }
.btn-outline-light { --bs-btn-color: var(--bosco-cream); --bs-btn-border-color: var(--bosco-border); --bs-btn-hover-bg: var(--bosco-bg-raised); --bs-btn-hover-color: var(--bosco-cream); --bs-btn-hover-border-color: var(--bosco-border); --bs-btn-active-bg: var(--bosco-bg-raised); --bs-btn-active-color: #fff; --bs-btn-active-border-color: var(--bosco-cream); }
.btn-outline-danger { --bs-btn-color: var(--bosco-danger); --bs-btn-border-color: #6b2d26; --bs-btn-hover-bg: #3a1b17; --bs-btn-hover-color: var(--bosco-danger); --bs-btn-hover-border-color: #8a3a31; }
.btn-outline-warning { --bs-btn-color: var(--bosco-warn); --bs-btn-border-color: #62491c; --bs-btn-hover-bg: #33270f; --bs-btn-hover-color: var(--bosco-warn); --bs-btn-hover-border-color: #7a5a22; }
.btn-outline-success { --bs-btn-color: var(--bosco-ok); --bs-btn-border-color: #2e5a3a; --bs-btn-hover-bg: #173020; --bs-btn-hover-color: var(--bosco-ok); --bs-btn-hover-border-color: #3b7049; }
.btn-outline-info { --bs-btn-color: var(--bosco-info); --bs-btn-border-color: #2b4a66; --bs-btn-hover-bg: #162737; --bs-btn-hover-color: var(--bosco-info); --bs-btn-hover-border-color: #3a6185; }
.btn-danger { --bs-btn-bg: #c94d40; --bs-btn-border-color: #c94d40; --bs-btn-hover-bg: #b0433a; --bs-btn-hover-border-color: #b0433a; }
.btn-success { --bs-btn-bg: #2f7a46; --bs-btn-border-color: #2f7a46; --bs-btn-hover-bg: #28683c; --bs-btn-hover-border-color: #28683c; }
.btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }

/* ---- Text colors on the dark ground (readable, same family as the accent) ---- */
.text-info { color: var(--bosco-info) !important; }
.text-warning { color: var(--bosco-warn) !important; }
.text-success { color: var(--bosco-ok) !important; }
.text-danger { color: var(--bosco-danger) !important; }
.text-muted { color: var(--bosco-muted) !important; }

/* ---- Badges: tinted background, colored text (never color alone: they always have words) ---- */
.badge { font-weight: 700; border-radius: 6px; padding: .35em .6em; }
.badge.bg-danger { background-color: #3a1b17 !important; color: var(--bosco-danger) !important; border: 1px solid #6b2d26; }
.badge.bg-warning { background-color: #33270f !important; color: var(--bosco-warn) !important; border: 1px solid #62491c; }
.badge.bg-success { background-color: #173020 !important; color: var(--bosco-ok) !important; border: 1px solid #2e5a3a; }
.badge.bg-info { background-color: #162737 !important; color: #9ccdf2 !important; border: 1px solid #2b4a66; }
.badge.bg-secondary { background-color: #2a2f27 !important; color: #c9d1bd !important; border: 1px solid #3a4235; }
.badge.bg-primary { background-color: #17283a !important; color: var(--bosco-info) !important; border: 1px solid #2b4a66; }
.badge-material { background-color: #33270f; color: var(--bosco-warn); border: 1px solid #62491c; font-size: .72rem; }
.badge-mano { background-color: #2c2219; color: #e0b48c; border: 1px solid #55402d; font-size: .72rem; }

/* ---- Site status (status selector) ---- */
.status-preventivo { background-color: #2a2f27 !important; color: #c9d1bd !important; border-color: #3a4235 !important; }
.status-in-corso   { background-color: #17283a !important; color: var(--bosco-info) !important; border-color: #2b4a66 !important; }
.status-in-attesa  { background-color: #33230f !important; color: #f2b36b !important; border-color: #62491c !important; }
.status-concluso   { background-color: #173020 !important; color: var(--bosco-ok) !important; border-color: #2e5a3a !important; }
.status-select { border-radius: 999px !important; font-size: .78rem; font-weight: 700; }

/* ---- Health light and progress ---- */
.health-green { color: #6cc58a; }
.health-yellow { color: #e8c23d; }
.health-red { color: #ef6b5e; }
.progress { --bs-progress-bg: var(--bosco-line); border-radius: 4px; }
.progress-bar { border-radius: 4px; }

/* ---- Tables ---- */
.table { --bs-table-bg: transparent; --bs-table-border-color: var(--bosco-line); --bs-table-hover-bg: rgba(238, 241, 227, 0.035); }
.card-bosco .table { --bs-table-bg: var(--bosco-bg-card); }
.table > thead > tr > th {
    background-color: var(--bosco-bg-card);
    color: var(--bosco-muted);
    border-bottom: 1px solid var(--bosco-line);
    font-size: .76rem; font-weight: 700; text-transform: none; letter-spacing: .01em;
    padding-top: .8rem; padding-bottom: .8rem;
}
.table > :not(caption) > * > * { border-bottom-color: var(--bosco-line); }

/* ---- Forms ---- */
.form-control, .form-select, .input-group-text { background-color: var(--bosco-bg-main); border-color: var(--bosco-border); border-radius: 8px; }
.form-control:focus, .form-select:focus { background-color: var(--bosco-bg-main); border-color: var(--bosco-accent); box-shadow: 0 0 0 3px rgba(232, 163, 61, 0.18); }
.form-control::placeholder { color: #7f8b72; }
.form-check-input:checked { background-color: var(--bosco-accent); border-color: var(--bosco-accent); }
.form-control:-webkit-autofill, .form-control:-webkit-autofill:focus { -webkit-box-shadow: 0 0 0 1000px var(--bosco-bg-main) inset; }

/* ---- Modals, menus, alerts ---- */
.modal-content { border-radius: 14px; --bs-modal-header-border-color: var(--bosco-line); --bs-modal-footer-border-color: var(--bosco-line); }
.modal-backdrop.show { opacity: .7; }
.dropdown-menu { --bs-dropdown-bg: var(--bosco-bg-card); --bs-dropdown-color: var(--bosco-cream); --bs-dropdown-border-color: var(--bosco-border); --bs-dropdown-link-color: var(--bosco-cream); --bs-dropdown-link-hover-bg: var(--bosco-bg-raised); --bs-dropdown-link-hover-color: #fff; --bs-dropdown-link-active-bg: var(--bosco-bg-raised); --bs-dropdown-divider-bg: var(--bosco-line); border-radius: 10px; box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45); }
.dropdown-item { display: flex; align-items: center; gap: 10px; min-height: 38px; font-size: .9rem; }
.dropdown-item i { width: 1.1em; text-align: center; color: var(--bosco-muted); }
.dropdown-item.text-danger i { color: inherit; }
.alert-warning { --bs-alert-bg: #2c2414; --bs-alert-color: #f3d9a8; --bs-alert-border-color: #5a4520; border-radius: 10px; }
.alert-danger { --bs-alert-bg: #2e1613; --bs-alert-color: #f6c0b8; --bs-alert-border-color: #6b2d26; border-radius: 10px; }
.alert-info { --bs-alert-bg: #13222f; --bs-alert-color: #c3e0f5; --bs-alert-border-color: #2b4a66; border-radius: 10px; }
.alert-success { --bs-alert-bg: #13261a; --bs-alert-color: #bfe7c9; --bs-alert-border-color: #2e5a3a; border-radius: 10px; }

/* ---- Tabs (site details): pills that scroll sideways on phones ---- */
.nav-tabs { border-bottom: 1px solid var(--bosco-line); gap: 4px; }
.nav-tabs .nav-link { border: 0 !important; border-radius: 8px; color: var(--bosco-muted); padding: .45rem .8rem; margin-bottom: 6px; }
.nav-tabs .nav-link:hover { color: var(--bosco-cream); background: var(--bosco-bg-raised); }
.nav-tabs .nav-link.active { background: var(--bosco-cream) !important; color: var(--bosco-bg-main) !important; }
@media (max-width: 767.98px) {
    .nav-tabs { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
    .nav-tabs::-webkit-scrollbar { display: none; }
    .nav-tabs .nav-link { white-space: nowrap; }
}

/* ---- Sites list (index.php) ---- */
.filter-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.filter-chip {
    height: 36px; padding: 0 14px; border-radius: 18px;
    border: 1px solid var(--bosco-border); background: var(--bosco-bg-card); color: #c4ceb4;
    font-size: .85rem; font-weight: 700; white-space: nowrap;
}
.filter-chip:hover { color: var(--bosco-cream); border-color: #4a5a40; }
.filter-chip[aria-pressed="true"] { background: var(--bosco-cream); border-color: var(--bosco-cream); color: var(--bosco-bg-main); }
.filter-tools { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-left: auto; }
.table .num { text-align: right; }
.filter-tools .input-group { width: 200px; flex: none; }
.status-select { min-width: 8.6rem; padding-right: 2rem !important; }
.site-name { font-weight: 700; font-size: .95rem; }
.site-sub { color: var(--bosco-muted); font-size: .8rem; }
.site-contact { font-size: .8rem; color: #c4ceb4; display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 4px; }
.site-contact a { color: inherit; }
.site-badges { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.site-badges .badge { font-size: .7rem; }
.site-dates { font-size: .82rem; color: #c4ceb4; white-space: nowrap; }
.site-dates small { display: block; color: #8e9a80; }
.money { font-weight: 700; white-space: nowrap; }
.row-actions { display: inline-flex; gap: 6px; align-items: center; }
.btn-open { height: 34px; padding: 0 14px; display: inline-flex; align-items: center; gap: 6px; }
.btn-more { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.btn-more::after { display: none; }

@media (max-width: 767.98px) {
    main.container { padding-left: 14px; padding-right: 14px; }
    .page-head h1 { font-size: 1.35rem; }
    .page-head .page-actions .btn-bosco { display: none; } /* phones: the "+" in the tab bar does it */
    .filter-chips { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px 2px; scrollbar-width: none; }
    .filter-chips::-webkit-scrollbar { display: none; }
    .filter-tools { margin-left: 0; width: 100%; }
    .filter-tools .input-group { width: auto; flex: 1 1 auto; }
    .table-stack td.num { text-align: right; flex-wrap: wrap; white-space: normal; }
    .table-stack td.num > div { flex-basis: 100%; text-align: right; }
    .card-stat h3 { font-size: 1.1rem; }

    /* Site cards */
    .table-stack tbody tr { background-color: var(--bosco-bg-card); border: 1px solid var(--bosco-line); border-radius: 14px; padding: 8px 0 4px; margin-bottom: 12px; }
    .table-stack td::before { text-transform: none; font-size: .75rem; color: #8e9a80; }
    .table-stack td.site-main { padding-top: .5rem !important; padding-bottom: .4rem !important; }
    .table-stack td.text-end { border-top: 1px solid var(--bosco-line); margin-top: 6px; padding-top: .7rem !important; }
    .table-stack td .btn-open { flex: 1 1 auto; justify-content: center; min-height: 44px; }
    .table-stack td .btn-more { min-width: 44px; min-height: 44px; }
}
.card-login { border-radius: 16px; border-color: var(--bosco-line); }
.page-login .btn-bosco, .card-login .btn-bosco { min-height: 44px; }

/* ---- Step 6.34: search, chip counts, details window bars, tablet cards ---- */
.page-search { position: relative; flex: 0 1 340px; margin-left: auto; }
.page-search i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--bosco-muted); pointer-events: none; }
.page-search .form-control { padding-left: 36px; height: 40px; background: var(--bosco-bg-card); }
.page-head .page-search + .page-actions { margin-left: 0; }
.chip-count { display: inline-flex; min-width: 22px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 10px; align-items: center; justify-content: center; font-size: .72rem; background: rgba(0, 0, 0, 0.28); }
.chip-count:empty { display: none; }
.filter-chip[aria-pressed="true"] .chip-count { background: rgba(21, 27, 19, 0.14); }

.det-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.det-quick[hidden] { display: none; }
.det-quick-btn { display: inline-flex; align-items: center; gap: 8px; }
.det-margin-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 10px; padding: 10px 14px; border-radius: 10px; background: var(--bosco-bg-main); border: 1px solid var(--bosco-line); font-size: .9rem; }
.det-margin-line strong { font-size: 1.05rem; }
.det-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; background: var(--bosco-bg-header); padding: 10px 12px max(12px, env(safe-area-inset-bottom)); }
.det-actions > .btn { margin: 0; min-height: 48px; font-size: .85rem; }

@media (max-width: 767.98px) {
    .page-search { order: 3; flex: 1 1 100%; margin-left: 0; }
    .page-search .form-control { height: 44px; }
    .det-quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .det-quick-btn { flex-direction: column; justify-content: center; gap: 4px; min-height: 56px; font-size: .8rem; }
    .det-quick-btn i { font-size: 1.15rem; }
    #modal-details .card-stat { padding: 10px; }
    #modal-details .card-stat h4 { font-size: 1.05rem; }
}

/* Tablets (768-1199 px, no side menu): the sites list is shown as cards, two per row, instead of a wide table */
@media (min-width: 768px) and (max-width: 1199.98px) {
    .sites-table, .sites-table tbody, .sites-table tr, .sites-table td { display: block; width: 100%; }
    .sites-table thead { display: none; }
    .sites-table tbody { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 12px; }
    .sites-table tbody tr { background: var(--bosco-bg-main); border: 1px solid var(--bosco-line); border-radius: 14px; padding: 8px 0 4px; display: flex; flex-direction: column; }
    .sites-table tbody tr:has(td[colspan]) { grid-column: 1 / -1; }
    .card:has(.sites-table) { background: transparent; border: 0; }
    .sites-table td { display: flex; justify-content: space-between; align-items: center; gap: 12px; border: 0; padding: .3rem .9rem !important; text-align: right; background: transparent; }
    .sites-table td::before { content: attr(data-label); text-align: left; font-weight: 600; font-size: .75rem; color: #8e9a80; }
    .sites-table td[data-label=""]::before, .sites-table td.site-main::before { display: none; }
    .sites-table td.site-main { display: block; text-align: left; padding-top: .5rem !important; }
    .sites-table td.text-end { margin-top: auto; border-top: 1px solid var(--bosco-line); padding-top: .7rem !important; }
    .sites-table td.text-end::before { display: none; }
    .sites-table td.text-end .row-actions { width: 100%; }
    .sites-table td .btn-open { flex: 1 1 auto; justify-content: center; min-height: 44px; }
    .sites-table td .btn-more { min-width: 44px; min-height: 44px; }
    .sites-table td.num { flex-wrap: wrap; }
    .sites-table td.num > div { flex-basis: 100%; text-align: right; }
}

/* Laptops (1200-1439 px, side menu open): a tighter sites table, so the actions column always fits */
@media (min-width: 1200px) and (max-width: 1439.98px) {
    .sites-table > :not(caption) > * > * { padding-left: .45rem; padding-right: .45rem; }
    .sites-table .status-select { min-width: 7.6rem; font-size: .74rem; }
    .sites-table .btn-open { padding: 0 10px; }
    .sites-table .btn-open-text { display: none; }
    .sites-table .money { font-size: .9rem; }
    main.container-xxl { padding-left: 20px !important; padding-right: 20px !important; }
}

/* ---- Step 6.35: Finance page ---- */
.kpi-row .card-stat { text-align: left; display: flex; flex-direction: column; gap: 2px; }
.kpi-row .card-stat h5 { font-size: 1.35rem; font-weight: 800 !important; letter-spacing: -0.02em; }
.kpi-row .card-stat .btn { align-self: flex-start; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 12px; }
.section-head > .btn { margin-left: auto; }
.form-panel { background: var(--bosco-bg-main); border: 1px solid var(--bosco-line); border-radius: 12px; padding: 14px; margin-bottom: 14px; }
.fc-sc { background: var(--bosco-bg-card); text-align: left !important; }
.fc-sc:hover { border-color: #4a5a40; }
@media (max-width: 767.98px) {
    .kpi-row .card-stat h5 { font-size: 1.1rem; }
    .fin-tabs { margin-left: -14px; margin-right: -14px; padding: 0 14px; }
    /* right-aligned numbers keep their column title; only cells with buttons hide it */
    .table-stack td.text-end:not(:has(.btn))::before { display: block; }
    .table-stack td.text-end:not(:has(.btn)) { justify-content: space-between; padding-top: .3rem !important; }
    #fc-table .table-stack td, #cap-table .table-stack td, #cap-sites .table-stack td { border-bottom: 0; }
    /* forecast and capacity rows become cards: the month / week is the card title */
    #fc-table .table-stack td:first-child, #cap-table .table-stack td:first-child, #cap-sites .table-stack td:first-child { display: block; text-align: left; font-size: 1rem; }
    #cap-table .table-stack td:last-child .d-flex { justify-content: flex-end; }
    .cap-bar { width: 5rem; }
}

/* ---- Step 6.36: Warehouse page ---- */
.wh-code { font-size: .72rem; font-weight: 700; letter-spacing: .04em; color: var(--bosco-muted); }
.wh-notes { font-size: .8rem; color: var(--bosco-muted); margin-top: 2px; white-space: normal; }
.wh-table td.site-main { min-width: 14rem; }
.wh-table tr.wh-low > td:first-child { box-shadow: inset 3px 0 0 var(--bosco-warn); }
.wh-table .badge { margin-left: 6px; }
.wh-status .badge { margin-left: 0; }
.btn-icon { width: 34px; height: 34px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.wh-move { height: 34px; display: inline-flex; align-items: center; padding: 0 12px; }
.wh-tile { border: 1px solid var(--bosco-line); color: inherit; font: inherit; cursor: pointer; }
.wh-tile:hover { border-color: #4a5a40; }
.wh-tile:focus-visible { outline: 2px solid var(--bosco-accent); outline-offset: 2px; }
@media (max-width: 767.98px) {
    .page-head .wh-actions { width: 100%; }
    .page-head .wh-actions .btn-bosco { display: inline-flex; align-items: center; margin-left: auto; }
    .wh-table td.site-main { min-width: 0; }
    .wh-table tr.wh-low { border-left: 3px solid var(--bosco-warn) !important; }
    .wh-table tr.wh-low > td:first-child { box-shadow: none; }
    .wh-table td .wh-row-actions { width: 100%; justify-content: flex-end; }
    .wh-table td .wh-move { flex: 1 1 auto; justify-content: center; min-height: 44px; }
    .wh-table td .btn-icon { width: 44px; height: 44px; }
    .wh-table td .wh-status { text-align: right; }
}
@media (max-width: 767.98px) {
    /* materials: edit / delete sit in the top corner of the card, so the card stays short */
    #card-materials .wh-table tbody tr { position: relative; }
    #card-materials .wh-table td.site-main { padding-right: 112px !important; }
    #card-materials .wh-table td.text-end { position: absolute; top: 10px; right: 10px; width: auto; border: 0; margin: 0; padding: 0 !important; }
    .wh-table td.num { padding-top: .2rem !important; padding-bottom: .2rem !important; }
}

/* ---- Step 6.37: clients, users, calendar, alerts, report, audit log, profile, labels, guide ---- */
.labels-page { max-width: 980px; }
.user-cell { display: flex; gap: 12px; align-items: flex-start; }
.user-cell .app-avatar { margin-top: 2px; }
.users-table .site-badges { margin-top: 4px; }
.profile-id { display: flex; gap: 14px; align-items: center; }
.profile-avatar { width: 56px; height: 56px; font-size: 1.1rem; background: var(--bosco-accent); color: var(--bosco-accent-ink); }
.report-period { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.cal-nav { align-items: center; }
.cal-nav .cal-title { min-width: 9rem; }
.audit-details { max-width: 30rem; white-space: normal; }
.section-head .chip-count { background: var(--bosco-bg-raised); }
a.wh-tile:hover { border-color: #4a5a40; }
@media (max-width: 767.98px) {
    .page-head .page-actions.keep-mobile { width: 100%; }
    .page-head .page-actions.keep-mobile .btn-bosco { display: inline-flex; align-items: center; margin-left: auto; }
    .report-period { grid-template-columns: 1fr; gap: 12px; }
    .cal-nav { width: 100%; margin-left: 0; }
    .cal-nav .cal-title { flex: 1 1 auto; min-width: 0; }
    /* list cards with only small buttons: the buttons sit in the top corner of the card */
    .cards-corner tbody tr { position: relative; }
    .cards-corner td.site-main { padding-right: 112px !important; }
    .cards-corner td.text-end:has(.btn) { position: absolute; top: 10px; right: 10px; width: auto; border: 0; margin: 0; padding: 0 !important; }
    .cards-corner td .btn-icon, .users-table td .btn-icon { width: 44px; height: 44px; }
    .users-table td .row-actions { width: 100%; justify-content: flex-end; }
    .site-contact a { padding: 4px 0; }
    #audit-table td.audit-details { display: block; text-align: left; }
    #audit-table td.audit-details::before { display: block; margin-bottom: 2px; }
    #audit-table td.site-main { display: block; }
    #al-overdue td .row-actions { width: 100%; }
    #al-overdue td .row-actions .btn { flex: 1 1 auto; justify-content: center; min-height: 44px; display: inline-flex; align-items: center; }
}
@media (max-width: 767.98px) {
    .site-contact { flex-direction: column; gap: 2px; }
    .site-contact a { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .table-stack td.is-empty, #audit-table td.is-empty { display: none; }
}

/* Greenhouse page: the values of a device wrap on narrow screens instead of overflowing the card */
.gh-values { display: flex; flex-wrap: wrap; gap: 4px 16px; }
@media (max-width: 767.98px) {
    .gh-page .table-stack td .gh-values { flex: 1 1 auto; min-width: 0; justify-content: flex-end; }
}

/* History charts (plain SVG). Marks carry the series colour; every text uses the text tokens. */
.chart-box { position: relative; width: 100%; min-height: 220px; margin-top: 6px; }
.chart-svg { display: block; width: 100%; height: auto; touch-action: pan-y; }
.chart-grid { stroke: var(--bosco-line); stroke-width: 1; }
.chart-axis { fill: var(--bosco-muted); font-size: 11px; }
.chart-band { fill: rgba(134, 211, 155, 0.10); }
.chart-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart-dot { stroke: var(--bosco-bg-card); stroke-width: 2; }
.chart-end-label { fill: var(--bosco-cream); font-size: 12px; font-weight: 700; }
.chart-cross { stroke: var(--bosco-muted); stroke-width: 1; }
.chart-tip { position: absolute; z-index: 2; pointer-events: none; background: var(--bosco-bg-raised); border: 1px solid var(--bosco-border);
    border-radius: 8px; padding: 6px 10px; font-size: .8rem; color: var(--bosco-cream); white-space: nowrap; }
.chart-tip-time { color: var(--bosco-muted); font-size: .75rem; margin-bottom: 2px; }
.chart-empty { display: flex; align-items: center; justify-content: center; min-height: 200px; color: var(--bosco-muted); font-size: .9rem; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: .8rem; color: var(--bosco-cream); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-line { display: inline-block; width: 14px; height: 3px; border-radius: 2px; margin-right: 6px; vertical-align: middle; }
.legend-item .legend-line { margin-right: 0; }
.legend-band { display: inline-block; width: 14px; height: 10px; border-radius: 2px; background: rgba(134, 211, 155, 0.25); }
.chart-table summary { color: var(--bosco-muted); cursor: pointer; }
.hbar-row { display: grid; grid-template-columns: minmax(110px, 30%) 1fr; gap: 12px; align-items: center; margin-bottom: 10px; font-size: .85rem; }
.hbar-name { color: var(--bosco-cream); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { display: flex; align-items: center; gap: 8px; min-width: 0; }
.hbar { height: 18px; background: #3987e5; border-radius: 0 4px 4px 0; flex: 0 0 auto; max-width: calc(100% - 90px); }
.hbar-value { color: var(--bosco-cream); font-weight: 700; white-space: nowrap; }
