:root {
  --bg: #eef3f8;
  --surface: rgba(255, 255, 255, 0.92);
  --surface-strong: #ffffff;
  --line: rgba(15, 23, 42, 0.10);
  --text: #172033;
  --muted: #64748b;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --danger: #b42318;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
  --shadow-soft: 0 8px 22px rgba(15, 23, 42, 0.06);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, 0.10), transparent 24%),
    radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 22%),
    linear-gradient(180deg, #f6f9fc 0%, #ebf1f7 100%);
}

body.modal-open {
  overflow: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

textarea {
  width: 100%;
  border: 1px solid rgba(15, 23, 42, 0.14);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  padding: 11px 13px;
  resize: vertical;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 22px;
  background: rgba(248, 251, 255, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--line);
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.brand {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.brand-meta {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.site-nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: end;
  gap: 10px;
}

.site-nav a {
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
}

.site-nav a:hover {
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-strong);
}

.nav-dropdown {
  position: relative;
  padding-bottom: 6px;
}

.nav-dropdown-toggle {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 600;
}

.nav-dropdown-toggle:hover,
.nav-dropdown:hover .nav-dropdown-toggle {
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-strong);
}

.nav-dropdown-menu {
  position: absolute;
  top: calc(100% - 2px);
  right: 0;
  min-width: 200px;
  display: grid;
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-soft);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease, visibility 120ms ease;
}

.nav-dropdown:hover .nav-dropdown-menu,
.nav-dropdown:focus-within .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0);
}

.nav-dropdown-menu a {
  border-radius: 12px;
}

.site-shell {
  padding: 18px 0 40px;
}

.app-frame {
  width: min(1600px, calc(100vw - 24px));
  margin: 0 auto;
}

.dashboard-grid,
.admin-page,
.report-page,
.period-page,
.auth-page {
  width: min(1320px, calc(100vw - 32px));
  margin: 24px auto;
}

.auth-page {
  display: grid;
  place-items: start center;
}

.auth-panel {
  width: min(420px, 100%);
  padding: 30px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.auth-panel h1 {
  margin: 0 0 22px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.4rem;
}

.auth-form {
  display: grid;
  gap: 16px;
}

.field-error {
  color: var(--danger);
  font-weight: 700;
}

.auth-link {
  display: inline-flex;
  margin-top: 18px;
  color: var(--accent-strong);
  font-weight: 700;
}

.analysis-page {
  width: min(1440px, calc(100vw - 32px));
}

.report-page-wide {
  width: min(1360px, calc(100vw - 32px));
}

.export-settings-form {
  display: grid;
  gap: 18px;
}

.export-settings-card {
  padding: 24px;
}

.export-search-card {
  justify-content: start;
  margin-bottom: 18px;
  padding: 14px 18px;
}

.export-search-card .field {
  width: min(520px, 100%);
}

.assignment-table-card {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  max-height: none;
  overflow-y: auto;
  overflow-x: auto;
}

.export-settings-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: start;
  margin-bottom: 18px;
}

.export-settings-head h2 {
  margin: 0 0 8px;
  font-family: Georgia, "Times New Roman", serif;
}

.export-settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.export-tabs {
  display: flex;
  gap: 12px;
  padding: 14px;
}

.export-tabs .ghost-button.is-active {
  background: rgba(15, 118, 110, 0.14);
  color: var(--accent-strong);
}

.selection-chip {
  display: flex;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
}

.selection-chip.is-filtered-out {
  display: none;
}

.selection-chip strong {
  display: inline-block;
  min-width: 68px;
  margin-right: 8px;
}

.selection-chip-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  margin-right: 10px;
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 700;
  vertical-align: middle;
}

.export-settings-actions {
  padding: 18px 22px;
}

.dashboard-overview {
  width: min(1320px, calc(100vw - 32px));
  margin: 12px auto 0;
}

.dashboard-sections {
  width: min(1320px, calc(100vw - 32px));
  display: grid;
  gap: 28px;
  margin: 24px auto;
}

.dashboard-section {
  display: grid;
  gap: 14px;
}

.dashboard-section-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: end;
}

.dashboard-section-head h2 {
  margin: 0;
  font-size: 1.25rem;
  letter-spacing: -0.01em;
}

.dashboard-grid {
  display: grid;
  gap: 14px;
}

