:root {
    --bms-primary: #1a56a8;
    --bms-primary-dark: #0f3d7a;
    --bms-primary-light: #2d6fc4;
    --bms-accent: #0ea5a0;
    --bms-bg: #f0f4f8;
    --bms-surface: #ffffff;
    --bms-text: #1e293b;
    --bms-muted: #64748b;
    --bms-border: #e2e8f0;
    --bms-sidebar-width: 250px;
    --bms-header-height: 64px;
    --bms-radius: 12px;
    --bms-shadow: 0 4px 24px rgba(15, 61, 122, 0.08);
}

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

html, body {
    margin: 0;
    padding: 0;
    font-family: "Source Sans 3", "Noto Sans Devanagari", "Noto Sans Bengali", "Noto Sans Oriya", "Noto Sans Tamil", "Noto Sans Telugu", "Noto Sans Gujarati", "Noto Sans Kannada", "Noto Sans Malayalam", "Noto Sans Gurmukhi", "Noto Nastaliq Urdu", "Segoe UI", sans-serif;
    color: var(--bms-text);
    background: var(--bms-bg);
    min-height: 100%;
    overflow-x: clip;
}

a { color: var(--bms-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ========== Login / Register ========== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 10% 0%, rgba(26, 86, 168, 0.22), transparent 55%),
        radial-gradient(700px 380px at 95% 90%, rgba(14, 165, 160, 0.14), transparent 50%),
        linear-gradient(160deg, #0f3d7a 0%, #1a56a8 45%, #0ea5a0 120%);
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-web-brand,
.login-site-links,
.login-feature-panel { display: none; }

.login-wrapper { width: 100%; }

.login-logo {
    text-align: center;
    margin-bottom: 1.5rem;
    color: #fff;
}

.login-logo .brand-mark {
    width: 72px;
    height: 72px;
    margin: 0 auto 1rem;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 24px rgba(15, 61, 122, 0.28);
}

.login-logo .brand-mark img {
    display: block;
    width: 100%;
    height: 100%;
}

.login-title {
    margin: 0 0 0.35rem;
    font-size: 1.65rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.login-subtitle {
    margin: 0;
    opacity: 0.88;
    font-size: 0.95rem;
}

.login-form-card {
    background: var(--bms-surface);
    border-radius: 16px;
    padding: 1.75rem;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18);
}

.login-card-title { display: none; }

.login-form .form-group { margin-bottom: 1.1rem; }

.login-role {
    display: flex;
    flex-wrap: wrap;
    gap: 1.1rem 1.5rem;
}

.register-name-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
    margin-bottom: 1.1rem;
    align-items: start;
}

.register-name-row .form-group {
    margin-bottom: 0;
    min-width: 0;
    text-align: left;
}

.register-name-row .form-label {
    justify-content: flex-start;
    align-items: flex-start;
    text-align: left;
    width: 100%;
    min-height: 2.5em;
    line-height: 1.25;
}

.register-otp {
    margin-bottom: 0;
}

.register-actions {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-top: 0.75rem;
}

.register-actions .login-btn,
.register-actions .login-btn.secondary {
    margin: 0;
    border-radius: 0;
}

.register-actions .login-btn.secondary {
    border-bottom: none;
    border-radius: 10px 10px 0 0;
}

.register-actions .login-btn:not(.secondary) {
    border-radius: 0 0 10px 10px;
}

@media (max-width: 640px) {
    .register-name-row { grid-template-columns: 1fr; }
}

.form-label {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.4rem;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--bms-text);
    text-align: left;
    width: 100%;
}

.form-label i { color: var(--bms-primary); font-size: 1.05rem; }

.form-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: #fff;
    min-height: 44px;
    color: var(--bms-text);
    -webkit-user-select: text;
    user-select: text;
}

.form-input:disabled {
    background: #f8fafc;
    color: var(--bms-muted);
    cursor: not-allowed;
}

.combobox {
    position: relative;
}

.combobox .form-input {
    padding-right: 2.1rem;
}

.combobox::after {
    content: "";
    position: absolute;
    right: 0.85rem;
    top: 50%;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--bms-muted);
    border-bottom: 2px solid var(--bms-muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.password-input-wrapper { position: relative; }
.password-input-wrapper .form-input { padding-right: 2.75rem; }

.password-toggle {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--bms-muted);
    cursor: pointer;
    padding: 0.35rem;
    font-size: 1.15rem;
}

.form-options {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    font-size: 0.875rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--bms-muted);
    cursor: pointer;
}

.forgot-password { color: var(--bms-primary); font-weight: 500; }

.login-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.8rem 1.25rem;
    min-height: 44px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--bms-primary) 0%, var(--bms-primary-dark) 100%);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s;
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(26, 86, 168, 0.35);
    text-decoration: none;
    color: #fff;
}

.login-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none;
}

.otp-send-block {
    margin-bottom: 1.1rem;
}

.otp-send-block .login-btn.secondary {
    margin-top: 0;
}

.otp-drop {
    margin-top: 0.75rem;
    padding: 0.9rem;
    border: 1px solid var(--bms-border);
    border-radius: 12px;
    background: #f8fafc;
}

.otp-drop .login-btn {
    margin-top: 0.75rem;
}

.register-otp-box {
    margin-top: 0.65rem;
}

.verify-input {
    position: relative;
}

.verify-input .form-input {
    padding-right: 7.2rem;
}

.verify-input .login-btn.phone-otp-btn {
    position: absolute;
    right: 0.35rem;
    top: 50%;
    transform: translateY(-50%);
    width: auto;
    min-width: 6.4rem;
    min-height: 32px;
    margin: 0;
    padding: 0.28rem 0.7rem;
    font-size: 0.85rem;
    box-shadow: none;
}

.verify-input .login-btn.phone-otp-btn:hover {
    transform: translateY(-50%);
}

.verified-badge {
    position: absolute;
    right: 0.4rem;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.28rem 0.55rem;
    border-radius: 8px;
    background: #e8f8ef;
    color: #17803d;
    font-size: 0.82rem;
    font-weight: 700;
    line-height: 1;
    pointer-events: none;
}

.otp-rejected {
    color: #b91c1c;
    font-weight: 700;
}

.form-input.account-email {
    background: #f8fafc;
    color: var(--bms-muted);
}

.login-btn.forgot-back {
    margin-top: 0.75rem;
    text-decoration: none;
}

.login-btn.secondary {
    background: #fff;
    color: var(--bms-primary);
    border: 1.5px solid var(--bms-primary);
    box-shadow: none;
    margin-top: 0.75rem;
}

.login-btn.secondary:hover {
    background: rgba(26, 86, 168, 0.06);
    box-shadow: none;
    color: var(--bms-primary);
}

.form-hint {
    display: block;
    margin-top: 0.35rem;
    font-size: 0.8rem;
    color: var(--bms-muted);
}

.name-combo {
    position: relative;
}

.name-combo.is-disabled {
    opacity: 0.72;
}

.name-combo .form-input {
    padding-right: 2.3rem;
}

.name-combo-caret {
    position: absolute;
    right: 0.15rem;
    top: 50%;
    transform: translateY(-50%);
    width: 2rem;
    height: 2rem;
    border: none;
    background: transparent;
    cursor: pointer;
}

.name-combo-caret::before {
    content: "";
    position: absolute;
    left: 50%;
    top: 42%;
    width: 0.45rem;
    height: 0.45rem;
    border-right: 2px solid var(--bms-muted);
    border-bottom: 2px solid var(--bms-muted);
    transform: translateX(-50%) rotate(45deg);
}

.name-combo-list {
    position: absolute;
    z-index: 80;
    left: 0;
    right: 0;
    top: calc(100% + 0.25rem);
    margin: 0;
    padding: 0.35rem 0;
    list-style: none;
    max-height: 14rem;
    overflow: auto;
    background: #fff;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(15, 40, 80, 0.12);
}

.name-combo-list button {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.55rem 0.85rem;
    font: inherit;
    color: var(--bms-text);
    cursor: pointer;
}

.name-combo-list button:hover,
.name-combo-list button.is-active {
    background: rgba(26, 86, 168, 0.08);
}

.name-combo-new {
    color: var(--bms-primary) !important;
    font-weight: 600;
}

.name-combo-clear {
    color: var(--bms-muted) !important;
}

.name-combo-empty {
    padding: 0.55rem 0.85rem;
    color: var(--bms-muted);
    font-size: 0.85rem;
}

.form-error {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.form-success {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
    border-radius: 8px;
    padding: 0.65rem 0.85rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
}

.login-footer {
    text-align: center;
    margin-top: 1.25rem;
    color: rgba(255, 255, 255, 0.75);
    font-size: 0.8rem;
}

.login-footer a {
    color: #fff;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.form-footer-links {
    margin-top: 1rem;
    text-align: center;
}

.back-to-login {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.9rem;
    font-weight: 500;
}

/* ========== App shell (index-style) ========== */
.bms-shell {
    height: 100%;
    min-height: 100dvh;
    max-height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--bms-bg);
    overflow: hidden;
}

.top-header {
    min-height: var(--bms-header-height);
    padding-top: env(safe-area-inset-top, 0px);
    background: linear-gradient(135deg, var(--bms-primary-dark) 0%, var(--bms-primary) 55%, var(--bms-primary-light) 100%);
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 12px rgba(15, 61, 122, 0.25);
    flex-shrink: 0;
}

.header-content {
    min-height: var(--bms-header-height);
    display: flex;
    align-items: center;
    padding: 0 1rem;
    gap: 0.65rem;
}

.header-start {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    flex: 1;
}

.mobile-menu-toggle,
.menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    order: 0;
    border: none;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    min-width: 44px;
    min-height: 44px;
    width: auto;
    height: 44px;
    padding: 0 0.75rem;
    gap: 0.45rem;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    z-index: 2;
}

.mobile-menu-toggle-text,
.menu-toggle-text {
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.02em;
}

.menu-bars {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 18px;
}

.menu-bars span {
    display: block;
    width: 100%;
    height: 2.5px;
    background: #fff;
    border-radius: 2px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1;
}

.header-left .logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.logo-badge {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
}

.logo-badge img {
    display: block;
    width: 100%;
    height: 100%;
}

.header-center {
    display: none;
}

.dashboard-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: left;
}

.dashboard-title-browser { display: none; }

