/* ==========================================================================
   ZAI theme ("Workbench": square, dense, bordered back-office look)
   Loaded after every other stylesheet (see view/common/meta*.html).
   Pure presentation overrides: no markup or JS depends on this file, so
   removing the <link> restores the previous look.
   Token names keep the --md- prefix from the earlier Material version;
   the Workbench-specific rules are in the block at the end of the file.
   ========================================================================== */

:root {
    --md-primary: #1c4fa8;
    --md-primary-dark: #163f86;
    --md-primary-hover: #17428c;
    --md-primary-container: #e6edf8;
    --md-on-primary: #ffffff;

    --md-appbar: #1c2b4a;                       /* navy */
    --md-appbar-hover: rgba(255, 255, 255, .12);
    --md-appbar-tint: #e8edf6;                  /* hovered dropdown item, same hue as the bar */

    --md-success: #1b6b35;
    --md-success-container: #e3f1e7;
    --md-danger: #b3261e;
    --md-danger-container: #f8e3e1;
    --md-warning: #e0a100;
    --md-warning-container: #f6ead2;
    --md-info: #0f7c8a;
    --md-info-container: #e0f0f2;

    --md-background: #e9ecef;
    --md-surface: #ffffff;
    --md-surface-variant: #eef1f4;   /* panel / table headers */
    --md-outline: #cfd5db;
    --md-outline-strong: #b9c1c9;
    --md-on-surface: #161a1d;
    --md-on-surface-variant: #5c6670;

    --md-radius-sm: 2px;
    --md-radius: 2px;
    --md-radius-pill: 2px;

    /* flat: surfaces are separated by borders, only floating layers get a shadow */
    --md-elev-1: none;
    --md-elev-2: none;
    --md-elev-3: 0 6px 18px rgba(22, 26, 29, .18);

    --md-font: 'IBM Plex Sans', 'Segoe UI', Arial, 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --md-mono: 'IBM Plex Mono', Consolas, monospace;
}

/* ---------- Base ---------- */
html, body {
    background: var(--md-background);
}
body {
    font-family: var(--md-font);
    font-size: 14px;
    color: var(--md-on-surface);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
h1, h2, h3, h4, h5, h6 {
    font-family: var(--md-font);
    font-weight: 500;
    color: var(--md-on-surface);
}
a {
    color: var(--md-primary);
}
a:hover {
    color: var(--md-primary-dark);
}
/* Solid selection so it stays visible on light-blue hover/active/selected backgrounds */
::selection {
    background: var(--md-primary);
    color: #fff;
}
::-moz-selection {
    background: var(--md-primary);
    color: #fff;
}
/* On the primary app bar and primary buttons, invert so the selection is still visible */
nav.navbar ::selection,
.btn-primary::selection,
.btn-primary ::selection {
    background: #fff;
    color: var(--md-primary-dark);
}
main {
    padding-bottom: 24px;
}
/* The footer is empty in every layout: hide the old dark bar */
footer.footer,
footer.footer .copyright {
    background: transparent;
    margin: 0;
}
footer.footer .copyright:empty {
    display: none;
}

/* ---------- Top app bar ---------- */
nav.navbar.fixed-top {
    background: var(--md-appbar) !important;
    min-height: 64px;
    padding: 6px 16px;
    box-shadow: var(--md-elev-2);
}
nav.navbar.fixed-top > a > img {
    border-radius: 10px;
    background: #fff;
    padding: 2px;
    height: 44px !important;
    width: 44px !important;
    object-fit: contain;
    margin-right: 12px;
}
nav.navbar .navbar-nav {
    font-size: 14px;
    align-items: center;
}
nav.navbar.navbar-dark .navbar-nav .nav-link {
    color: rgba(255, 255, 255, .86);
    font-weight: 500;
    letter-spacing: .01em;
    padding: 8px 14px;
    margin: 0 2px;
    border-radius: 0;
    transition: background-color .15s ease, color .15s ease;
}
nav.navbar.navbar-dark .navbar-nav .nav-link:hover,
nav.navbar.navbar-dark .navbar-nav .nav-link:focus {
    color: #fff;
    background: var(--md-appbar-hover);
}
nav.navbar.navbar-dark .navbar-nav .nav-link.md-active {
    color: #fff;
    background: rgba(255, 255, 255, .2);
}
/* Manage (admin) menu group: visually separated from the user menu */
#navbar-collapse-right .navbar-nav {
    padding-left: 12px;
    border-left: 1px solid rgba(255, 255, 255, .22);
}
#navbar-collapse-right .navbar-nav::before {
    content: 'MANAGE';
    color: rgba(255, 255, 255, .6);
    font-size: 11px;
    font-weight: 500;
    letter-spacing: .1em;
    margin-right: 6px;
}
nav.navbar .navbar-toggler {
    border: none;
    color: rgba(255, 255, 255, .86);
    font-size: 13px;
    font-weight: 500;
}
nav.navbar .navbar-toggler:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, .4);
}
/* Notification bell in the app bar */
nav.navbar .nav-link.text-danger {
    color: #ffb4ab !important;
}

/* Dropdown menus (menu markup uses .bg-dark / .text-light) */
nav.navbar .dropdown-menu,
.dropdown-menu {
    background: var(--md-surface) !important;
    border: none;
    border-radius: 0;
    box-shadow: var(--md-elev-3);
    padding: 8px 0;
    min-width: 200px;
}
nav.navbar .dropdown-menu .dropdown-item,
.dropdown-menu .dropdown-item {
    color: var(--md-on-surface) !important;
    font-size: 14px;
    padding: 10px 20px;
}
.dropdown-menu .dropdown-item:hover,
.dropdown-menu .dropdown-item:focus {
    background: var(--md-surface-variant);
    color: var(--md-on-surface) !important;
}