.dashboard-grid-primary {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.dashboard-grid-secondary {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.dashboard-card {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 12px;
  min-height: 172px;
  padding: 18px;
  border-radius: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-soft);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}

.dashboard-card-primary {
  min-height: 190px;
  background:
    linear-gradient(180deg, rgba(37, 99, 235, 0.06), rgba(255, 255, 255, 0.92)),
    var(--surface);
}

.dashboard-card h3 {
  margin: 0;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  line-height: 1.2;
}

.dashboard-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.dashboard-card-tag {
  display: inline-flex;
  width: fit-content;
  min-width: 42px;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.10);
  color: var(--accent-strong);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.06em;
}

.dashboard-card-action {
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.92rem;
}

.dashboard-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.20);
  box-shadow: var(--shadow);
}

.hero-card,
.toolbar-card,
.table-card,
.modal-panel {
  background: var(--surface);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.hero-card {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: start;
  padding: 24px 26px;
  border-radius: 20px;
}

.dashboard-hero {
  align-items: center;
}

.dashboard-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 18px;
}

.dashboard-summary span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.70);
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.2;
}

.dashboard-summary strong {
  color: var(--text);
  font-weight: 800;
}

.hero-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.78rem;
  color: var(--accent);
  font-weight: 700;
}

.hero-card h1,
.modal-header h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: -0.03em;
}

.hero-card h1 {
  font-size: clamp(1.9rem, 4vw, 3rem);
}

.hero-copy,
.toolbar-meta,
.field span,
.empty-state span {
  color: var(--muted);
}

.hero-copy {
  max-width: 62ch;
  line-height: 1.55;
}

.toolbar-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding: 16px 18px;
  border-radius: 16px;
}

.report-quality-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 22px;
  align-items: center;
  margin-top: 16px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background:
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.10), transparent 38%),
    var(--surface);
  box-shadow: var(--shadow);
}

.report-quality-card.is-warning {
  background:
    radial-gradient(circle at top right, rgba(180, 83, 9, 0.14), transparent 40%),
    var(--surface);
  border-color: rgba(180, 83, 9, 0.22);
}

.report-quality-card h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
}

.report-quality-card .hero-copy {
  margin-bottom: 0;
}

.quality-metrics {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.quality-metrics span {
  display: grid;
  gap: 2px;
  min-width: 92px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.05);
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
}

.quality-metrics strong {
  color: var(--text);
  font-size: 1.05rem;
}

.toolbar-card-search {
  align-items: end;
  gap: 12px;
  justify-content: start;
}

.toolbar-card-search .field {
  width: min(420px, 100%);
}

.toolbar-card-search .ghost-button {
  min-height: 36px;
  margin-bottom: 0;
  white-space: nowrap;
}

.lineitem-filter-toolbar {
  justify-content: start;
  gap: 18px;
  flex-wrap: wrap;
}

.inline-upload-form {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.lineitem-filter-toolbar .field {
  width: min(320px, 100%);
}

.period-picker-card {
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.period-picker-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 14px 18px;
  cursor: pointer;
  list-style: none;
}

.period-picker-summary::-webkit-details-marker {
  display: none;
}

.period-picker-summary-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.period-picker-summary h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.15rem;
}

.period-picker-body {
  padding: 0 18px 16px;
  border-top: 1px solid var(--line);
}

.period-year-form {
  max-width: 180px;
}

.period-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.period-tile {
  display: grid;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.42);
  min-height: 64px;
}

.period-tile-month {
  font-weight: 800;
  font-size: 0.92rem;
}

.period-tile-state {
  font-size: 0.72rem;
  color: var(--muted);
}

.period-tile.is-available {
  background: rgba(37, 99, 235, 0.08);
  border-color: rgba(37, 99, 235, 0.18);
}

.period-tile.is-filled {
  background: rgba(182, 212, 0, 0.18);
  border-color: rgba(112, 145, 0, 0.28);
}

.period-tile.is-filled .period-tile-state {
  color: #5f6f16;
  font-weight: 700;
}

.period-tile.is-active {
  background: rgba(37, 99, 235, 0.16);
  border-color: rgba(37, 99, 235, 0.45);
  box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.12);
}

.period-tile.is-active.is-filled {
  background: linear-gradient(180deg, rgba(182, 212, 0, 0.22), rgba(15, 118, 110, 0.14));
  border-color: rgba(15, 118, 110, 0.45);
}

.period-tile.is-missing {
  opacity: 0.45;
}