.header-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.header-back {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    height: 40px;
    padding: 0 0.85rem 0 0.65rem;
    border: none;
    border-radius: 8px;
    background: #dce775;
    color: #1b1b1b;
    font-size: 0.85rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.header-back i { font-size: 1.1rem; }

.profile-btn {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-chip {
    display: none;
    font-size: 0.85rem;
    opacity: 0.95;
    background: #dce775;
    color: #1b1b1b;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    border: none;
    max-width: min(420px, 48vw);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-chip-switch {
    cursor: pointer;
    appearance: auto;
    height: auto;
}

.branch-switch {
    max-width: 220px;
    min-width: 140px;
    padding: 0.35rem 0.55rem;
    font-size: 0.8rem;
    height: auto;
}

.login-pick-title {
    margin: 0 0 0.35rem;
    font-size: 1.15rem;
}

.branch-pick-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin: 1rem 0;
}

.branch-pick-card {
    text-align: left;
    border: 1px solid var(--bms-border);
    background: #fff;
    border-radius: 12px;
    padding: 0.85rem 1rem;
    cursor: pointer;
    font-family: inherit;
}

.branch-pick-card:hover {
    border-color: var(--bms-primary);
}

.branch-pick-card strong {
    display: block;
    color: var(--bms-primary-dark);
}

.branch-pick-card span {
    display: block;
    margin-top: 0.25rem;
    color: var(--bms-muted);
    font-size: 0.85rem;
}

.main-container {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.sidebar {
    position: fixed;
    top: calc(var(--bms-header-height) + env(safe-area-inset-top, 0px));
    left: 0;
    bottom: 0;
    z-index: 95;
    width: min(var(--bms-sidebar-width), 86vw);
    background: var(--bms-surface);
    border-right: 1px solid var(--bms-border);
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.sidebar.open { transform: translateX(0); }

.sidebar-collapse-btn {
    display: none;
}

.sidebar-nav { padding: 1rem 0.75rem; }

.nav-menu {
    list-style: none;
    margin: 0;
    padding: 0;
}

.nav-item { margin-bottom: 0.25rem; }

.nav-section-title {
    list-style: none;
    margin: 0.9rem 0.35rem 0.35rem;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--bms-muted);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    border-radius: 10px;
    color: var(--bms-text);
    font-weight: 500;
    font-size: 0.95rem;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
}

.nav-link i {
    font-size: 1.25rem;
    color: var(--bms-primary);
    width: 1.4rem;
    text-align: center;
}

.nav-link:hover {
    background: rgba(26, 86, 168, 0.08);
    text-decoration: none;
    color: var(--bms-primary-dark);
}

.nav-link.active {
    background: linear-gradient(135deg, rgba(26, 86, 168, 0.12), rgba(14, 165, 160, 0.08));
    color: var(--bms-primary-dark);
    font-weight: 600;
}

.main-content {
    flex: 1;
    min-width: 0;
    min-height: 0;
    padding: 1.5rem;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.content-wrapper { max-width: 1200px; margin: 0 auto; }

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bms-surface);
    border-radius: var(--bms-radius);
    padding: 1.25rem;
    box-shadow: var(--bms-shadow);
    border: 1px solid var(--bms-border);
    transition: transform 0.15s, box-shadow 0.15s;
    cursor: pointer;
    color: inherit;
    text-decoration: none;
    display: block;
}

.stat-card:hover,
.stat-card.active {
    transform: translateY(-2px);
    box-shadow: 0 8px 28px rgba(15, 61, 122, 0.12);
    text-decoration: none;
    color: inherit;
}

.card-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
}

.card-label {
    margin: 0 0 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bms-muted);
}

.card-value {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--bms-text);
}

.card-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(135deg, rgba(26, 86, 168, 0.12), rgba(14, 165, 160, 0.12));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bms-primary);
    font-size: 1.5rem;
    flex-shrink: 0;
}

.page-panel {
    background: var(--bms-surface);
    border-radius: var(--bms-radius);
    padding: 1.5rem;
    box-shadow: var(--bms-shadow);
    border: 1px solid var(--bms-border);
}

.page-panel h1 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
}

.page-panel p {
    margin: 0;
    color: var(--bms-muted);
}

.logout-item .nav-link { color: #b91c1c; }
.logout-item .nav-link i { color: #b91c1c; }

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
}

.sidebar-backdrop.open { display: block; }

.top-header.is-shop .logo span,
.top-header.is-shop .menu-toggle-text {
    display: none;
}

@media (min-width: 901px) {
    .menu-toggle { display: none; }
    .sidebar-backdrop { display: none !important; }

    .sidebar {
        position: relative;
        top: auto;
        left: auto;
        bottom: auto;
        z-index: 1;
        width: var(--bms-sidebar-width);
        min-width: var(--bms-sidebar-width);
        align-self: stretch;
        transform: none;
        box-shadow: none;
        flex-shrink: 0;
        transition: width 0.2s ease, min-width 0.2s ease, border-width 0.2s ease;
    }

    .bms-shell.sidebar-collapsed .sidebar {
        width: 0;
        min-width: 0;
        overflow: hidden;
        border-right-width: 0;
        padding: 0;
    }

    .sidebar-collapse-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
        align-self: flex-start;
        width: 28px;
        height: 48px;
        margin-top: 0.85rem;
        margin-left: -1px;
        border: 1px solid var(--bms-border);
        border-left: none;
        background: var(--bms-surface);
        color: var(--bms-primary);
        border-radius: 0 10px 10px 0;
        cursor: pointer;
        z-index: 2;
        box-shadow: 2px 0 10px rgba(15, 61, 122, 0.08);
        font-size: 1.35rem;
        line-height: 1;
        padding: 0;
    }

    .sidebar-collapse-btn:hover {
        background: rgba(26, 86, 168, 0.08);
    }

    .dashboard-title-compact { display: none; }
    .dashboard-title-browser { display: block; }

    .hide-on-desktop { display: none !important; }
    .desktop-only { display: flex !important; }
    .login-page:has(.login-feature-panel) {
        justify-content: flex-start;
        align-items: stretch;
        padding: 22px 5vw 18px;
    }
    .login-container:has(.login-feature-panel) {
        max-width: 1120px;
        margin: 0 auto;
        display: grid;
        grid-template-columns: minmax(240px, 1fr) 400px;
        grid-template-rows: auto 1fr auto;
        grid-template-areas:
            "brand brand"
            "features form"
            "links links";
        gap: 1rem 2.5rem;
        align-items: start;
        min-height: calc(100vh - 40px);
    }
    .login-web-brand {
        grid-area: brand;
        display: grid;
        grid-template-columns: 72px 1fr 72px;
        align-items: center;
        color: #fff;
    }
    .login-web-logo {
        width: 72px;
        height: 72px;
        border-radius: 16px;
        overflow: hidden;
        box-shadow: 0 8px 24px rgba(15, 61, 122, 0.28);
        justify-self: start;
    }
    .login-web-logo img {
        display: block;
        width: 100%;
        height: 100%;
    }
    .login-web-name {
        grid-column: 2;
        text-align: center;
    }
    .login-web-product {
        margin: 0 0 0.2rem;
        font-size: 1.55rem;
        font-weight: 700;
        letter-spacing: -0.03em;
        line-height: 1.2;
    }
    .login-web-title {
        margin: 0;
        font-size: 1.02rem;
        font-weight: 500;
        opacity: 0.92;
    }
    .login-feature-panel {
        grid-area: features;
        display: block;
        color: #fff;
        justify-self: start;
        max-width: 22.5rem;
        margin-left: -0.35rem;
        padding: 0.15rem 1.25rem 0 0;
    }
    .login-container:has(.login-feature-panel) .login-wrapper {
        grid-area: form;
        padding-top: 0;
        margin-top: 0;
    }
    .login-container:has(.login-feature-panel) .login-logo,
    .login-container:has(.login-feature-panel) .login-footer { display: none; }
    .login-site-links {
        grid-area: links;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 0.85rem 1.6rem;
        padding: 0.35rem 0 0.15rem;
        color: #fff;
        font-size: 0.95rem;
    }
    .login-site-links a {
        color: #fff;
        text-decoration: underline;
        text-underline-offset: 3px;
    }
    .login-feature-title {
        margin: 0 0 1.15rem;
        font-size: 1.85rem;
        font-weight: 700;
        letter-spacing: -0.03em;
        line-height: 1.2;
    }
    .login-feature-list {
        list-style: none;
        margin: 0 0 1.5rem;
        padding: 0;
        display: grid;
        gap: 0.85rem;
    }
    .login-feature-list li {
        display: flex;
        align-items: flex-start;
        gap: 0.7rem;
        font-size: 1.02rem;
        line-height: 1.4;
        opacity: 0.95;
    }
    .login-feature-list i {
        margin-top: 0.12rem;
        font-size: 1.2rem;
        color: #d8fff6;
    }
    .login-download-placeholder {
        margin: 0;
        padding: 0.85rem 1rem;
        border: 1px dashed rgba(255, 255, 255, 0.45);
        border-radius: 12px;
        font-size: 0.92rem;
        opacity: 0.9;
    }
    .login-card-title { display: block; margin-bottom: 0.65rem; }
    .login-card-title h2 {
        margin: 0;
        font-size: 1.15rem;
        letter-spacing: -0.02em;
    }
    .login-card-title p {
        margin: 0.15rem 0 0;
        color: var(--bms-muted);
        font-size: 0.8rem;
        line-height: 1.3;
    }
    .auth-fit .login-wrapper {
        width: 520px;
        max-width: min(520px, calc(100vw - 48px));
    }
    .auth-fit .login-form-card { padding: 0.85rem 1rem 0.75rem; }
    .auth-fit .login-form .form-group { margin-bottom: 0.4rem; }
    .auth-fit .register-name-row { margin-bottom: 0.4rem; gap: 0.55rem; }
    .auth-fit .form-label { margin-bottom: 0.15rem; font-size: 0.8rem; }
    .auth-fit .register-name-row .form-label { min-height: 2.4em; }
    .auth-fit .form-input { min-height: 36px; padding: 0.32rem 0.7rem; font-size: 0.8125rem; }
    .auth-fit .form-hint {
        margin-top: 0.15rem;
        font-size: 0.72rem;
        line-height: 1.25;
    }
    .auth-fit .login-btn { min-height: 38px; padding: 0.45rem 0.9rem; }
    .auth-fit .login-btn.secondary { margin-top: 0.35rem; }
    .auth-fit .otp-send-block { margin-bottom: 0.4rem; }
    .auth-fit .otp-drop { margin-top: 0.4rem; padding: 0.55rem 0.7rem; }
    .auth-fit .otp-drop .login-btn { margin-top: 0.4rem; }
    .auth-fit .form-footer-links { margin-top: 0.4rem; }
    .auth-fit .form-error,
    .auth-fit .form-success { margin-bottom: 0.4rem; padding: 0.4rem 0.65rem; }
    .auth-fit .login-card-title { margin-bottom: 0.5rem; }
    .logo-badge {
        width: 40px;
        height: 40px;
        border-radius: 10px;
    }
    .home-page .home-hero { justify-content: space-between; }
}

@media (max-width: 900px) {
    .header-content {
        padding: 0 0.7rem;
        gap: 0.45rem;
    }
    .header-left .logo span { display: none; }
    .dashboard-title {
        font-size: 0.95rem;
        text-align: left;
    }
    .header-right { gap: 0.35rem; }
    .header-back { height: 36px; padding: 0 0.7rem 0 0.5rem; font-size: 0.8rem; }
    .main-content {
        padding: 0.85rem 0.7rem calc(1.75rem + env(safe-area-inset-bottom, 0px));
    }
    .page-panel { padding: 1rem; }
    .page-panel h1 { font-size: 1.2rem; }
    .cards-grid { grid-template-columns: 1fr 1fr; gap: 0.75rem; }
    .stat-card { padding: 0.9rem; }
    .card-value { font-size: 1.05rem; }
    .card-label { font-size: 0.75rem; }
    .card-icon { width: 38px; height: 38px; font-size: 1.15rem; }
}

@media (max-width: 420px) {
    .menu-toggle-text,
    .mobile-menu-toggle-text { display: none; }
    .exp-add-btn span { display: none; }
    .exp-add-btn { padding: 0.5rem 0.65rem; }
}

