/* onsiteupdate — simple mobile-first UI (shared across all screens) */

:root {
    --bg: #f2f2f7;
    --surface: #ffffff;
    --surface-2: #f9f9fb;
    --border: #d1d1d6;
    --border-soft: #e5e5ea;
    --text: #1c1c1e;
    --text-muted: #636366;
    --text-faint: #8e8e93;
    --primary: #007aff;
    --primary-soft: #e8f2ff;
    --success: #248a3d;
    --success-soft: #e7f6ea;
    --danger: #d70015;
    --danger-soft: #ffecec;
    --warning: #b25000;
    --warning-soft: #fff4e5;
    --violet: #5856d6;
    --radius: 12px;
    --radius-sm: 10px;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    /* legacy aliases used in page markup */
    --panel: var(--surface);
    --panel-2: var(--surface-2);
    --line: var(--border);
    --line-soft: var(--border-soft);
    --ink: var(--text);
    --ink-dim: var(--text-muted);
    --ink-faint: var(--text-faint);
    --lime: var(--primary);
    --lime-dim: var(--primary);
    --lime-glow: var(--primary-soft);
    --lime-ink: #ffffff;
    --amber: var(--warning);
    --bg: #f2f2f7;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
}

body {
    min-height: 100vh;
    padding-bottom: calc(20px + var(--safe-bottom));
}

a { color: var(--primary); }

/* ── Header ── */
.ou-header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--surface);
    border-bottom: 1px solid var(--border-soft);
    box-shadow: var(--shadow);
    padding: 10px 12px 12px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
}

.ou-header-row {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 8px;
}

.ou-back {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    padding: 0 10px;
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-radius: var(--radius-sm);
    white-space: nowrap;
}

.ou-back:active { background: var(--primary-soft); }
.ou-back--ghost { visibility: hidden; pointer-events: none; }

.ou-header-center { min-width: 0; text-align: center; }

.ou-brand {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-faint);
    margin-bottom: 2px;
}

.ou-title {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.ou-subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.3;
}

.ou-logout {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 10px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}

.ou-logout:active { background: var(--border-soft); }

.ou-user-line {
    margin: 8px 0 0;
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.ou-main {
    max-width: 640px;
    margin: 0 auto;
    padding: 14px 12px 0;
}

.wrap { max-width: none; margin: 0; padding: 0; }

/* ── Menu home (grid tiles) ── */
.ou-menu-page {
    padding-bottom: 8px;
}

.ou-menu-section {
    margin-bottom: 20px;
}

.ou-menu-section-label {
    margin: 0 0 10px 2px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.ou-menu-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.ou-menu-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    min-height: 108px;
    padding: 14px 12px 12px;
    text-decoration: none;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    border-top: 3px solid var(--border-soft);
}

.ou-menu-tile:active {
    background: var(--surface-2);
    transform: scale(0.98);
}

.ou-menu-tile-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 10px;
    font-size: 18px;
    line-height: 1;
    background: var(--surface-2);
}

.ou-menu-tile-body {
    flex: 1;
    min-width: 0;
    width: 100%;
}

.ou-menu-tile-title {
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
}