.analysis-filter-form {
  margin-bottom: 12px;
}

.analysis-filter-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 12px;
}

.analysis-sheet {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 14px;
  margin-top: 18px;
  align-items: start;
}

.analysis-table-card,
.analysis-highlights-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-soft);
  overflow: hidden;
}

.analysis-table-card {
  overflow-x: auto;
}

.analysis-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  min-width: 1080px;
}

.analysis-table th,
.analysis-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  font-size: 0.96rem;
  white-space: nowrap;
}

.analysis-table thead th {
  background: rgba(255, 255, 255, 0.52);
  font-weight: 800;
  text-align: center;
}

.analysis-table .analysis-label-head,
.analysis-table .analysis-label-cell {
  min-width: 260px;
  text-align: center;
  white-space: normal;
}

.analysis-table .analysis-label-cell strong {
  display: block;
}

.analysis-table tbody td {
  text-align: center;
}

.analysis-band-row th {
  padding-top: 12px;
  padding-bottom: 8px;
  border-bottom: none;
}

.analysis-band-row .analysis-label-head {
  background: transparent;
}

.analysis-band {
  text-align: center;
  font-family: Georgia, "Times New Roman", serif;
  font-style: italic;
  padding-left: 0;
  padding-right: 0;
}

.analysis-band-periodic {
  background: rgba(255, 156, 38, 0.45);
}

.analysis-band-ytd {
  background: rgba(169, 189, 229, 0.65);
}

.analysis-budget-cell {
  color: #8b6a00;
  font-weight: 700;
}

.analysis-positive {
  color: var(--accent-strong);
  font-weight: 700;
}

.analysis-negative {
  color: var(--danger);
  font-weight: 700;
}

.analysis-subtotal-row {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 800;
}

.analysis-subtotal-row td {
  border-top: 2px solid rgba(45, 34, 28, 0.25);
}

.analysis-highlights-card {
  padding: 18px;
}

.analysis-highlights-card h2 {
  margin: 0 0 16px;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.analysis-highlights-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.analysis-highlights-list li {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
  border: 1px solid var(--line);
}

.toolbar-label {
  margin: 0 0 4px;
  font-weight: 700;
}

.filter-form select,
.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(74, 57, 45, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  padding: 12px 14px;
}

.table-subline {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.9rem;
}

.table-card {
  margin-top: 22px;
  border-radius: 26px;
  overflow: hidden;
}

.table-card-tight h2 {
  margin: 0;
  padding: 14px 18px 6px;
  font-size: 1.1rem;
}

.table-card-tight .period-table th,
.table-card-tight .period-table td {
  padding: 10px 14px;
}

.table-card-tight .actions-cell {
  gap: 8px;
}

.table-card-tight .ghost-button,
.table-card-tight .danger-button {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.table-text-cell {
  max-width: 420px;
  text-align: left;
  white-space: normal;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
  font-weight: 800;
}

.period-table {
  width: 100%;
  border-collapse: collapse;
}

.period-table th,
.period-table td {
  padding: 12px 16px;
  text-align: center;
  border-bottom: 1px solid var(--line);
}

.period-table thead th {
  font-size: 0.84rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.42);
}

.period-table tbody tr:hover {
  background: rgba(15, 118, 110, 0.05);
}

.subtotal-row {
  background: rgba(182, 212, 0, 0.12);
}

.report-highlight {
  font-weight: 700;
}

.report-subgroup-row td {
  padding: 12px 20px;
  background: rgba(15, 118, 110, 0.06);
}

.report-subgroup-heading {
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  font-weight: 800;
}

.report-table-card,
.section-card {
  margin-top: 18px;
}

.report-group {
  margin-top: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.report-group-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 20px 24px;
  list-style: none;
  cursor: pointer;
  background: transparent;
}

.report-group-summary::-webkit-details-marker {
  display: none;
}

.report-group-summary-main {
  display: flex;
  align-items: center;
  gap: 16px;
}

.report-group-summary h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
}

.report-group-toggle {
  width: 14px;
  height: 14px;
  border-right: 2px solid var(--accent-strong);
  border-bottom: 2px solid var(--accent-strong);
  transform: rotate(45deg);
  transition: transform 140ms ease;
  margin-top: 6px;
}

.period-picker-card[open] > .period-picker-summary .report-group-toggle,
.report-group[open] > .report-group-summary .report-group-toggle,
.report-subgroup-card[open] > .report-subgroup-summary .report-group-toggle {
  transform: rotate(225deg);
  margin-top: 0;
}

