:root {
    --app-blue: #2f6bff;
    --app-blue-dark: #1d54e0;
    --app-bg: #eef2fb;
    --app-ink: #1c2536;
    --app-muted: #8891a5;
    --app-border: #e6e9f2;
}

body {
    background-color: var(--app-bg);
    color: var(--app-ink);
}

/* Printing a page that embeds print.css content (e.g. Print All) should
   only output the print content itself, not the app chrome around it. */
@media print {
    .app-topbar,
    .sidebar,
    .app-bottom-nav {
        display: none !important;
    }

    .app-main {
        padding: 0 !important;
        margin: 0 !important;
        width: 100% !important;
    }
}

/* Global button system — solid pill-rounded blue primary, ghost outlines otherwise */
.btn {
    border-radius: 0.6rem;
    font-weight: 600;
    padding: 0.4rem 0.85rem;
    font-size: 0.9rem;
}

.btn-sm {
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 0.5rem;
}

.btn-lg {
    padding: 0.55rem 1.2rem;
    font-size: 1rem;
}

.btn-primary,
.btn-success {
    background: var(--app-blue);
    border-color: var(--app-blue);
    box-shadow: 0 6px 14px rgba(47, 107, 255, 0.28);
}

.btn-primary:hover,
.btn-primary:active,
.btn-success:hover,
.btn-success:active {
    background: var(--app-blue-dark);
    border-color: var(--app-blue-dark);
}

.btn-outline-primary,
.btn-outline-secondary {
    border-color: var(--app-border);
    color: var(--app-blue);
}

.btn-outline-light {
    border-radius: 0.7rem;
}

/* Global card system — soft, borderless, floating panels */
.card {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 4px 16px rgba(28, 37, 54, 0.06);
}

.card-title {
    color: var(--app-ink);
    font-weight: 700;
}

/* Global form controls — rounded, low-contrast borders */
.form-control,
.form-select,
.input-group-text {
    border-radius: 0.6rem;
    border-color: var(--app-border);
    padding: 0.4rem 0.65rem;
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--app-blue);
    box-shadow: 0 0 0 0.2rem rgba(47, 107, 255, 0.15);
}

.form-label {
    color: var(--app-muted);
    font-weight: 600;
    font-size: 0.85rem;
}

.input-group .form-control,
.input-group .input-group-text {
    border-radius: 0.85rem;
}

.input-group > .form-control:not(:last-child),
.input-group > .input-group-text:not(:last-child) {
    border-top-right-radius: 0;
    border-bottom-right-radius: 0;
}

.input-group > .form-control:not(:first-child),
.input-group > .input-group-text:not(:first-child) {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
}

.table {
    color: var(--app-ink);
}

/* App-style topbar: light, with a back-style brand mark instead of a dark bar */
.app-topbar {
    background: #fff !important;
    box-shadow: 0 2px 10px rgba(28, 37, 54, 0.06);
    padding: 0.75rem 0;
}

.app-topbar .navbar-brand {
    color: var(--app-ink) !important;
    font-weight: 700;
}

.app-topbar .btn-outline-light {
    color: var(--app-blue);
    border-color: var(--app-border);
}

.app-topbar .btn-outline-light:hover {
    background: var(--app-blue);
    border-color: var(--app-blue);
    color: #fff;
}

.app-topbar span.text-light,
.app-topbar .text-light {
    color: var(--app-muted) !important;
}

.sidebar {
    background: #fff !important;
}

.sidebar .nav-link {
    color: var(--app-muted);
    border-radius: 0.75rem;
    margin-bottom: 0.15rem;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
    color: var(--app-blue);
    background: rgba(47, 107, 255, 0.08);
    font-weight: 600;
}

/* App-like bottom tab bar, shown only below the md breakpoint */
.app-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--app-border);
    box-shadow: 0 -4px 14px rgba(28, 37, 54, 0.06);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