.ou-menu-tile-desc {
    margin-top: 3px;
    font-size: 11px;
    color: var(--text-muted);
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.ou-menu-tile--blue { border-top-color: var(--primary); }
.ou-menu-tile--blue .ou-menu-tile-icon { background: var(--primary-soft); }

.ou-menu-tile--violet { border-top-color: var(--violet); }
.ou-menu-tile--violet .ou-menu-tile-icon { background: #ecebff; }

.ou-menu-tile--green { border-top-color: var(--success); }
.ou-menu-tile--green .ou-menu-tile-icon { background: var(--success-soft); }

.ou-menu-tile--amber { border-top-color: var(--warning); }
.ou-menu-tile--amber .ou-menu-tile-icon { background: var(--warning-soft); }

.ou-menu-tile--default { border-top-color: var(--border); }

@media (min-width: 520px) {
    .ou-menu-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 12px;
    }

    .ou-menu-tile {
        min-height: 112px;
        padding: 16px 14px 14px;
    }

    .ou-menu-tile-title {
        font-size: 15px;
    }

    .ou-menu-tile-desc {
        font-size: 12px;
    }
}

@media (min-width: 720px) {
    .ou-main {
        max-width: 760px;
    }

    .ou-menu-grid {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

.ou-menu-list {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.ou-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
    min-height: 56px;
}

.ou-menu-item:last-child { border-bottom: none; }
.ou-menu-item:active { background: var(--surface-2); }

.ou-menu-item-body { flex: 1; min-width: 0; }

.ou-menu-item-title {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.25;
}

.ou-menu-item-desc {
    margin-top: 2px;
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.35;
}

.ou-menu-item-arrow {
    flex-shrink: 0;
    font-size: 18px;
    color: var(--text-faint);
    line-height: 1;
}

.ou-call-block {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.ou-call-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
    min-height: 52px;
}

.ou-call-row:last-of-type { border-bottom: none; }
.ou-call-row:active { background: var(--surface-2); }

.ou-call-job {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}

.ou-call-name {
    font-size: 15px;
    font-weight: 600;
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ou-call-status {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--surface-2);
    color: var(--text-muted);
    max-width: 42%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ou-call-empty {
    padding: 18px 14px;
    text-align: center;
    font-size: 14px;
    color: var(--text-faint);
}

.ou-call-viewall {
    display: block;
    text-align: center;
    padding: 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    text-decoration: none;
    border-top: 1px solid var(--border-soft);
    background: var(--surface-2);
}

/* ── Cards & forms ── */
.card {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.card-title {
    margin: 0 0 12px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
}

label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

select,
input[type="text"],
input[type="tel"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="search"],
textarea {
    width: 100%;
    padding: 12px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}

select {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 36px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%23636366' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-color: var(--surface);
    cursor: pointer;
}

.select-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.select-row select {
    flex: 1;
    min-width: 0;
    width: auto;
}

.btn-add {
    flex-shrink: 0;
    width: auto;
    min-width: 44px;
    min-height: 44px;
    padding: 0 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
    color: var(--text);
    font-size: 20px;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
}

.btn-add:active {
    background: var(--border-soft);
}

select:focus,
input:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }

.row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

@media (max-width: 380px) {
    .row2 { grid-template-columns: 1fr; }
}

.readonly-box {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 15px;
    font-weight: 600;
}

.readonly-box small {
    display: block;
    margin-top: 2px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    min-height: 48px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
}

.btn:active { opacity: 0.85; }

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.btn-violet {
    background: var(--violet);
    border-color: var(--violet);
    color: #fff;
}

.btn-outline { background: var(--surface); }

.btn-sm {
    min-height: 40px;
    padding: 8px 12px;
    font-size: 14px;
    width: auto;
}

.btn-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 4px;
}

.msg {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.msg-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid #b8e6c1;
}

.msg-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid #ffcaca;
}

.help-text {
    margin-top: 6px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.pill-amber { background: var(--warning-soft); color: var(--warning); }
.pill-lime { background: var(--success-soft); color: var(--success); }
.pill-danger { background: var(--danger-soft); color: var(--danger); }

.radio-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.radio-chip {
    flex: 1;
    min-width: 90px;
    text-align: center;
    padding: 12px 8px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    position: relative;
    background: var(--surface);
}

.radio-chip input { position: absolute; opacity: 0; }
.radio-chip.checked {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
}

/* ── Item search (challan / material out) ── */
.search-results,
#search_results {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    max-height: 220px;
    overflow-y: auto;
    display: none;
    background: var(--surface);
}

.search-result-item {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
}

.search-result-item:last-child { border-bottom: none; }
.search-result-item:active { background: var(--surface-2); }

.search-result-name { font-weight: 600; font-size: 15px; }
.search-result-rate { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.item-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}

.item-row:last-child { border-bottom: none; }

.item-row-detail { font-size: 12px; color: var(--text-muted); }
.item-row-amount { font-weight: 700; font-size: 14px; white-space: nowrap; }

.remove-item-btn {
    background: none;
    border: none;
    color: var(--danger);
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    line-height: 1;
}

.add-item-row { display: flex; gap: 8px; margin-top: 10px; }
.add-item-row input { flex: 1; }

.grand-total {
    text-align: right;
    font-weight: 700;
    font-size: 18px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 2px solid var(--border-soft);
}

/* ── Collect payment tabs ── */
.mode-tab {
    flex: 1;
    padding: 12px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    font-family: inherit;
}

.mode-tab.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.due-row,
.result-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-soft);
}

.due-row:last-child,
.result-row:last-child { border-bottom: none; }