.report-group-meta {
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 700;
}

.report-group-body {
  border-top: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.38);
  display: flex;
  flex-direction: column;
}

.report-table-scroll {
  display: block;
  height: auto;
  min-height: 0;
  max-height: 68vh;
  overflow-y: auto;
  overflow-x: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.report-table-scroll .period-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: #f7f1e8;
}

.report-group-stack {
  display: grid;
  gap: 14px;
  padding: 16px;
}

.report-subgroup-card {
  background: rgba(255, 255, 255, 0.56);
  border: 1px solid rgba(74, 57, 45, 0.08);
  border-radius: 18px;
  overflow: hidden;
}

.report-subgroup-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 18px;
  list-style: none;
  cursor: pointer;
}

.report-subgroup-summary::-webkit-details-marker {
  display: none;
}

.report-subgroup-summary h3 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.group-form {
  margin: 0;
}

.group-actions {
  display: flex;
  justify-content: end;
  padding: 18px 24px 22px;
  background: rgba(255, 255, 255, 0.28);
}

.report-value-cell {
  min-width: 180px;
}

.report-ytd-cell {
  min-width: 160px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  color: var(--accent-strong);
  font-weight: 700;
}

.report-inline-input,
.report-inline-notes {
  width: 100%;
  border: 1px solid rgba(74, 57, 45, 0.18);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.94);
  color: var(--text);
  padding: 10px 12px;
}

.report-inline-input {
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.report-inline-input.is-manual-override {
  border-color: rgba(217, 119, 6, 0.65);
  background: rgba(255, 247, 237, 0.98);
  box-shadow: inset 3px 0 0 rgba(217, 119, 6, 0.85);
}

.report-table-compact th,
.report-table-compact td {
  padding: 8px 12px;
}

.report-page-dense .report-group-summary,
.report-page-dense .report-subgroup-summary {
  padding: 12px 16px;
}

.report-page-dense .report-group-body {
  padding: 0 16px 12px;
}

.report-page-dense .report-table-scroll {
  height: auto;
  min-height: 0;
  max-height: 64vh;
}

.report-page-dense .report-table-compact th,
.report-page-dense .report-table-compact td {
  padding: 5px 9px;
}

.report-page-dense .report-table-compact .report-inline-input,
.report-page-dense .report-table-compact .report-inline-notes {
  padding: 5px 8px;
  min-height: 34px;
}

.report-page-dense .report-table-compact .table-subline {
  margin-top: 2px;
  font-size: 0.8rem;
}

.report-page-dense .report-table-compact .report-value-cell,
.report-page-dense .report-ytd-cell {
  min-width: 130px;
}

.report-page-dense .group-actions,
.report-page-dense .report-table-compact + .group-actions {
  padding: 10px 16px 12px;
}

.report-table-compact .table-subline {
  margin-top: 2px;
  font-size: 0.82rem;
}

.report-table-compact .report-inline-input,
.report-table-compact .report-inline-notes {
  padding: 7px 10px;
  border-radius: 10px;
}

.report-table-compact .report-value-cell {
  min-width: 150px;
}

.report-table-compact + .group-actions,
.report-group-body .group-actions {
  padding: 12px 18px 14px;
}

.section-heading {
  padding: 14px 20px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent-strong);
  background: rgba(15, 118, 110, 0.08);
}

.report-value {
  font-variant-numeric: tabular-nums;
}

.actions-column,
.actions-cell {
  text-align: right;
}

.actions-cell {
  display: flex;
  justify-content: end;
  gap: 12px;
  align-items: center;
}

.inline-form {
  margin: 0;
}

.primary-button,
.ghost-button,
.danger-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-button,
.ghost-button,
.danger-button {
  padding: 12px 18px;
  font-weight: 700;
}

.primary-button {
  background: var(--accent);
  color: #f7fffd;
}

.primary-button:hover,
.ghost-button:hover,
.danger-button:hover,
.icon-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.ghost-button:disabled,
.danger-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.ghost-button {
  background: rgba(15, 118, 110, 0.08);
  color: var(--accent-strong);
}

