/* Uphold — design system
   Mobile-first. Variables drive every colour, every radius, every spacing.
   Brand is overridden per business via JS (data-brand-color attribute on body). */

:root {
    /* Uphold tropical palette (Caribbean F&B identity) */
    --uphold-orange-light: #F4A23C;
    --uphold-orange:       #F58220;
    --uphold-orange-deep:  #E8542B;
    --uphold-teal:         #5F7F7C;
    --uphold-navy:         #1E2A3A;
    --uphold-cream:        #F5EDDF;
    --uphold-cream-soft:   #FAF6EC;

    /* Semantic aliases — keep names that the rest of the app already uses */
    --uphold-charcoal:     var(--uphold-navy);
    --tenant-accent:       var(--uphold-orange-deep);
    --uphold-accent:       var(--tenant-accent);
    --brand:               var(--uphold-orange-deep);
    --brand-light:         rgba(232, 84, 43, 0.10);
    --brand-dark:          #C7461F;

    /* Button gradient — used on the login CTA */
    --uphold-cta-gradient: linear-gradient(
        90deg,
        var(--uphold-orange-light) 0%,
        var(--uphold-orange) 45%,
        var(--uphold-orange-deep) 100%
    );

    /* Semantic */
    --success: #059669;
    --success-light: rgba(5, 150, 105, 0.10);
    --danger: #dc2626;
    --danger-light: rgba(220, 38, 38, 0.10);
    --warning: #d97706;
    --warning-light: rgba(217, 119, 6, 0.10);
    --info: #2563eb;
    --info-light: rgba(37, 99, 235, 0.10);

    /* Text */
    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;

    /* Backgrounds */
    --bg-page: #f8fafc;
    --bg-card: #ffffff;
    --bg-hover: #f1f5f9;

    /* Borders */
    --border: #e2e8f0;
    --border-light: #f1f5f9;

    /* Shape */
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 14px;

    /* Layout */
    --topbar-height: 56px;
    --bottom-nav-height: 64px;
    --sidebar-width: 260px;
    --content-max-width: 800px;
}

/* ---------- Reset / typography ---------- */
html, body { font-size: 16px; }

body {
    background-color: var(--bg-page);
    color: var(--text-primary);
    font-size: 0.9rem;
    -webkit-tap-highlight-color: transparent;
    transition: background-color .2s ease;
}
@media (min-width: 768px) {
    body { font-size: 0.95rem; }
}

/* iOS zoom prevention: 16px on inputs */
input, select, textarea, .form-control, .form-select {
    font-size: 16px !important;
}

/* Page transitions */
.app-content {
    animation: contentFadeIn .2s ease both;
}
@keyframes contentFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: none; }
}

h1, h2, h3, h4, h5, h6 { color: var(--text-primary); }

.page-title {
    font-size: 1.25rem;       /* h4 on mobile */
    font-weight: 600;
    line-height: 1.2;
    margin: 0;
}
@media (min-width: 768px) {
    .page-title { font-size: 1.5rem; }   /* h3 on desktop */
}

.section-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
    margin: 0;
}

.section-stack > * + * { margin-top: 1.5rem; }

a { color: var(--brand); }
a:hover { color: var(--brand-dark); }

/* ---------- Touch targets ---------- */
.btn, .form-control, .form-select, .nav-link,
.bottom-nav-item, .business-list-item,
.topbar-business, .topbar-action, .topbar-avatar {
    min-height: 44px;
}

.btn-reset {
    background: transparent;
    border: 0;
    padding: 0;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

/* Focus-visible: clean accessible outline */
*:focus { outline: none; }
*:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
    border-radius: 6px;
}
.form-control:focus-visible, .form-select:focus-visible {
    outline: none;
}

/* ---------- Buttons ---------- */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: filter .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.98); }

.btn-brand,
.btn-primary {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-brand:hover, .btn-brand:focus,
.btn-primary:hover, .btn-primary:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}
.btn-brand:disabled, .btn-primary:disabled {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
    opacity: .5;
    transform: none;
}

.btn-success { background-color: var(--success); border-color: var(--success); }
.btn-success:hover, .btn-success:focus { background-color: #047857; border-color: #047857; }
.btn-danger { background-color: var(--danger); border-color: var(--danger); }
.btn-danger:hover, .btn-danger:focus { background-color: #b91c1c; border-color: #b91c1c; }
.btn-warning { background-color: var(--warning); border-color: var(--warning); color: #fff; }
.btn-warning:hover, .btn-warning:focus { background-color: #b45309; border-color: #b45309; color: #fff; }

.btn-outline-success { color: var(--success); border-color: var(--success); }
.btn-outline-danger { color: var(--danger); border-color: var(--danger); }

.form-check-input:checked {
    background-color: var(--brand);
    border-color: var(--brand);
}
.form-check-input { accent-color: var(--brand); }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

/* Greek-tone overrides for default text-success / text-danger / text-muted */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-secondary-app { color: var(--text-secondary); }

/* ---------- Forms ---------- */
.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    color: var(--text-primary);
    background-color: var(--bg-card);
}
.form-control::placeholder { color: var(--text-muted); }
textarea.form-control { min-height: 80px; }
.form-text { font-size: 0.75rem; color: var(--text-muted); }
.form-control.is-invalid {
    border-color: var(--danger);
    box-shadow: none;
}
.invalid-feedback { font-size: 0.75rem; color: var(--danger); }

/* ---------- Cards ---------- */
.card {
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
}
.card.shadow-sm,
.card-soft {
    border: 0;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.card-body { padding: 1rem; }
@media (min-width: 768px) {
    .card-body { padding: 1.25rem; }
}

/* ---------- Auth (login) page ---------- */
.auth-shell {
    background: linear-gradient(180deg, var(--brand-light) 0%, var(--bg-page) 60%);
    min-height: 100vh;
}
.auth-card {
    width: 100%;
    max-width: 420px;
    border-radius: var(--radius-lg);
    border: 0;
}

/* ---------- App shell ---------- */
.app-shell {
    background-color: var(--bg-page);
    min-height: 100vh;
    padding-top: var(--topbar-height);
    padding-bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
}
.app-main { width: 100%; }
.app-content {
    max-width: 100%;
    padding: 1rem;
}
@media (min-width: 768px) {
    .app-shell {
        padding-top: 0;
        padding-bottom: 0;
        padding-left: var(--sidebar-width);
    }
    .app-content {
        max-width: var(--content-max-width);
        margin: 0 auto;
        padding: 1.5rem;
    }
    .app-bottom-nav, .app-topbar { display: none !important; }
}

/* ---------- Top bar (mobile) ---------- */
.app-topbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--topbar-height);
    z-index: 1040;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background-color: var(--brand-dark);
    color: #fff;
    /* No `overflow: hidden` here — it would clip the avatar dropdown menu.
       Truncation lives on .topbar-business-name below, which is enough. */
    transition: background-color .25s ease, box-shadow .2s ease;
}
/* Float the dropdown menu just below the topbar so it can't kiss the edge */
.app-topbar .dropdown-menu { margin-top: 4px; }
.app-topbar.is-scrolled {
    box-shadow: 0 1px 0 rgba(0,0,0,.08);
}
.topbar-business {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #fff;
    max-width: 70%;
    padding: 0;
    border-radius: var(--radius-sm);
}
.topbar-business:hover { background-color: transparent; }
.topbar-logo,
.topbar-logo-fallback {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background-color: rgba(255,255,255,.20);
    border: 2px solid #fff;
}
.topbar-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 600;
    font-size: 0.85rem;
}
.topbar-business-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-chevron { opacity: .85; font-size: 0.8rem; }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar-action,
.topbar-avatar {
    color: #fff;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
}
.topbar-action:hover,
.topbar-avatar:hover { background-color: rgba(255,255,255,.15); }
.topbar-avatar {
    background-color: #fff;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 0.85rem;
}

/* ---------- Bottom navigation (mobile) ---------- */
.app-bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 1040;
    display: flex;
    justify-content: space-around;
    height: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background-color: var(--bg-card);
    border-top: 1px solid var(--border);
}
.bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    text-decoration: none;
    color: var(--text-muted);
    font-size: 0.65rem;
    line-height: 1;
    padding: 6px 4px;
    transition: transform .1s ease, color .15s ease;
}
.bottom-nav-item:hover { color: var(--text-secondary); }
.bottom-nav-item:active { transform: scale(0.92); }
.bottom-nav-item i { font-size: 1.375rem; }
.bottom-nav-item.active { color: var(--brand); }