.otp-resend {
    display: inline-block;
    margin-top: 0.35rem;
    border: none;
    background: none;
    color: var(--bms-primary);
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.otp-resend:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-container-wide { max-width: 560px; }

.nav-item-hidden { display: none !important; }

.logo-img-sm {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    object-fit: cover;
    background: rgba(255, 255, 255, 0.18);
}

.stock-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.shop-hub-toolbar {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding: 0.7rem 0.9rem;
}

.shop-hub-toolbar h1 {
    margin: 0;
    font-size: 1.15rem;
    line-height: 1.25;
    min-width: 0;
}

.stock-action-btn {
    width: auto;
    padding: 0.65rem 1.1rem;
    white-space: nowrap;
}

.stock-form-panel { margin-bottom: 1rem; }
.stock-form-panel h2 {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem 1rem;
}

.form-group-span { grid-column: 1 / -1; }

/* Form panel header with red close (X) button — same in Blazor and React. */
.form-panel-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}
.form-panel-head h2 { margin: 0 0 1rem; }
.form-close-btn {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    padding: 0;
    border: 1px solid #fecaca;
    border-radius: 0.6rem;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
}
.form-close-btn:hover,
.form-close-btn:focus-visible {
    background: #b91c1c;
    border-color: #b91c1c;
    color: #fff;
}

.linked-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem 1rem;
}

.linked-fields .form-hint {
    grid-column: 1 / -1;
    margin: 0;
}

.stock-form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.25rem;
    flex-wrap: wrap;
}

.stock-form-actions-right {
    justify-content: flex-end;
}

.form-textarea-sm {
    resize: vertical;
    min-height: 4rem;
    max-height: 10rem;
}

.stock-toolbar-actions {
    display: flex;
    gap: 0.6rem;
    flex-wrap: wrap;
    margin: 0;
}

.exp-page-head {
    align-items: center;
}

.exp-page-head-main {
    min-width: 0;
    flex: 1;
}

.exp-page-head h1 {
    margin: 0;
}

.exp-head-totals {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem 1.5rem;
    margin-top: 0.55rem;
}

.exp-head-stat {
    display: flex;
    flex-direction: column;
    gap: 0.08rem;
}

.exp-head-stat span {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--bms-muted);
}

.exp-head-stat strong {
    font-size: 1.1rem;
    font-weight: 700;
}

.exp-add-btn {
    padding: 0.5rem 0.9rem;
    flex-shrink: 0;
    align-self: center;
}

.combo-field .form-input + .form-input {
    margin-top: 0.45rem;
}

.exp-chart-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.exp-analysis-grid {
    display: grid;
    grid-template-columns: 1.3fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.exp-chart-wide {
    grid-column: 1 / -1;
}

.exp-analysis-toolbar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.exp-person-picker {
    position: relative;
    max-width: 22rem;
}

.exp-person-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    text-align: left;
    cursor: pointer;
}

.exp-person-menu {
    position: absolute;
    z-index: 30;
    left: 0;
    right: 0;
    top: calc(100% + 4px);
    background: #fff;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    box-shadow: var(--bms-shadow);
    padding: 0.4rem;
    max-height: 16rem;
    overflow: auto;
}

.exp-person-option {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    font: inherit;
    color: inherit;
}

.exp-person-option:hover {
    background: #f4f7fb;
}

.exp-square {
    width: 1.1rem;
    height: 1.1rem;
    margin: 0;
    flex-shrink: 0;
    border: 2px solid var(--bms-primary);
    border-radius: 3px;
    background: #fff;
}

.exp-square:checked,
.exp-square.is-on {
    background: var(--bms-primary);
    box-shadow: inset 0 0 0 2px #fff;
}

.exp-svg-chart {
    width: 100%;
    height: auto;
    display: block;
}

.exp-svg-axis {
    stroke: #d5deea;
    stroke-width: 1;
}

.exp-svg-col {
    fill: var(--bms-primary);
}

.exp-svg-label,
.exp-svg-value {
    fill: var(--bms-muted);
    font-size: 10px;
}

.exp-svg-value {
    fill: var(--bms-primary-dark);
    font-weight: 600;
}

.exp-donut-wrap {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 0.75rem;
    align-items: center;
}

.exp-donut {
    width: 140px;
    height: 140px;
}

.exp-donut-slice {
    fill: none;
    stroke-width: 18;
    transform: rotate(-90deg);
    transform-origin: 60px 60px;
}

.exp-donut-empty {
    fill: none;
    stroke: #e8eef7;
    stroke-width: 18;
}

.exp-donut-total {
    font-size: 12px;
    font-weight: 700;
    fill: var(--bms-primary-dark);
}

.exp-donut-caption {
    font-size: 7px;
    fill: var(--bms-muted);
}

.exp-donut-legend {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.exp-donut-legend li {
    display: grid;
    grid-template-columns: 0.7rem 1fr auto;
    gap: 0.45rem;
    align-items: center;
    font-size: 0.85rem;
}

.exp-swatch {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
}

.exp-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
    margin-top: 1.1rem;
    padding-top: 0.9rem;
    border-top: 1px solid var(--bms-border);
    flex-wrap: wrap;
}

.exp-pager-meta {
    margin: 0;
    color: var(--bms-muted);
    font-size: 0.88rem;
}

.exp-pager-btns {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    flex-wrap: wrap;
}

.exp-page-btn {
    min-width: 2.15rem;
    height: 2.15rem;
    padding: 0 0.45rem;
    border: 1px solid var(--bms-border);
    background: #fff;
    color: var(--bms-primary-dark);
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    line-height: 1;
}

.exp-page-btn.exp-page-nav {
    min-width: auto;
    width: auto;
    padding: 0 0.7rem;
    gap: 0.2rem;
    display: inline-flex;
    align-items: center;
}

.exp-page-btn:hover:not(:disabled):not(.is-current) {
    border-color: var(--bms-primary);
    background: #f3f7fd;
}

.exp-page-btn.is-current {
    background: var(--bms-primary);
    border-color: var(--bms-primary);
    color: #fff;
}

.exp-page-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.exp-page-gap {
    color: var(--bms-muted);
    padding: 0 0.15rem;
}

.exp-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 80;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 1.25rem 0.85rem;
    overflow: auto;
}

.exp-modal {
    width: min(760px, 100%);
    margin: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
    border: 1px solid var(--bms-border);
    max-height: min(92vh, calc(100dvh - 1.5rem));
    display: flex;
    flex-direction: column;
    overflow: auto;
}

.exp-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 1rem 1.15rem 0.75rem;
    border-bottom: 1px solid var(--bms-border);
}

.exp-modal-head h2 {
    margin: 0;
    font-size: 1.15rem;
}

.exp-modal-close {
    border: none;
    background: #f1f5f9;
    width: 2rem;
    height: 2rem;
    border-radius: 999px;
    cursor: pointer;
    color: var(--bms-primary-dark);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.exp-modal-close:hover { background: #e2e8f0; }

.exp-modal-body {
    padding: 1rem 1.15rem 1.2rem;
    overflow: visible;
}

.exp-modal .name-combo-list {
    z-index: 90;
}

.exp-modal .exp-form { margin: 0; }
.exp-modal .stock-form-actions { margin-bottom: 0; }

.exp-confirm-modal {
    width: min(420px, 100%);
    max-height: none;
    min-height: 0;
}

.exp-confirm-text {
    margin: 0 0 1rem;
    color: var(--bms-text);
}

.login-btn.danger {
    background: #b91c1c;
    color: #fff;
}

.login-btn.danger:hover {
    background: #991b1b;
}

.exp-chart-card {
    background: var(--bms-surface);
    border: 1px solid var(--bms-border);
    border-radius: var(--bms-radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--bms-shadow);
}

.exp-chart-card h2 {
    margin: 0 0 0.75rem;
    font-size: 0.95rem;
}

.exp-bar-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.exp-bar-meta {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.85rem;
}

.exp-bar-track {
    height: 8px;
    border-radius: 99px;
    background: #e8eef7;
    overflow: hidden;
}

.exp-bar-fill {
    height: 100%;
    border-radius: 99px;
    background: var(--bms-primary);
}

.exp-expand {
    border: none;
    background: transparent;
    color: inherit;
    padding: 0 0.2rem 0 0;
    cursor: pointer;
    font-size: 1.15rem;
    line-height: 1;
    vertical-align: middle;
}

.exp-subrow td {
    background: #f8fafc;
    font-size: 0.9rem;
    color: var(--bms-muted);
}

.exp-scan-lines {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.exp-scan-lines li {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--bms-border);
    border-radius: 8px;
    background: #fff;
}

.table-wrap {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-x pan-y;
}

.record-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

@media (min-width: 901px) {
    .desktop-table + .record-list {
        display: none;
    }
}

@media (max-width: 900px) {
    .desktop-table {
        display: none;
    }
}

.exp-record-list {
    display: flex;
}

.exp-entry-grid {
    display: grid;
    grid-template-columns: minmax(7.2rem, 1.1fr) minmax(0, 1.4fr) max-content;
    column-gap: 0.65rem;
    row-gap: 0.28rem;
    align-items: center;
    cursor: pointer;
}

.exp-entry-grid:focus {
    outline: 2px solid rgba(26, 86, 168, 0.35);
    outline-offset: 2px;
}

.exp-entry-grid .exp-subline,
.exp-entry-grid .exp-titleline,
.exp-entry-grid .exp-tag {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.exp-entry-grid .exp-subline,
.exp-entry-grid .exp-titleline {
    color: var(--bms-text);
    font-weight: 500;
    text-align: left;
}

.exp-entry-grid .exp-subline {
    font-weight: 700;
    background: none;
}

.exp-entry-grid .exp-titleline {
    color: var(--bms-text);
}

.exp-entry-grid .exp-tag {
    text-align: left;
    max-width: none;
    justify-self: stretch;
}

.exp-entry-grid .record-amount {
    justify-self: end;
}

.exp-entry-actions {
    justify-self: end;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.exp-entry-actions .link-btn {
    min-height: 36px;
}

.exp-details {
    margin-top: 0.65rem;
    padding-top: 0.65rem;
    border-top: 1px solid var(--bms-border);
}

.exp-details > p {
    margin: 0;
    color: var(--bms-muted);
    font-size: 0.9rem;
}

.exp-detail-row {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    font-size: 0.9rem;
    margin-top: 0.35rem;
}

.exp-detail-label {
    margin: 0.55rem 0 0.25rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bms-muted);
}

.record-card {
    border: 1px solid var(--bms-border);
    border-radius: 12px;
    padding: 0.9rem 1rem;
    background: #fff;
}

.record-card.exp-entry {
    padding: 0.75rem 0.85rem;
}

.record-card-top {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: baseline;
}

.record-cats,
.exp-catline {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--bms-muted);
    font-weight: 500;
    text-align: center;
}

.record-title-line,
.exp-titleline {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    margin-top: 0.35rem;
    min-width: 0;
}

.record-title,
.exp-titleline span:first-child {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.record-tag,
.exp-tag {
    color: var(--bms-muted);
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 45%;
    flex-shrink: 0;
}

.exp-entry-grid .exp-titleline {
    display: block;
    margin-top: 0;
    color: var(--bms-text);
}

.exp-entry-grid .exp-tag {
    max-width: none;
    text-align: left;
    justify-self: stretch;
}

.exp-list-panel {
    overflow: visible;
}

.exp-filters {
    position: relative;
    z-index: 6;
    margin-bottom: 0.85rem;
    overflow: visible;
}

.exp-filters-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.exp-filters-toggle {
    flex: 1;
    min-width: 0;
    width: auto;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    border: 1px solid var(--bms-border);
    background: #f8fafc;
    border-radius: 10px;
    padding: 0.45rem 0.7rem;
    font: inherit;
    color: var(--bms-text);
    cursor: pointer;
    min-height: 42px;
}

.exp-filter-total {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.05rem;
    padding: 0.15rem 0.1rem 0.15rem 0.35rem;
}

.exp-filter-total span {
    color: var(--bms-muted);
    font-size: 0.75rem;
    font-weight: 600;
}

.exp-filter-total strong {
    font-size: 1rem;
    font-variant-numeric: tabular-nums;
}

.exp-filters-toggle span:first-child {
    font-weight: 700;
    flex-shrink: 0;
}

.exp-filters-summary {
    min-width: 0;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--bms-muted);
    font-size: 0.85rem;
    text-align: left;
}

.exp-filters-toggle i {
    margin-left: auto;
    color: var(--bms-muted);
}

.exp-filter-grid {
    display: grid;
    grid-template-columns: 1fr 1fr max-content;
    gap: 0.7rem 0.85rem;
    margin-top: 0.7rem;
    overflow: visible;
}

.exp-filter-apply-wrap {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.exp-filter-apply {
    min-height: 42px;
    width: auto;
    padding: 0.45rem 0.95rem;
}

.exp-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    overflow: visible;
}

.exp-filter-field label {
    font-weight: 600;
    font-size: 0.85rem;
}

.exp-filter-label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.exp-filter-label-row .link-btn {
    min-height: 0;
    padding: 0;
    font-size: 0.8rem;
}

.exp-filter-field input[type="month"],
.exp-filter-field input[type="date"] {
    font: inherit;
    border: 1px solid var(--bms-border);
    border-radius: 8px;
    padding: 0.45rem 0.55rem;
    min-height: 42px;
    width: 100%;
    background: #fff;
}

.exp-filters .name-combo {
    min-width: 0;
}

.exp-filters .name-combo-list,
.page-panel .name-combo-list {
    z-index: 90;
}

.exp-date-cell {
    white-space: nowrap;
    font-weight: 700;
    color: var(--bms-text);
    background: none;
}

.record-amount {
    font-weight: 700;
    color: var(--bms-primary-dark);
    white-space: nowrap;
}

.record-card-meta {
    margin-top: 0.35rem;
    color: var(--bms-muted);
    font-size: 0.85rem;
}

.record-notes {
    margin: 0.45rem 0 0;
    font-size: 0.9rem;
}

.record-card .row-actions {
    margin-top: 0;
    justify-content: flex-end;
}

.sale-record-card .record-card-top {
    cursor: pointer;
    align-items: center;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
}

.sale-record-card .record-card-top strong {
    justify-self: start;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sale-record-card .record-amount {
    justify-self: center;
}

.sale-record-card .expand-btn {
    justify-self: end;
}

.sale-record-card .sale-card-bills {
    margin-top: 0.55rem;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0.65rem;
    overflow-x: auto;
}

.sale-record-card .sale-card-edit {
    margin-top: 0.4rem;
    justify-content: flex-start;
}

.home-page .home-hero {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    text-align: left;
}

.home-hero-stats {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    min-width: 0;
}

.home-today-sale,
.home-profit-toggle {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    gap: 0.15rem;
    min-width: 9.25rem;
    min-height: 3.6rem;
    padding: 0.4rem 0.85rem;
    border-radius: 10px;
    border: 1px solid var(--bms-border);
    background: #f8fafc;
    box-sizing: border-box;
}

.home-today-sale span,
.home-profit-toggle span {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--bms-muted);
}

.home-today-sale strong,
.home-profit-toggle strong {
    font-size: 1.05rem;
    color: var(--bms-text);
    min-height: 1.25rem;
    line-height: 1.25rem;
}

.home-profit-toggle strong.is-masked {
    letter-spacing: 0.12em;
    color: var(--bms-muted);
    font-weight: 700;
}

.home-profit-toggle {
    cursor: pointer;
    font-family: inherit;
}

.home-profit-toggle.is-on {
    border-color: var(--bms-primary);
    background: rgba(26, 86, 168, 0.08);
}

.home-top-actions {
    grid-template-columns: 1fr 1fr;
}

.card-hint {
    display: none;
    margin: 0.35rem 0 0;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--bms-muted);
}

@media (min-width: 901px) {
    .home-top-actions {
        grid-template-columns: 1fr;
        max-width: 22rem;
    }
    .home-top-actions .stat-card {
        min-height: 7.75rem;
        padding: 1.7rem 1.1rem;
    }
    .home-top-actions .card-content {
        align-items: center;
        min-height: 4.5rem;
    }
    .card-hint { display: block; }
}

.home-credit-mention {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.4rem 0.75rem;
    margin: 0 0 1rem;
    padding: 0.15rem 0.15rem 0.35rem;
    color: var(--bms-muted);
    font-size: 0.92rem;
}

.home-credit-mention a {
    font-weight: 700;
    color: var(--bms-primary);
    text-decoration: none;
}

.home-credit-mention a:hover {
    text-decoration: underline;
}

.home-shops {
    margin-bottom: 1.5rem;
    text-align: left;
}

.home-shops-head {
    align-items: center;
    margin-bottom: 0.75rem;
}

.home-shops-head h2 {
    margin: 0;
}

.home-menu-section h2 {
    margin: 0 0 0.75rem;
    font-size: 1.15rem;
}

.home-howto-line {
    margin: 0;
    font-size: 1rem;
    color: var(--bms-text);
    line-height: 1.45;
}

.shop-today-bar {
    margin-bottom: 1rem;
    justify-content: flex-start;
}

.home-shop-list {
    max-width: none;
    margin: 0;
    text-align: left;
}

.home-shop-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}