.app-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 8px 2px;
    font-size: 0.7rem;
    color: var(--app-muted);
    text-decoration: none;
}

.app-bottom-nav-item i {
    font-size: 1.25rem;
}

.app-bottom-nav-item.active {
    color: var(--app-blue);
    font-weight: 600;
}

/* Leave room for the fixed bottom nav so content isn't hidden behind it */
@media (max-width: 767.98px) {
    .app-main {
        padding-bottom: 5rem !important;
    }

    .app-topbar {
        position: sticky;
        top: 0;
        z-index: 1031;
    }

    .card {
        border-radius: 0.9rem;
    }

    .table-responsive {
        font-size: 0.9rem;
    }
}

/* Standalone/installed PWA: hide the browser-style top bar's back-nav clutter feel */
@media all and (display-mode: standalone) {
    body {
        overscroll-behavior-y: contain;
    }
}

/* Mobile stacked label cards (user/labels) */
.label-card-list {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.label-item-card {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border: 1px solid #e9ecef;
    border-radius: 0.6rem;
    padding: 0.65rem 0.75rem;
    background: #fff;
}

.label-item-card-main {
    flex: 1 1 auto;
    min-width: 0;
}

.label-item-card-name {
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.label-item-card-number {
    font-size: 0.85rem;
    color: #6c757d;
}

.label-item-card-money {
    font-weight: 700;
    white-space: nowrap;
}

.label-item-card-actions {
    display: flex;
    gap: 0.35rem;
    width: 100%;
    justify-content: flex-end;
}

/* Name-grouped label list (user/labels) */
.name-group-header {
    padding: 0.3rem 0.15rem;
    margin-bottom: 0.35rem;
}

.name-group-title {
    font-weight: 700;
    color: var(--app-ink, #1c2536);
}

.name-group-subtotal {
    font-size: 0.85rem;
    color: var(--app-muted, #8891a5);
}

.name-group-subtotal strong {
    color: var(--app-ink, #1c2536);
}

.name-group-arrow {
    color: var(--app-muted, #8891a5);
    margin: 0 0.15rem;
}

.name-group-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.name-group-actions form {
    margin: 0;
}

.name-group-detail {
    margin-top: 0.4rem;
}

/* Add Labels collapsible panel (user/labels) */
#add-panel {
    margin-bottom: 1rem;
}

.add-panel-summary {
    list-style: none;
    cursor: pointer;
    background: #fff;
    border-radius: 0.7rem;
    padding: 0.6rem 0.85rem;
    font-weight: 600;
    color: var(--app-blue, #2f6bff);
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    margin-bottom: 0.5rem;
}

.add-panel-summary::-webkit-details-marker {
    display: none;
}

/* Bulk add labels — app-style floating panels (user/labels) */
.bulk-label-form {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 480px;
    margin: 0 auto 1rem;
}

.bulk-panel {
    background: #fff;
    border-radius: 0.7rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
    padding: 0.5rem 0.65rem;
}

.bulk-panel-name {
    padding: 0.4rem 0.65rem;
}

.bulk-panel-category-select {
    padding: 0.4rem 0.65rem;
}

.name-group-category {
    margin-right: 0.35rem;
}

/* Add More stays in the DOM (auto-add-on-type still works) but isn't shown */
#add-row-btn {
    display: none;
}

.bulk-name-input {
    width: 100%;
    border: none;
    outline: none;
    font-size: 0.9rem;
    color: #495057;
    background: transparent;
}

.bulk-name-input::placeholder {
    color: #adb5bd;
}

.bulk-rows-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 0.3rem;
    table-layout: fixed;
}

.bulk-rows-table thead th {
    text-align: left;
    padding: 0 0.3rem 0.15rem;
    color: #6c757d;
    font-weight: 600;
    font-size: 0.75rem;
}

.bulk-rows-table .bulk-col-number { width: 42%; }
.bulk-rows-table .bulk-col-money { width: 42%; }
.bulk-rows-table .bulk-col-remove { width: 16%; }

.bulk-rows-table tbody td {
    padding: 0 0.4rem;
    vertical-align: middle;
}

.bulk-rows-table .bulk-col-remove {
    text-align: center;
}

.bulk-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e3e7ee;
    border-radius: 0.7rem;
    padding: 0.4rem 0.55rem;
    font-size: 0.9rem;
    color: #212529;
    background: #fff;
    outline: none;
    transition: border-color 0.15s ease;
}

.bulk-input:focus {
    border-color: var(--app-blue);
}

.bulk-input::placeholder {
    color: #adb5bd;
}

.bulk-money-group {
    display: flex;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    border: 1.5px solid #e3e7ee;
    border-radius: 0.7rem;
    padding: 0 0.5rem;
    transition: border-color 0.15s ease;
}

.bulk-money-group:focus-within {
    border-color: var(--app-blue);
}

.bulk-money-symbol {
    color: #6c757d;
    font-weight: 600;
    font-size: 0.9rem;
    padding-right: 0.25rem;
}

.bulk-money-group .bulk-input {
    border: none;
    padding: 0.4rem 0.2rem;
}

.remove-row-btn,
.save-row-btn {
    width: 28px;
    height: 28px;
    flex: 0 0 28px;
    border-radius: 50%;
    font-size: 1rem;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    text-decoration: none;
}

.remove-row-btn {
    border: 1.5px solid #f1aeb5;
    background: #fff5f5;
    color: #dc3545;
}

.save-row-btn {
    border: 1.5px solid #b7e0c5;
    background: #f2fbf5;
    color: #1d9a4b;
    margin-right: 0.3rem;
}

.remove-row-btn:disabled {
    opacity: 0.35;
}

.bulk-add-btn {
    width: 100%;
    background: #fff;
    border: 1.5px dashed #c7d2fe;
    color: var(--app-blue);
    font-weight: 600;
    font-size: 0.9rem;
    border-radius: 0.7rem;
    padding: 0.45rem;
    box-shadow: 0 2px 10px rgba(15, 23, 42, 0.05);
}

.bulk-add-btn:active {
    background: #f4f7ff;
}

.bulk-total-bar {
    padding: 0.55rem 0.85rem;
}

.bulk-total-label {
    color: #495057;
    line-height: 1.2;
    font-size: 0.85rem;
}

.bulk-total-label strong {
    font-size: 1rem;
    color: #212529;
}

.bulk-submit-btn {
    background: var(--app-blue);
    color: #fff;
    border: none;
    border-radius: 0.6rem;
    padding: 0.45rem 1.5rem;
    font-size: 0.95rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(47, 107, 255, 0.3);
}

.bulk-submit-btn:active {
    background: var(--app-blue-dark);
}

@media (max-width: 767.98px) {
    .bulk-panel {
        border-radius: 0.9rem;
    }

    .bulk-rows-table thead th {
        font-size: 0.7rem;
    }

    .bulk-add-btn {
        min-height: 36px;
    }

    .bulk-total-bar {
        position: sticky;
        bottom: calc(4.25rem + env(safe-area-inset-bottom, 0));
        z-index: 5;
    }

    .bulk-submit-btn {
        min-height: 36px;
    }
}

/* Scrollable pill tabs on user/history (avoids wrapping on narrow screens) */
.history-tabs {
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
}

.history-tabs .nav-link {
    color: #333;
}

/* Mobile stacked history cards (user/history) */
.history-card {
    border: 1px solid #e9ecef;
    border-radius: 0.6rem;
    padding: 0.75rem;
    background: #fff;
    margin-bottom: 0.6rem;
}

.history-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.4rem;
}

.history-card-request-no {
    font-weight: 600;
}

.history-card-body {
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.3rem 0.75rem;
    font-size: 0.9rem;
    color: #495057;
}

.history-card-amount {
    font-weight: 700;
    color: #212529;
}