/* ---------- Sidebar (desktop) ---------- */
.app-sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 16px;
    overflow-y: auto;
    z-index: 1030;
}

.sidebar-brand {
    display: flex;
    align-items: baseline;
    gap: 2px;
    padding: 0.25rem 0.25rem 1rem;
    font-size: 1.1rem;
    line-height: 1;
}
.sidebar-brand-mark {
    color: var(--brand);
    font-weight: 700;
    letter-spacing: -0.5px;
}
.sidebar-brand-tail {
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-business {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    margin-bottom: 1rem;
    transition: background-color .15s ease;
}
.sidebar-business:hover { background-color: var(--bg-hover); }
.sidebar-business-logo {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
    background-color: var(--brand);
}
.sidebar-business-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}
.sidebar-business-text {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex: 1 1 auto;
    min-width: 0;
}
.sidebar-business-name {
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-business-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-nav { display: flex; flex-direction: column; gap: 2px; flex: 1 1 auto; }
.sidebar-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    height: 44px;
    padding: 0 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: background-color .15s ease, color .15s ease;
}
.sidebar-nav-link i { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.sidebar-nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-primary);
}
.sidebar-nav-link.active {
    background-color: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}
.sidebar-nav-link.active::before {
    content: "";
    position: absolute;
    left: 0;
    top: 8px;
    bottom: 8px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background-color: var(--brand);
}
.sidebar-nav-link-toggle .bi-chevron-down { transition: transform .2s ease; }
.sidebar-nav-link-toggle[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }
.sidebar-nav-sub {
    display: flex;
    flex-direction: column;
    gap: 1px;
    padding-left: 1.5rem;
    margin: 2px 0;
}
.sidebar-nav-link-sub {
    height: 36px;
    padding: 0 10px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}
.sidebar-nav-link-sub i { font-size: 14px; width: 16px; text-align: center; }
.sidebar-nav-link-sub:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.sidebar-nav-link-sub.active {
    background-color: var(--brand-light);
    color: var(--brand);
    font-weight: 600;
}

.sidebar-footer {
    border-top: 1px solid var(--border-light);
    padding-top: 1rem;
    margin-top: 1rem;
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}
.sidebar-user-avatar {
    width: 32px; height: 32px;
    border-radius: 50%;
    background-color: var(--brand);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.sidebar-user-text { min-width: 0; }
.sidebar-user-text strong {
    font-size: 0.875rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.sidebar-user-text small { font-size: 0.7rem; color: var(--text-muted); }

/* ---------- Business selector modal ---------- */
.business-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 12px 16px;
    background-color: transparent;
    transition: background-color .15s ease;
}
.business-list-item:hover { background-color: var(--bg-hover); }
.business-list-item.is-active { background-color: var(--brand-light); }
.business-list-logo {
    width: 36px; height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    object-fit: cover;
}
.business-list-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
}
.business-list-text { flex: 1 1 auto; min-width: 0; }
.business-list-text strong {
    display: block;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.business-list-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.business-list-check { color: var(--brand); font-size: 1.25rem; margin-left: 0.35rem; }

/* ---------- Toasts ---------- */
.toast-container { z-index: 1090; }
.app-toast-container { max-width: min(92vw, 360px); }
@media (min-width: 768px) {
    .app-toast-container {
        right: 0 !important;
        left: auto !important;
        transform: none !important;
    }
}
.toast {
    border-radius: var(--radius);
    border: 0 !important;
    animation: toastIn .25s ease both;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateY(-12px); }
    to { opacity: 1; transform: none; }
}

/* ---------- Day page ---------- */
.day-navigator-date {
    font-size: 1.05rem;
    font-weight: 600;
    text-transform: capitalize;
    line-height: 1.2;
    color: var(--text-primary);
}
.btn-icon {
    width: 44px; height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 1.05rem;
    flex-shrink: 0;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-secondary);
}
.btn-icon:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.btn-icon:disabled { opacity: 0.4; }

.btn-pill {
    border-radius: 999px;
    padding: 0 14px;
    font-weight: 500;
    font-size: 0.8rem;
    height: 36px;
    line-height: 34px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-secondary);
}
.btn-pill:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.btn-pill-active {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.btn-pill-active:hover, .btn-pill-active:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}
.btn-pill-sm {
    padding: 0 10px;
    height: 28px;
    line-height: 26px;
    font-size: 0.75rem;
}

/* Reconciliation card */
.reconciliation-card {
    border: 0 !important;
    border-top: 3px solid var(--brand) !important;
    border-radius: var(--radius);
    background-color: var(--bg-card);
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
}
.reconciliation-row + .reconciliation-row {
    border-top: 1px dashed var(--border-light);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
}
.reconciliation-cell {
    text-align: center;
    padding: 4px 6px;
}
.reconciliation-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.reconciliation-value {
    font-size: clamp(1.1rem, 4vw, 1.4rem);
    font-weight: 600;
    line-height: 1.15;
    margin-top: 4px;
    word-break: break-word;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.reconciliation-input {
    border: 0;
    border-bottom: 2px solid var(--border);
    border-radius: 0;
    padding: 4px 2px;
    width: 100%;
    text-align: center;
    font-size: clamp(1.1rem, 4vw, 1.4rem) !important;
    font-weight: 600;
    color: var(--text-primary);
    background-color: transparent;
    transition: border-color .15s ease;
    font-variant-numeric: tabular-nums;
}
.reconciliation-input:focus {
    outline: none;
    border-bottom-color: var(--brand);
    box-shadow: none;
}
.reconciliation-input.is-saving { opacity: 0.5; }
.carry-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-style: italic;
    text-align: center;
    line-height: 1.2;
}

/* Income method breakdown pills */
.income-breakdown {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px dashed var(--border-light);
    gap: 6px;
}
.income-method-pill {
    font-size: 0.7rem;
    padding: 4px 10px;
    background-color: var(--bg-hover) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border) !important;
    border-radius: 999px;
    font-weight: 500;
}
.income-method-pill strong {
    color: var(--success);
    font-variant-numeric: tabular-nums;
}

/* Quick action cards — explicit 2x2 grid (no Bootstrap row reliance) */
.quick-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.quick-action {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    text-align: left;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    transition: transform 100ms ease, box-shadow 100ms ease;
    min-height: 110px;
    color: var(--text-primary);
}
.quick-action:hover:not(:disabled),
.quick-action:focus:not(:disabled) {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.08);
}
.quick-action:active:not(:disabled) {
    transform: scale(0.97);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.quick-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}
