/* ==========================================================================
   Service Report POC - mobile overrides (designed for 360 / 390 / 414 px)
   Goal: fewer taps, less scrolling (compact cards, chip toggles, sticky jump bar)
   ========================================================================== */

/* "clip" (not "hidden") so body does not become a scroll container - keeps position:sticky working */
body { overflow-x: clip; }

@media (max-width: 991.98px) {
    :root { --topbar-h: 56px; }
    .app-topbar { padding: 6px 12px; gap: 6px; min-height: 56px; }
    .topbar-title h1 { font-size: 17px; }
    .topbar-sub { font-size: 12px; margin-top: 0; }
    .app-content { padding: 12px 12px 20px; }
    .action-bar { padding-left: 12px; padding-right: 12px; }
}

@media (max-width: 767.98px) {
    body { font-size: 15px; }
    .app-content { padding-bottom: 88px; }          /* room for the FAB */

    /* ---------- Dashboard: compact ---------- */
    .welcome { padding: 14px 16px; margin-bottom: 10px; }
    .welcome-hi { font-size: 13px; }
    .welcome-name { font-size: 18px; }
    .welcome-cta { min-height: 40px; padding: 0 12px; font-size: 14px; }
    .stat-grid { --bs-gutter-x: .5rem; --bs-gutter-y: .5rem; }
    .stat-card { padding: 10px 6px; align-items: center; text-align: center; gap: 0; border-radius: 12px; }
    .stat-icon { display: none; }
    .stat-value { font-size: 22px; order: -1; }
    .stat-label { font-size: 11px; line-height: 1.2; }
    .panel { padding: 12px 14px; }
    .panel-head { margin-bottom: 2px; }
    .panel-head h3 { font-size: 15px; }
    .sr-row { padding: 10px 2px; gap: 8px; }
    .sr-row-main { gap: 2px; }
    .sr-row-cust { font-size: 14px; }
    .sr-row .chips { display: none; }

    /* ---------- SR lists: compact cards ---------- */
    .list-toolbar { gap: 8px; margin-bottom: 10px; }
    .list-toolbar .search-box { max-width: none; }
    .card-list { gap: 8px; }
    .sr-card-body { padding: 10px 12px; gap: 4px; }
    .sr-card .kv-mini { display: flex; flex-wrap: wrap; gap: 2px 12px; }
    .sr-card .kv-mini dt { display: none; }
    .sr-card .kv-mini dd { font-size: 13px; color: var(--muted); }
    .sr-card-actions a, .sr-card-actions button { min-height: 44px; font-size: 13.5px; }

    /* ---------- Create SR ---------- */
    .form-hero { padding: 10px 12px; margin-bottom: 8px; }
    .form-hero-no { font-size: 18px; }
    .form-hero-hint { display: none; }
    .sr-form .f-card { padding: 12px 12px 14px; margin-bottom: 8px; }
    .f-head { font-size: 14.5px; margin-bottom: 10px; }
    .sr-form .row { --bs-gutter-y: .6rem; --bs-gutter-x: .6rem; }
    .form-label { font-size: 12.5px; margin-bottom: 4px; }
    .form-control, .form-select { min-height: 44px; }
    textarea.form-control { min-height: 44px; }

    .line-list { gap: 6px; }
    .line-item { gap: 6px; }
    .line-no { width: 24px; height: 24px; margin-top: 10px; font-size: 11.5px; }
    .btn-remove { min-width: 36px; height: 44px; padding: 0 6px; }
    .btn-add { margin-top: 8px; min-height: 42px; }

    .tool-kv { grid-template-columns: 1fr 1fr; }

    /* Service items -> compact 2-line cards: Description / Qty · Price · Amount */
    .items-table, .items-table tbody { display: block; }
    .items-table thead { display: none; }
    .items-table tr.item-row {
        display: grid;
        grid-template-columns: 1fr 1fr 1fr 36px;
        grid-template-areas: "type desc desc act" "qty price amt amt";
        gap: 6px 6px;
        padding: 8px;
        margin-bottom: 8px;
        border: 1px solid var(--line);
        border-radius: 12px;
        background: #fafbfc;
    }
    .items-table td, .items-table td.col-num { display: block; width: auto !important; padding: 0; border: 0; text-align: left; }
    .items-table td[data-label]::before {
        content: attr(data-label);
        display: block;
        font-size: 11px; font-weight: 600; color: var(--muted);
        margin-bottom: 2px;
    }
    .items-table .col-desc::before { display: none !important; }
    .items-table .col-sno { display: none; }
    .items-table .col-desc { grid-area: desc; }
    .items-table td[data-label="Qty"] { grid-area: qty; }
    .items-table td[data-label="Unit Price S$"] { grid-area: price; }
    .items-table .col-amount { grid-area: amt; text-align: right; }
    .items-table .col-act { grid-area: act; }
    .items-table output { padding: 12px 2px 0; font-size: 15px; text-align: right; }
    .items-table .col-act .btn-remove { width: 36px; min-width: 0; }

    /* Sticky bottom action bar: equal thumb-sized buttons */
    .action-bar { padding: 8px 10px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); }
    .action-bar-inner { gap: 8px; }
    .action-bar .btn {
        flex: 1 1 0; min-width: 0;
        flex-direction: column; gap: 1px;
        min-height: 52px; padding: 4px;
        font-size: 12px; line-height: 1.1;
    }
    .action-bar .btn i { font-size: 18px; }
    .action-bar .btn-grow { flex: 1.3 1 0; }

    /* ---------- View SR ---------- */
    .kv dt { flex-basis: 45%; font-size: 13.5px; }
    .kv dd { font-size: 14.5px; }
    .view-item { grid-template-columns: 1fr 1fr 1fr; gap: 6px 10px; }
    .view-item .vi-no { grid-column: 1 / 3; font-weight: 700; color: var(--muted); font-size: 12.5px; }
    .view-item .vi-type { grid-column: 3; justify-self: end; font-size: 12px; font-weight: 600; padding: 1px 8px; border-radius: 6px; background: #eef1f5; color: var(--ink-2); }
    .view-item .vi-no::before { content: "Item "; }
    .view-item .vi-desc { grid-column: 1 / -1; font-weight: 600; }
    .view-item .vi-num { text-align: left; font-size: 14px; }
    .view-item .vi-num::before { content: attr(data-label); display: block; font-size: 11.5px; color: var(--muted); font-weight: 600; }

    /* ---------- Masters ---------- */
    .master-modal .modal-body { padding: 14px; }
    .master-modal .modal-footer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
    .master-modal .modal-footer .btn { min-height: 48px; }
    .filter-select { flex: 1 1 100%; }

    /* Login */
    .login-card { padding: 28px 20px; }
}

@media (max-width: 374.98px) {
    .kv-mini { grid-template-columns: 1fr; }
    .stat-value { font-size: 20px; }
    .stat-label { font-size: 10.5px; }
    .chip-toggle span { padding: 0 12px; }
}