.result-main { min-width: 0; }
.result-title { font-size: 15px; font-weight: 600; }
.result-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.result-amount { font-size: 13px; font-weight: 600; white-space: nowrap; }

/* ── Carry-in status flow ── */
.ci-flow-status-trigger {
    display: inline-block;
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    text-align: left;
    font: inherit;
}

.ci-flow-status-text {
    font-weight: 700;
    font-size: 16px;
    color: var(--text);
    border-bottom: 1px dashed var(--text-muted);
    padding-bottom: 2px;
}

.ci-flow-popover {
    position: fixed;
    z-index: 9999;
    min-width: 220px;
    max-width: 300px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
    padding: 6px 0;
    display: none;
}

.ci-flow-popover-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 6px 14px 8px;
    border-bottom: 1px solid var(--border-soft);
}

.ci-flow-popover-list { list-style: none; margin: 0; padding: 4px 0; }

.ci-flow-popover-list li button {
    display: block;
    width: 100%;
    text-align: left;
    background: none;
    border: none;
    padding: 12px 14px;
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}

.ci-flow-popover-list li button:active { background: var(--primary-soft); color: var(--primary); }

.ci-flow-popover-back-list { list-style: none; margin: 0; padding: 4px 0; border-bottom: 1px solid var(--border-soft); }

.ci-flow-popover-back-list li button {
    width: 100%;
    text-align: left;
    padding: 10px 14px;
    border: none;
    background: transparent;
    font-size: 14px;
    color: var(--text-muted);
    cursor: pointer;
    font-family: inherit;
}

.ci-flow-popover-empty { padding: 10px 14px; font-size: 13px; color: var(--text-muted); }

.ci-flow-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: none;
    align-items: flex-end;
    justify-content: center;
    padding: 12px;
    padding-bottom: calc(12px + var(--safe-bottom));
}

.ci-flow-modal.open { display: flex; }

.ci-flow-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
}

.ci-flow-modal-panel {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: 92vh;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: 16px 16px 12px 12px;
    padding: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.ci-flow-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.ci-flow-modal-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
}

.ci-flow-modal-close {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
}

.ci-modal-form .ci-modal-meta { color: var(--text-muted); font-size: 13px; margin: 0 0 12px; }
.ci-modal-field { margin-bottom: 12px; }
.ci-modal-field label { display: block; margin-bottom: 6px; }
.ci-modal-field label .req { color: var(--danger); }

.ci-modal-field select,
.ci-modal-field input,
.ci-modal-field textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 16px;
    font-family: inherit;
}

.ci-modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.ci-modal-hint { font-size: 12px; color: var(--text-muted); margin: 6px 0 0; }
.ci-modal-warn { color: var(--warning); font-size: 13px; margin: 0; }
.ci-modal-error { color: var(--danger); padding: 12px 0; }

.ci-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 16px;
}

.ci-modal-actions .btn-ghost {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    width: auto;
    min-height: 44px;
}

.ci-po-results {
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    max-height: 160px;
    overflow: auto;
    margin-top: 6px;
    display: none;
}

.ci-po-results.open { display: block; }

.ci-po-results button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 10px 12px;
    border: none;
    border-bottom: 1px solid var(--border-soft);
    background: var(--surface);
    color: var(--text);
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

.ci-po-results button:last-child { border-bottom: none; }
.ci-po-results button:active { background: var(--primary-soft); }

/* ── Login ── */
.ou-login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--bg);
}

.ou-login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 28px 22px;
    box-shadow: var(--shadow);
}

.ou-login-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
    font-weight: 700;
}

.ou-login-card .sub {
    margin: 0 0 22px;
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
}

.ou-login-error {
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: var(--danger-soft);
    color: var(--danger);
    font-size: 14px;
    font-weight: 600;
}