.quick-action-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.15rem;
    margin-bottom: 8px;
}
.quick-action-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.quick-action-total {
    font-size: 1.15rem;
    font-weight: 600;
    margin-top: 2px;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.quick-action-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 500;
}
.quick-action-income .quick-action-icon { background-color: var(--success-light); color: var(--success); }
.quick-action-income .quick-action-total { color: var(--success); }
.quick-action-expense .quick-action-icon { background-color: var(--danger-light); color: var(--danger); }
.quick-action-expense .quick-action-total { color: var(--danger); }
.quick-action-payroll .quick-action-icon { background-color: var(--info-light); color: var(--info); }
.quick-action-payroll .quick-action-total { color: var(--info); }
.quick-action-z .quick-action-icon { background-color: var(--brand-light); color: var(--brand-dark); }
.quick-action-z .quick-action-total { color: var(--text-primary); }

/* Transaction list */
.transaction-accordion .accordion-item {
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: 0.65rem;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
}
.transaction-accordion .accordion-button {
    background-color: var(--bg-card);
    box-shadow: none;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.9rem;
}
.transaction-accordion .accordion-button:not(.collapsed) {
    background-color: var(--brand-light);
    color: var(--text-primary);
}
.transaction-accordion .accordion-button:focus { box-shadow: none; border: 0; }
.transaction-accordion .accordion-button strong {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
}
.transaction-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 10px 16px 10px 8px;
    background-color: var(--bg-card);
    border-top: 1px solid var(--border-light);
    min-height: 56px;
}
.transaction-item:first-child { border-top: 0; }
.transaction-item:hover { background-color: var(--bg-hover); }

.transaction-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    font-size: 0.95rem;
}
.transaction-item-income .transaction-icon { background-color: var(--success); }
.transaction-item-expense .transaction-icon { background-color: var(--danger); }
.transaction-item-payroll .transaction-icon { background-color: var(--info); }
.transaction-item-z .transaction-icon { background-color: var(--text-muted); }

.transaction-content { flex: 1 1 auto; min-width: 0; }
.transaction-row1 {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}
.transaction-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.transaction-method {
    background-color: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border) !important;
    font-weight: 500;
    font-size: 0.7rem;
}
.transaction-amount {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    margin-left: auto;
}
.transaction-row2 {
    display: flex;
    gap: 0.65rem;
    margin-top: 2px;
    flex-wrap: wrap;
    color: var(--text-muted);
    font-size: 0.75rem;
}
.transaction-row2 i { margin-right: 2px; }
.transaction-actions {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}
.transaction-btn {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: background-color .15s ease;
}
.transaction-btn:hover { background-color: var(--bg-hover); color: var(--text-primary); }

.transaction-item.is-pending {
    opacity: 0.65;
    background-color: var(--warning-light);
    border-left: 3px dashed var(--warning);
}
.transaction-item.is-pending .transaction-amount { text-decoration: line-through; }

.moved-from-badge {
    background-color: var(--warning-light) !important;
    color: var(--warning) !important;
    border: 0 !important;
    font-size: 0.6rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Modal: amount input, payment pills, kind tabs, drag handle.
   Note: don't strip border-radius unconditionally on .modal-fullscreen-sm-down
   here — that class is on every entry modal, and Bootstrap already zeroes
   the radius inside its own @media (max-width: 575.98px) block when the
   fullscreen variant actually activates. The MODAL POLISH SPRINT block at
   the end of this file sets the desktop radius. */
.modal-content {
    border-radius: var(--radius-lg);
    border: 0;
}
.modal-header {
    border-bottom: 1px solid var(--border-light);
    height: 56px;
    padding: 0 16px;
    align-items: center;
}
.modal-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.modal-body { padding: 20px; }
.modal-footer {
    border-top: 1px solid var(--border-light);
    padding: 12px 16px;
    gap: 8px;
    flex-direction: column-reverse;
}
.modal-footer .btn {
    flex: 1 0 auto;
    min-height: 48px;
    border-radius: var(--radius);
    font-weight: 500;
    width: 100%;
}
@media (min-width: 768px) {
    .modal-footer { flex-direction: row; justify-content: flex-end; }
    .modal-footer .btn { min-height: 40px; flex: 0 0 auto; width: auto; }
}

/* Mobile drag handle on top of fullscreen modals */
@media (max-width: 767.98px) {
    .modal-fullscreen-sm-down .modal-content::before {
        content: "";
        display: block;
        width: 36px;
        height: 4px;
        border-radius: 2px;
        background-color: #d1d5db;
        margin: 10px auto;
    }
}

.btn-close {
    width: 32px; height: 32px;
    border-radius: 50%;
    background-color: var(--bg-hover);
    background-position: center;
    background-size: 14px;
    opacity: 1;
    padding: 0;
    transition: background-color .15s ease;
}
.btn-close:hover { background-color: var(--border); }

.amount-wrap { position: relative; }
.amount-prefix {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-weight: 600;
    color: var(--text-muted);
    pointer-events: none;
    font-size: 1.6rem;
}
.amount-input {
    padding-left: 2.5rem !important;
    padding-right: 0.75rem !important;
    font-size: 2.5rem !important;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius);
    height: 64px;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}
.amount-input:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-light) !important;
}