.home-shop-grid .branch-pick-card {
    width: 100%;
    min-height: 8.25rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    box-shadow: 0 8px 22px rgba(15, 40, 80, 0.08);
}

.home-add-shop {
    display: inline-flex;
    margin-top: 0;
    margin-left: auto;
    text-decoration: none;
    width: auto;
}

.home-add-shop i {
    margin-right: 0.35rem;
}

.desktop-only { display: none !important; }

.home-shop-desktop-actions {
    display: none;
    margin-top: 0.4rem;
    gap: 0.65rem;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
}

@media (min-width: 901px) {
    .home-shop-desktop-actions.desktop-only {
        display: flex !important;
    }
}

.branch-pick-card.is-current {
    border-color: var(--bms-primary);
    background: rgba(26, 86, 168, 0.06);
}

.shop-current-tag {
    display: block;
    margin-top: 0.4rem;
    font-style: normal;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--bms-primary);
}

.account-shop-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.account-shop-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--bms-border);
}

.account-shop-row strong {
    display: block;
    color: var(--bms-primary-dark);
}

.account-shop-row span,
.account-shop-row em {
    display: block;
    margin-top: 0.2rem;
    font-style: normal;
}

.account-shop-actions {
    display: flex;
    gap: 0.85rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.data-table th,
.data-table td {
    text-align: left;
    padding: 0.75rem 0.65rem;
    border-bottom: 1px solid var(--bms-border);
}

.data-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--bms-muted);
}

.row-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
    white-space: nowrap;
}

.link-btn {
    border: none;
    background: transparent;
    color: var(--bms-primary);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}

.link-btn.danger { color: #b91c1c; }

@media (max-width: 700px) {
    .form-grid { grid-template-columns: 1fr; }
    .stock-toolbar {
        flex-direction: row;
        align-items: center;
        gap: 0.5rem;
    }
    .stock-toolbar > div:first-child {
        min-width: 0;
        flex: 1;
    }
    .stock-action-btn { width: 100%; justify-content: center; }
    .stock-toolbar > .stock-action-btn,
    .stock-toolbar > .stock-toolbar-actions {
        width: auto;
        flex-shrink: 0;
        margin-left: auto;
    }
    .stock-toolbar .stock-action-btn,
    .stock-toolbar-actions .stock-action-btn {
        width: auto;
        padding: 0.4rem 0.65rem;
        min-height: 2rem;
        font-size: 0.78rem;
    }
    .shop-hub-toolbar {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.4rem;
        padding: 0.45rem 0.65rem;
    }
    .shop-hub-toolbar h1 { font-size: 0.98rem; }
    .shop-hub-page .card-label { display: none; }
    .shop-hub-page .card-content { align-items: center; }
    .home-hero-stats {
        flex-wrap: nowrap;
        gap: 0.4rem;
    }
    .shop-today-bar .home-hero-stats { justify-content: center; }
    .home-today-sale,
    .home-profit-toggle {
        min-width: 0;
        flex: 1 1 0;
        max-width: 7.5rem;
        min-height: 2.85rem;
        padding: 0.28rem 0.45rem;
    }
    .home-today-sale span,
    .home-profit-toggle span { font-size: 0.68rem; }
    .home-today-sale strong,
    .home-profit-toggle strong { font-size: 0.92rem; }
    .home-shop-grid {
        grid-template-columns: 1fr;
        gap: 0.45rem;
    }
    .home-shop-grid .branch-pick-card {
        min-height: 0;
        padding: 0.55rem 0.7rem;
        box-shadow: none;
    }
    .home-shop-grid .branch-pick-card:hover,
    .home-shop-grid .branch-pick-card:focus,
    .home-shop-grid .branch-pick-card.is-current {
        border-color: var(--bms-border);
        background: #fff;
        box-shadow: none;
    }
    .exp-page-head {
        flex-direction: row;
        align-items: flex-start;
    }
    .exp-page-head .exp-add-btn {
        width: auto;
    }
    .exp-filter-grid {
        grid-template-columns: 1fr 1fr max-content;
    }
    .exp-filter-apply {
        width: auto;
    }
    .exp-entry-grid {
        grid-template-columns: minmax(6.4rem, 1.1fr) minmax(0, 1fr) max-content;
        column-gap: 0.4rem;
    }
    .exp-pager { justify-content: center; }
    .exp-pager-btns { justify-content: center; width: 100%; }
    .exp-modal-backdrop { padding: 0.6rem; align-items: stretch; }
    .exp-modal { max-height: none; min-height: min(100%, 100dvh - 1.2rem); }
    .exp-confirm-modal { min-height: 0; margin: auto; }
    .home-top-actions,
    .cards-grid { grid-template-columns: 1fr; }
    .linked-fields { grid-template-columns: 1fr; }
    .customer-search-row { flex-direction: column; align-items: stretch; }
    .customer-add-info-btn { width: 100%; }
    .sale-line-row { grid-template-columns: 1fr; }
    .sale-grand-total { text-align: left; }
    .home-hero { flex-direction: column; align-items: stretch; }
    .home-add-shop { width: auto; justify-content: center; margin-left: auto; }
    .login-page {
        align-items: flex-start;
        padding: max(1rem, env(safe-area-inset-top, 0px)) 0.85rem max(1rem, env(safe-area-inset-bottom, 0px));
    }
    .login-form-card { padding: 1.15rem; }
    .login-title { font-size: 1.35rem; }
    .register-name-row { grid-template-columns: 1fr; }
    .summary-strip { grid-template-columns: 1fr 1fr; }
    .exp-chart-grid,
    .exp-analysis-grid,
    .exp-donut-wrap { grid-template-columns: 1fr; }
    .filter-pills { overflow-x: auto; flex-wrap: nowrap; padding-bottom: 0.25rem; }
    .pill { flex-shrink: 0; min-height: 40px; }
    .nav-link { min-height: 44px; }
    .stat-card:hover { transform: none; }
}

.section-heading {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}

.customer-search-block { position: relative; margin-bottom: 1.25rem; }

.suggest-list {
    list-style: none;
    margin: 0.35rem 0 0;
    padding: 0.35rem;
    position: absolute;
    left: 0;
    right: 0;
    z-index: 20;
    background: #fff;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    box-shadow: var(--bms-shadow);
    max-height: 220px;
    overflow-y: auto;
}

.suggest-item {
    width: 100%;
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    border: none;
    background: transparent;
    text-align: left;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
}

.suggest-item:hover { background: rgba(26, 86, 168, 0.08); }
.suggest-item small { color: var(--bms-muted); }

.sale-lines { margin-top: 0.5rem; }
.sale-lines-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.sale-lines-header h3 { margin: 0; font-size: 1rem; }

.sale-line-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr auto;
    gap: 0.75rem;
    align-items: start;
    padding: 0.85rem 0;
    border-top: 1px solid var(--bms-border);
}