.danger-button {
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.icon-button {
  padding: 10px 14px;
  background: rgba(74, 57, 45, 0.08);
  color: var(--text);
}

.flash,
.form-errors {
  margin-top: 18px;
  padding: 14px 16px;
  border-radius: 18px;
}

.flash-success {
  background: rgba(15, 118, 110, 0.12);
  color: var(--accent-strong);
}

.flash-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.flash-with-action span {
  flex: 1 1 260px;
}

.flash-with-action .ghost-button {
  padding: 8px 12px;
}

.flash-warning {
  background: rgba(217, 119, 6, 0.11);
  color: #92400e;
}

.lineitem-category-alert {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.lineitem-category-alert span {
  flex: 1 1 280px;
}

.flash-error,
.form-errors {
  background: rgba(180, 35, 24, 0.09);
  color: #8f1b13;
}

.manual-override-alert {
  margin-top: 18px;
  border: 1px solid rgba(217, 119, 6, 0.35);
  border-radius: 18px;
  background: rgba(255, 247, 237, 0.96);
  color: #92400e;
  overflow: hidden;
}

.manual-override-alert summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 14px 16px;
  font-weight: 800;
}

.manual-override-alert summary::-webkit-details-marker {
  display: none;
}

.manual-override-list {
  display: grid;
  gap: 8px;
  padding: 0 16px 14px;
}

.manual-override-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
}

.manual-override-name {
  min-width: 0;
  color: var(--text);
  font-weight: 700;
}

.manual-override-values {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.manual-override-link {
  white-space: nowrap;
  color: var(--accent-strong);
  font-weight: 800;
  text-decoration: none;
}

.manual-override-link:hover {
  text-decoration: underline;
}

[id^="line-item-"] {
  scroll-margin-top: 96px;
}

[id^="line-item-"]:target td {
  background: rgba(255, 247, 237, 0.92);
  box-shadow: inset 0 2px 0 rgba(217, 119, 6, 0.45), inset 0 -2px 0 rgba(217, 119, 6, 0.45);
}

.empty-state {
  display: grid;
  gap: 4px;
  padding: 32px 12px;
  text-align: center;
}

.modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 30;
  overflow: auto;
}

.modal.is-open {
  display: flex;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(45, 34, 28, 0.38);
}

.modal-panel {
  position: relative;
  width: min(560px, 100%);
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  padding: 28px;
  max-height: min(calc(100vh - 48px), 920px);
  overflow: hidden;
}

.modal-panel-wide {
  width: min(1080px, 100%);
}

.modal-panel-tall {
  width: min(980px, 100%);
}

.trend-modal-panel {
  width: min(1400px, calc(100vw - 32px));
  max-height: min(calc(100vh - 32px), 980px);
}