/* Payment method pills — equal-width grid, brand-active state */
.payment-pills {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 6px;
}
.payment-pill {
    height: 44px;
    border: 1px solid transparent;
    border-radius: 10px;
    background-color: var(--bg-hover);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: all 150ms ease;
}
.payment-pill:hover { background-color: var(--brand-light); color: var(--text-primary); }
.payment-pill.is-active {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.kind-tabs {
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.kind-tabs .kind-tab {
    border: 0;
    background: transparent;
    padding: 8px 12px;
    font-weight: 500;
    color: var(--text-muted);
    font-size: 0.85rem;
}
.kind-tabs .kind-tab.active {
    color: var(--brand);
    border-bottom: 2px solid var(--brand);
    background: transparent;
}
.collapse-toggle { color: var(--text-muted); cursor: pointer; font-size: 0.8rem; }

/* Finalize button (sticky at bottom) */
.finalize-button {
    width: 100%;
    height: 52px;
    border-radius: var(--radius);
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
    font-size: 0.95rem;
    font-weight: 500;
    position: sticky;
    bottom: calc(var(--bottom-nav-height) + env(safe-area-inset-bottom, 0px) + 12px);
    z-index: 10;
}
.finalize-button:hover, .finalize-button:focus {
    background-color: var(--brand-dark);
    border-color: var(--brand-dark);
    color: #fff;
}
@media (min-width: 768px) {
    .finalize-button { position: static; }
}

.finalized-banner {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: var(--success-light);
    color: #065f46;
    border: 1px solid rgba(5, 150, 105, .2);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-top: 1.5rem;
}
.finalized-banner i.fs-5 { color: var(--success); }
.finalized-banner-actions {
    margin-left: auto;
    display: flex;
    gap: 8px;
}
.unlock-link {
    background: transparent;
    border: 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    text-decoration: underline;
    padding: 4px 8px;
    cursor: pointer;
}
.unlock-link:hover { color: var(--text-primary); }

/* ---------- Dashboard ---------- */
.period-selector .btn-pill { flex: 1 1 0; min-width: 0; }
.dashboard-summary {
    border-radius: var(--radius);
    padding: 1.25rem;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background-color: var(--bg-card);
    border: 1px solid var(--border);
}
.dashboard-summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    font-weight: 600;
}
.dashboard-summary-value {
    font-size: 1.8rem;
    font-weight: 700;
    margin-top: 4px;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    color: var(--text-primary);
}
.dashboard-summary.bg-success-subtle {
    background-color: var(--success-light) !important;
}
.dashboard-summary.bg-success-subtle .dashboard-summary-value { color: var(--success); }
.dashboard-summary.bg-danger-subtle {
    background-color: var(--danger-light) !important;
}
.dashboard-summary.bg-danger-subtle .dashboard-summary-value { color: var(--danger); }
.dashboard-change {
    display: inline-block;
    margin-top: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.store-list { display: flex; flex-direction: column; gap: 10px; }
.store-card {
    display: block;
    background-color: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
    text-decoration: none;
    color: inherit;
    padding: 12px;
    transition: transform .15s ease, box-shadow .15s ease;
}
.store-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 14px rgba(15, 23, 42, 0.08);
    color: inherit;
}
.store-card:active { transform: scale(0.98); }
.store-card-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.store-card-rank {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background-color: var(--bg-hover);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.7rem;
    display: grid;
    place-items: center;
    flex-shrink: 0;
}
.store-card-rank.rank-1 { background-color: #fcd34d; color: #fff; }
.store-card-rank.rank-top { background-color: var(--brand-light); color: var(--brand); }
.store-card-rank-1 {
    border: 1px solid #fcd34d;
    box-shadow: 0 4px 14px rgba(252, 211, 77, .15);
}
.store-card-logo {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
}
.store-card-logo-fallback {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 0.85rem;
}
.store-card-name {
    flex: 1;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.store-card-status {
    font-size: 0.65rem;
    padding: 3px 8px;
    flex-shrink: 0;
}
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.status-finalized { background-color: var(--success-light); color: var(--success); }
.status-open { background-color: var(--warning-light); color: var(--warning); }
.status-not_started { background-color: var(--bg-hover); color: var(--text-muted); }

/* Compact metric grid inside store card */
.store-card-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 4px;
    font-size: 0.85rem;
    background-color: var(--bg-hover);
    border-radius: var(--radius-sm);
    padding: 8px 6px;
}
.store-card-metric {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.15;
    gap: 2px;
}
.store-card-metric-label {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    font-weight: 600;
}
.store-card-metric-value {
    font-size: 0.95rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}
.store-card-metric-delta {
    font-size: 0.65rem;
    font-weight: 600;
}

.store-card-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}
.store-card-methods .badge {
    background-color: var(--bg-hover) !important;
    color: var(--text-secondary) !important;
    border: 1px solid var(--border) !important;
    font-weight: 500;
    font-size: 0.65rem;
    padding: 3px 8px;
    border-radius: 999px;
}
@media (max-width: 767.98px) {
    .store-card-methods {
        max-height: 0;
        overflow: hidden;
        transition: max-height .25s ease, margin-top .25s ease;
        margin-top: 0;
    }
    .store-card.is-expanded .store-card-methods {
        max-height: 200px;
        margin-top: 6px;
    }
}

.store-card-sparkline {
    display: flex;
    align-items: flex-end;
    height: 24px;
    gap: 2px;
    margin-top: 8px;
}
.store-sparkline-bar {
    flex: 0 0 4px;
    min-height: 2px;
    border-radius: 2px 2px 0 0;
    background-color: var(--brand);
    opacity: 0.5;
}
.store-sparkline-bar:last-child { opacity: 1; }

/* ---------- Reports filter bar / tables ---------- */
.report-filter-bar {
    position: sticky;
    top: 0;
    z-index: 10;
    background-color: var(--bg-page);
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
@media (min-width: 768px) {
    .report-filter-bar {
        position: static;
        background: transparent;
        border-bottom: 0;
        padding: 0;
    }
}

.report-table thead th {
    background-color: var(--bg-hover);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-size: 0.7rem;
    font-weight: 600;
}
.report-table tbody tr {
    min-height: 48px;
}
.report-table tbody tr:hover { background-color: var(--bg-hover); }
.report-table td, .report-table th { padding: 10px 12px; vertical-align: middle; }
.report-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}
.report-table tfoot td, .report-table .totals-row td {
    font-weight: 700;
    border-top: 2px solid var(--border);
    background-color: var(--bg-hover);
}

/* ---------- Tabs (registry, settings) ---------- */
.registry-tabs .nav-link {
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.85rem;
    font-weight: 500;
}
.registry-tabs .nav-link.active {
    background-color: var(--brand);
    color: #fff;
}

/* ---------- Misc utilities ---------- */
.input-group-search .input-group-text {
    background-color: var(--bg-card);
    border-color: var(--border);
    color: var(--text-muted);
}
.tabular-nums { font-variant-numeric: tabular-nums; }

.active-touch {
    transform: scale(0.98);
    filter: brightness(0.96);
    transition: none !important;
}

.btn .submit-spinner { display: none; }
.btn.is-loading .submit-spinner { display: inline-block; }
.btn.is-loading .submit-icon, .btn.is-loading .submit-text { opacity: 0.6; }
.btn[disabled] { cursor: progress; }

/* Offline banner — hidden by default; sits BELOW the topbar (lower z-index) */
.offline-banner {
    position: fixed;
    top: var(--topbar-height);
    left: 0; right: 0;
    z-index: 1030;                   /* topbar is 1040 — banner stays below it */
    background-color: var(--danger);
    color: #fff;
    padding: 8px 16px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 500;
    transform: translateY(-100%);
    transition: transform .25s ease;
    pointer-events: none;
}
.offline-banner[hidden] {
    display: none !important;
}
.offline-banner.is-visible {
    transform: translateY(0);
    pointer-events: auto;
}
@media (min-width: 768px) {
    .offline-banner { top: 0; left: var(--sidebar-width); }
}

/* Pending settle table */
.pending-table th { font-size: 0.7rem; }
.pending-table td { font-size: 0.85rem; }

/* History */
.history-table { font-size: 0.875rem; }
.history-table thead th {
    background-color: var(--bg-hover);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    font-size: 0.7rem;
    font-weight: 600;
}
.history-cards .store-card { background-color: var(--bg-card); }

/* Pending modal table */
.pending-table .form-check-input { margin-top: 0; }

/* ---------- Notifications ---------- */
.topbar-action.position-relative { position: relative; }
.topbar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 999px;
    background-color: var(--danger);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    box-shadow: 0 0 0 2px var(--brand-dark);
    pointer-events: none;
}
.topbar-badge[hidden] { display: none !important; }
.sidebar-nav-badge {
    margin-left: auto;
    min-width: 20px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;
    background-color: var(--danger);
    color: #fff;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
.sidebar-nav-badge[hidden] { display: none !important; }

.notifications-offcanvas {
    --bs-offcanvas-width: 360px;
}
.notifications-offcanvas .offcanvas-footer { background-color: var(--bg-card); }

.notification-list { max-height: none; }
.notification-item {
    display: flex;
    align-items: stretch;
    gap: 8px;
    border-top: 1px solid var(--border-light);
    background-color: var(--bg-card);
    padding: 0;
}
.notification-item:first-child { border-top: 0; }
.notification-item.is-unread { background-color: rgba(254, 243, 199, 0.45); }

.notification-checkbox {
    margin: 14px 0 0 14px;
    flex-shrink: 0;
}
.notification-link {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    text-decoration: none;
    color: var(--text-primary);
    flex: 1 1 auto;
    min-width: 0;
}
.notification-link:hover { background-color: var(--bg-hover); color: var(--text-primary); }
.notification-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 0.95rem;
}
.notification-icon-info { background-color: var(--info-light); color: var(--info); }
.notification-icon-warning { background-color: var(--warning-light); color: var(--warning); }
.notification-icon-danger { background-color: var(--danger-light); color: var(--danger); }
.notification-content {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.notification-title {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}
.notification-item.is-unread .notification-title { font-weight: 700; }
.notification-message {
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.3;
}
.notification-time {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Sidebar collapsed responses */
.sidebar-nav-link-toggle .ms-auto.small { font-size: .8rem; opacity: .7; }

/* ---------- Segmented control (equal-width pills inside a tray) ---------- */
.segmented {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 4px;
    background-color: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 3px;
    width: 100%;
}
.segmented > a,
.segmented > button,
.segmented > label {
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    border: 0;
    padding: 8px 12px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: 8px;
    text-align: center;
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: background-color 150ms ease, color 150ms ease, box-shadow 150ms ease;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    line-height: 1.2;
    min-height: 36px;
}
.segmented > a:hover,
.segmented > button:hover,
.segmented > label:hover {
    color: var(--text-primary);
}
.segmented > .active,
.segmented > [aria-selected="true"] {
    background-color: var(--bg-card);
    color: var(--text-primary);
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    font-weight: 600;
}
.segmented-brand > .active,
.segmented-brand > [aria-selected="true"] {
    background-color: var(--brand);
    color: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .12);
}
.segmented-brand > .active:hover,
.segmented-brand > [aria-selected="true"]:hover { color: #fff; }

.sort-control { width: 100%; }

/* ---------- Filter scroll (horizontal pill row that overflows on narrow screens) ---------- */
.filter-scroll {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding: 4px 4px 6px;
    margin-left: -4px;
    margin-right: -4px;
}
.filter-scroll::-webkit-scrollbar { display: none; }
.filter-scroll > * {
    flex-shrink: 0;
    white-space: nowrap;
}
.filter-scroll > a,
.filter-scroll > button {
    height: 32px;
    line-height: 30px;
    padding: 0 14px;
    border-radius: 999px;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: var(--text-secondary);
    text-decoration: none;
    transition: background-color 150ms ease, color 150ms ease, border-color 150ms ease;
}
.filter-scroll > a:hover,
.filter-scroll > button:hover { color: var(--text-primary); background-color: var(--bg-hover); }
.filter-scroll > a.active,
.filter-scroll > button.active,
.filter-scroll > a[aria-selected="true"] {
    background-color: var(--brand);
    border-color: var(--brand);
    color: #fff;
}
.filter-scroll > a.active:hover,
.filter-scroll > button.active:hover { color: #fff; background-color: var(--brand-dark); border-color: var(--brand-dark); }

/* ---------- Premium polish ---------- */

/* Subtle elevation on primary actions */
.btn-brand,
.btn-primary,
.btn-success,
.btn-danger,
.btn-warning,
.btn-secondary {
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: filter 150ms ease, transform 100ms ease, box-shadow 150ms ease;
}
.btn-brand:hover, .btn-primary:hover,
.btn-success:hover, .btn-danger:hover,
.btn-warning:hover, .btn-secondary:hover {
    box-shadow: 0 2px 4px rgba(15, 23, 42, .10);
}
.btn-brand:active, .btn-primary:active,
.btn-success:active, .btn-danger:active,
.btn-warning:active, .btn-secondary:active {
    box-shadow: none;
    transform: translateY(1px);
}

/* Card hover (desktop only — mobile uses tap feedback instead) */
@media (hover: hover) {
    .card:hover,
    .store-card:hover,
    .quick-action:hover:not(:disabled) {
        box-shadow: 0 4px 12px rgba(15, 23, 42, .06);
    }
}

/* Tighten heading metrics — avoids the "loose" letter-spacing default */
.page-title { letter-spacing: -0.01em; }

/* ============================================================
   DESKTOP POLISH (>= 768px)
   Mobile-first stays; this section layers on top.
   ============================================================ */

/* --- A. Per-page max-widths (driven by body class) --- */
@media (min-width: 768px) {
    /* Default: keep current 800px focused width */
    .page-default .app-content,
    .page-day .app-content        { max-width: 720px; }
    .page-settings .app-content,
    .page-notifications .app-content,
    .page-registry-form .app-content { max-width: 900px; }
    .page-registry .app-content   { max-width: 1000px; }
    .page-history .app-content    { max-width: 1100px; }
    .page-reports .app-content    { max-width: 1200px; }
    .page-transactions .app-content { max-width: 1200px; }
    .page-dashboard .app-content  { max-width: 1280px; }

    /* More breathing room at the edges on desktop */
    .app-content { padding: 1.75rem 2rem; }
}

/* --- M. Sidebar responsive width --- */
@media (min-width: 768px) and (max-width: 1279px) {
    :root { --sidebar-width: 240px; }
    .app-sidebar { padding: 14px; }
}
@media (min-width: 1280px) {
    :root { --sidebar-width: 260px; }
}

/* --- B. Sidebar refinement --- */
@media (min-width: 768px) {
    .sidebar-brand {
        font-size: 1.2rem;
        padding: 0.5rem 0.5rem 1rem;
        border-bottom: 1px solid var(--border-light);
        margin-bottom: 0.85rem;
    }
    .sidebar-section-label {
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 0.06em;
        text-transform: uppercase;
        color: var(--text-muted);
        padding: 0.85rem 12px 0.35rem;
        margin: 0;
    }
    .sidebar-section-label:first-of-type { padding-top: 0.25rem; }
}

/* --- C. Reconciliation card cap on desktop --- */
@media (min-width: 768px) {
    .page-day .reconciliation-card {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* --- D. Dashboard grid --- */
@media (min-width: 768px) {
    /* Summary tiles: 4 in a row on tablets+ */
    .page-dashboard .row > [class*="col-"] .dashboard-summary {
        height: 100%;
    }
    /* Bootstrap rows already do col-md-3 stuff; reinforce gap */
    .page-dashboard .row { row-gap: 1rem; }
}
@media (min-width: 992px) {
    .page-dashboard .store-list {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
        gap: 16px;
    }
    .page-dashboard .store-list > .store-card { padding: 16px; }
}

/* --- E. Table polish on desktop --- */
@media (min-width: 768px) {
    .table {
        --bs-table-hover-bg: var(--bg-hover);
        font-size: 0.9rem;
    }
    .table thead th {
        background-color: var(--bg-page);
        color: var(--text-secondary);
        font-weight: 600;
        font-size: 0.78rem;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        border-bottom: 1px solid var(--border);
        padding: 12px;
    }
    .table tbody td { padding: 12px; vertical-align: middle; }
    .table tbody tr { transition: background-color 120ms ease; }
    .table tbody tr:hover { background-color: var(--bg-hover); }
    /* Numeric / amount columns align right and use tabular nums */
    .table .num,
    .table .text-end { font-variant-numeric: tabular-nums; }
    /* Sticky header for long data tables */
    .table-sticky thead th {
        position: sticky;
        top: 0;
        z-index: 2;
        box-shadow: inset 0 -1px 0 var(--border);
    }
}

/* --- F. Form layout polish --- */
@media (min-width: 768px) {
    /* Cap input width on settings/profile forms so they don't stretch */
    .page-settings .form-control,
    .page-settings .form-select,
    .page-notifications .form-control,
    .page-notifications .form-select { max-width: 400px; }
    .page-settings textarea.form-control { max-width: 100%; }
    /* Submit buttons sit at fit-content (not full-width) on desktop */
    .form-actions .btn,
    .form-actions-desktop .btn { min-width: 200px; width: auto; }
    /* Card-wrapped forms get more padding */
    form .card-body { padding: 1.5rem; }
    /* Form-row gaps a touch larger */
    form .mb-3 { margin-bottom: 1.25rem !important; }
}

/* --- G. Hover lift across interactive surfaces --- */
@media (hover: hover) and (min-width: 768px) {
    .card:not(.no-hover):hover,
    .store-card:hover,
    .quick-action:hover:not(:disabled),
    .business-list-item:hover {
        transform: translateY(-1px);
        box-shadow: 0 6px 16px rgba(15, 23, 42, .07);
    }
    .sidebar-nav-link { transition: background-color 150ms ease, color 150ms ease, transform 150ms ease; }
    .btn { transition: filter 150ms ease, transform 100ms ease, box-shadow 150ms ease, background-color 150ms ease; }
}

/* --- H. Keyboard shortcut hints (desktop only) --- */
.kbd-hint { display: none; }
@media (min-width: 768px) {
    .kbd-hint {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        position: absolute;
        top: 8px;
        right: 8px;
        min-width: 22px;
        height: 22px;
        padding: 0 6px;
        font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
        font-size: 0.7rem;
        font-weight: 600;
        color: var(--text-muted);
        background-color: var(--bg-hover);
        border: 1px solid var(--border);
        border-radius: 6px;
        line-height: 1;
        pointer-events: none;
    }
    .quick-action { position: relative; }
    .quick-action:hover .kbd-hint { color: var(--text-secondary); border-color: var(--text-muted); }
}

/* --- J. Modal centering & sizing on desktop --- */
@media (min-width: 768px) {
    .modal-dialog:not(.modal-fullscreen):not(.modal-lg):not(.modal-xl) {
        max-width: 600px;
        margin: 1.75rem auto;
    }
    .modal-content {
        border: 0;
        box-shadow: 0 20px 60px rgba(15, 23, 42, .18),
                    0 4px 14px rgba(15, 23, 42, .08);
    }
}

/* --- K. Typography scale-up on desktop --- */
@media (min-width: 768px) {
    body { font-size: 1rem; }
    .page-title { font-size: 1.75rem; }
    .card-title, h5.card-title { font-size: 1.1rem; }
    /* Reconciliation big numbers */
    .reconciliation-value { font-size: 1.6rem !important; }
    .dashboard-summary-value { font-size: 2rem; }
}

/* --- L. Spacing scale-up on desktop --- */
@media (min-width: 768px) {
    .card-body { padding: 1.5rem; }
    .section-stack > * + * { margin-top: 2rem; }
}

/* ============================================================
   PAGE HEADER + FILTER BAR + EMPTY STATE
   Standard layout primitives used by list pages.
   ============================================================ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-header-meta {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}
.page-header-meta .text-muted { font-size: 0.85rem; }
.page-header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}
@media (max-width: 767.98px) {
    /* Default mobile layout: keep title and actions on the same row.
       Title takes the remaining width, actions shrink to fit content. */
    .page-header {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }
    .page-header > .page-title,
    .page-header-meta { flex: 1 1 auto; min-width: 0; }
    .page-header-actions { flex-shrink: 0; width: auto; }
    .page-header-actions .btn { flex: 0 0 auto; width: auto; }

    /* Registry pages keep the previous full-width column-stack layout
       because Import/New are central registry actions, not secondary. */
    .page-registry .page-header,
    .page-registry-form .page-header {
        flex-direction: column;
        align-items: stretch;
    }
    .page-registry .page-header-actions,
    .page-registry-form .page-header-actions { width: 100%; }
    .page-registry .page-header-actions .btn,
    .page-registry-form .page-header-actions .btn { flex: 1 1 0; min-width: 0; }
}

/* Segmented control wrapper that caps width on desktop.
   !important guards against any future selector that competes
   with this width — the wrapper is meant to be a hard cap. */
.segmented-wrapper {
    max-width: 400px !important;
    margin-bottom: 1rem;
}
.segmented-wrapper > .segmented { width: 100%; }
@media (max-width: 767.98px) {
    .segmented-wrapper { max-width: none !important; }
}

/* Filter bar — grid on desktop, stacked on mobile */
.filter-bar {
    display: grid;
    grid-template-columns: 1fr 240px auto;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    align-items: center;
}
.filter-bar--two { grid-template-columns: 1fr auto; }
@media (max-width: 767.98px) {
    .filter-bar,
    .filter-bar--two { grid-template-columns: 1fr; }
}
.filter-bar .form-control,
.filter-bar .form-select,
.filter-bar .btn { min-height: 44px; }
.filter-bar-search {
    position: relative;
}
.filter-bar-search > .bi-search {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
    font-size: 0.95rem;
}
.filter-bar-search .form-control {
    padding-left: 36px;
    height: 44px;
}
.filter-bar-search .form-control:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}

/* Empty state card constrained on desktop */
.empty-state {
    text-align: center;
    padding: 2rem 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background-color: var(--bg-card);
}
@media (min-width: 768px) {
    .empty-state {
        max-width: 480px;
        margin: 3rem auto;
        padding: 2.5rem 2rem;
    }
}
.empty-state .empty-state-icon {
    font-size: 2.5rem;
    color: var(--text-muted);
    display: block;
    margin-bottom: 0.5rem;
}
.empty-state .empty-state-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    flex-wrap: wrap;
    margin-top: 1rem;
}

/* ============================================================
   .btn-excel — premium Excel button (Microsoft Excel green family)
   ============================================================ */
.btn-excel {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.875rem;
    text-decoration: none;
    border: 1px solid #1f7244;
    background: #ffffff;
    color: #1f7244;
    transition: background-color 150ms ease, color 150ms ease,
                border-color 150ms ease, box-shadow 150ms ease,
                transform 100ms ease;
    cursor: pointer;
    min-height: 40px;
    box-shadow: 0 1px 2px rgba(31, 114, 68, 0.06);
}
.btn-excel:hover,
.btn-excel:focus {
    background: #1f7244;
    color: #ffffff;
    border-color: #1f7244;
    box-shadow: 0 4px 10px rgba(31, 114, 68, 0.18);
    transform: translateY(-1px);
}
.btn-excel:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(31, 114, 68, 0.10);
}
.btn-excel i { font-size: 1.05rem; line-height: 1; }
.btn-excel.is-loading { pointer-events: none; opacity: 0.7; }
.btn-excel.is-loading i { animation: btn-excel-spin 1s linear infinite; }
@keyframes btn-excel-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Solid variant — primary export emphasis */
.btn-excel-solid {
    background: #1f7244;
    color: #ffffff;
    border-color: #1f7244;
}
.btn-excel-solid:hover,
.btn-excel-solid:focus {
    background: #185a36;
    border-color: #185a36;
    color: #ffffff;
}

/* Label visibility — full text on desktop; icon-only on mobile to keep
   Excel export from looking like the page's primary action. The registry
   pages (page-registry / page-registry-form) keep the label because
   Import is a primary workflow action there. */
.btn-excel-label { display: inline; }
@media (max-width: 767.98px) {
    .btn-excel .btn-excel-label { display: none; }
    .btn-excel { padding: 8px 12px; gap: 0; }  /* tighten icon-only button */
    .page-registry .btn-excel .btn-excel-label,
    .page-registry-form .btn-excel .btn-excel-label { display: inline; }
    .page-registry .btn-excel,
    .page-registry-form .btn-excel { padding: 8px 16px; gap: 8px; }
}

/* ============================================================
   Unified Transactions list (/transactions/)
   ============================================================ */
.tx-totals { background-color: var(--bg-card); }
.tx-totals .vr { color: var(--border); }

.tx-filters .tx-filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.5rem;
}
.tx-filter-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
    color: var(--text-muted);
}
.tx-pill-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    padding: 1px 7px;
    margin-left: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--text-secondary);
    background-color: var(--bg-hover);
    border-radius: 999px;
    line-height: 1.5;
}
.filter-scroll > a.active .tx-pill-count {
    background-color: rgba(255, 255, 255, .25);
    color: #fff;
}