.ou-login-card button[type="submit"] {
    width: 100%;
    min-height: 48px;
    margin-top: 8px;
    border: none;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.ou-login-link {
    display: inline-block;
    margin-top: 14px;
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
}

/* ── Preview actions ── */
.preview-actions {
    display: grid;
    gap: 10px;
    margin-top: 8px;
}

@media (min-width: 480px) {
    .preview-actions { grid-template-columns: 1fr 1fr; }
}

/* ── Material out extras ── */
.selected-party,
.readonly-box.inline {
    background: var(--surface-2);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-size: 14px;
    font-weight: 600;
    margin-top: 8px;
}

.selected-party { display: none; }

.search-result-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.item-row-name { font-weight: 600; font-size: 15px; flex: 1; }

.optional-tag {
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    font-size: 12px;
}

.serial-row { margin-top: 8px; }

.serial-input-row {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-top: 6px;
}

.serial-input-row input[type="text"] { flex: 1; }

.scan-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border-radius: var(--radius-sm);
    border: 1px solid var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.desc-row { margin-top: 8px; }

.field-label-sm {
    font-size: 11px;
    color: var(--text-muted);
    margin-bottom: 4px;
    display: block;
}

.scan-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.55);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.scan-modal.open { display: flex; }

.scan-modal-inner {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 16px;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
}

.scan-modal-inner #scan_reader {
    width: 100%;
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.scan-modal-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin: 10px 0 0;
    text-align: center;
}

.scan-close-btn { margin-top: 12px; width: 100%; }

/* ── Collect payment search results ── */
.result-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 10px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-soft);
}

.result-item:last-child { border-bottom: none; }
.result-item:active { background: var(--surface-2); }

#search_results {
    display: none;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    margin-top: 6px;
    max-height: 240px;
    overflow-y: auto;
}

/* ── Preview document ── */
.doc-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.doc-no { font-weight: 700; font-size: 18px; }
.doc-meta { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.item-row-top {
    display: flex;
    justify-content: space-between;
    gap: 10px;
}

.item-name { font-size: 15px; font-weight: 600; }
.item-amount { font-size: 15px; white-space: nowrap; }
.item-qty { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.grand-total.split {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    font-size: 17px;
}

.btn-row { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 4px; }

@media (min-width: 480px) {
    .btn-row { grid-template-columns: 1fr 1fr; }
}

/* ── Master list (Party / Item) ── */
.ou-master-toolbar {
    display: flex;
    gap: 10px;
    align-items: stretch;
    margin-bottom: 12px;
}

.ou-master-toolbar input[type="search"] {
    flex: 1;
    margin: 0;
}

.ou-master-list {
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin-bottom: 12px;
}

.ou-master-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    border-bottom: 1px solid var(--border-soft);
}

.ou-master-row:last-child { border-bottom: none; }

.ou-master-row-body {
    flex: 1;
    min-width: 0;
}

.ou-master-row-title {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.25;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ou-master-row-sub {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ou-master-row-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.ou-master-row-actions .btn {
    width: auto;
    min-height: 40px;
    padding: 8px 12px;
    font-size: 13px;
}

.btn-danger-outline {
    color: var(--danger);
    border-color: #f5c2c7;
    background: var(--danger-soft);
}

.ou-master-empty {
    padding: 24px 14px;
    text-align: center;
    font-size: 14px;
    color: var(--text-faint);
}

.ou-master-form-view { display: none; }
.ou-master-form-view.is-open { display: block; }
.ou-master-list-view.is-hidden { display: none; }

.ou-filter-row {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ou-filter-chip {
    padding: 8px 12px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: var(--surface);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
}

.ou-filter-chip.is-active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.checkbox-row input[type="checkbox"] {
    width: 20px;
    height: 20px;
    margin: 0;
}

.btn-row.ou-form-actions {
    grid-template-columns: 1fr 1fr 1fr;
}

.ou-readonly-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

@media (min-width: 480px) {
    .ou-readonly-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.ou-readonly-grid .readonly-box span {
    display: block;
    font-size: 15px;
    font-weight: 600;
}

@media (max-width: 420px) {
    .btn-row.ou-form-actions {
        grid-template-columns: 1fr;
    }
}

/* ── Company context ── */
.ou-company-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 8px;
    padding: 8px 10px;
    background: var(--primary-soft);
    border: 1px solid #c9defa;
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.ou-company-bar-label {
    color: var(--text-muted);
    font-weight: 600;
}

.ou-company-bar-name {
    font-weight: 700;
    color: var(--primary);
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ou-company-bar-switch {
    font-weight: 600;
    font-size: 12px;
    text-decoration: none;
    white-space: nowrap;
}

.ou-company-pick-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ou-company-pick {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
}

.ou-company-pick.is-selected,
.ou-company-pick:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

.ou-company-pick input[type="radio"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

.ou-company-pick-name {
    font-size: 15px;
    font-weight: 600;
}