.sale-line-total .line-total-value {
    padding: 0.7rem 0;
    font-weight: 700;
}

.sale-line-remove { margin-top: 1.85rem; }

.sale-grand-total {
    margin-top: 1rem;
    text-align: right;
    font-size: 1.05rem;
}

@media (max-width: 900px) {
    .sale-line-row {
        grid-template-columns: 1fr;
        padding: 0.85rem;
        border: 1px solid var(--bms-border);
        border-radius: 12px;
        background: #f8fafc;
        margin-bottom: 0.75rem;
    }
    .sale-line-remove { margin-top: 0.5rem; }
}

.customer-block { margin-bottom: 1.25rem; }
.customer-fields-grid {
    margin-bottom: 0.5rem;
}
.customer-fields-grid .customer-search-block { margin-bottom: 0; }
.customer-search-row {
    display: flex;
    gap: 0.75rem;
    align-items: flex-end;
}
.customer-search-row .customer-search-block { flex: 1; margin-bottom: 0; }
.customer-add-info-btn { margin-bottom: 0.15rem; }

.customer-selected-card {
    margin-top: 0.85rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
    align-items: center;
    padding: 0.85rem 1rem;
    border: 1px solid var(--bms-border);
    border-radius: 12px;
    background: rgba(26, 86, 168, 0.05);
}
.customer-selected-body {
    flex: 1;
    min-width: 0;
}
.customer-purchase-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-shrink: 0;
}
.customer-selected-purchases {
    flex: 1 1 100%;
    margin-top: 0.15rem;
}

.customer-photo {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}
.customer-photo.placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(26, 86, 168, 0.12);
    color: var(--bms-primary);
    font-size: 1.35rem;
}

.customer-selected-name {
    font-weight: 700;
    font-size: 1.05rem;
    margin-bottom: 0.25rem;
}
.customer-selected-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1.25rem;
    color: var(--bms-muted);
    font-size: 0.9rem;
}
.customer-selected-meta i { margin-right: 0.25rem; }

.customer-more-grid { margin-top: 0.85rem; }
.customer-photo-preview {
    margin-top: 0.5rem;
}
.customer-photo-preview img {
    width: 72px;
    height: 72px;
    border-radius: 10px;
    object-fit: cover;
}

.sale-row { cursor: pointer; }
.sale-row:hover { background: rgba(26, 86, 168, 0.04); }

.expand-btn {
    border: none;
    background: transparent;
    color: var(--bms-primary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.expand-col {
    width: auto;
    min-width: 2.75rem;
    text-align: right;
    vertical-align: middle;
}
.data-table .customer-purchase-actions {
    margin-left: 0;
    justify-content: flex-end;
}

.customer-record-card .record-card-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.customer-record-card .record-card-top strong {
    flex: 1;
    min-width: 0;
}

.customer-record-card .expand-btn {
    margin-left: auto;
}

.sale-items-list {
    margin: 0;
    padding-left: 1.1rem;
}

.sale-detail-row td {
    background: #f8fafc;
    padding-top: 0;
    padding-bottom: 0.85rem;
}

.sale-items-panel {
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    padding: 0.75rem;
    background: #fff;
}
.sale-items-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}
.nested-table th { background: transparent; }

.auth-layout { position: relative; min-height: 100vh; }
.auth-lang-corner {
    position: fixed;
    top: max(0.75rem, env(safe-area-inset-top, 0px));
    right: max(0.75rem, env(safe-area-inset-right, 0px));
    z-index: 40;
}

.auth-loading-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bms-bg);
}

.auth-loading-shell.auth-loading-boot {
    background: #1a56a8;
}

.auth-loading-card {
    background: var(--bms-surface);
    border: 1px solid var(--bms-border);
    border-radius: var(--bms-radius);
    padding: 1rem 1.5rem;
    box-shadow: var(--bms-shadow);
    color: var(--bms-muted);
}

