:root {
  color-scheme: light;
  --primary: #5c6bc0;
  --primary-hover: #4e5ba3;
  --sidebar: #484b61;
  --page: #f2f2f7;
  --ink: rgba(0, 0, 0, .87);
  --muted: #70727d;
  --line: #e8e8e8;
  --yellow: #ffee58;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { color: var(--ink); background: var(--page); font: 13px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); text-decoration: underline; }
.demo-ribbon { position: fixed; z-index: 1200; right: 14px; bottom: 12px; padding: 5px 10px; border: 1px solid #f0a08d; border-radius: 3px; color: #80311f; background: #fff1ed; box-shadow: 0 2px 8px #0002; font-size: 10px; font-weight: 800; letter-spacing: .11em; }
.bb-button { display: inline-flex; min-height: 32px; align-items: center; justify-content: center; gap: 6px; padding: 5px 11px; border: 1px solid var(--primary); border-radius: 3px; color: #fff; background: var(--primary); line-height: 1.2; white-space: nowrap; }
.bb-button:hover { border-color: var(--primary-hover); color: #fff; background: var(--primary-hover); text-decoration: none; }
.bb-button.outline { color: var(--primary); background: #fff; }
.bb-button.outline:hover { color: #fff; background: var(--primary); }
.bb-button.small { min-height: 27px; padding: 4px 9px; font-size: 12px; }
.bb-button:disabled { cursor: default; opacity: .5; }
.bb-input, .bb-select { width: 100%; min-width: 0; height: 31px; padding: 5px 8px; border: 1px solid #d8d9df; border-radius: 3px; color: #424242; background: #fff; }
.bb-input:focus, .bb-select:focus { outline: 0; border-color: #8ea5e4; box-shadow: 0 0 0 2px #5c6bc033; }
.muted { color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

/* Login */
.login-page { display: grid; min-height: 100vh; place-items: center; padding: 48px 18px; background: var(--sidebar); }
.login-stack { display: flex; width: min(100%, 470px); flex-direction: column; align-items: center; gap: 35px; }
.login-brand { display: inline-flex; align-items: center; gap: 11px; color: #fff; font-size: 39px; font-weight: 300; letter-spacing: -.045em; }
.login-brand:hover { color: #fff; text-decoration: none; }
.brightbill-glyph { width: 36px; height: 36px; flex: none; }
.login-brand .brightbill-glyph { width: 43px; height: 43px; }
.login-brand-word { color: #fff; }
.login-brand-word b { color: #ffe340; font-weight: 350; }
.login-card { width: 100%; min-height: 345px; padding: 44px 46px 38px; border-radius: 6px; background: #fff; box-shadow: 0 7px 18px #2222; text-align: center; }
.login-card h1 { margin: 0 0 25px; font-size: 25px; font-weight: 300; }
.login-card p { margin: 22px 0 0; font-size: 13px; }
.login-card p a { color: #1b73e8; }
.login-form { display: grid; gap: 20px; }
.login-form .bb-input { height: 58px; padding: 10px 13px; font-size: 14px; }
.login-form .bb-button { min-width: 120px; min-height: 54px; justify-self: center; border-radius: 30px; font-size: 13px; }
.login-step-note { margin-top: 14px !important; color: var(--muted); font-size: 12px !important; }
.login-back { margin: 1px 0 0; border: 0; color: #1b73e8; background: transparent; }

/* Shell */
.bb-shell { display: grid; min-height: 100vh; grid-template-columns: 155px minmax(0, 1fr); }
.bb-sidebar { position: sticky; top: 0; display: flex; height: 100vh; flex-direction: column; padding: 16px 9px 18px; overflow-y: auto; color: #f4f5fa; background: var(--sidebar); }
.bb-brand { display: flex; min-height: 51px; align-items: center; gap: 7px; padding: 0 6px 14px; color: #fff; font-size: 19px; font-weight: 650; letter-spacing: -.045em; white-space: nowrap; }
.bb-brand:hover { color: #fff; text-decoration: none; }
.bb-brand .brightbill-glyph { width: 27px; height: 27px; }
.bb-brand-word b { color: #ffe340; font-weight: 700; }
.bb-nav { display: flex; flex-direction: column; gap: 0; }
.bb-nav-group { margin: 14px 0 5px; padding: 0 5px; color: #dadbe1; font-size: 11px; font-weight: 750; }
.bb-nav a { display: flex; min-height: 24px; align-items: center; gap: 8px; padding: 2px 5px; border-radius: 2px; color: #e3e5ed; font-size: 12px; }
.bb-nav a:hover, .bb-nav a.active { color: #fff; background: #ffffff12; text-decoration: none; }
.nav-icon { display: inline-grid; width: 14px; flex: none; place-items: center; color: #d8dbe8; font-size: 13px; }
.nav-count { min-width: 19px; margin-left: auto; padding: 1px 5px; border-radius: 10px; color: #333; background: var(--yellow); font-size: 10px; font-weight: 800; text-align: center; }
.bb-main { min-width: 0; }
.bb-topbar { position: relative; z-index: 20; display: flex; height: 40px; align-items: center; justify-content: space-between; padding: 0 15px; background: #fff; box-shadow: 0 1px 2px #0000000b; }
.notification-globe { position: relative; width: 25px; height: 25px; border: 0; color: #52566a; background: transparent; font-size: 16px; }
.notification-count { position: absolute; top: 0; right: 0; display: grid; width: 13px; height: 13px; place-items: center; border-radius: 50%; color: #fff; background: #ef5350; font-size: 8px; font-weight: 800; }
.user-menu { position: relative; display: flex; align-items: center; gap: 8px; }
.avatar { display: grid; width: 22px; height: 22px; place-items: center; border-radius: 50%; color: #fff; background: #92949c; font-size: 9px; font-weight: 750; }
.user-toggle { display: flex; align-items: center; gap: 7px; padding: 0; border: 0; color: #555; background: transparent; }
.user-name { max-width: 145px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-dropdown { position: absolute; z-index: 30; top: calc(100% + 7px); right: 0; display: none; min-width: 170px; padding: 5px 0; border: 1px solid #ddd; border-radius: 4px; background: #fff; box-shadow: 0 4px 14px #0002; }
.user-dropdown.open { display: block; }
.user-dropdown a, .user-dropdown button { display: block; width: 100%; padding: 8px 12px; border: 0; color: #424242; background: #fff; text-align: left; }
.user-dropdown a:hover, .user-dropdown button:hover { background: #f5f5f7; text-decoration: none; }
.user-dropdown .signout { border-top: 1px solid var(--line); }
.bb-page { min-width: 0; padding: 13px 14px 34px; }
.page-heading { display: flex; min-height: 35px; align-items: center; justify-content: space-between; gap: 12px; }
.page-heading h1 { margin: 0; color: #424242; font-size: 22px; font-weight: 300; line-height: 1.25; }
.page-heading .bb-button { min-width: 170px; }
.page-rule { height: 1px; margin: 9px 0 17px; border: 0; background: #dedfe3; }
.content-card { border: 1px solid #e6e6e9; border-radius: 4px; background: #fff; box-shadow: 0 2px 5px #00000010; }
.not-available { min-height: 178px; display: grid; place-items: center; color: #777; font-size: 14px; }

/* Home */
.stat-periods { display: flex; flex-wrap: wrap; gap: 7px; margin: 0 0 13px; }
.stat-period { min-height: 29px; padding: 4px 12px; border: 1px solid var(--primary); border-radius: 3px; color: var(--primary); background: transparent; }
.stat-period.active { color: #fff; background: var(--primary); }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 13px; }
.stat-tile { min-height: 164px; padding: 18px 17px; background: #fff; }
.stat-number { display: block; margin-bottom: 15px; color: #444; font-size: 47px; font-weight: 300; line-height: 1; }
.stat-label { max-width: 115px; font-size: 15px; font-weight: 650; line-height: 1.35; }
.home-footer { margin-top: 16px; padding: 14px 2px; color: #888; font-size: 11px; }

/* Approvals */
.approval-card { overflow: hidden; }
.approval-table { min-width: 760px; }
.approval-head, .approval-row { display: grid; grid-template-columns: 205px minmax(230px, 1fr) 106px 118px 104px 126px; align-items: center; }
.approval-head { min-height: 54px; color: #333; font-weight: 700; }
.approval-head > div { padding: 5px 9px; }
.approval-head .approval-vendor-head { display: grid; align-content: center; gap: 3px; }
.approval-vendor-head .bb-input { height: 24px; padding: 3px 7px; font-size: 11px; font-weight: 400; }
.approval-head .amount-col, .approval-row .amount-col { text-align: right; }
.approval-row { min-height: 45px; border-top: 1px solid var(--line); }
.approval-row > div { min-width: 0; padding: 7px 9px; }
.approval-actions { display: flex; align-items: center; }
.approval-actions .bb-button { min-width: 50px; min-height: 23px; padding: 2px 7px; border-radius: 0; font-size: 11px; }
.approval-actions .bb-button:first-child { border-radius: 3px 0 0 3px; }
.approval-actions .bb-button:last-child { margin-left: -1px; border-radius: 0 3px 3px 0; }
.vendor-name { display: block; overflow: hidden; color: #333; text-overflow: ellipsis; white-space: nowrap; }
.vendor-memo { display: block; overflow: hidden; color: #4d4d4d; font-size: 11px; font-style: italic; text-overflow: ellipsis; white-space: nowrap; }
.approval-circle { display: grid; width: 23px; height: 23px; place-items: center; border: 2px solid #c5c9cb; border-radius: 50%; color: #63666a; font-size: 8px; font-weight: 700; }
.approval-due { color: #505050; }
.approval-total { display: flex; min-height: 48px; align-items: center; justify-content: space-between; padding: 8px 12px; border-top: 1px solid var(--line); background: #f7f7f8; }
.approval-total .bb-button { min-width: 105px; }
.approval-total strong { font-size: 12px; }
.select-all-chip { min-height: 22px; padding: 2px 7px; border: 1px solid #ddd; border-radius: 3px; color: #444; background: #f4f4f4; font-size: 10px; font-weight: 650; }
.select-all-chip.selected { color: #fff; border-color: var(--primary); background: var(--primary); }

/* Payments and lists */
.payments-tools { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 11px; }
.payments-actions, .payments-filters { display: flex; align-items: center; gap: 7px; }
.payments-actions .bb-button, .payments-filters .bb-button { min-height: 30px; }
.payments-filters .bb-input { width: min(260px, 25vw); height: 31px; }
.payments-filters .bb-select { width: 145px; height: 31px; }
.dropdown-wrap { position: relative; }
.columns-menu, .bulk-menu { position: absolute; z-index: 30; top: calc(100% + 5px); right: 0; display: none; min-width: 195px; max-height: 390px; overflow: auto; padding: 8px 10px; border: 1px solid #ddd; border-radius: 4px; background: #fff; box-shadow: 0 4px 12px #0002; }
.columns-menu.open, .bulk-menu.open { display: block; }
.columns-menu label { display: flex; align-items: center; gap: 7px; padding: 4px 1px; }
.columns-menu button, .bulk-menu button { display: block; width: 100%; padding: 6px 1px; border: 0; color: #4d4d4d; background: transparent; text-align: left; }
.table-scroll { width: 100%; overflow-x: auto; }
.payments-table { width: 100%; min-width: 1140px; border-collapse: collapse; table-layout: fixed; }
.payments-table th { height: 40px; padding: 8px 7px; border-bottom: 1px solid #e3e3e5; color: #333; background: #fbfbfc; font-size: 11px; text-align: left; white-space: nowrap; }
.payments-table td { height: 44px; padding: 6px 7px; border-bottom: 1px solid var(--line); color: #424242; font-size: 11px; vertical-align: middle; }
.payments-table tbody tr:hover { background: #fafaff; }
.payments-table .invoice-number-cell { font-weight: 650; }
.payments-table .memo-cell { color: #555; }
.payments-table .amount-cell { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.payments-table th.amount-cell { text-align: right; }
.payments-table .badge { display: inline-block; padding: 3px 6px; border-radius: 3px; color: #fff; font-size: 10px; font-weight: 650; white-space: nowrap; }
.badge-released { background: #66bb6a; }
.badge-approved { background: #5c6bc0; }
.badge-progress { background: #ffb74d; color: #333 !important; }
.badge-batched { background: #78909c; }
.badge-not-batched { color: #5c6268 !important; background: #e5e7eb; }
.payments-table .detail-button { min-height: 25px; padding: 3px 7px; border: 1px solid #8c93c7; border-radius: 3px; color: var(--primary); background: #fff; font-size: 10px; white-space: nowrap; }
.payments-table .detail-button:hover { color: #fff; background: var(--primary); }
.table-empty { padding: 26px; color: #777; text-align: center; }
.table-pager { display: flex; min-height: 49px; align-items: center; justify-content: flex-end; gap: 9px; padding: 6px 12px; color: #555; background: #fff; font-size: 11px; }
.table-pager select { height: 27px; margin-left: 4px; padding: 2px 7px; border: 1px solid #d7d7dc; border-radius: 3px; background: #fff; }
.pager-buttons { display: flex; gap: 3px; }
.pager-buttons button { min-width: 28px; height: 27px; border: 1px solid transparent; border-radius: 3px; color: #505050; background: transparent; }
.pager-buttons button:hover:not(:disabled) { border-color: #d8d8df; background: #f6f6f8; }
.pager-buttons button:disabled { color: #bbb; cursor: default; }

/* Pay and payable details */
.pay-vendor { margin-bottom: 13px; padding: 14px 15px 10px; background: #fff; }
.pay-vendor h2 { margin: 0 0 9px; color: #444; font-size: 14px; font-weight: 600; }
.pay-table { width: 100%; border-collapse: collapse; }
.pay-table th, .pay-table td { padding: 9px 8px; border-bottom: 1px solid #e8e8ed; text-align: left; }
.pay-table th:last-child, .pay-table td:last-child { text-align: right; }
.pay-vendor-total { display: flex; justify-content: flex-end; gap: 24px; padding: 10px 8px 3px; font-size: 11px; }
.pay-action-row { display: flex; justify-content: flex-end; padding: 12px 0 4px; }
.payable-header { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.payable-header h2 { margin: 0; font-size: 18px; font-weight: 600; }
.payable-summary { padding: 16px 18px; }
.payable-fields { display: grid; grid-template-columns: minmax(250px, 1fr) minmax(250px, 1fr); column-gap: 35px; }
.payable-field { display: grid; min-height: 34px; grid-template-columns: minmax(160px, 45%) minmax(0, 1fr); align-items: center; gap: 10px; border-bottom: 1px solid #f0f0f2; }
.payable-field strong { color: #3f3f3f; font-size: 12px; }
.payable-field span { overflow-wrap: anywhere; color: #555; }
.payable-section { margin-top: 20px; }
.payable-section h3 { margin: 0 0 9px; padding-bottom: 7px; border-bottom: 1px solid #e5e5e8; color: #454545; font-size: 16px; font-weight: 550; }
.line-items { width: 100%; border-collapse: collapse; }
.line-items th, .line-items td { padding: 9px 8px; border-bottom: 1px solid #e8e8e8; text-align: left; }
.line-items th { font-weight: 650; }
.line-items th:last-child, .line-items td:last-child { text-align: right; }
.attachment-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.attachment-viewer { display: flex; width: 100%; height: min(74vh, 720px); min-height: 460px; flex-direction: column; overflow: hidden; border: 1px solid #cfd2d7; background: #38393a; }
.attachment-viewer iframe { display: block; width: 100%; height: 100%; border: 0; background: #555; }
.attachment-empty { display: grid; min-height: 220px; place-items: center; color: #666; background: #fafafa; font-size: 14px; }
.audit-stack { display: grid; grid-template-columns: repeat(3, minmax(190px, 1fr)); gap: 9px; }
.audit-card { min-height: 100px; padding: 14px 15px; border: 1px solid #e7e7e7; border-radius: 4px; color: #666; background: #f4f4f5; }
.audit-card strong { display: block; margin-bottom: 5px; color: #4b4b4b; font-weight: 600; }
.recent-table { width: 100%; border-collapse: collapse; }
.recent-table th, .recent-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; }

/* Dialogs and notices */
.bb-dialog { width: min(470px, calc(100vw - 24px)); max-height: 90vh; padding: 0; overflow: hidden; border: 1px solid #d7d7dc; border-radius: 5px; background: #fff; box-shadow: 0 12px 38px #0003; }
.bb-dialog::backdrop { background: #0007; }
.bill-dialog { width: min(470px, calc(100vw - 24px)); height: min(90vh, 850px); }
.dialog-head { display: flex; min-height: 43px; align-items: center; justify-content: space-between; gap: 6px; padding: 7px 10px; border-bottom: 1px solid var(--line); }
.dialog-head button { min-height: 26px; padding: 3px 9px; border: 1px solid var(--primary); border-radius: 3px; color: var(--primary); background: #fff; font-size: 11px; }
.dialog-head button.active { color: #fff; background: var(--primary); }
.dialog-body { padding: 13px; }
.bill-open-link { display: inline-block; margin: 8px 10px; padding: 4px 8px; border-radius: 3px; color: #fff; background: var(--primary); font-size: 11px; font-style: italic; }
.approval-viewer-host { height: calc(100% - 94px); margin: 0 10px 10px; background: #555; }
.approval-pdf { display: block; width: 100%; height: 100%; border: 0; background: #555; }
.reject-copy { margin-bottom: 13px; color: #555; }
.reject-copy em { color: #777; }
.reject-form label { display: block; margin: 11px 0 5px; font-weight: 650; }
.reject-form input { width: 100%; height: 32px; padding: 5px 8px; border: 1px solid #cfd1d7; border-radius: 3px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 7px; padding: 10px 13px; border-top: 1px solid var(--line); }
.toast { position: fixed; z-index: 1250; right: 22px; bottom: 49px; padding: 10px 15px; border-radius: 4px; color: #fff; background: #34363d; box-shadow: 0 4px 15px #0003; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .15s, transform .15s; }
.toast.visible { opacity: 1; transform: translateY(0); }

@media (max-width: 1050px) {
  .approval-head, .approval-row { grid-template-columns: 150px minmax(220px, 1fr) 82px 100px 92px 108px; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .payments-tools { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 760px) {
  .bb-shell { grid-template-columns: 64px minmax(0, 1fr); }
  .bb-sidebar { align-items: center; padding-right: 5px; padding-left: 5px; }
  .bb-brand { justify-content: center; padding: 2px 0 14px; }
  .bb-brand-word, .bb-nav-group, .bb-nav a .nav-label, .nav-count { display: none; }
  .bb-nav { width: 100%; align-items: center; }
  .bb-nav a { width: 35px; min-height: 34px; justify-content: center; padding: 2px; }
  .nav-icon { width: auto; font-size: 16px; }
  .bb-page { padding: 11px 10px 30px; }
  .page-heading h1 { font-size: 20px; }
  .page-heading .bb-button { min-width: 0; }
  .payments-filters { width: 100%; }
  .payments-filters .bb-input { width: auto; flex: 1; }
  .payments-filters .bb-select { width: 125px; }
  .payable-fields { grid-template-columns: 1fr; }
  .audit-stack { grid-template-columns: 1fr; }
}
@media (max-width: 520px) {
  .login-page { padding: 34px 14px; }
  .login-stack { gap: 24px; }
  .login-brand { font-size: 28px; }
  .login-card { min-height: 315px; padding: 35px 19px 28px; }
  .bb-topbar { padding: 0 9px; }
  .page-heading { align-items: flex-start; }
  .page-heading .bb-button { min-height: 29px; padding: 4px 7px; font-size: 11px; }
  .stat-grid { gap: 8px; }
  .stat-tile { min-height: 137px; padding: 14px 12px; }
  .stat-number { font-size: 39px; }
  .stat-label { font-size: 13px; }
  .payments-actions { flex-wrap: wrap; }
  .payments-filters { flex-wrap: wrap; }
  .payments-filters .bb-input { width: 100%; flex-basis: 100%; }
  .payable-summary { padding: 12px 10px; }
  .payable-field { grid-template-columns: 132px minmax(0, 1fr); gap: 6px; }
  .attachment-viewer { min-height: 350px; height: 60vh; }
}