/* App-bar dropdowns: the open parent becomes a white tab and the menu hangs
   directly from it, so parent and children read as one piece */
nav.navbar.navbar-dark .navbar-nav .dropdown:hover > .nav-link,
nav.navbar.navbar-dark .navbar-nav .dropdown.show > .nav-link {
    background: var(--md-surface);
    color: var(--md-appbar);
}
nav.navbar .navbar-nav .dropdown > .dropdown-menu {
    left: 2px;               /* line up with the tab (nav-link has 2px side margin) */
    margin-top: 0;
    top: 100%;
    padding: 4px 0 8px;
    box-shadow: 0 8px 16px rgba(0, 0, 0, .18);
    clip-path: inset(0 -20px -20px -20px); /* no shadow on top, so the tab joins seamlessly */
}
nav.navbar .navbar-nav .dropdown > .dropdown-menu .dropdown-item:hover,
nav.navbar .navbar-nav .dropdown > .dropdown-menu .dropdown-item:focus {
    background: var(--md-appbar-tint);
    color: var(--md-appbar) !important;
}

/* Subscription balance pill (defined in menu.html) on the colored app bar */
.subscription-balance {
    border-radius: var(--md-radius-sm);
    border-color: rgba(255, 255, 255, .25);
    background: rgba(255, 255, 255, .1);
}
.subscription-balance.is-positive {
    background: rgba(255, 255, 255, .12);
    border-color: rgba(129, 201, 149, .7);
}
.subscription-balance.is-positive .subscription-balance-icon,
.subscription-balance.is-positive .subscription-balance-value {
    color: #a8dab5;
}

/* ---------- Surfaces: cards, panels, sidenav ---------- */
.card,
.panel,
.sidenav,
.info-box {
    background: var(--md-surface);
    border: none;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
}
.card {
    margin-bottom: 16px;
    overflow: hidden;
}
.card-header {
    background: var(--md-surface);
    border-bottom: 1px solid var(--md-outline);
    font-size: 16px;
    font-weight: 500;
    padding: 16px 20px;
}
.card-body {
    padding: 20px;
}
.card-footer {
    background: var(--md-surface);
    border-top: 1px solid var(--md-outline);
}
.panel-default {
    border: none;
}
.panel-body {
    background: transparent;
}
/* The profile page nests cards inside a panel: flatten the outer one */
.panel.panel-default {
    background: transparent;
    box-shadow: none;
    padding: 0;
}

