/* =========================================================
   HBA ProjectBiller — Global Stylesheet
   ========================================================= */

/* ----- CSS Custom Properties ----- */
:root {
    --font-serif:    'Cormorant Garamond', Georgia, serif;
    --font-sans:     'Jost', 'Helvetica Neue', Arial, sans-serif;

    /* Brand palette */
    --brand-navy:    #1A2B4A;
    --brand-gold:    #C9A84C;
    --brand-gold-lt: #E8D5A3;
    --brand-cream:   #F8F5EF;

    /* Surface */
    --bg-page:       #F4F1EB;
    --bg-card:       #FFFFFF;
    --bg-sidebar:    #1A2B4A;
    --bg-topbar:     #FFFFFF;

    /* Text */
    --text-primary:  #1A1A2E;
    --text-muted:    #6B7280;
    --text-light:    #9CA3AF;
    --text-on-dark:  #F8F5EF;

    /* Borders */
    --border:        #E5E0D8;
    --border-focus:  #C9A84C;

    /* Status colours */
    --s-active-bg:   #EFF6FF;
    --s-active-txt:  #1D4ED8;
    --s-pending-bg:  #FEF9C3;
    --s-pending-txt: #854D0E;
    --s-returned-bg: #FEF2F2;
    --s-returned-txt:#991B1B;
    --s-approved-bg: #F0FDF4;
    --s-approved-txt:#166534;
    --s-inactive-bg: #F3F4F6;
    --s-inactive-txt:#4B5563;
    --s-nobilling-bg:#F5F3FF;
    --s-nobilling-txt:#6D28D9;

    /* Bill control */
    --bc-pending-bg:  #FFF7ED;
    --bc-pending-txt: #9A3412;
    --bc-passed-bg:   #F0FDF4;
    --bc-passed-txt:  #166534;

    /* Approval type */
    --ap-pm-bg:  #F5F3FF;
    --ap-pm-txt: #5B21B6;
    --ap-ar-bg:  #EFF6FF;
    --ap-ar-txt: #1D4ED8;

    /* Misc */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --shadow-card: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-hover: 0 4px 12px rgba(0,0,0,0.10);
    --transition: 150ms ease;

    /* Layout */
    --sidebar-w: 240px;
    --topbar-h:  64px;
}

/* ----- Reset / Base ----- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-page);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { font-family: var(--font-serif); }

a { color: var(--brand-gold); text-decoration: none; }
a:hover { text-decoration: underline; }

button { cursor: pointer; font-family: var(--font-sans); }

/* ----- App Shell ----- */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ----- Sidebar ----- */
.sidebar {
    width: var(--sidebar-w);
    min-width: var(--sidebar-w);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
    transition: width 220ms ease, min-width 220ms ease;
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
}

/* Brand */
.sb-brand {
    padding: 24px 20px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sb-logo-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sb-logo-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.sb-logo-img {
    width: 52px;
    height: 52px;
    border-radius: var(--radius-sm);
    object-fit: contain;
    background: rgba(255,255,255,0.12);
    padding: 5px;
}

.sb-logo-text {
    font-family: var(--font-serif);
    font-size: 18px;
    font-weight: 600;
    color: var(--text-on-dark);
    line-height: 1.2;
}

.sb-logo-sub {
    font-size: 10px;
    font-weight: 300;
    color: var(--brand-gold-lt);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* Nav */
.sb-nav {
    padding: 12px 12px 0;
    flex: 1;
    overflow-y: auto;
}

.nav-section-lbl {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    padding: 12px 8px 4px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 12px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.70);
    font-size: 13.5px;
    font-weight: 400;
    transition: background var(--transition), color var(--transition);
    position: relative;
    text-decoration: none;
}

.nav-link:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-on-dark);
    text-decoration: none;
}

.nav-link.active {
    background: rgba(201,168,76,0.18);
    color: var(--brand-gold-lt);
    font-weight: 500;
}

