/* Shared visual system. Layout and feature-specific rules live in app.css. */
:root {
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --canvas: #f5f7fb;
  --surface: #fff;
  --surface-subtle: #f8fafc;
  --line: #e2e8f0;
  --line-dark: #cbd5e1;
  --radius: 12px;
  --radius-lg: 14px;
  --radius-xl: 16px;
  --sidebar-width: 240px;
  --motion-fast: 160ms ease-out;
  --motion-base: 220ms ease-out;
  --motion-smooth: 280ms ease-out;
}

body { font-size: 14px; line-height: 1.55; }
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
html { scrollbar-gutter: stable; }
.app-shell { background: var(--canvas); }
h1 { font-size: clamp(23px, 2vw, 28px); font-weight: 700; letter-spacing: -0.035em; line-height: 1.3; text-wrap: balance; }
h2 { font-size: 17px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; }
h3 { font-size: 15px; line-height: 1.45; }
.eyebrow { color: var(--slate-600); font-size: 12px; font-weight: 600; letter-spacing: 0.04em; }
small, .field-help { line-height: 1.5; }
.page-content { width: min(1440px, 100%); padding: 16px clamp(16px, 2.5vw, 36px) 28px; }
.page-heading { align-items: center; gap: 12px 20px; margin-bottom: 14px; }
.page-heading h1 { margin-bottom: 0; }
.page-heading > div:first-child { min-width: 0; max-width: none; }
.page-heading .eyebrow { margin-bottom: 6px; }
.expense-list-heading .project-expense-actions { display: grid; grid-template-columns: 120px 152px; gap: 12px; flex: 0 0 auto; }
.expense-list-heading .project-expense-actions .button { width: 100%; min-height: 44px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.expense-list-overview .project-bulk-delete-button { margin-left: auto; }
@media (min-width: 1101px) {
  .expense-list-heading .project-expense-actions { align-self: flex-start; }
  .project-page-heading .project-expense-actions { position: static; align-self: center; }
}
@media (max-width: 1100px) {
  .expense-list-heading { flex-direction: column; align-items: stretch; }
  .expense-list-heading .project-expense-actions { align-self: flex-end; }
}
@media (max-width: 600px) {
  .expense-list-heading .project-expense-actions { width: 100%; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
}
.finance-processing-tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.finance-processing-tabs a { display: inline-flex; align-items: center; gap: 6px; min-height: 44px; padding: 10px 16px; border-bottom: 3px solid transparent; color: var(--slate-600); text-decoration: none; }
.finance-processing-tabs a:hover { background: var(--surface-subtle); color: var(--slate-900); }
.finance-processing-tabs a[aria-current="page"] { border-bottom-color: var(--slate-900); color: var(--slate-900); font-weight: 600; }
.finance-processing-tabs a:focus-visible { outline: 2px solid var(--primary-500); outline-offset: 2px; }
.panel, .expense-list-panel { border-radius: var(--radius-lg); box-shadow: var(--shadow-xs); }

/* Quiet navigation and one clear page title in the content area. */
.sidebar { padding: 24px 16px 16px; background: var(--slate-900); box-shadow: none; }
.sidebar, .sidebar .main-nav { color-scheme: dark; scrollbar-width: thin; scrollbar-color: var(--slate-600) var(--slate-900); }
.sidebar::-webkit-scrollbar, .sidebar .main-nav::-webkit-scrollbar { width: 6px; height: 6px; }
.sidebar::-webkit-scrollbar-track, .sidebar .main-nav::-webkit-scrollbar-track { background: var(--slate-900); }
.sidebar::-webkit-scrollbar-thumb, .sidebar .main-nav::-webkit-scrollbar-thumb { background: var(--slate-600); border-radius: 8px; }
.sidebar::-webkit-scrollbar-thumb:hover, .sidebar .main-nav::-webkit-scrollbar-thumb:hover { background: var(--slate-500); }
.sidebar::-webkit-scrollbar-corner, .sidebar .main-nav::-webkit-scrollbar-corner { background: var(--slate-900); }
.sidebar .brand { min-height: 44px; padding-inline: 12px; }
.sidebar .brand-logo { display: block; width: 184px; max-width: 100%; height: 40px; object-fit: cover; object-position: center; }
.main-nav { margin-top: 24px; }
.nav-label { color: var(--slate-400); font-size: 11px; letter-spacing: 0.08em; }
.nav-group-toggle { min-height: 44px; border-radius: 4px; font-size: 14px; font-weight: 500; }
.nav-group.is-open > .nav-group-toggle { color: var(--slate-50); background: transparent; }
.nav-group-toggle:hover, .nav-group.is-open > .nav-group-toggle:hover { background: rgba(255, 255, 255, 0.05); }
.nav-group-panel { margin-left: 8px; padding-left: 8px; border-left: 0; }
.nav-link { min-height: 44px; border-radius: 4px; font-size: 13px; font-weight: 500; }
.nav-link.active, .nav-group-panel .nav-link.active { color: var(--primary-100); background: rgba(59, 130, 246, 0.14); border-left: 0; box-shadow: none; font-weight: 600; }
.nav-group-panel .nav-link.active::before { content: none; }
.nav-placeholder { font-size: 12px; }
.topbar { background: var(--surface); backdrop-filter: none; -webkit-backdrop-filter: none; box-shadow: none; }
.topbar-title { color: var(--slate-600); font-size: 14px; font-weight: 500; }
.topbar-user-status { padding: 0; border: 0; background: transparent; box-shadow: none; gap: 12px; font-size: 12px; }
.topbar-role { padding: 5px 9px; color: var(--slate-600); background: var(--slate-100); font-size: 12px; font-weight: 500; letter-spacing: 0; }
.company-dot::after { content: none; }
.sidebar-user .user-copy strong { font-size: 13px; }
.sidebar-user .user-copy small { color: var(--slate-400); font-size: 12px; }
.app-footer { color: var(--slate-600); font-size: 12px; }

/* Stable controls: feedback changes color without moving the target. */
.button { min-height: 44px; padding-inline: 16px; font-size: 13px; font-weight: 600; transition: background-color var(--motion-fast), border-color var(--motion-fast), color var(--motion-fast), box-shadow var(--motion-fast); }
.button-primary { color: #fff; background: var(--primary-600); box-shadow: none; }
.button-primary:hover:not(:disabled) { background: var(--primary-700); transform: none; box-shadow: none; }
.button-secondary, .button-back { color: var(--slate-700); border-color: var(--line-dark); background: var(--surface); box-shadow: none; }
.button-secondary:hover, .button-back:hover { color: var(--slate-900); border-color: var(--slate-400); background: var(--slate-50); }
.button-success { background: var(--emerald-700); box-shadow: none; }
.button-success:hover:not(:disabled) { background: #065f46; transform: none; box-shadow: none; }
.button-warning { background: var(--primary-600); box-shadow: none; }
.button-warning:hover:not(:disabled) { background: var(--primary-700); transform: none; box-shadow: none; }
.button-danger { background: var(--rose-700); box-shadow: none; }
.button-danger:hover:not(:disabled) { background: #9f1239; transform: none; box-shadow: none; }
.button-lg { min-height: 46px; font-size: 14px; }
input:not([type='checkbox']):not([type='radio']):not([type='hidden']), select, textarea {
  border-color: var(--line-dark);
  border-radius: var(--radius-sm);
  font-size: 14px;
  transition: border-color var(--motion-fast), box-shadow var(--motion-fast), background-color var(--motion-fast);
}
.field input:not([type='checkbox']):not([type='radio']), .field select { min-height: 44px; }
input::placeholder, textarea::placeholder { color: var(--slate-500); opacity: 1; }
.field label, .field legend { font-size: 13px; font-weight: 600; }
.field-help, .label-row > span { color: var(--slate-600); font-size: 12px; }
.field-help.danger-text { color: var(--rose-700); }

/* Two equal columns at wide widths, one readable column on smaller screens. */
.expense-form-shell { max-width: 1120px; }
.expense-form-heading { margin-bottom: 14px; }
.expense-form-heading h1 { margin-bottom: 6px; }
.required-note { margin: 0; color: var(--slate-600); font-size: 12px; }
.required-note b { color: var(--rose-700); }
.expense-layout { gap: 20px; align-items: start; }
.expense-layout .form-panel { padding: 24px; }
.form-section-heading { margin-bottom: 24px; gap: 10px; }
.form-section-heading > span { width: 28px; height: 28px; background: var(--primary-50); color: var(--primary-700); border: 1px solid var(--primary-100); font-size: 13px; font-weight: 600; }
.form-section-heading h2 { margin: 0; }
.expense-layout .stack-form { display: grid; gap: 18px; }
.expense-layout .stack-form > .field { margin-bottom: 0; }
.check-card { padding: 14px; border-width: 1px; border-radius: var(--radius-sm); box-shadow: none; transition: border-color var(--motion-fast), background-color var(--motion-fast); }
.check-card:has(input:checked), .check-card.is-checked { border-color: #a7f3d0; background: var(--emerald-50); box-shadow: none; }
.budget-confirmation-title { margin: 0; gap: 8px; }
.budget-confirmation-title strong { font-size: 13px; font-weight: 600; }
.status-badge { padding: 5px 8px; font-size: 12px; line-height: 1.2; font-weight: 500; transition: color var(--motion-fast), background-color var(--motion-fast); }
.status-badge.status-unchecked { color: var(--slate-600); background: var(--slate-100); border-color: var(--line); }
.status.status-closed { color: var(--rose-700); background: var(--rose-50); border-color: var(--rose-100); }
.status.status-closed::before { background: var(--rose-500); }
.expense-form-shell { overflow-anchor: none; }
.allocation-list { display: block; margin-bottom: 4px; }
.allocation-entry { display: flow-root; }
.allocation-card { padding: 10px 12px 12px; margin-bottom: 10px; border-radius: 10px; background: var(--surface-subtle); transition: border-color var(--motion-fast), background-color var(--motion-fast); }
.allocation-card:not(.is-collapsed) { border-color: var(--primary-200); }
.allocation-card header { margin-bottom: 0; }
.allocation-card header strong { font-size: 13px; font-weight: 600; }
.allocation-card > header { align-items: center; gap: 8px; }
.allocation-toggle { display: flex; flex: 1; align-items: center; gap: 8px; min-width: 0; min-height: 44px; padding: 0; border: 0; background: transparent; color: var(--slate-800); text-align: left; cursor: pointer; }
.allocation-number { flex: 0 0 auto; white-space: nowrap; }
.allocation-header-amount { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.allocation-toggle-action { display: inline-flex; flex: 0 0 28px; margin-left: auto; justify-content: center; align-items: center; min-height: 28px; border-radius: 6px; color: var(--slate-500); transition: background-color var(--motion-fast), color var(--motion-fast); }
.allocation-summary { display: flex; flex: 1; min-width: 0; align-items: center; justify-content: flex-end; gap: 8px; margin: 0; color: var(--slate-600); font-size: 11px; line-height: 1.5; font-variant-numeric: tabular-nums; white-space: nowrap; }
.allocation-summary[hidden] { display: none; }
.allocation-summary [data-allocation-summary-dates] { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.allocation-summary-dxc { flex: 0 0 auto; padding: 1px 5px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface); }
.allocation-summary-dxc.is-complete { color: var(--primary-700); border-color: var(--primary-200); background: var(--primary-50); }
.allocation-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(225deg) translateY(-2px); }
.allocation-toggle:hover .allocation-toggle-action { color: var(--primary-700); background: var(--primary-50); border-color: var(--primary-200); }
.allocation-toggle:active .allocation-toggle-action { background: var(--slate-100); }
.allocation-toggle:focus-visible { outline: 2px solid var(--primary-600); outline-offset: 4px; border-radius: var(--radius-sm); }
.allocation-body[hidden] { display: none; }
.allocation-body.is-animating, .allocation-entry.is-animating { overflow: hidden; }
.allocation-remove { flex: 0 0 44px; width: 44px; height: 44px; padding: 0; display: grid; place-items: center; border: 0; border-radius: 6px; color: var(--slate-500); background: transparent; cursor: pointer; transition: color var(--motion-fast), background-color var(--motion-fast); }
.allocation-remove svg { width: 15px; height: 15px; }
.allocation-remove:hover { color: var(--rose-600); border-color: var(--rose-100); background: var(--rose-50); }
.allocation-remove:active { background: var(--rose-100); }
.allocation-remove:focus-visible { outline: 2px solid var(--rose-600); outline-offset: 3px; }
.allocation-card-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; padding-top: 12px; }
.allocation-card-grid .field { min-width: 0; margin: 0; }
.allocation-card-grid .field-purpose { grid-column: 1 / -1; grid-row: 1; }
.allocation-card-grid .field-range { grid-column: 1 / -1; }
.allocation-card-grid .field-amount { grid-column: 1; grid-row: 2; }
.allocation-card-grid .field-amount > label { line-height: 20px; }
.allocation-card-grid .allocation-dxc { grid-column: 2; grid-row: 2; align-self: start; margin-top: 26px; }
.allocation-dxc .check-card { margin: 0; min-height: 44px; padding: 8px 10px; }
.allocation-dxc .budget-confirmation-title { gap: 6px; }
.allocation-dxc .status-badge { padding: 3px 5px; }
.allocation-card-grid input { width: 100%; min-width: 0; }
.allocation-add { width: 100%; min-height: 44px; }
.allocation-notice { display: flex; align-items: flex-start; gap: 8px; margin: 12px 0; padding: 10px 12px; border: 1px solid #fde68a; border-radius: 8px; color: #92400e; background: #fffbeb; font-size: 13px; line-height: 1.5; }
.allocation-notice[hidden] { display: none; }
.allocation-notice .ui-icon { flex: 0 0 18px; width: 18px; height: 18px; margin-top: 1px; }
.payment-range-input { display: flex; align-items: center; min-width: 0; border: 1px solid var(--line-dark); border-radius: var(--radius-sm); background: var(--surface); }
.payment-range-input:focus-within { border-color: var(--primary-500); box-shadow: 0 0 0 3px var(--primary-100); }
.allocation-card-grid .payment-range-input input, .project-range-field .payment-range-input input { flex: 1; width: 0; padding: 10px 12px; border: 0; box-shadow: none; background: transparent; font-size: 13px; font-variant-numeric: tabular-nums; }
.payment-range-input button { flex: 0 0 44px; display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: var(--radius-sm); background: transparent; color: var(--slate-500); cursor: pointer; }
.payment-range-input button:hover { color: var(--primary-700); background: var(--primary-50); }
.payment-range-input button:focus-visible { outline: 2px solid var(--primary-600); outline-offset: -3px; }
.range-time-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.range-time-fields[hidden] { display: none; }
dialog.payment-range-dialog { width: min(392px, calc(100vw - 24px)); }
.payment-range-dialog > header, .payment-range-dialog > footer { padding: 16px 20px; }
.payment-range-dialog > .dialog-body { padding: 12px 16px; }
.payment-range-dialog header h2 { font-size: 16px; }
.payment-range-dialog header p { margin: 4px 0 0; color: var(--slate-500); font-size: 12px; }
.range-calendar-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.range-calendar-nav button { display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 8px; background: transparent; color: var(--slate-600); cursor: pointer; }
.range-calendar-nav button:hover:not(:disabled) { background: var(--slate-100); }
.range-calendar-nav button:disabled { opacity: 0.3; cursor: default; }
.range-weekdays, .range-calendar-days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.range-weekdays { padding: 4px 0; font-size: 11px; color: var(--slate-500); }
.range-calendar-days button, .range-calendar-days > span { min-height: 42px; }
.range-calendar-days button { padding: 0; border: 0; border-radius: 6px; background: transparent; color: var(--slate-700); font-size: 13px; font-variant-numeric: tabular-nums; cursor: pointer; }
.range-calendar-days button:disabled { color: var(--slate-300); cursor: default; }
.range-calendar-days button:hover:not(:disabled) { background: var(--primary-100); }
.range-calendar-days button.is-between { border-radius: 0; background: var(--primary-50); color: var(--primary-800); }
.range-calendar-days button.is-selected, .range-calendar-days button.is-selected:hover { background: var(--primary-600); color: white; }
.range-calendar-days button:focus-visible, .range-calendar-nav button:focus-visible { outline: 2px solid var(--primary-600); outline-offset: -3px; }
.range-selection { min-height: 22px; margin: 12px 0 0; text-align: center; color: var(--slate-600); font-size: 12px; font-variant-numeric: tabular-nums; }
.reason-panel, .form-submit-bar { grid-column: 1 / -1; }
.form-submit-bar { margin: 0; padding: 18px 24px; background: var(--surface); backdrop-filter: none; box-shadow: var(--shadow-md); }
.form-submit-bar > div:first-child > span { color: var(--slate-600); font-size: 12px; }
.form-submit-bar > div:first-child > strong { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }

/* Filters and data share a restrained type scale and neutral surfaces. */
.expense-list-toolbar { grid-template-columns: minmax(180px, 0.85fr) minmax(0, 2fr); align-items: end; gap: 10px 16px; padding: 12px 16px; }
.expense-list-toolbar.expense-search-only { grid-template-columns: minmax(0, 1fr); }
.project-expense-filters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.project-expense-filters .field { min-width: 0; margin: 0; }
.project-expense-filters select { width: 100%; }
.expense-list-overview { border-top: 1px solid var(--line); padding-top: 8px; min-height: 36px; align-items: center; gap: 12px; flex-wrap: wrap; white-space: normal; }
.expense-list-overview > div { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: 4px 8px; padding: 0 12px 0 0; }
.expense-list-overview .project-bulk-delete-button { min-height: 36px; padding: 6px 12px; }
.expense-list-toolbar .field > label { margin-bottom: 4px; line-height: 1.4; }
.expense-list-toolbar input[type=search], .expense-list-toolbar select { height: 40px; min-height: 40px; margin-bottom: 0; }
.team-panel > .panel-heading, .project-directory > .panel-heading { padding: 12px 16px; gap: 8px 16px; flex-wrap: wrap; }
.team-filter, .project-filter-bar { padding: 10px 16px; }
.project-sort-filter { min-width:0; }
@media(min-width:761px) { .project-filter-bar { grid-template-columns:minmax(180px,2fr) repeat(2,minmax(140px,1fr)); } }
.team-filter { grid-template-columns: minmax(0, 2fr) minmax(180px, 1fr); }
.clear-expense-filters { margin-left: auto; }
.expense-list-overview span { color: var(--slate-600); font-size: 12px; font-weight: 400; letter-spacing: 0; text-transform: none; }
.expense-list-overview strong { font-size: 14px; font-weight: 600; }
.data-table th, .project-table th, .expense-modal-table th { background: var(--slate-50); color: var(--slate-600); font-size: 12px; font-weight: 600; letter-spacing: 0; text-transform: none; }
.data-table td { font-size: 14px; line-height: 1.5; }
.project-expense-panel .expense-modal-table-wrap { position: relative; contain: inline-size; }
.data-table .person-cell small, .data-table .import-person-cell small, .record-card footer > small { font-size: 12px; color: var(--slate-600); }
.data-table .status-badge, .data-table .role-tag, .data-table .active-dot { font-size: 12px; }
.data-table .button { font-size: 12px; }
.project-name-cell { padding-right: 18px !important; }
.project-row-hint { display: none; }
.project-table { table-layout: fixed; }
.project-code-column { width: 12%; }
.project-name-column { width: 38%; }
.project-responsible-column { width: 22%; }
.project-count-column { width: 12%; }
.project-money-column { width: 16%; }
.project-status-column { width: 150px; }
.project-table:has(.project-status-column) .project-name-column { width: 28%; }
.accounting-status-filter { flex: 0 1 210px; width: 210px; min-width: 150px; margin: 0; }
@media (max-width: 600px) {
  .expense-list-search:has(.accounting-status-filter) { flex-wrap: wrap; }
  .expense-list-search:has(.accounting-status-filter) .input-icon-wrap { flex-basis: 100%; }
  .accounting-status-filter { flex-basis: 100%; width: 100%; }
}
.project-table .project-row-responsible { color: var(--slate-700); white-space: normal; overflow-wrap: anywhere; }
@media (max-width: 1100px) {
  .project-row-responsible::before { content: 'Người phụ trách: '; color: var(--slate-500); font-size: 12px; }
}
.money-cell, .project-row-money, .allocation-amount { font-variant-numeric: tabular-nums; } .stat-card { box-shadow: none; transition: border-color var(--motion-fast), box-shadow var(--motion-fast); } .stat-card:hover { transform: none; border-color: var(--line-dark); box-shadow: var(--shadow-sm); }
.detail-grid dt { color: var(--slate-600); font-size: 12px; font-weight: 500; text-transform: none; letter-spacing: 0; }
.detail-grid dd { font-size: 14px; overflow-wrap: anywhere; }
.detail-total { background: var(--slate-50); }

/* Compact record detail: information and payments beside the review controls. */
.page-back-link { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; width: fit-content; color: var(--slate-600); font-size: 13px; font-weight: 500; border-radius: var(--radius-sm); transition: color var(--motion-fast); }
.page-back-link:hover { color: var(--primary-700); }
.page-back-link .button-icon { width: 16px; height: 16px; }
.project-page-heading { display: grid; grid-template-columns: minmax(0, 1fr) auto; position: relative; padding-top: 0; align-items: center; gap: 8px 20px; }
.project-page-heading > div:first-child { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: baseline; gap: 4px 12px; }
.project-page-heading .page-back-link { position: static; grid-column: 1 / -1; min-height: 28px; margin-bottom: 2px; }
.project-page-heading .eyebrow { margin: 0; overflow-wrap: anywhere; }
.project-page-heading h1 { margin: 0; font-size: clamp(22px, 2vw, 26px); overflow-wrap: anywhere; }
.project-page-heading .project-expense-period { grid-column: 1 / -1; gap: 4px 16px; margin-top: 0; font-size: 12px; }
.project-page-heading .project-expense-period span { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.project-page-heading .project-expense-actions { position: static; align-self: center; }
.expense-detail-shell { max-width: 1120px; }
.detail-action-bar { margin-bottom: 8px; gap: 8px 16px; }
.detail-heading { padding: 14px 24px; }
.detail-heading h1 { margin: 0; font-size: clamp(21px, 2vw, 26px); }
.detail-heading .eyebrow { margin-bottom: 6px; }
.detail-updated { margin: 8px 0 0; color: var(--slate-600); font-size: 12px; }
.detail-content-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(290px, 0.65fr); align-items: start; }
.detail-main-content { min-width: 0; border-right: 1px solid var(--line); }
.detail-workflow-column { min-width: 0; padding: 20px; }
.detail-panel .panel-heading { padding: 18px 24px 12px; gap: 10px; border-bottom: 0; }
.detail-panel h2 { font-size: 15px; }
.detail-grid { padding: 0 24px 18px; column-gap: 20px; }
.detail-grid > div { padding: 10px 0; }
.detail-grid .detail-field-wide { grid-column: 1 / -1; }
.detail-grid dd { line-height: 1.5; font-weight: 500; }
.detail-grid dt { margin-bottom: 4px; }
.detail-grid dd small { display: inline; margin-left: 8px; font-size: 12px; }
.detail-description { white-space: pre-wrap; }
.detail-panel .allocation-table { padding: 0 24px 18px; gap: 8px; }
.detail-main-content .allocation-main { grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; }
.detail-main-content .allocation-index { display: none; }
.detail-main-content .allocation-date-info { justify-content: flex-start; text-align: left; }
.detail-main-content .allocation-amount { font-size: 14px; font-weight: 600; }
.detail-main-content .allocation-purpose { padding-left: 0; font-size: 13px; }
.detail-total { padding: 16px 24px; border-top: 1px solid var(--line); }
.detail-total span { font-size: 13px; font-weight: 500; }
.detail-total strong { font-size: 24px; font-weight: 700; }
.detail-panel .finance-workflow { border: 1px solid var(--line); border-radius: var(--radius); background: var(--slate-50); overflow: hidden; }
.detail-panel .finance-workflow .panel-heading { padding: 16px; align-items: flex-start; border-bottom: 1px solid var(--line); }
.finance-workflow .panel-heading > div { flex: 1 1 100%; }
.finance-workflow .panel-heading p { margin: 6px 0 0; font-size: 12px; line-height: 1.5; }
.finance-workflow-body { padding: 16px; }
.finance-workflow-body:empty { display: none; }
.finance-workflow-body > p { margin: 0 0 12px; font-size: 12px; color: var(--slate-600); overflow-wrap: anywhere; }
.finance-workflow .stack-form { display: grid; gap: 12px; margin: 0; }
.finance-workflow .stack-form .field { margin: 0; }
.finance-workflow .stack-form > p { margin: 0; font-size: 12px; color: var(--slate-600); }
.finance-workflow .stack-form textarea { width: 100%; min-height: 100px; background: var(--surface); }
.finance-workflow .stack-form > .button { width: 100%; white-space: normal; line-height: 1.4; padding-block: 10px; }
.finance-workflow-actions { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.finance-workflow-actions .button { width: 100%; white-space: normal; line-height: 1.4; padding-block: 10px; }
.finance-request-note { padding: 12px; margin: 0 0 14px; border: 1px solid var(--amber-200); background: var(--amber-50); }
.finance-request-note strong { font-size: 13px; }
.finance-request-note p { margin: 6px 0 0; font-size: 12px; }
.status-badge.status-pending { color: #854d0e; background: var(--amber-100); border: 1px solid var(--amber-200); }
.finance-request-meta { color: var(--slate-600); }
.finance-request-note .finance-request-reason { margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--amber-200); color: var(--slate-800); font-size: 13px; line-height: 1.6; }
.finance-request-rejected { border-color: var(--line-dark); background: var(--surface); }
.finance-workflow .finance-rejection-form { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.button.finance-confirm-button { color: var(--surface); background: var(--emerald-700); border-color: var(--emerald-700); box-shadow: none; }
.button.finance-confirm-button:hover:not(:disabled) { color: var(--surface); background: color-mix(in srgb, var(--emerald-700) 88%, var(--slate-950)); border-color: var(--emerald-700); box-shadow: none; transform: none; }
.button.finance-confirm-button:focus-visible { outline-color: var(--emerald-600); }
.button.finance-reopen-button { color: var(--amber-700); background: var(--amber-50); border-color: var(--amber-300); box-shadow: none; }
.button.finance-reopen-button:hover:not(:disabled) { color: var(--amber-700); background: var(--amber-100); border-color: var(--amber-500); box-shadow: none; transform: none; }
.button.finance-confirm-button:disabled, .button.finance-reopen-button:disabled { color: var(--slate-500); background: var(--slate-100); border-color: var(--line); opacity: 1; box-shadow: none; }
.finance-reopen-button:focus-visible { outline-color: var(--amber-600); }
.workbook-preview .excel-cell.excel-pending-cell { color: #854d0e; background: var(--amber-100); font-weight: 600; text-align: center; }
.workbook-preview .excel-unconfirmed-cell { color: var(--slate-600); background: var(--slate-100) !important; }
.report-sheet-tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.report-sheet-tabs button { min-height: 44px; padding: 8px 12px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--slate-600); font: inherit; font-size: 12px; }
.report-sheet-tabs button[aria-pressed='true'] { border-bottom-color: #17365d; background: var(--surface); color: #17365d; font-weight: 600; }
.workbook-sheet-name { color: #17365d; border-bottom-color: #17365d; }
.workbook-preview .excel-cell { font-family: 'Times New Roman', serif; font-size: 15px; color: #1e293b; }
.workbook-preview .report-preview-title { height: 59px; font-size: 27px; font-weight: 700; color: #17365d; white-space: normal; }
.workbook-preview .report-preview-context { height: 30px; color: var(--slate-600); white-space: normal; }
.workbook-preview .report-preview-totals .excel-cell { background: #eaf1f8; color: #17365d; font-weight: 700; }
.workbook-preview .excel-data-heading { background: #dce6f1; color: #17365d; }
.workbook-preview .excel-alt-row .excel-cell { background: #f5f8fc; }
.workbook-preview .excel-blank-row .excel-cell { height: 11px; padding-block: 0; }
.workbook-preview .report-preview-text { white-space: normal; overflow-wrap: anywhere; }
.workbook-preview .report-template-grid .report-template-title { text-align: center; }
.workbook-preview .report-template-total.excel-number-cell { font-weight: 700; }
dialog.app-dialog.export-preview-dialog[open] { display: flex; flex-direction: column; width: min(1560px, calc(100% - 24px)); max-width: calc(100% - 24px); height: min(820px, calc(100dvh - 24px)); max-height: calc(100dvh - 24px); border: 1px solid var(--line-dark); border-radius: 10px; }
dialog.app-dialog.export-preview-dialog > header { flex: 0 0 auto; min-height: 48px; padding: 6px 14px; gap: 16px; border-bottom: 1px solid var(--line); }
dialog.app-dialog.export-preview-dialog header h2 { margin: 0; color: var(--slate-800); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
dialog.app-dialog.export-preview-dialog > .export-preview-body { flex: 1 1 auto; min-height: 0; max-height: none; padding: 0; overflow: hidden; background: var(--surface); }
.export-detail-content { display: flex; flex-direction: column; height: 100%; min-height: 0; min-width: 0; }
.export-detail-content > .export-results-summary { flex: 0 0 auto; margin: 0; padding: 6px 14px; }
.export-detail-scroll { flex: 1 1 0; min-height: 0; min-width: 0; overflow: auto; overscroll-behavior: contain; scrollbar-width: auto; scrollbar-color: #bac7d6 #f8fafc; scrollbar-gutter: stable; }
dialog.app-dialog.export-preview-dialog.is-expanded[open] { width: calc(100vw - 12px); max-width: calc(100vw - 12px); height: calc(100dvh - 12px); max-height: calc(100dvh - 12px); }
.export-window-actions { display: flex; align-items: center; flex: 0 0 auto; gap: 8px; }
.export-window-actions .button { min-height: 36px; padding: 6px 10px; font-size: 12px; white-space: nowrap; }
.export-window-close { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--slate-600); cursor: pointer; }
.export-window-close:hover { background: var(--slate-100); }
.export-window-close svg { width: 18px; height: 18px; }
.export-detail-scroll:focus-visible { outline: 2px solid var(--primary-500); outline-offset: -2px; }
dialog.app-dialog > form.export-filters { display: grid; grid-template-columns: minmax(160px, 1.2fr) minmax(160px, 1.2fr) minmax(145px, 1fr) minmax(200px, 1.3fr) max-content; flex: 0 0 auto; align-items: end; gap: 12px; padding: 12px 14px; margin: 0; border-bottom: 1px solid #dce5ef; background: #f8fafc; position: relative; z-index: 4; }
dialog.app-dialog > form.export-filters:has(> .export-project-field[hidden]) { grid-template-columns: minmax(160px, 1.2fr) minmax(145px, 1fr) minmax(200px, 1.3fr) max-content; }
.export-date-range { display: grid; grid-template-columns: minmax(0, 1fr); gap: 6px; min-width: 0; margin: 0; padding: 0; border: 0; }
.export-date-range > label { margin: 0; color: #526780; font-size: 12px; font-weight: 600; line-height: 1.4; }
.export-filters .payment-range-input { height: 40px; box-sizing: border-box; }
.export-filters .payment-range-input input[data-payment-range] { flex: 1; width: 0; min-width: 0; height: 38px; min-height: 38px; border: 0; background: transparent; box-shadow: none; }
.export-filters .payment-range-input button { width: 40px; height: 38px; flex-basis: 40px; }
.export-filters .payment-range-input button svg { width: 16px; height: 16px; }
.export-filter-reset { justify-self: end; width: max-content; min-height: 40px; height: 40px; padding: 8px 12px; white-space: nowrap; }
.export-results-summary { margin: 0 0 10px; color: #526780; font-size: 13px; }
@media (min-width: 801px) and (max-width: 1300px) {
  dialog.app-dialog > form.export-filters, dialog.app-dialog > form.export-filters:has(> .export-project-field[hidden]) { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .export-filters:has(> .export-project-field[hidden]) .export-search { grid-column: 1 / -1; }
}
.export-filters > label, .export-project-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; margin: 0; color: #526780; font-size: 12px; font-weight: 600; line-height: 1.4; }
.export-filters input:not([type=checkbox]), .export-project-picker summary { box-sizing: border-box; width: 100%; min-width: 0; min-height: 40px; height: 40px; padding: 8px 11px; margin: 0; border: 1px solid #cbd5e1; border-radius: 6px; background: #fff; color: #17365d; box-shadow: none; font: 400 13px/1.4 var(--font-ui, sans-serif); transition: border-color 150ms ease, box-shadow 150ms ease; }
.export-filters input:not([type=checkbox]):hover, .export-project-picker summary:hover { border-color: #94a8c1; }
.export-filters input:not([type=checkbox]):focus, .export-project-picker summary:focus-visible { border-color: #6486b1; outline: 2px solid #3b82f626; outline-offset: 1px; box-shadow: none; }
.export-filters input::placeholder { color: #8292a6; opacity: 1; }
.export-filters input[type=date] { font-variant-numeric: tabular-nums; color-scheme: light; }
.export-filters select { width: 100%; min-width: 0; height: 40px; margin: 0; padding: 8px; font-size: 13px; }
.export-project-picker { position: relative; width: 100%; min-width: 0; }
.export-project-picker summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; list-style: none; cursor: pointer; white-space: nowrap; }
.export-project-picker summary::-webkit-details-marker { display: none; }
.export-project-picker summary::after { content: ''; flex: 0 0 6px; width: 6px; height: 6px; border-right: 1.5px solid #647a94; border-bottom: 1.5px solid #647a94; transform: rotate(45deg) translateY(-2px); }
.export-project-picker[open] summary { border-color: #6486b1; }
.export-project-picker[open] summary::after { transform: rotate(225deg) translate(-1px, -1px); }
.export-project-options { position: absolute; left: 0; top: calc(100% + 6px); width: max(100%, 300px); max-width: calc(100vw - 52px); max-height: 250px; overflow: auto; padding: 4px; background: #fff; color: #17365d; border: 1px solid #cbd5e1; border-radius: 6px; box-shadow: 0 8px 24px #17365d14; scrollbar-width: thin; }
.export-project-options label { display: flex; align-items: center; gap: 9px; min-height: 40px; padding: 8px; border-radius: 4px; font-size: 13px; font-weight: 400; line-height: 1.4; cursor: pointer; margin: 0; }
.export-project-options label:hover { background: #eaf1f8; }
.export-project-options > label { border-bottom: 1px solid #e6ebf1; border-radius: 0; font-weight: 600; }
.export-project-options input { width: 16px; height: 16px; flex: 0 0 auto; margin: 0; accent-color: #315f93; }
.export-filter-error { grid-column: 1 / -1; color: #b42318; font-size: 12px; }
.export-detail-content[aria-busy=true] { opacity: .6; }
.export-preview-actions a[aria-disabled=true] { opacity: .5; cursor: wait; }
@media (max-width: 800px) {
  dialog.app-dialog > form.export-filters, dialog.app-dialog > form.export-filters:has(> .export-project-field[hidden]) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; padding: 10px 12px; }
  .export-filters input:not([type=checkbox]), .export-project-picker summary { min-height: 44px; height: 44px; }
  .export-filters:has(> .export-project-field[hidden]) .export-search { grid-column: 1 / -1; }
  .export-date-range { grid-column: 1 / -1; }
  .export-filters .payment-range-input { height: 44px; }
  .export-filters .payment-range-input input[data-payment-range], .export-filters .payment-range-input button { height: 42px; min-height: 42px; }
  .export-filter-reset { min-height: 44px; height: 44px; justify-self: start; }
}
.export-detail-table { width: max-content; min-width: 100%; table-layout: fixed; border-collapse: separate; border-spacing: 0; color: #1e293b; font: 15px/1.5 'Times New Roman', serif; }
.export-detail-table thead { position: sticky; top: 0; z-index: 2; }
.export-detail-table th, .export-detail-table td { padding: 10px 12px; border-right: 1px solid #e6ebf1; border-bottom: 1px solid #e6ebf1; vertical-align: middle; white-space: normal; overflow-wrap: anywhere; }
.export-detail-table th { padding-block: 8px; background: #eaf1f8; color: #17365d; font-weight: 700; text-align: center; }
.export-detail-table th:first-child { white-space: nowrap; }
.export-detail-table .export-week-header, .export-detail-table .export-week-period { white-space: nowrap; overflow-wrap: normal; }
.export-detail-table .export-column-totals td { background: #eaf1f8; color: #17365d; font-weight: 700; white-space: nowrap; }
.export-detail-table tbody tr:nth-child(even) td { background: #f8fafc; }
.export-detail-table .export-number { text-align: right; white-space: nowrap; }
.export-detail-table .export-date { white-space: nowrap; }
.export-detail-table .export-expense-total { font-weight: 700; color: #17365d; }
.export-preview-empty { display: grid; place-items: center; height: 100%; margin: 0; padding: 24px; color: var(--slate-600); }
dialog.app-dialog.export-preview-dialog > footer { display: flex; flex: 0 0 auto; flex-direction: row; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px; border-top: 1px solid var(--line); }
.export-preview-total { color: var(--slate-600); font-size: 13px; }
.export-preview-total strong { margin-left: 6px; color: var(--slate-900); font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.export-preview-actions { display: flex; flex: 0 0 auto; gap: 8px; }
.export-preview-dialog .export-preview-actions .button { width: auto; min-height: 40px; padding: 8px 14px; }
@media (max-width: 600px) {
  dialog.app-dialog.export-preview-dialog > footer { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
  .export-preview-total, .export-preview-actions { flex-basis: 100%; }
  .export-preview-actions .button { flex: 1; }
  .export-preview-dialog .export-preview-actions .button { min-height: 44px; }
}

@media (max-width: 1100px) {
  .detail-content-layout { grid-template-columns: minmax(0, 1fr); }
  .detail-main-content { border-right: 0; }
  .detail-workflow-column { border-top: 1px solid var(--line); }
}
@media (max-width: 700px) {
  .detail-heading { padding: 18px; }
  .detail-panel .panel-heading { padding: 16px 18px 10px; }
  .detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 0 18px 16px; gap: 0 16px; }
  .detail-grid dd small { display: block; margin-left: 0; }
  .detail-panel .allocation-table { padding: 0 18px 16px; }
  .detail-main-content .allocation-main { grid-template-columns: minmax(0, 1fr) auto; }
  .detail-main-content .allocation-badge-group { grid-column: 1; grid-row: 1; }
  .detail-main-content .allocation-date-info { grid-column: 1 / -1; grid-row: 2; padding-left: 0; }
  .detail-main-content .allocation-amount { grid-column: 2; grid-row: 1; text-align: right; }
  .detail-total { padding: 16px 18px; flex-direction: row; align-items: center; flex-wrap: wrap; }
  .detail-total strong { align-self: auto; font-size: 22px; }
  .detail-workflow-column { padding: 16px; }
  .detail-action-buttons .button { min-width: 0; padding-inline: 12px; }
}
@media (max-width: 340px) {
  .detail-grid { grid-template-columns: minmax(0, 1fr); }
}

/* Dialogs and sign-in use the same surfaces and type scale. */
dialog.app-dialog { border-radius: var(--radius-lg); }
dialog.app-dialog header { background: var(--surface); }
dialog.app-dialog header h2 { font-size: 18px; line-height: 1.4; }
dialog.app-dialog header button { width: 44px; height: 44px; flex-shrink: 0; }
dialog.app-dialog footer { background: var(--slate-50); }
.auth-shell { min-height: 100dvh; padding: 24px; background: var(--canvas); }
.auth-page { width: min(480px, 100%); min-width: 0; }
.auth-layout, .auth-panel { width: 100%; min-width: 0; }
.auth-card { width: 100%; padding: 32px; border: 1px solid var(--line); box-shadow: var(--shadow-md); border-radius: var(--radius-xl); }
.auth-brand { justify-content: center; margin-bottom: 20px; }
.auth-logo { display: block; width: 220px; max-width: 100%; height: 48px; object-fit: cover; object-position: center; }
.auth-heading { margin-bottom: 28px; text-align: center; }
.auth-heading h1 { margin: 0; font-size: 24px; }
.auth-form { gap: 20px; }
.auth-form .field { min-width: 0; margin-bottom: 0; }
.auth-form .field-help { display: block; margin-top: 6px; }
.auth-form .password-toggle { min-height: 36px; }
@media (max-width: 520px) {
  .auth-shell { padding: 16px; }
  .auth-card { padding: 28px 20px; }
}
@media (max-width: 360px) {
  .auth-shell { padding: 12px; }
  .auth-card { padding: 24px 18px; }
}

@media (min-width: 1280px) {
  .expense-layout { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1101px) {
  .team-panel > .table-wrap, .project-directory > .table-wrap, .expense-list-panel > .project-table-wrap { display: block; overflow-x: auto; }
}
@media (max-width: 900px) {
  .expense-list-toolbar { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 700px) {
  .page-content { padding: 12px 16px 24px; }
  .page-heading { align-items: stretch; gap: 10px; }
  .expense-list-toolbar { padding: 12px; gap: 10px; }
  .project-expense-filters { grid-template-columns: minmax(0, 1fr); }
  .project-expense-filters .field { width: 100%; }
  .project-expense-actions { gap: 8px; width: 100%; }
  .project-expense-actions .button { flex: 1 1 auto; width: auto; }
  .expense-list-overview .project-bulk-delete-button { min-height: 44px; margin-left: auto; }
  .expense-list-overview > div:last-of-type strong { white-space: nowrap; }
  .topbar { padding-inline: 16px; }
  .topbar-role { font-size: 11px; }
  .topbar-status-separator { display: none; }
  .expense-layout .form-panel { padding: 20px; }
  .form-section-heading { margin-bottom: 20px; }
  .form-submit-bar { position: static; padding: 20px; }
  .form-submit-bar > div:first-child > strong { font-size: 24px; }
  .detail-action-buttons { flex-wrap: wrap; }
  .budget-confirmation-title { flex-wrap: wrap; }
}
@media (max-width: 900px) {
  .project-page-heading { grid-template-columns: minmax(0, 1fr); }
  .project-page-heading .project-expense-actions { justify-self: end; }
}
@media (max-width: 700px) {
  .expense-list-toolbar input[type=search], .expense-list-toolbar select { height: 44px; min-height: 44px; }
  .project-page-heading .page-back-link { min-height: 36px; }
  .team-filter, .project-filter-bar { padding: 10px 12px; }
}
@media (max-width: 400px) {
  .expense-layout .submit-actions { flex-direction: column; align-items: stretch; }
  .expense-layout .submit-actions .button { width: 100%; }
  .allocation-card-grid { grid-template-columns: minmax(0, 1fr); }
  .allocation-card-grid .field-purpose { grid-column: auto; }
  .allocation-card-grid .field-amount, .allocation-card-grid .allocation-dxc { grid-column: 1 / -1; grid-row: auto; }
  .allocation-card-grid .allocation-dxc { margin-top: 0; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}