/* Navigation drawer style side menu (Profile pages) */
.sidenav {
    padding: 12px 8px;
}
.sidenav .list-group .list-group-heading {
    margin: 4px 16px 8px;
    color: var(--md-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.sidenav .list-group .list-group-item,
.sidenav .list-group .list-group-item:first-child,
.sidenav .list-group .list-group-item:last-child {
    border: none;
    border-radius: var(--md-radius-pill);
    margin-bottom: 2px;
    background: transparent;
}
.sidenav .list-group .list-group-item > a {
    color: var(--md-on-surface-variant);
    padding: 10px 16px;
    font-weight: 500;
    border-radius: var(--md-radius-pill);
    text-decoration: none;
}
.sidenav .list-group .list-group-item > a i {
    margin-right: 8px;
}
.sidenav .list-group .list-group-item:hover {
    background: var(--md-surface-variant);
}
.sidenav .list-group .list-group-item.active {
    background: var(--md-primary-container);
    border: none;
}
.sidenav .list-group .list-group-item.active > a {
    color: var(--md-primary-dark);
}

/* Generic list groups */
.list-group-item {
    border-color: var(--md-outline);
}

/* ---------- Stat tiles (.info-box) ---------- */
.info-box {
    display: flex;
    align-items: center;
    min-height: 88px;
    padding: 16px;
    margin-bottom: 16px;
    overflow: hidden;
}
.info-box-icon {
    float: none;
    flex: 0 0 56px;
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: var(--md-radius) !important;
    font-size: 24px;
    line-height: 56px;
    text-align: center;
}
.info-box-icon i {
    width: auto;
}
.info-box-content {
    flex: 1 1 auto;
    margin-left: 16px;
    padding: 0;
    min-width: 0;
}
/* Payment page sets a fixed 72px tile height inline; let tiles grow to fit */
.payment-summary-row .info-box {
    height: calc(100% - 16px) !important;
    min-height: 88px !important;
}
.payment-summary-row .info-box-icon {
    flex: 0 0 56px !important;
    width: 56px !important;
    height: 56px !important;
    font-size: 24px !important;
}
.payment-summary-row .info-box-content {
    margin-left: 16px !important;
    padding: 0 !important;
}
/* Payment page: amount + "Request" button share a line and wrap when narrow */
.info-box .payment-summary-value {
    display: flex !important;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
}
.info-box-text {
    color: var(--md-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .06em;
}
.info-box-number {
    font-size: 22px;
    font-weight: 500;
    line-height: 1.3;
    font-variant-numeric: tabular-nums;
}

/* ---------- Buttons ---------- */
.btn {
    font-family: var(--md-font);
    font-weight: 500;
    letter-spacing: .02em;
    border-radius: var(--md-radius-sm);
    padding: 7px 16px;
    transition: background-color .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.btn-sm {
    padding: 4px 10px;
    font-size: 13px;
}
.btn-lg {
    border-radius: var(--md-radius);
}
.btn:focus,
.btn.focus {
    box-shadow: 0 0 0 3px rgba(26, 115, 232, .25);
}
.btn-primary {
    background: var(--md-primary);
    border-color: var(--md-primary);
}
.btn-primary:hover,
.btn-primary:not(:disabled):not(.disabled):active {
    background: var(--md-primary-hover);
    border-color: var(--md-primary-hover);
    box-shadow: var(--md-elev-1);
}
.btn-success {
    background: var(--md-success);
    border-color: var(--md-success);
}
.btn-success:hover {
    background: #137333;
    border-color: #137333;
    box-shadow: var(--md-elev-1);
}
.btn-danger {
    background: var(--md-danger);
    border-color: var(--md-danger);
}
.btn-danger:hover {
    background: #c5221f;
    border-color: #c5221f;
    box-shadow: var(--md-elev-1);
}
.btn-warning {
    background: var(--md-warning);
    border-color: var(--md-warning);
    color: #202124;
}
.btn-info {
    background: var(--md-info);
    border-color: var(--md-info);
    color: #fff;
}
.btn-info:hover {
    background: #0e8796;
    border-color: #0e8796;
    color: #fff;
    box-shadow: var(--md-elev-1);
}
.btn-secondary {
    background: var(--md-surface);
    border-color: var(--md-outline);
    color: var(--md-primary);
}
.btn-secondary:hover {
    background: var(--md-primary-container);
    border-color: var(--md-outline);
    color: var(--md-primary-dark);
}
.btn-light {
    background: var(--md-surface-variant);
    border-color: transparent;
}
.btn-link {
    color: var(--md-primary);
    font-weight: 500;
    text-decoration: none;
}
.btn-link:hover {
    text-decoration: none;
    background: var(--md-primary-container);
}
.btn-outline-primary {
    color: var(--md-primary);
    border-color: var(--md-outline);
}
.btn-outline-primary:hover {
    background: var(--md-primary-container);
    color: var(--md-primary-dark);
    border-color: var(--md-outline);
}

/* ---------- Form fields (outlined) ---------- */
.form-control,
.custom-select,
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select,
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple {
    border: 1px solid var(--md-outline-strong);
    border-radius: var(--md-radius-sm);
    background-color: var(--md-surface);
    color: var(--md-on-surface);
    transition: border-color .15s ease, box-shadow .15s ease;
}
.form-control {
    height: calc(1.5em + 1rem + 2px);
    padding: .5rem .875rem;
}
textarea.form-control {
    height: auto;
}
/* Buttons that also carry .form-control (full-width buttons) keep button colors */
.btn.form-control {
    height: auto;
    padding: 9px 16px;
}
.btn-primary.form-control {
    background: var(--md-primary);
    border-color: var(--md-primary);
    color: var(--md-on-primary);
}
.btn-primary.form-control:hover {
    background: var(--md-primary-hover);
    border-color: var(--md-primary-hover);
}
.btn-success.form-control { background: var(--md-success); border-color: var(--md-success); color: #fff; }
.btn-danger.form-control  { background: var(--md-danger);  border-color: var(--md-danger);  color: #fff; }
.btn-info.form-control    { background: var(--md-info);    border-color: var(--md-info);    color: #fff; }
.form-control:hover,
.custom-select:hover {
    border-color: var(--md-on-surface);
}
.form-control:focus,
.custom-select:focus,
.dataTables_wrapper .dataTables_filter input:focus,
.select2-container--default.select2-container--focus .select2-selection--multiple,
.select2-container--default.select2-container--open .select2-selection--single {
    border-color: var(--md-primary);
    box-shadow: 0 0 0 1px var(--md-primary);
    outline: none;
}
.form-control:disabled,
.form-control[readonly] {
    background: var(--md-surface-variant);
    border-color: var(--md-outline);
    color: var(--md-on-surface-variant);
}
label,
.control-label {
    color: var(--md-on-surface-variant);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
}
.form-check-input,
input[type=checkbox],
input[type=radio] {
    accent-color: var(--md-primary);
}
.input-group-text {
    background: var(--md-surface-variant);
    border-color: var(--md-outline-strong);
}
.select2-container--default .select2-selection--single {
    height: calc(1.5em + 1rem + 2px);
    display: flex;
    align-items: center;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
}
.select2-dropdown {
    border: none;
    border-radius: var(--md-radius-sm);
    box-shadow: var(--md-elev-3);
    overflow: hidden;
}
.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background: var(--md-primary-container);
    color: var(--md-primary-dark);
}

/* ---------- Tabs (Material underline indicator) ---------- */
.nav-tabs {
    border-bottom: 1px solid var(--md-outline);
}
.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    border-radius: 0;
    color: var(--md-on-surface-variant);
    font-weight: 500;
    padding: 12px 20px;
    margin-bottom: -1px;
}
.nav-tabs .nav-link:hover {
    background: var(--md-surface-variant);
    color: var(--md-on-surface);
    border-color: transparent;
}
.nav-tabs .nav-link.active,
.nav-tabs .nav-item.show .nav-link {
    background: transparent;
    color: var(--md-primary);
    border-bottom-color: var(--md-primary);
}
.nav-pills .nav-link {
    border-radius: var(--md-radius-pill);
    font-weight: 500;
}
.nav-pills .nav-link.active {
    background: var(--md-primary-container);
    color: var(--md-primary-dark);
}

/* ---------- Data tables ---------- */
.dataTables_wrapper {
    background: var(--md-surface);
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
    padding: 12px 16px 8px;
    margin-bottom: 16px;
}
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info {
    color: var(--md-on-surface-variant);
    font-size: 13px;
}
.dataTables_wrapper .dataTables_filter input {
    height: 36px;
    padding: 4px 12px 4px 34px;
    margin-left: 8px;
    min-width: 220px;
    background: var(--md-surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='%235f6368'%3E%3Cpath d='M15.5 14h-.79l-.28-.27A6.47 6.47 0 0 0 16 9.5 6.5 6.5 0 1 0 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z'/%3E%3C/svg%3E") no-repeat 10px center;
}
.dataTables_wrapper .dataTables_length select {
    height: 36px;
    padding: 2px 8px;
    margin: 0 4px;
}
table.dataTable,
.table {
    color: var(--md-on-surface);
    font-variant-numeric: tabular-nums;
}
table.dataTable {
    border-collapse: collapse !important;
}
table.dataTable thead th,
table.dataTable thead td,
.table thead th {
    color: var(--md-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    letter-spacing: .03em;
    background-color: var(--md-surface);
    border-bottom: 1px solid var(--md-outline) !important;
    border-top: none;
    padding: 10px 12px;
    white-space: nowrap;
}
table.dataTable tbody td,
.table td {
    border-top: 1px solid var(--md-outline);
    padding: 6px 12px;
    vertical-align: middle;
    line-height: 1.4;
}
/* Cell renderers wrap content in <p>; drop Bootstrap's 1rem paragraph gap */
table.dataTable tbody td p,
.table td p {
    margin: 0 0 2px;
}
table.dataTable tbody td p:last-child,
.table td p:last-child {
    margin-bottom: 0;
}
/* Clear row boundaries: subtle zebra on even rows */
table.dataTable tbody tr:nth-child(even),
.table tbody tr:nth-child(even) {
    background-color: #f7f9fc;
}
table.dataTable.no-footer,
.dataTables_wrapper.no-footer .dataTables_scrollBody,
.dataTables_wrapper .dataTables_scrollHead table.dataTable,
.dataTables_scrollBody table.dataTable {
    border-bottom: 1px solid var(--md-outline) !important;
}
.dataTables_scrollHeadInner table.dataTable {
    border-bottom: none !important;
}
table.dataTable tbody tr {
    background-color: var(--md-surface);
}
table.dataTable.stripe tbody tr.odd,
table.dataTable.display tbody tr.odd,
.table-striped tbody tr:nth-of-type(odd) {
    background-color: #fafbfc;
}
table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover,
table.dataTable tbody tr:hover,
.table-hover tbody tr:hover {
    background-color: var(--md-primary-container);
}
table.dataTable.display tbody tr > .sorting_1,
table.dataTable.display tbody tr.odd > .sorting_1,
table.dataTable.display tbody tr.even > .sorting_1 {
    background-color: transparent;
}
table.dataTable tbody tr.selected,
table.dataTable tbody tr.selected:hover {
    background-color: #d2e3fc;
}
table.dataTable td.dataTables_empty {
    color: var(--md-on-surface-variant);
    padding: 32px 12px;
}
/* Pagination */
.dataTables_wrapper .dataTables_paginate {
    padding-top: 8px;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    border: none !important;
    border-radius: var(--md-radius-pill) !important;
    min-width: 36px;
    padding: 6px 12px !important;
    margin: 0 2px;
    color: var(--md-on-surface-variant) !important;
    background: transparent !important;
    font-weight: 500;
}
.dataTables_wrapper .dataTables_paginate .paginate_button:hover {
    background: var(--md-surface-variant) !important;
    color: var(--md-on-surface) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--md-primary-container) !important;
    color: var(--md-primary-dark) !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled,
.dataTables_wrapper .dataTables_paginate .paginate_button.disabled:hover {
    color: var(--md-outline-strong) !important;
    background: transparent !important;
}
/* RowGroup headers */
table.dataTable tr.dtrg-group td,
table.dataTable tr.group td {
    background: var(--md-surface-variant) !important;
    color: var(--md-on-surface);
    font-weight: 500;
}
/* Compact icon buttons inside table rows */
table.dataTable tbody .btn {
    padding: 4px 10px;
    font-size: 13px;
}
table.dataTable tbody .btn-sm,
table.dataTable tbody .btn-xs {
    padding: 3px 8px;
}
/* Text-style link buttons (item titles) sit flush with the cell text */
table.dataTable tbody .btn-link {
    padding: 0;
    text-align: left;
}

/* ---------- Badges, alerts, chips ---------- */
.badge {
    font-family: var(--md-font);
    font-weight: 500;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: var(--md-radius-pill);
    letter-spacing: .02em;
}
.badge-primary   { background: var(--md-primary-container); color: var(--md-primary-dark); }
.badge-success   { background: var(--md-success-container); color: #0d652d; }
.badge-danger    { background: var(--md-danger-container); color: #a50e0e; }
.badge-warning   { background: var(--md-warning-container); color: #8a5a00; }
.badge-info      { background: var(--md-info-container); color: #0b6e7a; }
.badge-secondary { background: var(--md-surface-variant); color: var(--md-on-surface-variant); }

.alert {
    border: none;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-1);
}
.alert-danger  { background: var(--md-danger-container); color: #a50e0e; }
.alert-success { background: var(--md-success-container); color: #0d652d; }
.alert-warning { background: var(--md-warning-container); color: #6d4c00; }
.alert-info    { background: var(--md-info-container); color: #0b6e7a; }

/* Bootstrap contextual colors aligned to the Material palette */
.bg-primary { background-color: var(--md-primary) !important; }
.bg-success { background-color: var(--md-success) !important; }
.bg-danger  { background-color: var(--md-danger) !important; }
.bg-warning { background-color: var(--md-warning) !important; }
.bg-info    { background-color: var(--md-info) !important; }
.text-primary { color: var(--md-primary) !important; }
.text-success { color: var(--md-success) !important; }
.text-danger  { color: var(--md-danger) !important; }
.text-info    { color: var(--md-info) !important; }
.text-muted   { color: var(--md-on-surface-variant) !important; }

/* ---------- Dialogs (layer.js) ---------- */
.layui-layer:not(.layui-layer-tips):not(.layui-layer-msg):not(.layui-layer-loading) {
    border-radius: var(--md-radius) !important;
    box-shadow: var(--md-elev-3) !important;
    overflow: hidden;
}
.layui-layer-title {
    background: var(--md-surface) !important;
    border-bottom: 1px solid var(--md-outline) !important;
    font-family: var(--md-font);
    font-size: 16px !important;
    font-weight: 500;
    color: var(--md-on-surface) !important;
    height: 52px !important;
    line-height: 52px !important;
    padding: 0 80px 0 20px !important;
}
/* layer.js puts the "close2" button outside the top-right corner, which the
   rounded, overflow-hidden dialog above clips. Draw it inside like close1. */
.layui-layer .layui-layer-setwin .layui-layer-close2 {
    right: -2px;
    top: 2px;
    width: 16px;
    height: 16px;
    background-position: 1px -40px;
}
.layui-layer .layui-layer-setwin .layui-layer-close2:hover {
    background-position: 1px -40px;
    opacity: .7;
}
.layui-layer-btn {
    padding: 8px 16px 16px !important;
}
.layui-layer-btn a {
    border-radius: var(--md-radius-sm) !important;
    height: 36px !important;
    line-height: 36px !important;
    padding: 0 18px !important;
    font-weight: 500;
    border-color: var(--md-outline) !important;
    background: var(--md-surface) !important;
    color: var(--md-primary) !important;
}
.layui-layer-btn .layui-layer-btn0 {
    background: var(--md-primary) !important;
    border-color: var(--md-primary) !important;
    color: #fff !important;
}
.layui-layer-msg,
.layui-layer-fast-msg {
    border-radius: var(--md-radius-sm) !important;
    border: none !important;
    box-shadow: var(--md-elev-2) !important;
}
.layui-layer-dialog .layui-layer-content {
    font-size: 14px;
    padding: 20px !important;
}

/* Bootstrap modals */
.modal-content {
    border: none;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-3);
}
.modal-header,
.modal-footer {
    border-color: var(--md-outline);
}

/* ---------- Login / register card ---------- */
.login-section {
    background: var(--md-surface);
    border: none;
    border-radius: var(--md-radius);
    box-shadow: var(--md-elev-2);
    overflow: hidden;
    margin: 32px auto;
    max-width: 480px;
}
.login-section .logon-tab {
    border-bottom: 1px solid var(--md-outline);
}
.login-section .logon-tab > a {
    background: var(--md-surface);
    color: var(--md-on-surface-variant);
    font-weight: 500;
    border-bottom: 3px solid transparent;
    text-decoration: none;
}
.login-section .logon-tab > a:hover {
    background: var(--md-surface-variant);
    color: var(--md-on-surface);
}
.login-section .logon-tab > a.active {
    background: var(--md-surface);
    color: var(--md-primary);
    border-bottom-color: var(--md-primary);
}

/* ---------- Misc ---------- */
.page-header {
    border-bottom: none;
    margin: 8px 0 16px;
}
hr {
    border-top-color: var(--md-outline);
}
.tooltip-inner {
    background: #3c4043;
    border-radius: 4px;
    font-size: 12px;
}
.datepicker.dropdown-menu {
    padding: 8px;
}
.datepicker table tr td.active,
.datepicker table tr td.active:hover,
.datepicker table tr td.active.active {
    background: var(--md-primary) !important;
    border-radius: var(--md-radius-pill);
}

/* Subtle scrollbars */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-thumb {
    background: #c4c7c5;
    border-radius: 10px;
    border: 2px solid var(--md-background);
}
::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Small screens ---------- */
@media (max-width: 767px) {
    .login-section {
        width: auto !important;
        margin: 16px;
    }
    nav.navbar.navbar-dark .navbar-nav .nav-link {
        border-radius: var(--md-radius-sm);
    }
    #navbar-collapse-right .navbar-nav {
        border-left: none;
        border-top: 1px solid rgba(255, 255, 255, .22);
        padding: 8px 0 0;
        margin-top: 8px;
    }
    nav.navbar .navbar-nav {
        align-items: stretch;
    }
    .dataTables_wrapper {
        padding: 8px;
    }
    .dataTables_wrapper .dataTables_filter input {
        min-width: 0;
        width: 100%;
        margin-left: 0;
    }
}

/* ---------- Ticket window: read-only header for an existing ticket ---------- */
.ticket-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 0 0 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--md-outline);
}
.ticket-head-main {
    min-width: 0;
    flex: 1;
}
.ticket-head-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 6px;
}
.ticket-chip {
    display: inline-block;
    padding: 0 8px;
    border-radius: 999px;
    background: var(--md-surface-variant);
    color: var(--md-on-surface-variant);
    font-size: 12px;
    font-weight: 500;
    line-height: 20px;
}
.ticket-chip.ticket-topic {
    background: var(--md-primary-container);
    color: var(--md-primary-dark);
}
.ticket-chip.ticket-open {
    background: var(--md-success-container);
    color: var(--md-success);
}
.ticket-no {
    color: var(--md-on-surface-variant);
    font-size: 12px;
    font-variant-numeric: tabular-nums;
}
.ticket-subject {
    color: var(--md-on-surface);
    overflow-wrap: anywhere;
}
.ticket-users {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
    color: var(--md-on-surface-variant);
    font-size: 12px;
}
.ticket-users > i {
    margin-right: 2px;
}
.ticket-users .ticket-user {
    display: inline-block;
    padding: 0 8px;
    border: 1px solid var(--md-outline);
    border-radius: 999px;
    color: var(--md-on-surface);
    font-size: 12px;
    line-height: 18px;
}
.ticket-head-actions {
    flex: none;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
.ticket-head-actions .ticket-att {
    font-size: 12px;
}
@media (max-width: 767px) {
    .ticket-head {
        flex-direction: column;
    }
    .ticket-head-actions {
        align-items: flex-start;
    }
}

/* Ticket title block (render_ticket_subject in common_admin.js):
   thin rules above and below the title, then a plain row of labelled facts. */
.ticket-subject .ts-title {
    padding: 6px 0;
    border-top: 1px solid var(--md-outline);
    font-size: 15px;
    font-weight: 600;
    line-height: 1.4;
    color: var(--md-on-surface);
}
.ticket-subject .ts-message {
    padding: 0 0 6px;
    font-size: 14px;
    line-height: 1.45;
    color: var(--md-on-surface);
}
.ticket-subject .ts-facts {
    display: flex;
    flex-wrap: wrap;
    gap: 2px 22px;
    padding-top: 5px;
    border-top: 1px solid var(--md-outline);
}
.ticket-subject .ts:not(:has(.ts-facts)) {
    border-bottom: 1px solid var(--md-outline);
}
.ticket-subject .ts-fact {
    display: flex;
    flex-direction: column;
    min-width: 0;
}
.ticket-subject .ts-label {
    color: var(--md-on-surface-variant);
    font-size: 10px;
    font-weight: 500;
    letter-spacing: .06em;
    line-height: 14px;
    text-transform: uppercase;
}
.ticket-subject .ts-value {
    font-size: 13px;
    font-weight: 500;
    line-height: 18px;
    overflow-wrap: anywhere;
}
.ticket-subject .ts-address .ts-value {
    color: var(--md-on-surface);
}
.ticket-subject .ts-tracking .ts-value {
    color: var(--md-primary);
    font-family: ui-monospace, Consolas, 'Roboto Mono', monospace;
    font-size: 12.5px;
}
.ticket-subject .ts-qty .ts-value {
    color: var(--md-on-surface);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.ticket-subject .ts-inbound .ts-value {
    color: #b06000;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.ticket-subject .ts-offer .ts-value {
    color: var(--md-success);
}

/* ==========================================================================
   Workbench layer: borders instead of shadows, grey panel headers,
   column lines in tables, denser rows, underline bar for the active menu item.
   ========================================================================== */
body {
    font-size: 13.5px;
}
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

/* App bar: lower, flat, active item marked with an underline bar */
nav.navbar.fixed-top {
    min-height: 52px;
    padding: 4px 16px;
}
nav.navbar.fixed-top > a > img {
    height: 38px !important;
    width: 38px !important;
    border-radius: 2px;
}
nav.navbar.navbar-dark .navbar-nav .nav-link {
    padding: 7px 12px;
    font-size: 13.5px;
}
nav.navbar.navbar-dark .navbar-nav .nav-link.md-active {
    background: rgba(255, 255, 255, .14);
    box-shadow: inset 0 -3px 0 #7fa6ee;
}
nav.navbar.navbar-dark .navbar-nav .dropdown:hover > .nav-link,
nav.navbar.navbar-dark .navbar-nav .dropdown.show > .nav-link {
    box-shadow: none;
}
nav.navbar .dropdown-menu .dropdown-item,
.dropdown-menu .dropdown-item {
    font-size: 13.5px;
    padding: 8px 18px;
}
.subscription-balance {
    border-radius: 2px !important;
}

/* Surfaces: 1px border, no shadow; grey headers */
.card,
.panel,
.sidenav,
.info-box,
.dataTables_wrapper,
.login-section,
.alert {
    border: 1px solid var(--md-outline);
    box-shadow: none;
}
.panel.panel-default {
    border: none;
}
.card-header {
    background: var(--md-surface-variant);
    font-size: 14px;
    font-weight: 600;
    padding: 10px 16px;
}
.card-body {
    padding: 16px;
}
.dataTables_wrapper {
    padding: 10px 12px 6px;
}
.alert-danger  { border-color: #e7b9b5; }
.alert-success { border-color: #b7d9c1; }
.alert-warning { border-color: #e6cf9c; }
.alert-info    { border-color: #b3d7dc; }

/* Buttons: compact, square */
.btn {
    padding: 5px 12px;
    letter-spacing: 0;
}
.btn-sm {
    padding: 3px 9px;
}
.btn:focus,
.btn.focus {
    box-shadow: 0 0 0 2px rgba(28, 79, 168, .3);
}
.btn-secondary {
    border-color: var(--md-outline-strong);
}

/* Form fields: a bit lower */
.form-control {
    height: calc(1.5em + .75rem + 2px);
    padding: .375rem .75rem;
}
.select2-container--default .select2-selection--single {
    height: calc(1.5em + .75rem + 2px);
}
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    height: 32px;
}
.form-control:focus,
.custom-select:focus,
.dataTables_wrapper .dataTables_filter input:focus {
    box-shadow: 0 0 0 2px rgba(28, 79, 168, .18);
}

/* Tables: grey header, column lines, dense rows */
table.dataTable thead th,
table.dataTable thead td,
.table thead th {
    background-color: var(--md-surface-variant);
    color: var(--md-on-surface);
    font-weight: 600;
    letter-spacing: 0;
    padding: 7px 10px;
    border-right: 1px solid var(--md-outline);
}
table.dataTable tbody td,
.table td {
    padding: 5px 10px;
    border-top: 1px solid #e2e6ea;
    border-right: 1px solid #e2e6ea;
}
table.dataTable thead th:last-child,
table.dataTable thead td:last-child,
.table thead th:last-child,
table.dataTable tbody td:last-child,
.table td:last-child {
    border-right: none;
}
table.dataTable tbody tr:nth-child(even),
.table tbody tr:nth-child(even) {
    background-color: #f7f8fa;
}
table.dataTable.hover tbody tr:hover,
table.dataTable.display tbody tr:hover,
table.dataTable tbody tr:hover,
.table-hover tbody tr:hover {
    background-color: #eaf0fb;
}
table.dataTable tbody tr.selected,
table.dataTable tbody tr.selected:hover {
    background-color: #d9e4f7;
}
.dataTables_wrapper .dataTables_paginate .paginate_button {
    min-width: 30px;
    padding: 4px 10px !important;
}
.dataTables_wrapper .dataTables_paginate .paginate_button.current,
.dataTables_wrapper .dataTables_paginate .paginate_button.current:hover {
    background: var(--md-primary) !important;
    color: #fff !important;
}

/* Badges: square tags */
.badge {
    padding: 3px 7px;
    font-size: 11.5px;
    letter-spacing: 0;
}

/* Tabs: grey strip with an underline on the active tab */
.nav-tabs .nav-link {
    padding: 8px 16px;
}

/* Dialogs (layer.js / Bootstrap): square, 1px border, grey title bar */
.layui-layer:not(.layui-layer-tips):not(.layui-layer-msg):not(.layui-layer-loading) {
    border: 1px solid var(--md-outline-strong);
}
.layui-layer-title {
    background: var(--md-surface-variant) !important;
    font-size: 14px !important;
    font-weight: 600;
    height: 42px !important;
    line-height: 42px !important;
    padding: 0 70px 0 16px !important;
}
.layui-layer-setwin {
    top: 13px !important;
}
.layui-layer-btn a {
    height: 32px !important;
    line-height: 32px !important;
    padding: 0 14px !important;
}
.modal-content {
    border: 1px solid var(--md-outline-strong);
}
.modal-header {
    background: var(--md-surface-variant);
}

/* Side menu (Profile pages) */
.sidenav .list-group .list-group-item > a {
    padding: 8px 14px;
}
.sidenav .list-group .list-group-item.active {
    box-shadow: inset 3px 0 0 var(--md-primary);
}

/* Ticket window pieces that used pill shapes / other fonts */
.ticket-chip,
.ticket-users .ticket-user {
    border-radius: 2px;
}
.ticket-subject .ts-tracking .ts-value {
    font-family: var(--md-mono);
}

::-webkit-scrollbar-thumb {
    border-radius: 2px;
}

/* Table cells that may hold long unbroken strings (UPC, offer codes): wrap them
   so they do not force the column wider than its share */
table.dataTable tbody td.cell-wrap {
    overflow-wrap: anywhere;
}
table.dataTable tbody td.cell-wrap .btn-add-upc {
    white-space: nowrap;
}

/* Item tables: request dialog (payment/index.js) and "Covers N items" popup (payment/payment_items.js) */
/* Summary cards shown as an equation (user Payment page, admin Payment summary)
   .payment-summary-row > .payment-summary-col / .summary-op ("+", "=") / .summary-sep */
.payment-summary-row{
    display: flex;
    align-items: stretch;
    margin-bottom: 4px;
}
.payment-summary-col{
    flex: 1 1 0;
    min-width: 0;
}
/* "+" "=" between Available, Pending and Total; a divider before Receivable */
.summary-op{
    flex: 0 0 28px;
    align-self: center;
    margin-bottom: 1rem;   /* info-box bottom margin */
    text-align: center;
    font-size: 22px;
    font-weight: 600;
    color: #8a939c;
}
.summary-sep{
    flex: 0 0 1px;
    margin: 0 16px 1rem;
    background: #cfd5db;
}
.payment-summary-row .payment-summary-col + .payment-summary-col{ margin-left: 12px; }
.summary-total{ border-color: #1c4fa8 !important; box-shadow: inset 0 0 0 1px #1c4fa8; }
.summary-cents{ font-size: 55%; top: -0.75em; margin-left: 1px; font-weight: 500; color: #5c6670; }
.summary-hint{
    font-size: 11px;
    color: #8a939c;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.payment-summary-row .info-box{
    display: flex;
    height: 72px;
    min-height: 72px;
}
.payment-summary-row .info-box-icon{
    align-items: center;
    display: flex;
    flex: 0 0 72px;
    float: none;
    font-size: 36px;
    height: 72px;
    justify-content: center;
    line-height: 1;
    padding: 0 !important;
    text-align: center;
    width: 72px;
}
.payment-summary-row .info-box-icon > i{
    display: block;
    margin: 0;
    text-align: center;
    width: 100%;
}
.payment-summary-row .info-box-content{
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
    margin-left: 0;
    min-width: 0;
    padding: 5px 8px;
}
.payment-summary-value{
    align-items: center;
    display: flex;
    gap: 8px;
    white-space: nowrap;
}
.payment-processing-date{
    color: #138496;
    font-size: 17px;
    white-space: nowrap;
}
/* Pending box filters the table below; Receivable box opens a popup */
.summary-filter, .summary-click { cursor: pointer; transition: border-color .12s, box-shadow .12s; }
.summary-filter:hover, .summary-click:hover { border-color: #1c4fa8; }
.summary-filter.active { border-color: #1c4fa8; box-shadow: inset 0 -3px 0 #1c4fa8; }
/* narrow screens: the equation keeps its own line, Receivable / Last Paid wrap below */
@media (max-width: 1199px){
    .payment-summary-row{ flex-wrap: wrap; }
    .payment-summary-col{ flex: 1 1 26%; }
    .summary-sep{ flex: 0 0 100%; height: 0; margin: 0; background: none; }
    .payment-summary-row .summary-sep + .payment-summary-col{ margin-left: 0; }
}
@media (max-width: 575px){
    .payment-summary-row{ flex-direction: column; }
    .payment-summary-row .payment-summary-col + .payment-summary-col{ margin-left: 0; }
    .summary-op{ margin: -10px 0 -6px; font-size: 18px; }
    .summary-sep{ display: none; }
}

/* cents as a small raised part: 1,117<sup>.31</sup> (money2() in manage_payment, money_sup() in payment) */
.money-cents { font-size: 75%; top: -0.45em; margin-left: 1px; color: inherit; opacity: .8; font-weight: inherit; }

/* "Export Excel" button placed before a DataTable search box (payment_items.js add_export_button) */
.btn-export-xlsx { margin-right: 10px; vertical-align: middle; }
.btn-export-xlsx i { margin-right: 4px; color: #1e6b3a; }

/* admin Transaction page: tag on the grey (cancelled) rows */
.at-cancel-tag { display: inline-block; margin-top: 2px; padding: 0 6px; font-size: 11px; line-height: 17px; background: #d5dadf; color: #3d4650; cursor: help; }

.pi-popup { padding: 12px 16px; }
.pi-note { margin-bottom: 8px; font-size: 12px; color: #5c6670; }
.pi-table-wrap { max-height: 60vh; overflow: auto; border: 1px solid #cfd5db; }
.pi-table { margin: 0; font-size: 12px; }
.pi-table thead th { position: sticky; top: 0; z-index: 1; padding: 5px 8px; font-size: 11.5px; }
.pi-table td { padding: 4px 8px; vertical-align: top; line-height: 1.35; }
.pi-table .pi-name { overflow-wrap: anywhere; color: #161a1d; }
.pi-table .pi-sub { color: #5c6670; font-size: 11.5px; font-variant-numeric: tabular-nums; }
.pi-table .pi-dot { margin: 0 6px; color: #b9c1c9; }
.pi-table .pi-track { font-family: 'IBM Plex Mono', SFMono-Regular, Consolas, monospace; font-size: 11px; color: #3d4650; }
.pi-table .pi-money { font-variant-numeric: tabular-nums; white-space: nowrap; }
.pi-table .pi-of { color: #8a939c; font-size: 11px; }
/* partly requested / partly covered item */
.pi-table tr.pi-partial-row td { background: #fff8e6; }
.pi-table tr.pi-partial-row td:first-child { box-shadow: inset 3px 0 0 #d9a21b; }
.pi-table tr.pi-partial-row .pi-money { color: #8a5a00; font-weight: 600; }
.pi-partial-tag { display: inline-block; margin-top: 2px; padding: 0 6px; font-size: 11px; line-height: 17px;
    background: #fff4dc; color: #8a5a00; border: 1px solid #f0d79a; cursor: help; }
.pi-partial-hint { display: flex; align-items: flex-start; gap: 8px; padding: 6px 10px; font-size: 12px; line-height: 1.45;
    color: #5a4a1e; background: #fffaf0; border: 1px solid #f0d79a; }
.pi-partial-swatch { flex: 0 0 auto; width: 10px; height: 10px; margin-top: 3px; background: #fff4dc; box-shadow: inset 3px 0 0 #d9a21b, 0 0 0 1px #f0d79a; }

/* Item payment status tags under an item's detail (payment/payment_items.js payment_item_status) */
.pis-wrap { margin-top: 4px; display: flex; flex-wrap: wrap; gap: 4px; }
.pis { display: inline-block; padding: 0 6px; font-size: 11.5px; line-height: 18px; font-weight: 600; border: 1px solid transparent; font-variant-numeric: tabular-nums; }
.pis-unpaid { background: #eef1f4; color: #5c6670; border-color: #d5dadf; }
.pis-requested { background: #fff4dc; color: #8a5a00; border-color: #f0d79a; }
.pis-pending { background: #e6edf8; color: #1c4fa8; border-color: #b9cbe9; }
.pis-paid { background: #e3f3e8; color: #1e6b3a; border-color: #a9d8b8; }

/* "Covers N items" link under a payment's detail (payment/payment_items.js) */
.payment-items-link {
    margin-top: 4px;
    font-size: 12.5px;
}
.payment-items-table td {
    vertical-align: top;
    font-variant-numeric: tabular-nums;
}