.nav-icon {
    font-size: 15px;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.nav-badge {
    margin-left: auto;
    background: var(--brand-gold);
    color: var(--brand-navy);
    font-size: 11px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Run info */
.sb-run {
    padding: 14px 20px;
    border-top: 1px solid rgba(255,255,255,0.08);
}

.sb-run-lbl {
    font-size: 10px;
    font-weight: 500;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
    margin-bottom: 4px;
}

.sb-run-period {
    font-family: var(--font-serif);
    font-size: 15px;
    color: var(--brand-gold-lt);
}

.sb-run-status {
    font-size: 11px;
    color: rgba(255,255,255,0.45);
    margin-top: 2px;
}

/* User footer */
.sb-user {
    padding: 14px 16px;
    border-top: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    gap: 10px;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    flex-shrink: 0;
    color: #fff;
}

.avatar-pm   { background: #7C3AED; }
.avatar-ar   { background: #1D4ED8; }
.avatar-both { background: linear-gradient(135deg, #7C3AED 50%, #1D4ED8 50%); }

.sb-user-info { flex: 1; min-width: 0; }

.sb-user-name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-on-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sb-user-role {
    font-size: 10px;
    color: rgba(255,255,255,0.45);
    margin-top: 1px;
}

/* ----- Main column ----- */
.main-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

/* ----- Top bar ----- */
.topbar {
    height: var(--topbar-h);
    min-height: var(--topbar-h);
    background: var(--bg-topbar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    gap: 16px;
}

.sb-toggle-row {
    display: flex;
    justify-content: flex-end;
    padding: 10px 12px 4px;
}

.sb-hamburger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    background: none;
    color: rgba(255,255,255,0.50);
    border-radius: var(--radius-sm);
    flex-shrink: 0;
    transition: background var(--transition), color var(--transition);
}

.sb-hamburger:hover {
    background: rgba(255,255,255,0.08);
    color: var(--text-on-dark);
}

.sb-reopen-btn {
    position: fixed;
    top: 14px;
    left: 12px;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-card);
    transition: background var(--transition), color var(--transition);
}

.sb-reopen-btn:hover {
    background: var(--bg-page);
    color: var(--text-primary);
}

.topbar-title {
    font-family: var(--font-serif);
    font-size: 22px;
    font-weight: 600;
    color: var(--brand-navy);
    flex: 1;
    transition: margin-left 220ms ease;
}

/* When the sidebar is collapsed, the floating .sb-reopen-btn (fixed,
   left:12px, 32px wide) would otherwise overlap the topbar title. */
.sidebar.collapsed + .main-col .topbar-title {
    margin-left: 26px;
}

.topbar-chips {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tb-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.tb-chip-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-light);
}

.tb-run-badge {
    background: var(--brand-navy);
    color: var(--brand-gold-lt);
    border-color: var(--brand-navy);
    font-weight: 500;
}

.tb-period-badge {
    background: var(--brand-cream);
    color: var(--brand-navy);
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 600;
    border-color: var(--brand-gold-lt);
}

/* User chip in topbar */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: var(--bg-page);
}

.user-chip .avatar { width: 26px; height: 26px; font-size: 10px; flex-shrink: 0; }

.user-chip-body {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.user-chip-name {
    font-size: 12.5px;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.2;
}

.user-chip-sub {
    display: flex;
    align-items: center;
    gap: 6px;
}

.signout-btn {
    background: none;
    border: none;
    padding: 0;
    font-size: 10px;
    color: var(--text-light);
    cursor: pointer;
    text-decoration: underline;
    font-family: inherit;
    line-height: 1;
}

.signout-btn:hover { color: var(--text-primary); }

.role-pill {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 10px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.role-pill-pm   { background: #EDE9FE; color: #5B21B6; }
.role-pill-ar   { background: #DBEAFE; color: #1D4ED8; }
.role-pill-both { background: linear-gradient(90deg, #EDE9FE 50%, #DBEAFE 50%); color: #3730A3; }

/* ----- Page content area ----- */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

/* ----- Loading states ----- */
.auth-loading {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-page);
    z-index: 9999;
}

.page-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--brand-gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.lines-loading {
    display: flex;
    justify-content: center;
    padding: 24px 0;
}

.lines-loading .spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* ----- Empty state ----- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 24px;
    text-align: center;
}

.empty-icon {
    font-size: 48px;
    color: var(--brand-gold);
    margin-bottom: 16px;
    opacity: 0.6;
}

.empty-title {
    font-family: var(--font-serif);
    font-size: 22px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-hint {
    font-size: 13px;
    color: var(--text-muted);
    max-width: 320px;
}

/* ----- Approvals info bar ----- */
.approvals-info {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ----- IC Control filter bar ----- */
.ic-filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.ic-filter-bar .search-input {
    flex: 1;
    max-width: 400px;
}

/* ----- Topbar period selector ----- */
.topbar-period {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 3px;
}

.topbar-period-lbl {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.period-select {
    padding: 4px 26px 4px 10px;
    font-family: var(--font-serif);
    font-size: 13px;
    font-weight: 600;
    color: var(--brand-navy);
    background-color: var(--brand-cream);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='11' height='11' viewBox='0 0 12 12'%3E%3Cpath fill='%231A2B4A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 11px;
    border: 1px solid var(--brand-gold-lt);
    border-radius: 20px;
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    min-width: 120px;
}

.period-select:focus {
    border-color: var(--brand-gold);
    box-shadow: 0 0 0 2px rgba(201,168,76,0.20);
}

/* ----- Billing search ----- */
.billing-search {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    margin-bottom: 12px;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filter-lbl {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--brand-navy);
}

.billing-search .search-input {
    flex: 1;
    max-width: 400px;
    padding: 7px 12px;
    font-size: 13.5px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.billing-search .search-input:focus {
    border-color: var(--border-focus);
}

.billing-search .search-input::placeholder {
    color: var(--text-light);
}

.company-filter {
    padding: 7px 32px 7px 12px;
    font-size: 13px;
    font-family: var(--font-sans);
    font-weight: 500;
    color: var(--brand-navy);
    background-color: var(--bg-card);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231A2B4A' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 12px;
    border: 1.5px solid var(--brand-navy);
    border-radius: var(--radius-md);
    outline: none;
    min-width: 180px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.company-filter:focus {
    box-shadow: 0 0 0 3px rgba(26,43,74,0.12);
}

.company-filter option {
    font-weight: 400;
    color: var(--text-primary);
}

/* ----- Tabs (ProjectBilling page) ----- */
.tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border);
    padding-bottom: 0;
}

.tab {
    padding: 8px 18px 10px;
    font-size: 13.5px;
    font-weight: 400;
    color: var(--text-muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: color var(--transition), border-color var(--transition);
    user-select: none;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
    color: var(--brand-navy);
    font-weight: 500;
    border-bottom-color: var(--brand-gold);
}

.tab-badge {
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-page);
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: 10px;
    min-width: 20px;
    height: 18px;
    padding: 0 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition), color var(--transition);
}

.tab-badge.active {
    background: var(--brand-gold);
    border-color: var(--brand-gold);
    color: var(--brand-navy);
}

/* ----- Project list ----- */
.project-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ----- Accordion Item ----- */
.acc-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    overflow: hidden;
    transition: box-shadow var(--transition);
}

.acc-item:hover { box-shadow: var(--shadow-hover); }

.acc-item.acc-open { border-color: var(--brand-gold-lt); }

.acc-hdr {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    cursor: pointer;
    user-select: none;
    min-height: 58px;
}

.chevron {
    font-size: 12px;
    color: var(--text-light);
    transition: transform var(--transition);
    flex-shrink: 0;
}

.chevron.open { transform: rotate(180deg); }

.acc-id {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
    min-width: 80px;
}

.acc-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.acc-chips {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.acc-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    margin-left: 8px;
}

/* Accordion body */
.acc-body {
    padding: 0 16px 16px;
    border-top: 1px solid var(--border);
}

.info-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 12px 0 10px;
}

.chip {
    font-size: 11px;
    font-weight: 500;
    padding: 3px 8px;
    border-radius: 12px;
    background: var(--bg-page);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.notes-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
}

.notes-lbl {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    padding-top: 8px;
    flex-shrink: 0;
    width: 44px;
}

.notes-ta {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    font-family: var(--font-sans);
    font-size: 13px;
    color: var(--text-primary);
    background: var(--bg-page);
    resize: vertical;
    min-height: 60px;
    max-height: 160px;
    transition: border-color var(--transition);
    outline: none;
}

.notes-ta:focus {
    border-color: var(--border-focus);
    background: var(--bg-card);
}

.notes-ta::placeholder { color: var(--text-light); }

.sec-lbl {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-light);
    margin-bottom: 8px;
}

/* ----- Badges ----- */
.status-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
    white-space: nowrap;
}

.s-active   { background: var(--s-active-bg);   color: var(--s-active-txt); }
.s-pending  { background: var(--s-pending-bg);  color: var(--s-pending-txt); }
.s-returned { background: var(--s-returned-bg); color: var(--s-returned-txt); }
.s-approved { background: var(--s-approved-bg); color: var(--s-approved-txt); }
.s-inactive { background: var(--s-inactive-bg); color: var(--s-inactive-txt); }
.s-nobilling { background: var(--s-nobilling-bg); color: var(--s-nobilling-txt); }

.bc-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.bc-pending { background: var(--bc-pending-bg); color: var(--bc-pending-txt); }
.bc-passed  { background: var(--bc-passed-bg);  color: var(--bc-passed-txt); }

.ap-badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 10px;
    white-space: nowrap;
}

.ap-pm { background: var(--ap-pm-bg); color: var(--ap-pm-txt); }
.ap-ar { background: var(--ap-ar-bg); color: var(--ap-ar-txt); }

/* ----- Buttons ----- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 500;
    border: 1px solid transparent;
    transition: background var(--transition), color var(--transition), border-color var(--transition), opacity var(--transition);
    white-space: nowrap;
    line-height: 1.4;
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--brand-navy);
    color: var(--text-on-dark);
    border-color: var(--brand-navy);
}

.btn-primary:not(:disabled):hover {
    background: #243D66;
    border-color: #243D66;
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border-color: var(--border);
}

.btn-secondary:not(:disabled):hover {
    background: var(--bg-page);
}

.btn-approve {
    background: var(--s-approved-bg);
    color: var(--s-approved-txt);
    border-color: #BBF7D0;
}

.btn-approve:not(:disabled):hover {
    background: #DCFCE7;
}

.btn-return {
    background: var(--s-returned-bg);
    color: var(--s-returned-txt);
    border-color: #FECACA;
}

.btn-return:not(:disabled):hover {
    background: #FEE2E2;
}

/* ----- Billing Lines Table ----- */
.bl-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

.bl-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.bl-table thead th {
    background: var(--bg-page);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.bl-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background var(--transition);
}

.bl-table tbody tr:last-child { border-bottom: none; }

.bl-table tbody tr:hover { background: #FAFAF8; }

/* Fully billed (100%) or zero-contract-amount lines are locked from editing */
.bl-table tbody tr.bl-row-locked {
    background: var(--s-returned-bg);
    cursor: not-allowed;
}

.bl-table tbody tr.bl-row-locked:hover { background: #FCE4E4; }

.bl-table td {
    padding: 8px 10px;
    vertical-align: middle;
}

.bl-table th.num,
.bl-table td.num {
    text-align: right;
}

.bl-id {
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    color: var(--text-muted);
    white-space: nowrap;
}

.bl-desc {
    max-width: 220px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bl-table tfoot .bl-totals-row {
    font-weight: 700;
    border-top: 2px solid var(--border);
}

/* Preset select */
.pct-wrap {
    display: flex;
    align-items: center;
    gap: 4px;
    justify-content: flex-end;
}

.pct-sel {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--font-sans);
    background: var(--bg-card);
    color: var(--text-primary);
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition);
}

.pct-sel:focus { border-color: var(--border-focus); }

/* ----- Page header / grid toolbar (JCR-style admin pages) ----- */
.pg-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.back-link {
    font-family: var(--font-sans);
    font-size: 13px;
    font-weight: 500;
    color: var(--brand-navy);
    text-decoration: none;
}

.back-link:hover {
    text-decoration: underline;
}

.pg-footer {
    margin-top: 16px;
}

.pg-title {
    font-family: var(--font-serif);
    font-size: 24px;
    font-weight: 600;
    color: var(--brand-navy);
    line-height: 1.2;
}

.wb-grid-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-bottom: 8px;
}

.transfer-box {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

/* DxGrid — navy column headers (applied via CustomizeElement on GridElementType.HeaderCell) */
.grid-header-navy {
    background-color: var(--brand-navy) !important;
    color: #fff !important;
}

.grid-header-navy button,
.grid-header-navy svg {
    color: rgba(255,255,255,0.75) !important;
    fill: rgba(255,255,255,0.75) !important;
}

/* DxGrid — selected row highlight (applied via CustomizeElement on GridElementType.DataRow) */
.grid-row-selected td {
    background-color: rgba(201, 168, 76, 0.15) !important;
}

/* DxGrid — bold total summary footer (applied via CustomizeElement on GridElementType.FooterCell) */
.grid-footer-bold {
    font-weight: 700 !important;
}

.picker-trigger {
    cursor: pointer;
    color: var(--brand-navy);
    text-decoration: underline dotted;
    text-underline-offset: 2px;
}

.picker-trigger:hover {
    color: var(--brand-gold);
}

/* Custom pct input */
.pct-inp {
    width: 72px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--font-sans);
    text-align: right;
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.pct-inp:focus { border-color: var(--border-focus); }

.reset-lnk {
    font-size: 13px;
    color: var(--text-light);
    cursor: pointer;
    transition: color var(--transition);
    line-height: 1;
}

.reset-lnk:hover { color: var(--brand-gold); }

.field-error {
    margin-top: 4px;
    font-size: 10.5px;
    color: var(--s-returned-txt);
    white-space: normal;
    text-align: right;
}

/* Amount input */
.amt-inp {
    width: 96px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 4px 6px;
    font-size: 12px;
    font-family: var(--font-sans);
    text-align: right;
    background: var(--bg-card);
    color: var(--text-primary);
    outline: none;
    transition: border-color var(--transition);
}

.amt-inp:focus { border-color: var(--border-focus); }

.empty-lines {
    padding: 20px;
    text-align: center;
    color: var(--text-light);
    font-size: 13px;
}

/* ----- Workflow history ----- */
.hist-acc {
    margin: 0 14px 10px;
}

.hist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.hist-table thead th {
    background: var(--bg-page);
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    text-align: left;
}

.hist-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.hist-table tbody tr:last-child { border-bottom: none; }

.hist-table td {
    padding: 8px 10px;
    vertical-align: middle;
    text-align: left;
}

/* Remove number input spinners */
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; }

/* ----- Blazor error UI ----- */
#blazor-error-ui {
    color-scheme: light only;
    background: #FFFBEB;
    border-top: 1px solid #F59E0B;
    bottom: 0;
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 10px 20px;
    position: fixed;
    width: 100%;
    z-index: 9999;
    font-size: 13px;
    color: var(--text-primary);
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 16px;
    color: var(--text-muted);
}

#blazor-error-ui a.reload {
    margin-left: 8px;
    text-decoration: underline;
    color: var(--brand-navy);
}

/* ----- WASM loading progress ----- */
.loading-progress {
    position: absolute;
    display: block;
    width: 6rem;
    height: 6rem;
    inset: 25vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.5rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--brand-gold);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-muted);
    inset: calc(25vh + 4rem) 0 auto 0.2rem;
}

.loading-progress-text::after {
    content: var(--blazor-load-percentage-text, "Loading");
}

/* ----- Scrollbar ----- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #C5C0B8; }

/* ----- DevExpress Toast override ----- */
.dxbs-toast-container {
    z-index: 9000 !important;
}