/* Sticky date headers */
.tx-day-group { margin-bottom: 1.25rem; }
.tx-day-header {
    position: sticky;
    top: var(--topbar-height);
    background: var(--bg-page);
    margin: 0;
    padding: 8px 0;
    z-index: 5;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: capitalize;
    border-bottom: 1px solid var(--border-light);
}
@media (min-width: 768px) {
    .tx-day-header { top: 0; padding: 12px 0; font-size: 0.95rem; }
}

.tx-day-items {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-top: 6px;
}

.tx-item {
    display: flex;
    align-items: stretch;
    gap: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    color: inherit;
    text-decoration: none;
    transition: background-color 120ms ease, transform 100ms ease, box-shadow 120ms ease;
}
.tx-item:hover {
    background-color: var(--bg-hover);
    color: inherit;
}
.tx-item-icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}
.tx-item-income .tx-item-icon { background-color: var(--success-light); color: var(--success); }
.tx-item-expense .tx-item-icon { background-color: var(--danger-light); color: var(--danger); }
.tx-item-payroll .tx-item-icon { background-color: var(--info-light); color: var(--info); }
.tx-item-z_report .tx-item-icon { background-color: var(--bg-hover); color: var(--text-secondary); }
.tx-item-pending { border-left: 3px solid var(--warning); }