.lang-switch { margin-bottom: 1rem; }
.lang-switch .form-label { margin-bottom: 0.35rem; }
.lang-switch-compact {
    margin: 0;
    position: relative;
    display: flex;
    align-items: center;
}
.lang-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.28rem;
    min-height: 40px;
    height: 40px;
    padding: 0 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    cursor: pointer;
    line-height: 1;
}
.lang-pill i { font-size: 0.95rem; }
.lang-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 50;
    min-width: 9.5rem;
    max-height: 16rem;
    overflow-y: auto;
    margin: 0;
    padding: 0.3rem;
    list-style: none;
    background: #fff;
    color: var(--bms-text);
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    box-shadow: var(--bms-shadow);
}
.lang-menu-item {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 7px;
    padding: 0.55rem 0.65rem;
    min-height: 40px;
    font-size: 0.82rem;
    cursor: pointer;
}
.lang-menu-item:hover,
.lang-menu-item.active {
    background: #e8f0fb;
    color: var(--bms-primary);
}
.lang-select-sm {
    appearance: none;
    border: 1px solid rgba(255, 255, 255, 0.35);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    border-radius: 8px;
    padding: 0.2rem 0.45rem;
    font-size: 0.75rem;
    cursor: pointer;
    min-width: 4.5rem;
    max-width: 7.5rem;
    height: 32px;
}
.lang-select-sm option { color: #1e293b; }

.bill-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 40;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.bill-modal {
    width: min(560px, 100%);
    background: #fff;
    border-radius: 16px;
    padding: 1.25rem 1.35rem 1.4rem;
    box-shadow: var(--bms-shadow);
    max-height: min(90vh, calc(100dvh - 2rem));
    overflow-y: auto;
}
.bill-modal h2 { margin: 0 0 0.25rem; font-size: 1.2rem; }
.bill-modal-sub { margin: 0 0 1rem; color: var(--bms-muted); }
.radio-row { display: flex; flex-wrap: wrap; gap: 0.65rem 1rem; margin-bottom: 0.45rem; }
.radio-option { display: flex; align-items: center; gap: 0.4rem; font-weight: 600; cursor: pointer; }
.radio-option input { accent-color: var(--bms-primary); }

.lang-select { min-width: 8.5rem; max-width: 14rem; }

.summary-strip {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.85rem;
    margin-bottom: 1rem;
}

.summary-card {
    background: var(--bms-surface);
    border: 1px solid var(--bms-border);
    border-radius: var(--bms-radius);
    padding: 0.9rem 1rem;
    box-shadow: var(--bms-shadow);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.summary-card span {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--bms-muted);
}

.summary-card strong {
    font-size: 1.25rem;
}

.summary-card.credit strong { color: #047857; }
.summary-card.due strong { color: #b45309; }

.filter-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.pill {
    border: 1px solid var(--bms-border);
    background: #fff;
    color: var(--bms-text);
    border-radius: 999px;
    padding: 0.35rem 0.85rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.pill.active {
    background: var(--bms-primary);
    border-color: var(--bms-primary);
    color: #fff;
}

.type-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 700;
}

.type-badge.credit {
    background: rgba(4, 120, 87, 0.12);
    color: #047857;
}

.type-badge.due {
    background: rgba(180, 83, 9, 0.12);
    color: #b45309;
}

.row-settled { opacity: 0.65; }
.muted { color: var(--bms-muted); }

.admin-shell {
    min-height: 100vh;
    background: var(--bms-bg);
}

.admin-top {
    background: var(--bms-primary);
    color: #fff;
    padding: 0.85rem 1.25rem;
}

.admin-top-inner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    max-width: 1200px;
    margin: 0 auto;
}

.admin-top-inner strong { margin-right: auto; }
.admin-top .user-chip { color: #fff; background: rgba(255,255,255,0.16); }
.admin-top .profile-btn { color: #fff; }

.admin-body { padding-top: 1rem; }

.admin-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 1rem;
}

.admin-tabs button {
    border: 1px solid var(--bms-border);
    background: #fff;
    border-radius: 999px;
    padding: 0.4rem 0.9rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
}

.admin-tabs button.active {
    background: var(--bms-primary);
    border-color: var(--bms-primary);
    color: #fff;
}

.admin-shop-head {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: flex-start;
}

.admin-shop-head p {
    margin: 0.25rem 0 0;
    color: var(--bms-muted);
}

.record-card-kv {
    display: flex;
    justify-content: space-between;
    gap: 0.75rem;
    align-items: baseline;
    margin-top: 0.3rem;
    font-size: 0.88rem;
}

.record-card-kv span {
    color: var(--bms-muted);
    flex-shrink: 0;
}

.record-card-kv b {
    font-weight: 600;
    text-align: right;
    word-break: break-word;
}

@media (max-width: 480px) {
    .cards-grid,
    .summary-strip {
        grid-template-columns: 1fr;
    }
    .login-logo .brand-mark {
        width: 60px;
        height: 60px;
    }
}

.web-only-label { display: none; }

@media (min-width: 901px) {
    .phone-only-label { display: none !important; }
    .web-only-label { display: inline; }

    .stock-form-actions {
        align-items: center;
        margin-top: 0.85rem;
        gap: 0.55rem;
    }

    .stock-form-actions .login-btn,
    .stock-form-actions .login-btn.secondary,
    .stock-form-actions .stock-action-btn {
        width: auto;
        margin-top: 0;
        min-height: 2.45rem;
        height: 2.45rem;
        padding: 0 1rem;
        font-size: 0.9rem;
        box-sizing: border-box;
    }

    .customer-search-row {
        align-items: flex-end;
        gap: 0.65rem;
    }

    .customer-search-row .customer-search-block {
        flex: 0 1 22rem;
        max-width: 24rem;
        margin-bottom: 0;
    }

    .customer-add-info-btn {
        width: auto;
        max-width: 16.5rem;
        height: auto;
        min-height: 2.45rem;
        padding: 0.4rem 0.75rem;
        margin-top: 0;
        margin-bottom: 0;
        white-space: normal;
        line-height: 1.2;
        font-size: 0.8rem;
        text-align: center;
    }

    .stock-form-panel h2 {
        margin-bottom: 0.7rem;
    }

    .stock-form-panel .form-input,
    .bill-modal .form-input {
        min-height: 2.4rem;
        padding: 0.45rem 0.75rem;
    }

    .stock-form-panel .customer-block {
        margin-bottom: 0.75rem;
    }

    .sale-line-row {
        padding: 0.55rem 0;
        gap: 0.6rem;
    }

    .sale-line-remove { margin-top: 1.65rem; }

    .sale-grand-total { margin-top: 0.65rem; }

    .bill-modal {
        padding: 1rem 1.15rem 1.1rem;
    }

    .bill-modal .form-group {
        margin-bottom: 0.65rem;
    }

    .bill-modal-sub { margin-bottom: 0.7rem; }

    .bill-modal .stock-form-actions {
        margin-top: 0.7rem;
        flex-wrap: nowrap;
    }

    .row-actions .login-btn,
    .row-actions .stock-action-btn {
        width: auto;
        margin-top: 0;
        min-height: 2.15rem;
        height: 2.15rem;
        padding: 0 0.8rem;
        font-size: 0.82rem;
    }

    .stock-toolbar .stock-action-btn {
        min-height: 2.45rem;
        height: 2.45rem;
        padding: 0 1rem;
        margin-top: 0;
        font-size: 0.9rem;
    }

    .exp-modal .stock-form-actions .login-btn {
        margin-top: 0;
    }
}

/* Page search: a search box in each page header, always shown.
   Desktop: at the top right. Phone: on its own line under the title. */
.stock-toolbar-actions {
    align-items: center;
}

/* Keep the search box and the page's buttons on one line on wider screens. */
.stock-toolbar-actions:has(.page-search-wrap) {
    flex-wrap: nowrap;
    flex-shrink: 0;
}

.stock-toolbar > div:first-child {
    min-width: 0;
}

.page-search-wrap {
    display: flex;
    align-items: center;
}

.page-search {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: clamp(14rem, 24vw, 22rem);
    height: 2.6rem;
    padding: 0 0.35rem 0 0.75rem;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    background: #fff;
    color: #64748b;
}

.page-search:focus-within {
    border-color: var(--bms-primary, #1e4f9c);
    box-shadow: 0 0 0 3px rgba(26, 86, 168, 0.12);
}

.page-search input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    font: inherit;
    color: #0f172a;
}

.page-search input::-webkit-search-cancel-button { display: none; }

.page-search-clear {
    display: inline-flex;
    border: none;
    background: transparent;
    color: #64748b;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem;
}

@media (max-width: 700px) {
    .stock-toolbar { flex-wrap: wrap; }
    /* Phone: the search box and the page's buttons take their own full-width line under the title. */
    .stock-toolbar > .stock-toolbar-actions:has(.page-search-wrap) { width: 100%; margin-left: 0; }
    .stock-toolbar-actions .page-search-wrap { flex: 1; min-width: 0; }
    .page-search-wrap .page-search { width: 100%; height: 2.2rem; }
    /* Personal Expenditure: the search box sits directly in the header; put it on its own line. */
    .exp-page-head > .page-search-wrap { order: 3; flex: 1 0 100%; }
}

/* Desktop: page title and its description sit on one line (title, then description). */
@media (min-width: 701px) {
    .page-panel.stock-toolbar {
        align-items: center;
    }

    .page-panel.stock-toolbar > div:first-child:not(.exp-page-head-main) {
        display: flex;
        align-items: baseline;
        gap: 0.9rem;
        flex: 1 1 auto;
    }

    .page-panel.stock-toolbar > div:first-child:not(.exp-page-head-main) > h1 {
        margin: 0;
        white-space: nowrap;
        flex-shrink: 0;
    }

    /* The description never takes more than two lines; longer text ends with "…". */
    .page-panel.stock-toolbar > div:first-child:not(.exp-page-head-main) > p {
        min-width: 0;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
        line-clamp: 2;
        overflow: hidden;
    }
}

/* Edit / Delete row actions shown as icons (pencil, bin). The name is in title and aria-label. */
.link-btn.icon-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 8px;
    font-size: 1.15rem;
    line-height: 1;
    font-weight: 400;
    flex-shrink: 0;
}

.link-btn.icon-action:hover,
.link-btn.icon-action:focus-visible {
    background: rgba(26, 86, 168, 0.1);
    outline: none;
}

.link-btn.danger.icon-action:hover,
.link-btn.danger.icon-action:focus-visible {
    background: rgba(185, 28, 28, 0.1);
}

.link-btn.icon-action:disabled {
    opacity: 0.45;
    cursor: default;
}

/* ---- App shell: brand name, language dropdown, account menu (face icon), phone footer ---- */
.top-header .header-left .logo {
    min-width: 0;
    flex-shrink: 1;
}

.top-header .header-left .logo span.logo-badge {
    display: flex;
    flex-shrink: 0;
}

.top-header .header-left .logo span.brand-name {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 1.05rem;
    letter-spacing: 0;
}

.header-lang {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: #fff;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.header-lang select {
    appearance: none;
    -webkit-appearance: none;
    height: 38px;
    max-width: 9.5rem;
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 999px;
    padding: 0 1.75rem 0 0.8rem;
    background-color: rgba(255, 255, 255, 0.16);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    background-size: 0.8rem;
    color: #fff;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
}

.header-lang select:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.header-lang select option {
    color: #1e293b;
    background: #fff;
}

.account-menu-wrap {
    position: relative;
    flex-shrink: 0;
}

.profile-btn.avatar-btn {
    background: #fff;
    color: var(--bms-primary);
    border: 2px solid rgba(255, 255, 255, 0.75);
    font-size: 1.3rem;
}

.profile-btn.avatar-btn[aria-expanded="true"] {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
}

.account-menu-backdrop {
    position: fixed;
    inset: 0;
    z-index: 140;
}

.account-menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    z-index: 150;
    width: 15.5rem;
    max-width: calc(100vw - 1.5rem);
    padding: 0.4rem;
    border-radius: 14px;
    background: #fff;
    color: var(--bms-text);
    box-shadow: 0 12px 32px rgba(15, 61, 122, 0.28);
}

.account-menu-who {
    padding: 0.6rem 0.75rem 0.5rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--bms-border);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-menu button,
.account-menu a {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    border: none;
    border-radius: 9px;
    padding: 0.7rem 0.75rem;
    background: none;
    color: var(--bms-text);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
}

.account-menu button i,
.account-menu a i {
    font-size: 1.15rem;
    color: var(--bms-primary);
}

.account-menu button:hover,
.account-menu button:focus-visible {
    background: #eef4fb;
    outline: none;
}

.account-menu button.danger,
.account-menu button.danger i {
    color: #b91c1c;
}

.home-personal-cards {
    margin-top: 0.75rem;
}

a.stat-card {
    display: block;
    color: inherit;
    text-decoration: none;
}

.bottom-nav {
    display: none;
}

@media (max-width: 700px) {
    /* Phones: Back lives in the footer. */
    .top-header .header-back { display: none; }
    .header-lang select { height: 36px; max-width: 6.75rem; }

    .bottom-nav {
        display: flex;
        flex-shrink: 0;
        gap: 0.15rem;
        padding: 0.3rem 0.25rem calc(0.3rem + env(safe-area-inset-bottom, 0px));
        background: #fff;
        border-top: 1px solid var(--bms-border);
        box-shadow: 0 -4px 16px rgba(15, 61, 122, 0.08);
        z-index: 80;
    }

    .bottom-nav button,
    .bottom-nav a {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 0.15rem;
        padding: 0.4rem 0.1rem;
        border: none;
        border-radius: 12px;
        background: none;
        color: var(--bms-muted);
        font-family: inherit;
        font-size: 0.72rem;
        font-weight: 600;
        text-decoration: none;
        cursor: pointer;
    }

    .bottom-nav i { font-size: 1.35rem; line-height: 1; }

    .bottom-nav span {
        max-width: 100%;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .bottom-nav .active {
        color: var(--bms-primary);
        background: #e9f1fb;
    }

    .bottom-nav button:disabled {
        opacity: 0.4;
        cursor: default;
    }
}

/* Phone compact list: one bordered list, one row per record (name, then a small detail line, icons at the right). */
.record-list.compact-list {
    gap: 0;
}

/* Phones: the panel is the box; the rows run edge to edge so the detail line gets the full width. */
@media (max-width: 900px) {
    .page-panel:has(.compact-list) {
        padding: 0.25rem 0;
        overflow: hidden;
    }

    .page-panel:has(.compact-list) > :not(.compact-list):not(.desktop-table) {
        margin-left: 0.9rem;
        margin-right: 0.9rem;
    }
}

.compact-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.55rem 0.35rem 0.55rem 0.9rem;
    border-bottom: 1px solid var(--bms-border);
}

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

.compact-row-text {
    flex: 1;
    min-width: 0;
}

.compact-row-text strong,
.compact-row-meta {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.compact-row-text strong {
    font-size: 0.95rem;
}

.compact-row-meta {
    margin-top: 0.1rem;
    color: var(--bms-muted);
    font-size: 0.8rem;
}

.compact-row .row-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    gap: 0.1rem;
    margin: 0;
}

.compact-row-meta b {
    color: var(--bms-text);
    font-weight: 600;
}

/* Quantity at the right of a compact stock row; red when nothing is left. */
.compact-row-qty {
    flex-shrink: 0;
    min-width: 2.2em;
    text-align: right;
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.1;
}

.compact-row-qty small {
    display: block;
    color: var(--bms-muted);
    font-size: 0.62rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.compact-row-qty.is-zero {
    color: #b91c1c;
}

/* Text that is useful on desktop but takes too much room on a phone. */
@media (max-width: 700px) {
    .hide-on-phone {
        display: none !important;
    }
}

/* Sell list: "GST" tag beside the bill icons of a GST sale. */
.bill-kind-tag {
    display: inline-flex;
    align-items: center;
    height: 1.35rem;
    padding: 0 0.45rem;
    border-radius: 999px;
    background: #e9f1fb;
    color: var(--bms-primary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.radio-option.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Phone Sell list row: name · time · GST · amount, then first item and the arrow / Download / Share.
   Opened: every item with its amount and the total; Download and Share move below the list. */
.sale-row-card {
    padding: 0.75rem 0.9rem;
}

.sale-row-l1,
.sale-row-l2 {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
}

.sale-row-l1 {
    cursor: pointer;
}

.sale-row-name {
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sale-row-when {
    flex: 1;
    min-width: 0;
    color: var(--bms-muted);
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sale-row-l2 {
    margin-top: 0.3rem;
}

.sale-row-first {
    flex: 1;
    min-width: 0;
    color: var(--bms-muted);
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}

.sale-row-first b {
    color: var(--bms-text, #1f2937);
    font-weight: 600;
}

.sale-row-more {
    color: var(--bms-primary);
    font-weight: 600;
}

.sale-row-icons {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.sale-row-lines {
    margin-top: 0.55rem;
    padding: 0.55rem 0.7rem;
    border-radius: 10px;
    background: #f4f7fc;
    font-size: 0.88rem;
}

.sale-row-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 0.75rem;
    align-items: baseline;
    padding: 0.15rem 0;
}

.sale-row-line > span:first-child {
    overflow-wrap: anywhere;
}

.sale-row-line b {
    min-width: 4.5rem;
    text-align: right;
}

.sale-row-qp {
    color: var(--bms-muted);
    white-space: nowrap;
}

.sale-row-total {
    margin-top: 0.3rem;
    padding-top: 0.4rem;
    border-top: 1px solid var(--bms-border);
}

.sale-row-bottom {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
}

.sale-row-spacer {
    flex: 1;
}

/* Personal Expenditure page: totals, filter chips, rows grouped by day.
   Phone: two lines per row (description, tag, amount / category · person, payment, arrow, edit, delete).
   Computer (901px+): the same rows line up as table columns. */
.pexp-head {
    display: grid;
    gap: 0.75rem;
}

.pexp-head-top {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.pexp-head-top h1 {
    flex: 1;
    margin: 0;
}

.pexp-head-top .pexp-add {
    flex: none;
    width: auto;
    min-width: 0;
}

.pexp-add-long {
    display: none;
}

.pexp-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.pexp-stat {
    display: grid;
    gap: 0.1rem;
    text-align: left;
    border: 1px solid transparent;
    border-radius: 10px;
    background: #f4f7fc;
    padding: 0.5rem 0.65rem;
    font: inherit;
    color: inherit;
}

button.pexp-stat {
    cursor: pointer;
}

.pexp-stat.is-on {
    background: #e3edfa;
    border-color: #b9d0ef;
}

.pexp-stat span {
    font-size: 0.75rem;
    color: var(--bms-muted);
}

.pexp-stat strong {
    font-size: 0.95rem;
    color: var(--bms-primary-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pexp-head .page-search-wrap {
    width: 100%;
}

.pexp-panel {
    padding: 0;
    overflow: hidden;
}

.pexp-chips {
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.75rem 1rem 0.35rem;
    scrollbar-width: none;
}

.pexp-chips::-webkit-scrollbar {
    display: none;
}

.pexp-chip {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    max-width: 14rem;
    height: 2rem;
    padding: 0 0.7rem;
    border: 1px solid var(--bms-border);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    font-size: 0.82rem;
    color: var(--bms-text);
    cursor: pointer;
}

.pexp-chip span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pexp-chip.is-on {
    background: #e9f1fb;
    border-color: #c5d8f1;
    color: var(--bms-primary);
    font-weight: 600;
}

.pexp-chip-panel {
    margin: 0.35rem 1rem 0.25rem;
    padding: 0.6rem;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 6px 16px rgba(15, 61, 122, 0.08);
}

.pexp-day-pick {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.pexp-pick {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 15rem;
    overflow-y: auto;
}

.pexp-pick button,
.pexp-check {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.45rem 0.5rem;
    border: 0;
    border-radius: 8px;
    background: none;
    font: inherit;
    font-size: 0.9rem;
    text-align: left;
    color: var(--bms-text);
    cursor: pointer;
}

.pexp-pick button.is-on {
    background: #e9f1fb;
    color: var(--bms-primary);
    font-weight: 600;
}

.pexp-pick-empty,
.pexp-empty {
    padding: 0.5rem 1rem;
    color: var(--bms-muted);
    font-size: 0.88rem;
}

.pexp-filter-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.4rem 1rem 0.65rem;
    border-bottom: 1px solid var(--bms-border);
    font-size: 0.85rem;
    color: var(--bms-muted);
}

.pexp-filter-total strong {
    font-size: 1rem;
    color: var(--bms-text);
}

.pexp-colhead {
    display: none;
}

.pexp-day {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--bms-border);
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

.pexp-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto auto;
    grid-template-areas:
        "l1 amount amount amount"
        "meta pay chev actions";
    align-items: center;
    column-gap: 0.25rem;
    padding: 0.55rem 0.5rem 0.55rem 1rem;
    border-bottom: 1px solid var(--bms-border);
}

.pexp-row.is-open {
    grid-template-areas:
        "l1 amount amount amount"
        "meta pay chev chev"
        "details details details details"
        ". . . actions";
}

.pexp-l1 {
    grid-area: l1;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    min-width: 0;
    cursor: pointer;
}

.pexp-title {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.97rem;
}

.pexp-tag {
    flex: none;
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    background: #fdf1e3;
    color: #a35a00;
    font-size: 0.68rem;
    font-weight: 700;
}

.pexp-row .pexp-none {
    display: none;
}

.pexp-amount {
    grid-area: amount;
    justify-self: end;
    padding-right: 0.5rem;
    font-weight: 700;
    color: var(--bms-primary-dark);
    white-space: nowrap;
}

.pexp-meta {
    grid-area: meta;
    display: flex;
    min-width: 0;
    margin-top: 0.15rem;
    overflow: hidden;
    white-space: nowrap;
    color: var(--bms-muted);
    font-size: 0.82rem;
    cursor: pointer;
}

.pexp-cat,
.pexp-person {
    overflow: hidden;
    text-overflow: ellipsis;
}

.pexp-cat {
    flex: none;
    max-width: 65%;
}

.pexp-cat:empty {
    display: none;
}

.pexp-cat:not(:empty) + .pexp-person:not(.pexp-none)::before {
    content: " · ";
    white-space: pre;
}

.pexp-pay-cell {
    grid-area: pay;
}

.pexp-pay {
    padding: 0.05rem 0.35rem;
    border: 1px solid var(--bms-border);
    border-radius: 6px;
    font-size: 0.68rem;
    font-weight: 700;
    color: #475569;
    white-space: nowrap;
}

.pexp-chev {
    grid-area: chev;
}

.pexp-actions {
    grid-area: actions;
    display: inline-flex;
    justify-content: flex-end;
}

.pexp-details {
    grid-area: details;
    margin: 0.45rem 0.5rem 0 0;
    padding: 0.5rem 0.7rem 0.6rem;
    border-radius: 10px;
    background: #f4f7fc;
}

.pexp-details .exp-detail-row:first-child {
    margin-top: 0;
}

.pexp-details .exp-scan-lines {
    margin-top: 0.4rem;
    padding-top: 0.35rem;
    border-top: 1px solid #dbe4f0;
}

.pexp-panel .exp-pager {
    padding: 0.6rem 1rem 0.75rem;
}

/* Persons picker in the Add / Edit form */
.pexp-people {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}

.pexp-person-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    height: 2rem;
    padding: 0 0.75rem;
    border: 1px solid var(--bms-border);
    border-radius: 999px;
    background: #fff;
    font: inherit;
    font-size: 0.85rem;
    color: var(--bms-text);
    cursor: pointer;
}

.pexp-person-chip.is-on {
    background: #e9f1fb;
    border-color: #9fbde6;
    color: var(--bms-primary);
    font-weight: 600;
}

.pexp-person-new {
    border-style: dashed;
    color: var(--bms-muted);
}

.pexp-person-add .form-input {
    width: 9rem;
    height: 2rem;
    padding: 0 0.65rem;
    border-radius: 999px;
}

@media (min-width: 901px) {
    .pexp-head {
        grid-template-columns: minmax(0, 1fr) auto;
        grid-template-areas:
            "title stats"
            "search add";
        align-items: center;
    }

    .pexp-head-top {
        display: contents;
    }

    .pexp-head-top h1 {
        grid-area: title;
    }

    .pexp-head-top .pexp-add {
        grid-area: add;
        justify-self: end;
    }

    .pexp-stats {
        grid-area: stats;
        grid-template-columns: repeat(3, 9.5rem);
    }

    .pexp-head .page-search-wrap {
        grid-area: search;
    }

    .pexp-head .page-search {
        width: 100%;
        max-width: none;
    }

    .pexp-add-short {
        display: none;
    }

    .pexp-stat strong {
        font-size: 1.05rem;
    }

    .pexp-add-long {
        display: inline;
    }

    .pexp-colhead,
    .pexp-row {
        grid-template-columns: 2.25rem minmax(0, 1.6fr) minmax(0, 1.2fr) 6.5rem minmax(0, 0.9fr) 5rem 7rem 4.75rem;
    }

    .pexp-colhead {
        display: grid;
        column-gap: 0.5rem;
        padding: 0.5rem 0.5rem 0.5rem 0.75rem;
        border-bottom: 1px solid var(--bms-border);
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--bms-muted);
    }

    .pexp-num {
        text-align: right;
    }

    .pexp-row,
    .pexp-row.is-open {
        grid-template-areas:
            "chev title cat tag person pay amount actions"
            ". details details details details details details .";
        column-gap: 0.5rem;
        padding: 0.45rem 0.5rem 0.45rem 0.75rem;
    }

    .pexp-l1,
    .pexp-meta {
        display: contents;
    }

    .pexp-title {
        grid-area: title;
    }

    .pexp-row .pexp-tag {
        grid-area: tag;
        justify-self: start;
    }

    .pexp-row .pexp-none {
        display: block;
        background: none;
        color: var(--bms-muted);
    }

    .pexp-cat {
        grid-area: cat;
        max-width: none;
        color: var(--bms-muted);
        font-size: 0.85rem;
        white-space: nowrap;
    }

    .pexp-cat:empty {
        display: block;
    }

    .pexp-person {
        grid-area: person;
        font-size: 0.88rem;
        color: var(--bms-text);
        white-space: nowrap;
    }

    .pexp-person.pexp-none {
        color: var(--bms-muted);
    }

    .pexp-cat:not(:empty) + .pexp-person:not(.pexp-none)::before {
        content: none;
    }

    .pexp-amount {
        padding-right: 0;
    }

    .pexp-details {
        max-width: 34rem;
        margin: 0.25rem 0 0.35rem;
    }

    .pexp-day {
        padding-left: 0.75rem;
        padding-right: 5.75rem;
    }
}

/* Product Add / Edit popup: from the bottom on phones, centred on computers.
   Category and Subcategory share one line; Name and SKU share one line on computers. */
.pform-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(15, 23, 42, 0.45);
}

.page-panel.pform-sheet {
    width: min(34rem, 100%);
    max-height: 90vh;
    max-height: 90dvh;
    margin: 0;
    overflow-y: auto;
    border-radius: 16px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
}

.pform-grab {
    display: none;
}

.pform-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.75rem;
}

.pform-grid .form-group {
    min-width: 0;
    margin: 0;
}

.pform-full {
    grid-column: 1 / -1;
}

.pform-sheet .stock-form-actions {
    margin-top: 0.9rem;
    justify-content: flex-end;
}

/* Cancel and Save the same size. */
.pform-sheet .stock-form-actions .stock-action-btn {
    min-width: 7.5rem;
    justify-content: center;
}

.pform-sheet textarea.form-input {
    min-height: 3.5rem;
}

@media (max-width: 600px) {
    /* Phones: centred on the screen too, with a small margin all round. dvh keeps Save / Cancel
       clear of the browser and phone bars at the bottom; the app's bottom menu hides while open. */
    .pform-backdrop {
        padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
    }

    body:has(.pform-backdrop) .bottom-nav {
        visibility: hidden;
    }

    .page-panel.pform-sheet {
        width: 90vw;
        max-height: 90dvh;
        border-radius: 16px;
        padding: 0.8rem 0.9rem 0.9rem;
    }

    .pform-grid {
        gap: 0.6rem 0.5rem;
    }

    .pform-pair {
        grid-column: 1 / -1;
    }

    .pform-sheet .form-label {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .pform-sheet .stock-form-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .pform-sheet .stock-form-actions {
        align-items: stretch;
    }

    .pform-sheet .stock-form-actions .stock-action-btn {
        width: 100%;
        height: 2.75rem;
        min-height: 2.75rem;
        margin: 0;
        padding-top: 0;
        padding-bottom: 0;
        box-sizing: border-box;
    }
}

/* Stock Add / Edit popup (inside the Product popup frame, .pform-*).
   Phone: Product, then Price and Stock parts; pairs share a line; Save / Cancel stay at the bottom.
   Computer: four columns, no scrolling. */
.page-panel.sform-sheet {
    width: min(54rem, 100%);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sform-form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

.sform-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.sform-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-areas:
        "product product qty loc"
        "desc desc desc desc"
        "cost sell disc maxdisc"
        "mfg exp vendor vendor"
        "after after after after";
    gap: 0.7rem;
}

.sform-grid .form-group {
    min-width: 0;
    margin: 0;
}

.sform-product { grid-area: product; }
.sform-qty { grid-area: qty; }
.sform-loc { grid-area: loc; }
.sform-desc { grid-area: desc; }
.sform-cost { grid-area: cost; }
.sform-sell { grid-area: sell; }
.sform-disc { grid-area: disc; }
.sform-maxdisc { grid-area: maxdisc; }
.sform-after { grid-area: after; }
.sform-mfg { grid-area: mfg; }
.sform-exp { grid-area: exp; }
.sform-vendor { grid-area: vendor; }
.sform-price-title { grid-area: pricetitle; }
.sform-stock-title { grid-area: stocktitle; }

.sform-section {
    display: none;
    margin: 0.35rem 0 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--bms-muted);
}

.sform-desc {
    margin: -0.35rem 0 0;
    font-size: 0.82rem;
    color: var(--bms-muted);
}

.sform-pair {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 2.6rem;
    border: 1px solid var(--bms-border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.sform-pair label {
    display: flex;
    align-items: center;
    min-width: 0;
    padding-right: 0.5rem;
}

.sform-pair label + label {
    border-left: 1px solid var(--bms-border);
}

.sform-pair input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    padding: 0 0.4rem 0 0.65rem;
    background: transparent;
    font: inherit;
    color: var(--bms-text);
    outline: none;
}

.sform-pair:focus-within {
    border-color: var(--bms-primary);
}

.sform-pair span {
    flex: none;
    font-size: 0.8rem;
    color: var(--bms-muted);
}

.sform-after {
    margin: 0;
    padding: 0.45rem 0.7rem;
    border-radius: 8px;
    background: #ecfdf5;
    color: #0f766e;
    font-size: 0.85rem;
}

.sform-actions {
    flex: none;
}

@media (max-width: 600px) {
    .sform-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-template-areas:
            "product product"
            "desc desc"
            "pricetitle pricetitle"
            "cost sell"
            "disc disc"
            "maxdisc maxdisc"
            "after after"
            "stocktitle stocktitle"
            "qty loc"
            "mfg exp"
            "vendor vendor";
        gap: 0.55rem 0.5rem;
    }

    .page-panel.sform-sheet {
        width: 90vw;
    }

    .sform-section {
        display: block;
    }

    .sform-desc {
        margin-top: -0.25rem;
    }

    .sform-actions {
        padding-top: 0.6rem;
        border-top: 1px solid var(--bms-border);
    }
}

/* Sell Add / Edit popup on phones: pairs share a line like the Stock popup
   (Mobile + Place; Quantity + Sell price; Line total + Remove). */
@media (max-width: 600px) {
    .sform-sheet .customer-fields-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem 0.5rem;
    }

    .sform-sheet .customer-fields-grid > :first-child {
        grid-column: 1 / -1;
    }

    .sform-sheet .customer-fields-grid .form-group {
        min-width: 0;
        margin: 0;
    }

    .sform-sheet .sale-line-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        padding: 0.65rem;
    }

    .sform-sheet .sale-line-row > .form-group {
        min-width: 0;
        margin: 0;
    }

    .sform-sheet .sale-line-row > .form-group:first-child {
        grid-column: 1 / -1;
    }

    .sform-sheet .sale-line-total,
    .sform-sheet .sale-line-remove {
        align-self: center;
        margin-top: 0;
    }

    .sform-sheet .sale-line-remove {
        justify-self: end;
    }

    .sform-sheet .sale-line-total {
        display: flex;
        align-items: baseline;
        gap: 0.4rem;
    }

    .sform-sheet .sale-line-total .form-label {
        margin: 0;
    }

    .sform-sheet .customer-block {
        margin-bottom: 0.75rem;
    }
}

/* Add / Edit expenditure: same popup as Product, Stock and Sell (centred, at most 90% of the
   screen, Save / Cancel stay visible at the bottom). Personal and shop expenditure. */
.exp-modal-backdrop {
    z-index: 1200;
    align-items: center;
}

.exp-modal {
    max-height: 90vh;
    max-height: 90dvh;
}

.exp-modal .exp-form .stock-form-actions {
    position: sticky;
    bottom: 0;
    z-index: 2;
    margin: 0.75rem -1.15rem -1.2rem;
    padding: 0.7rem 1.15rem 0.9rem;
    background: #fff;
    border-top: 1px solid var(--bms-border);
    justify-content: flex-end;
}

.exp-modal .exp-form .stock-form-actions .stock-action-btn {
    min-width: 7.5rem;
    justify-content: center;
}

/* Cancel on the left, Save on the right, like the other popups. */
.exp-modal .exp-form .stock-form-actions .stock-action-btn.secondary {
    order: -1;
}

body:has(.exp-modal-backdrop) .bottom-nav {
    visibility: hidden;
}

@media (max-width: 600px) {
    .exp-modal-backdrop {
        padding: 0.75rem 0.75rem calc(0.75rem + env(safe-area-inset-bottom, 0px));
        align-items: center;
    }

    .exp-modal {
        width: 90vw;
        min-height: 0;
        max-height: 90dvh;
        margin: 0;
    }

    .exp-modal-head {
        padding: 0.8rem 0.9rem 0.6rem;
    }

    .exp-modal-body {
        padding: 0.75rem 0.9rem 1.2rem;
    }

    /* Pairs share a line: Category + Subcategory, Location + Tag, Description + Amount, Date + Payment. */
    .exp-modal .exp-form .form-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.55rem 0.5rem;
    }

    .exp-modal .exp-form .form-grid > .form-group {
        min-width: 0;
        margin: 0;
    }

    .exp-modal .exp-form .form-grid > .form-group-span {
        grid-column: 1 / -1;
    }

    .exp-modal .exp-form .form-grid > .form-group:not(.form-group-span) > .form-hint {
        display: none;
    }

    .exp-modal .exp-form .form-label {
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .exp-modal .exp-form .stock-form-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
        margin: 0.75rem -0.9rem -1.2rem;
        padding: 0.65rem 0.9rem 0.8rem;
    }

    .exp-modal .exp-form .stock-form-actions .stock-action-btn {
        width: 100%;
        min-width: 0;
        height: 2.75rem;
        margin: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
}

/* Attendance: today's numbers, List (grouped by day) or 14-day grid (one line per person). */
.att-head {
    display: grid;
    gap: 0.75rem;
}

.att-head h1 {
    margin: 0;
}

.att-stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.5rem;
}

.att-stat {
    border-radius: 10px;
    background: #f4f7fc;
    padding: 0.5rem 0.7rem;
}

.att-stat span {
    display: block;
    font-size: 0.75rem;
    color: var(--bms-muted);
}

.att-stat strong {
    font-size: 1.15rem;
}

.att-stat.is-live strong { color: #15803d; }
.att-stat.is-blue strong { color: var(--bms-primary); }
.att-stat.is-amber strong { color: #a35a00; }

.att-tools {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    flex-wrap: wrap;
}

.att-tools .page-search-wrap {
    flex: 1;
    min-width: 12rem;
}

.att-tools .page-search {
    width: 100%;
}

.att-tabs {
    display: flex;
    gap: 0.2rem;
    padding: 0.2rem;
    border-radius: 10px;
    background: #f4f7fc;
}

.att-tabs button {
    border: 0;
    border-radius: 8px;
    background: none;
    padding: 0.4rem 0.9rem;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--bms-muted);
    cursor: pointer;
}

.att-tabs button.is-on {
    background: #fff;
    color: var(--bms-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.att-panel {
    padding: 0;
    overflow: hidden;
}

.att-day {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--bms-border);
    font-size: 0.8rem;
    font-weight: 700;
    color: #475569;
}

.att-day small {
    font-weight: 600;
    color: var(--bms-muted);
}

.att-row {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.6rem 0.9rem 0.6rem 1rem;
    border-bottom: 1px solid var(--bms-border);
}

.att-avatar {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 50%;
    color: #fff;
    font-size: 0.8rem;
    font-weight: 700;
}

.att-avatar.is-small {
    width: 1.4rem;
    height: 1.4rem;
    font-size: 0.6rem;
}

.att-who {
    flex: 1;
    min-width: 0;
}

.att-who > b {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.att-who > span {
    font-size: 0.8rem;
    color: var(--bms-muted);
}

.att-who > span b {
    color: var(--bms-text);
}

.att-pill {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    background: #f4f7fc;
    color: #334155;
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
}

.att-pill.is-live {
    background: #dcfce7;
    color: #15803d;
}

.att-pill.is-missing {
    background: #fdf1e3;
    color: #a35a00;
}

.att-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #15803d;
    animation: att-pulse 1.6s infinite;
}

@keyframes att-pulse {
    50% { opacity: 0.35; }
}

.att-grid-wrap {
    overflow-x: auto;
    padding: 0.75rem 0.75rem 0.25rem;
}

.att-grid {
    border-collapse: separate;
    border-spacing: 3px;
    width: 100%;
    font-size: 0.72rem;
}

.att-grid th {
    padding: 0.15rem;
    text-align: center;
    font-weight: 600;
    color: var(--bms-muted);
}

.att-grid th.is-today {
    color: var(--bms-primary);
}

.att-grid .att-name {
    position: sticky;
    left: 0;
    z-index: 1;
    background: #fff;
    text-align: left;
    padding-right: 0.5rem;
    white-space: nowrap;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--bms-text);
}

.att-grid td.att-name {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    height: 1.9rem;
}

.att-cell {
    min-width: 2.1rem;
    height: 1.9rem;
    border-radius: 6px;
    text-align: center;
    font-weight: 700;
    cursor: pointer;
}

.att-cell.is-full,
.att-legend i.is-full { background: #bfe3cf; color: #065f46; }
.att-cell.is-part,
.att-legend i.is-part { background: #e6f4ea; color: #15803d; }
.att-cell.is-live,
.att-legend i.is-live { background: #dcfce7; color: #15803d; box-shadow: inset 0 0 0 1.5px #86efac; }
.att-cell.is-missing,
.att-legend i.is-missing { background: #fdf1e3; color: #a35a00; }
.att-cell.is-absent,
.att-legend i.is-absent { background: #f1f5f9; color: #cbd5e1; cursor: default; }

.att-cell.is-picked {
    box-shadow: inset 0 0 0 2px var(--bms-primary);
}

.att-picked {
    margin: 0.5rem 0 0;
    padding: 0 1rem;
    font-size: 0.85rem;
    color: var(--bms-muted);
}

.att-picked b {
    color: var(--bms-text);
}

.att-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem 0.9rem;
    padding: 0.6rem 1rem 0.85rem;
    font-size: 0.75rem;
    color: var(--bms-muted);
}

.att-legend i {
    display: inline-block;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 3px;
    margin-right: 0.3rem;
    vertical-align: -1px;
}

.att-mine {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.att-mine p {
    margin: 0;
    flex: 1;
}

@media (min-width: 901px) {
    .att-head {
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
    }

    .att-stats {
        grid-template-columns: repeat(3, 9rem);
    }

    .att-tools {
        grid-column: 1 / -1;
    }
}

/* Phones: show the full name "Inventory & Stock Manager" on two short lines instead of cutting it off. */
@media (max-width: 600px) {
    .top-header .header-left .logo span.brand-name {
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        font-size: 0.82rem;
        line-height: 1.15;
        max-width: 9.2rem;
    }
}

/* Shop Management cards on desktop: title · label · hint on one line ("Stock · Track · Add, edit, delete stock").
   Phones and tablets (900px and below) are not changed. */
@media (min-width: 901px) {
    .shop-hub-page .home-top-actions .card-info {
        display: flex;
        flex-wrap: wrap;
        align-items: baseline;
        gap: 0.15rem 0.5rem;
        min-width: 0;
    }
    .shop-hub-page .home-top-actions .card-value { order: 0; }
    .shop-hub-page .home-top-actions .card-label { order: 1; margin: 0; font-size: 0.95rem; font-weight: 500; }
    .shop-hub-page .home-top-actions .card-hint { order: 2; margin: 0; font-size: 0.95rem; }
    .shop-hub-page .home-top-actions .card-label::before,
    .shop-hub-page .home-top-actions .card-hint::before { content: "·"; margin-right: 0.5rem; color: #98a2b3; }
    .shop-hub-page .home-top-actions .stat-card { min-height: 0; padding: 1.1rem 1.4rem; }
    .shop-hub-page .home-top-actions .card-content { align-items: center; min-height: 0; }
}