.trend-modal-layout {
  display: grid;
  grid-template-columns: minmax(260px, 340px) minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.trend-picker-panel,
.trend-chart-panel {
  min-height: 0;
}

.trend-picker-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.trend-picker-help {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.35;
}

.trend-picker-list {
  display: grid;
  gap: 8px;
  max-height: 570px;
  overflow: auto;
  padding-right: 4px;
}

.trend-picker-option {
  display: grid;
  gap: 4px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: rgba(248, 251, 255, 0.85);
  color: var(--text);
  cursor: pointer;
}

.trend-picker-option:hover,
.trend-picker-option.is-active {
  border-color: rgba(37, 99, 235, 0.45);
  background: rgba(37, 99, 235, 0.08);
}

.trend-picker-option span {
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
}

.trend-picker-option strong {
  font-size: 0.9rem;
  line-height: 1.25;
}

.trend-picker-empty {
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-weight: 700;
}

.trend-chart-card {
  position: relative;
  min-height: 560px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(248, 251, 255, 0.9);
}

.trend-chart-tools {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.trend-chart-tools .field {
  width: min(180px, 100%);
}

.trend-chart {
  width: 100%;
  height: 520px;
  display: block;
}

.trend-chart-empty {
  display: grid;
  place-items: center;
  min-height: 280px;
  color: var(--muted);
  font-weight: 600;
}

.trend-chart-empty.is-hidden {
  display: none;
}

.trend-chart-legend {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.trend-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 999px;
  background: rgba(37, 99, 235, 0.08);
  color: var(--accent-strong);
  font-size: 0.84rem;
}

.trend-pill i {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  flex: 0 0 auto;
}

.trend-pill-muted {
  background: rgba(15, 23, 42, 0.06);
  color: var(--muted);
}

.trend-axis {
  stroke: rgba(23, 32, 51, 0.24);
  stroke-width: 1;
}

.trend-grid {
  stroke: rgba(23, 32, 51, 0.10);
  stroke-width: 1;
}

.trend-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-average-line {
  stroke-width: 1.5;
  stroke-dasharray: 7 7;
  opacity: 0.55;
}

.trend-area {
  fill: rgba(37, 99, 235, 0.10);
}

.trend-dot {
  fill: var(--accent-strong);
}

.trend-hit {
  fill: transparent;
  cursor: crosshair;
}

.trend-tooltip {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 3px;
  min-width: 170px;
  max-width: 260px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow-soft);
  pointer-events: none;
}

.trend-tooltip strong,
.trend-tooltip b {
  color: var(--text);
}

.trend-tooltip span,
.trend-tooltip em {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: normal;
}

.trend-label {
  fill: var(--muted);
  font-size: 12px;
  font-weight: 600;
}

.trend-value-label {
  fill: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.modal-form-stack {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  gap: 16px;
  min-height: 0;
  overflow: hidden;
}

.modal-form-scroll {
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.field {
  display: grid;
  gap: 8px;
}

.field-checkbox {
  align-content: end;
}

.field-checkbox input {
  width: auto;
  accent-color: var(--accent);
}

.relation-picker {
  display: grid;
  gap: 8px;
  max-height: 240px;
  overflow: auto;
  padding: 10px;
  border: 1px solid rgba(74, 57, 45, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
}

.relation-picker-tall {
  max-height: 420px;
}

.subtotal-bulk-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.subtotal-bulk-actions .ghost-button {
  padding: 8px 12px;
}

.relation-option {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.relation-option:hover {
  background: rgba(15, 118, 110, 0.08);
}

.relation-option input {
  width: auto;
  margin: 0;
  accent-color: var(--accent);
}

[data-report-type-target].is-hidden {
  display: none;
}

.is-hidden {
  display: none !important;
}

.modal-actions {
  display: flex;
  justify-content: end;
  gap: 12px;
  margin-top: 22px;
}

@media (max-width: 1100px) {
  .dashboard-grid-primary,
  .dashboard-grid-secondary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .trend-modal-layout {
    grid-template-columns: 1fr;
  }

  .trend-picker-list {
    max-height: 210px;
  }

  .trend-chart-card {
    min-height: 420px;
  }

  .trend-chart {
    height: 380px;
  }
}

@media (max-width: 760px) {
  .dashboard-sections,
  .admin-page,
  .report-page,
  .period-page {
    width: min(100vw - 20px, 100%);
    margin: 20px auto 40px;
  }

  .dashboard-overview {
    width: min(100vw - 20px, 100%);
  }

  .dashboard-grid-primary,
  .dashboard-grid-secondary {
    grid-template-columns: 1fr;
  }

  .dashboard-section-head {
    display: grid;
  }

  .dashboard-card,
  .dashboard-card-primary {
    min-height: 0;
  }

  .period-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .analysis-filter-grid,
  .analysis-sheet {
    grid-template-columns: 1fr;
  }

  .analysis-table {
    table-layout: auto;
  }

  .hero-card,
  .toolbar-card,
  .modal-panel {
    padding: 22px;
  }

  .modal {
    padding: 10px;
  }

  .trend-modal-panel {
    width: min(100vw - 20px, 100%);
    max-height: calc(100vh - 20px);
    overflow: auto;
  }

  .trend-chart-card {
    min-height: 340px;
    padding: 12px;
  }

  .trend-chart {
    height: 300px;
  }

  .hero-card,
  .toolbar-card,
  .report-quality-card,
  .modal-actions,
  .actions-cell,
  .form-grid {
    display: grid;
  }

  .report-quality-card {
    grid-template-columns: 1fr;
  }

  .quality-metrics {
    justify-content: stretch;
  }

  .quality-metrics span {
    flex: 1 1 90px;
  }

  .actions-column,
  .actions-cell {
    text-align: left;
    justify-content: start;
  }

  .period-table thead {
    display: none;
  }

  .period-table,
  .period-table tbody,
  .period-table tr,
  .period-table td {
    display: block;
    width: 100%;
  }

  .period-table tr {
    padding: 16px;
    border-bottom: 1px solid var(--line);
  }

  .period-table td {
    padding: 6px 0;
    border: 0;
  }

  .site-header,
  .site-nav {
    display: grid;
  }
}