.tx-item-body { flex: 1 1 auto; min-width: 0; }
.tx-item-row1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
}
.tx-item-name {
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.tx-item-amount { font-variant-numeric: tabular-nums; font-weight: 600; }
.tx-item-row2 {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    margin-top: 2px;
}
.tx-item-business {
    color: var(--text-muted);
    margin-left: auto;
}

/* ============================================================
   Logo fixes — preserve aspect ratio, white-bg fallback for
   branded logos (HankyPanky etc.)
   ============================================================ */
.business-list-logo,
.sidebar-business-logo {
    object-fit: contain;
    background-color: #ffffff;
}
.business-list-logo-fallback,
.sidebar-business-logo-fallback {
    /* Fallback chips intentionally fill with brand color */
    background-color: inherit;
}

/* ============================================================
   Day stats card — small "today vs last 7 days" comparison
   shown between the reconciliation card and the quick actions.
   Three chips wrap on narrow viewports.
   ============================================================ */
.day-stats-card .card-body {
    padding: 0.75rem 1rem;
}
.day-stats-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}
.day-stats-item {
    flex: 1 1 0;
    min-width: 9rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    background-color: var(--bg-hover);
}
.day-stats-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-muted);
}
.day-stats-value {
    font-variant-numeric: tabular-nums;
    font-weight: 700;
    font-size: 1rem;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.day-stats-value i {
    font-size: 1.05rem;
}
.day-stats-hint {
    font-size: 0.7rem;
    color: var(--text-muted);
}
.day-stats-item.positive .day-stats-value { color: var(--success); }
.day-stats-item.negative .day-stats-value { color: var(--danger); }

/* ============================================================
   DASHBOARD HIGHLIGHTS — top "Top 3" card surfaced above the
   summary row. Three coloured tiles inside one soft card.
   ============================================================ */
.highlights-card {
    background-color: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 12px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.highlights-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 768px) {
    .highlights-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}
.highlight-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid var(--border);
    background-color: var(--bg-card);
    color: inherit;
    text-decoration: none;
    transition: background-color 120ms ease, transform 100ms ease, box-shadow 120ms ease;
}
.highlight-item:hover {
    background-color: var(--bg-hover);
    color: inherit;
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.06);
}
.highlight-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.05rem;
}
.highlight-best .highlight-icon {
    background-color: rgba(255, 193, 7, 0.18);
    color: var(--warning);
}
.highlight-expense .highlight-icon {
    background-color: rgba(220, 53, 69, 0.14);
    color: var(--danger);
}
.highlight-variance .highlight-icon {
    background-color: rgba(13, 110, 253, 0.14);
    color: var(--brand);
}
.highlight-body {
    display: flex;
    flex-direction: column;
    min-width: 0;
    flex: 1 1 auto;
}
.highlight-label {
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.highlight-value {
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.highlight-amount {
    font-variant-numeric: tabular-nums;
    font-weight: 600;
    margin-top: 2px;
}

/* ============================================================
   AUDIT SPRINT 2 — RESPONSIVE FIXES
   Each fix is scoped tightly via specific selectors so it only
   overrides the offending rule. No existing rules are edited.
   ============================================================ */

/* --- 1. Notifications offcanvas overflows at 320px ---
   Was: --bs-offcanvas-width: 360px (fixed). On a 320px viewport
   the offcanvas body is wider than the screen, forcing horizontal
   scroll inside the offcanvas and pushing close button off-screen.
   Fix: cap to 100vw on narrow phones; keep 360px from 380px+. */
@media (max-width: 379.98px) {
    .notifications-offcanvas {
        --bs-offcanvas-width: 100vw;
    }
}

/* --- 2. iPhone notch / dynamic-island safe-area on topbar ---
   Was: .app-topbar has position: fixed; top: 0 with no safe-area
   padding, and .app-shell padding-top is just var(--topbar-height).
   On notched iPhones in portrait, the topbar's brand text and
   avatar can sit under the dynamic island.
   Fix: extend topbar height with safe-area-inset-top via padding,
   and bump app-shell padding-top by the same inset. */
.app-topbar {
    padding-top: calc(12px + env(safe-area-inset-top, 0px));
    height: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}
.app-shell {
    padding-top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}
@media (min-width: 768px) {
    /* Desktop has no topbar — restore zero padding-top regardless of inset. */
    .app-shell { padding-top: 0; }
}
/* Sticky tx-day-header lives at top: var(--topbar-height) on mobile —
   add the same safe-area inset so it doesn't slide under an inset topbar. */
.tx-day-header {
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}
@media (min-width: 768px) {
    .tx-day-header { top: 0; }  /* desktop unchanged */
}
/* Offline banner sits below topbar; same correction. */
.offline-banner {
    top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
}
@media (min-width: 768px) {
    .offline-banner { top: 0; }  /* desktop pinned to viewport top */
}

/* --- 3. .report-filter-bar sticky hides behind fixed topbar on mobile ---
   Was: position: sticky; top: 0. The fixed topbar (56px) sits on
   top of it, so the filter bar is invisible while scrolling on
   mobile. Desktop is unaffected because the same rule already
   switches to position: static at >= 768px.
   Fix: offset sticky top by topbar height + safe-area inset. */
@media (max-width: 767.98px) {
    .report-filter-bar {
        top: calc(var(--topbar-height) + env(safe-area-inset-top, 0px));
    }
}

/* --- 4. Sticky-hover on touch devices for nav / list items ---
   Was: .bottom-nav-item:hover, .transaction-item:hover,
   .tx-item:hover, .business-list-item:hover etc. apply a
   background change on :hover. On touch devices, :hover sticks
   after a tap until the next tap elsewhere, so the previously
   tapped row looks "selected" until the user taps somewhere new.
   Fix: only paint hover on devices that actually have hover.
   Restated as more-specific rules so we don't edit the originals. */
@media (hover: none) {
    .bottom-nav-item:hover { color: var(--text-muted); }
    .transaction-item:hover { background-color: var(--bg-card); }
    .tx-item:hover { background-color: var(--bg-card); }
    .business-list-item:hover { background-color: transparent; }
    .notification-link:hover { background-color: var(--bg-card); }
    .btn-icon:hover { background-color: var(--bg-card); color: var(--text-secondary); }
    .btn-pill:hover { background-color: var(--bg-card); color: var(--text-secondary); }
    .transaction-btn:hover { background-color: transparent; color: var(--text-secondary); }
    .sidebar-business:hover { background-color: var(--bg-card); }
    .sidebar-nav-link:hover { background-color: transparent; color: var(--text-secondary); }
    .sidebar-nav-link.active:hover {
        background-color: var(--brand-light);
        color: var(--brand);
    }
    .payment-pill:hover {
        background-color: var(--bg-hover);
        color: var(--text-secondary);
    }
    .filter-scroll > a:hover,
    .filter-scroll > button:hover {
        background-color: var(--bg-card);
        color: var(--text-secondary);
    }
}

/* --- 5. Dashboard summary values overflow at 320px ---
   Was: .dashboard-summary-value is 1.8rem (~28.8px). When the
   summary tiles render in a Bootstrap col-6 grid on phones, each
   tile is ~144px wide minus 1.25rem padding each side = ~104px.
   Greek-format figures like "12.345,67 €" overflow at that size.
   Fix: clamp the font-size on viewports < 380px so it scales down
   gracefully. Tablet/desktop sizes (set elsewhere) untouched. */
@media (max-width: 379.98px) {
    .dashboard-summary-value {
        font-size: 1.4rem;
    }
    .dashboard-summary {
        padding: 1rem;
    }
}

/* --- 6. iOS 100vh trap on .app-shell and .auth-shell ---
   Was: min-height: 100vh. iOS Safari counts the URL bar as part
   of 100vh, then collapses the bar on scroll, leaving a gap or
   forcing layout jumps. dvh (dynamic viewport height) accounts
   for this. Use @supports so older browsers keep the 100vh
   fallback they already have. */
@supports (min-height: 100dvh) {
    .app-shell { min-height: 100dvh; }
    .auth-shell { min-height: 100dvh; }
}

/* --- 7. Bottom-nav-item label overflow on small phones ---
   Was: .bottom-nav-item font-size 0.65rem with 5 nav items at
   320px = ~64px per item. Long labels like "Transactions" can
   exceed that and either wrap (breaking the 64px height) or
   clip awkwardly. Fix: clamp single-line + ellipsis on the label
   span (the icon stays full size). */
.bottom-nav-item {
    overflow: hidden;
}
.bottom-nav-item > span,
.bottom-nav-item > .bottom-nav-label {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

/* ============================================================
   MODAL POLISH SPRINT
   ============================================================ */

/* --- FIX 1: hide native number-input spinner arrows --- */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }

/* --- FIX 2: rounded modal corners + premium shadow --- */
.modal-content {
    border-radius: 20px;
    border: 0;
    overflow: hidden;
    box-shadow:
        0 24px 60px rgba(15, 23, 42, .14),
        0 6px 16px rgba(15, 23, 42, .06);
}
/* Bottom-sheet mobile look only kicks in where Bootstrap's
   modal-fullscreen-sm-down actually activates (≤575.98px). Between
   576px and 767px the modal stays centered and keeps the desktop radius. */
@media (max-width: 575.98px) {
    .modal-fullscreen-sm-down .modal-content {
        border-radius: 20px 20px 0 0;
        box-shadow: none;
    }
}
.modal-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 20px;
}
.modal-footer {
    border-top: 1px solid var(--border);
    padding: 16px 20px;
}

/* --- Mobile scroll fix: entry modals wrap header/body/footer in a <form>,
   which breaks Bootstrap's flex-column chain on .modal-content. Make the
   form inherit the chain so .modal-body can scroll inside .modal-dialog-
   scrollable instead of overflowing the viewport. --- */
.modal-content > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    max-height: 100%;
    overflow: hidden;
}
.modal-content > form > .modal-body {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1 1 auto;
    min-height: 0;
}

/* --- FIX 5: modal padding & spacing + sticky-on-mobile footer --- */
.modal-body { padding: 20px; }
.modal-body .form-group,
.modal-body .mb-3 { margin-bottom: 1.25rem; }
.modal-body label.form-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
@media (max-width: 767.98px) {
    /* Save button always reachable on mobile */
    .modal-fullscreen-sm-down .modal-footer {
        position: sticky;
        bottom: 0;
        background: var(--bg-card);
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.04);
        z-index: 5;
    }
}

/* --- FIX 3: custom file picker --- */
.custom-file-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.custom-file-label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border: 1.5px dashed var(--border);
    border-radius: 10px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease,
                color 150ms ease;
    width: fit-content;
    margin: 0;
}
.custom-file-label:hover {
    border-color: var(--brand);
    color: var(--brand);
    background: var(--brand-light);
}
.custom-file-label .bi { font-size: 1.1rem; }
.custom-file-label.has-file {
    border-style: solid;
    border-color: var(--success);
    color: var(--success);
    background: rgba(5, 150, 105, 0.05);
}
.custom-file-preview {
    display: none;
    position: relative;
    width: fit-content;
}
.custom-file-preview img {
    max-width: 120px;
    max-height: 120px;
    border-radius: 8px;
    border: 1px solid var(--border);
    object-fit: cover;
    display: block;
}
.custom-file-preview .file-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger);
    color: #fff;
    border: 0;
    display: grid;
    place-items: center;
    cursor: pointer;
    line-height: 1;
}

/* --- FIX 4: custom searchable select --- */
.custom-select {
    position: relative;
    width: 100%;
}
.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
    cursor: pointer;
    text-align: left;
    min-height: 44px;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.custom-select-trigger:hover { border-color: var(--brand); }
.custom-select-trigger.is-open {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px var(--brand-light);
}
.custom-select-trigger .bi-chevron-down {
    transition: transform 150ms ease;
    color: var(--text-muted);
    flex-shrink: 0;
}
.custom-select-trigger.is-open .bi-chevron-down { transform: rotate(180deg); }
.custom-select-value {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.custom-select-value.is-placeholder { color: var(--text-muted); }
.custom-select-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(15, 23, 42, 0.10);
    max-height: 280px;
    display: flex;
    flex-direction: column;
    z-index: 1060;
}
.custom-select-search {
    width: 100%;
    border: 0;
    border-bottom: 1px solid var(--border);
    padding: 12px 14px;
    font-size: 0.9rem;
    outline: none;
    border-radius: 10px 10px 0 0;
    background: var(--bg-card);
}
.custom-select-options {
    list-style: none;
    margin: 0;
    padding: 4px;
    overflow-y: auto;
    flex: 1 1 auto;
}
.custom-select-options li {
    padding: 10px 12px;
    font-size: 0.9rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 100ms ease, color 100ms ease;
}
.custom-select-options li:hover,
.custom-select-options li.is-active {
    background: var(--brand-light);
    color: var(--brand);
}
.custom-select-options li.is-selected {
    background: var(--brand);
    color: #fff;
}
.custom-select-options li.is-hidden { display: none; }
.custom-select-empty {
    padding: 12px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}
/* Hide the underlying native select that the custom UI mirrors. */
.custom-select-native { display: none !important; }

