:root {
  --brand-red: #ed3338;
  --brand-red-dark: #bf1f24;
  --brand-navy: #000000;
  --brand-yellow: #f0eeee;
  --brand-cream: #f0eeee;
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(0, 0, 0, 0.12);
  --text: #000000;
  --muted: #5f5a5a;
  --success: #000000;
  --warning: #000000;
  --danger: #ed3338;
  --shadow: 0 24px 48px rgba(0, 0, 0, 0.12);
  --radius-lg: 24px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "Century Schoolbook", "New Century Schoolbook", Georgia, serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(240, 238, 238, 0.85), transparent 24%),
    radial-gradient(circle at top right, rgba(237, 51, 56, 0.1), transparent 20%),
    linear-gradient(135deg, #ffffff 0%, #f0eeee 52%, #ffffff 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
}

#app {
  min-height: 100vh;
}

.loading-screen,
.empty-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
}

.spinner-card,
.auth-card,
.empty-card {
  width: min(100%, 540px);
  background: var(--panel-strong);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 32px;
  animation: fade-up 260ms ease;
}

.spinner {
  width: 54px;
  height: 54px;
  border-radius: 999px;
  border: 4px solid rgba(0, 0, 0, 0.1);
  border-top-color: var(--brand-red);
  margin-bottom: 16px;
  animation: spin 1s linear infinite;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 24px;
  padding: 24px;
}

.auth-hero {
  position: relative;
  overflow: hidden;
  border-radius: 36px;
  padding: 44px;
  background:
    linear-gradient(155deg, rgba(0, 0, 0, 0.98), rgba(0, 0, 0, 0.9)),
    linear-gradient(135deg, rgba(237, 51, 56, 0.58), transparent 56%);
  color: white;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.auth-hero::before,
.auth-hero::after {
  content: "";
  position: absolute;
  inset: auto;
  border-radius: 999px;
  filter: blur(6px);
}

.auth-hero::before {
  width: 340px;
  height: 340px;
  right: -60px;
  top: -60px;
  background: rgba(240, 238, 238, 0.22);
}

.auth-hero::after {
  width: 280px;
  height: 280px;
  left: -80px;
  bottom: -90px;
  background: rgba(237, 51, 56, 0.22);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.hero-chip {
  position: relative;
  z-index: 1;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(6px);
}

.hero-chip strong {
  display: block;
  font-size: 15px;
  margin-bottom: 6px;
}

.brand-lockup {
  position: relative;
  z-index: 1;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 58px;
  height: 58px;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  color: white;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 0.04em;
  box-shadow: 0 18px 30px rgba(237, 51, 56, 0.24);
}

.brand-lockup h1,
.auth-card h2,
.panel-header h2,
.section-title,
.modal-header h3 {
  font-family: "Century Schoolbook", "New Century Schoolbook", Georgia, serif;
  letter-spacing: 0.02em;
}

.brand-lockup h1 {
  font-size: clamp(34px, 4vw, 56px);
  margin: 18px 0 12px;
  line-height: 0.94;
  text-transform: uppercase;
}

.brand-lockup p,
.auth-card p,
.section-subtitle,
.metric-label,
.helper-text,
.panel-subtitle {
  color: rgba(255, 255, 255, 0.78);
  max-width: 48ch;
}

.auth-card {
  align-self: center;
  justify-self: center;
}

.auth-card h2 {
  margin: 0 0 10px;
  font-size: 34px;
  text-transform: uppercase;
  color: var(--brand-navy);
}

.auth-card p {
  color: var(--muted);
  margin: 0 0 24px;
}

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

.field-grid.single {
  grid-template-columns: 1fr;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field.span-2 {
  grid-column: 1 / -1;
}

.field label {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--brand-navy);
}

.field input,
.field select,
.field textarea,
.search-input {
  width: 100%;
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.92);
  color: var(--text);
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.field textarea {
  min-height: 110px;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.search-input:focus {
  outline: none;
  border-color: rgba(237, 51, 56, 0.42);
  box-shadow: 0 0 0 4px rgba(237, 51, 56, 0.08);
  transform: translateY(-1px);
}

.button-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 24px;
}

.compact-actions {
  gap: 8px;
  margin-top: 0;
}

.compact-actions .button,
.compact-actions .secondary-button,
.compact-actions .ghost-button,
.compact-actions .danger-button {
  padding: 9px 12px;
}

.button,
.ghost-button,
.secondary-button,
.danger-button,
.nav-item {
  border: 0;
  border-radius: 14px;
  padding: 12px 18px;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.button {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  color: white;
  font-weight: 700;
  box-shadow: 0 18px 28px rgba(237, 51, 56, 0.22);
}

.button:hover,
.ghost-button:hover,
.secondary-button:hover,
.danger-button:hover,
.nav-item:hover {
  transform: translateY(-1px);
}

.button:disabled,
.ghost-button:disabled,
.secondary-button:disabled,
.danger-button:disabled {
  opacity: 0.56;
  cursor: not-allowed;
  transform: none;
}

.secondary-button {
  background: rgba(0, 0, 0, 0.08);
  color: var(--brand-navy);
  font-weight: 700;
}

.ghost-button {
  background: transparent;
  color: var(--brand-navy);
  border: 1px dashed rgba(0, 0, 0, 0.18);
  font-weight: 700;
}

.danger-button {
  background: rgba(160, 25, 25, 0.08);
  color: var(--danger);
  font-weight: 700;
}

.inline-message {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(237, 51, 56, 0.08);
  color: var(--brand-red-dark);
  border: 1px solid rgba(237, 51, 56, 0.12);
}

.inline-message.info {
  background: rgba(240, 238, 238, 0.9);
  color: var(--text);
  border-color: rgba(0, 0, 0, 0.08);
}

.app-shell {
  display: grid;
  grid-template-columns: 290px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  min-height: 100vh;
  padding: 24px 18px;
  background:
    linear-gradient(180deg, rgba(0, 0, 0, 0.97), rgba(0, 0, 0, 0.92)),
    linear-gradient(140deg, rgba(237, 51, 56, 0.22), transparent 60%);
  color: white;
}

.sidebar-brand {
  padding: 10px 10px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar-brand .brand-mark {
  width: 50px;
  height: 50px;
  border-radius: 16px;
}

.sidebar-brand h2 {
  margin: 16px 0 6px;
  font-size: 28px;
  line-height: 0.95;
  text-transform: uppercase;
}

.sidebar-brand p,
.sidebar-footer p {
  margin: 0;
  color: rgba(255, 255, 255, 0.7);
}

.nav {
  padding: 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-item {
  text-align: left;
  background: transparent;
  color: rgba(255, 255, 255, 0.78);
  font-weight: 700;
}

.nav-item.active {
  background: rgba(255, 255, 255, 0.12);
  color: white;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.sidebar-footer {
  margin-top: auto;
  padding: 18px 10px 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.main-shell {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 26px 12px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 42px);
  text-transform: uppercase;
  line-height: 0.95;
}

.topbar p {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.user-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.user-chip strong {
  display: block;
  color: var(--brand-navy);
}

.user-chip span {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.content-shell {
  padding: 10px 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.panel,
.table-panel,
.chart-panel,
.metric-card,
.review-card,
.summary-card {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  animation: fade-up 240ms ease;
}

.panel {
  padding: 24px;
}

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

.panel-header h2,
.section-title {
  margin: 0;
  font-size: 24px;
  color: var(--brand-navy);
  text-transform: uppercase;
}

.panel-subtitle,
.section-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

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

.metric-card {
  padding: 22px;
  position: relative;
  overflow: hidden;
}

.metric-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -30px auto;
  width: 140px;
  height: 140px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(237, 51, 56, 0.12), rgba(240, 238, 238, 0.72));
}

.metric-label {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 13px;
  color: var(--muted);
}

.metric-value {
  margin: 0;
  font-size: clamp(28px, 3vw, 38px);
  color: var(--brand-navy);
  font-weight: 800;
}

.metric-footnote {
  margin-top: 10px;
  font-size: 14px;
  color: var(--muted);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: 1.18fr 0.82fr;
  gap: 18px;
}

.chart-panel,
.table-panel {
  padding: 24px;
}

.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  min-height: 190px;
  padding-top: 16px;
}

.chart-bar {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 10px;
}

.chart-bar-fill {
  border-radius: 16px 16px 10px 10px;
  min-height: 16px;
  background: linear-gradient(180deg, var(--brand-red), #000000);
  box-shadow: 0 18px 24px rgba(0, 0, 0, 0.14);
}

.chart-bar-fill.alert {
  background: linear-gradient(180deg, #d91f2f, #7c0815);
}

.chart-bar-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--brand-navy);
  text-align: center;
}

.chart-bar-value {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

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

.summary-card {
  padding: 18px;
}

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

.master-card {
  padding: 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.summary-card h3 {
  margin: 0 0 14px;
  font-size: 16px;
  color: var(--brand-navy);
  text-transform: uppercase;
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.list-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(240, 238, 238, 0.7);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.list-item strong {
  display: block;
  margin-bottom: 4px;
}

.list-item small {
  display: block;
  color: var(--muted);
}

.filters-row {
  display: grid;
  grid-template-columns: 1.2fr repeat(3, minmax(0, 0.65fr)) auto;
  gap: 12px;
  align-items: end;
}

.helper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.table-wrap {
  overflow: auto;
  border-radius: 20px;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.project-table-wrap {
  max-height: min(68vh, 720px);
  overflow: auto;
  scrollbar-gutter: stable both-edges;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 960px;
}

.data-table th,
.data-table td {
  padding: 14px 16px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}

.data-table th {
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.94), rgba(0, 0, 0, 0.88));
  color: white;
  position: sticky;
  top: 0;
  z-index: 1;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 12px;
}

.data-table tbody tr {
  background: rgba(255, 255, 255, 0.88);
}

.data-table tbody tr:nth-child(2n) {
  background: rgba(240, 238, 238, 0.65);
}

.data-table tbody tr:hover {
  background: rgba(237, 51, 56, 0.08);
}

.cell-title {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cell-title strong {
  color: var(--brand-navy);
}

.cell-title span,
.muted {
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  color: var(--brand-navy);
  white-space: nowrap;
}

.badge.red {
  background: rgba(237, 51, 56, 0.12);
  color: var(--brand-red-dark);
}

.badge.yellow {
  background: rgba(240, 238, 238, 0.95);
  color: #000000;
}

.badge.green {
  background: rgba(240, 238, 238, 0.95);
  color: #000000;
}

.badge.gray {
  background: rgba(0, 0, 0, 0.08);
  color: var(--muted);
}

.project-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.steps-checklist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 240px;
}

.modal-steps-checklist {
  margin-top: 12px;
}

.step-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: rgba(255, 255, 255, 0.96);
  color: var(--text);
  border-radius: 14px;
  padding: 10px 12px;
  text-align: left;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
}

.step-pill:hover {
  transform: translateY(-1px);
  border-color: rgba(237, 51, 56, 0.28);
}

.step-pill.completed {
  background: rgba(37, 122, 73, 0.12);
  border-color: rgba(37, 122, 73, 0.34);
}

.step-pill-marker {
  flex: 0 0 auto;
  min-width: 48px;
  border-radius: 999px;
  padding: 4px 8px;
  font-size: 11px;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.step-pill.completed .step-pill-marker {
  background: rgba(37, 122, 73, 0.18);
  color: #1f5b37;
}

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

.review-session-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 18px;
}

.review-card {
  padding: 22px;
}

.review-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.review-card h3 {
  margin: 0 0 6px;
  color: var(--brand-navy);
}

.review-meta {
  color: var(--muted);
  font-size: 14px;
}

.note-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.project-comment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 18px;
}

.project-comment-card {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.project-comment-card p {
  margin: 10px 0 0;
  color: var(--text);
  white-space: pre-wrap;
}

.project-comment-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.project-comment-meta strong {
  color: var(--brand-navy);
}

.project-comment-meta span {
  color: var(--muted);
  font-size: 13px;
}

.review-session-card {
  padding: 24px;
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.review-session-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.review-session-top h3 {
  margin: 0 0 6px;
  color: var(--brand-navy);
}

.review-summary-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.review-summary-text {
  margin: 0 0 16px;
  color: var(--muted);
}

.review-note-wrap {
  max-height: 420px;
}

.review-note-table {
  min-width: 760px;
}

.review-filters {
  grid-template-columns: 1.3fr 0.8fr auto;
}

.note-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(240, 238, 238, 0.72);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.note-item p {
  margin: 0 0 10px;
}

.note-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.empty-state {
  padding: 38px 16px;
  border-radius: 20px;
  text-align: center;
  color: var(--muted);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(240, 238, 238, 0.88));
  border: 1px dashed rgba(0, 0, 0, 0.16);
}

.compact-empty {
  padding: 20px 14px;
}

.feedback-panel {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(0, 0, 0, 0.12);
  margin-bottom: 18px;
}

.feedback-panel strong {
  display: block;
  margin-bottom: 8px;
}

.feedback-panel.error {
  background: rgba(237, 51, 56, 0.08);
  color: var(--brand-red-dark);
  border-color: rgba(237, 51, 56, 0.16);
}

.feedback-panel.success {
  background: rgba(240, 238, 238, 0.95);
  color: var(--success);
  border-color: rgba(0, 0, 0, 0.12);
}

.feedback-list {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 6px;
}

.compact-table {
  min-width: 640px;
}

.outflow-table .row-alert td {
  background: rgba(237, 51, 56, 0.08);
}

.pivot-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.pivot-control-grid,
.pivot-summary-grid {
  display: grid;
  gap: 16px;
}

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

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

.pivot-helper-row {
  margin-top: 0;
}

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

.pivot-slicer-card {
  padding: 16px 18px;
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.86);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.pivot-slicer-head,
.pivot-bar-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.pivot-slicer-head strong {
  display: block;
  color: var(--brand-navy);
  margin-bottom: 4px;
}

.pivot-slicer-head small,
.pivot-muted {
  color: var(--muted);
  font-size: 13px;
}

.pivot-chip-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 172px;
  overflow: auto;
  padding-right: 4px;
}

.pivot-chip {
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 999px;
  padding: 8px 12px;
  background: white;
  color: var(--brand-navy);
  font-size: 12px;
  font-weight: 700;
}

.pivot-chip.active {
  background: linear-gradient(135deg, var(--brand-red), var(--brand-red-dark));
  color: white;
  border-color: transparent;
  box-shadow: 0 10px 18px rgba(237, 51, 56, 0.18);
}

.pivot-layout {
  display: grid;
  grid-template-columns: 0.88fr 1.12fr;
  gap: 18px;
  align-items: start;
}

.pivot-breakdown-card,
.pivot-table-panel {
  height: 100%;
}

.pivot-bar-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pivot-bar-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pivot-bar-meta strong {
  color: var(--brand-navy);
}

.pivot-bar-meta span {
  color: var(--muted);
  font-size: 13px;
}

.pivot-bar-track {
  width: 100%;
  height: 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.pivot-bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--brand-red), #000000);
}

.pivot-table-wrap {
  max-height: 560px;
}

.pivot-table {
  min-width: 760px;
}

.pivot-table th:not(:first-child),
.pivot-table td:not(:first-child) {
  text-align: right;
}

.pivot-table tfoot th {
  position: sticky;
  bottom: 0;
  z-index: 1;
  background: rgba(240, 238, 238, 0.96);
  color: var(--brand-navy);
  border-top: 1px solid rgba(0, 0, 0, 0.1);
}

.toast-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 60;
}

.toast {
  min-width: 260px;
  max-width: 360px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.92);
  color: white;
  box-shadow: var(--shadow);
  animation: fade-up 220ms ease;
}

.toast.error {
  background: rgba(237, 51, 56, 0.96);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.34);
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.modal-card {
  width: min(1120px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  background: var(--panel-strong);
  border-radius: 28px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.74);
}

.modal-header,
.modal-body,
.modal-footer {
  padding: 22px 24px;
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-header h3 {
  margin: 0 0 6px;
  font-size: 28px;
  color: var(--brand-navy);
  text-transform: uppercase;
}

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.modal-section {
  padding: 18px;
  border-radius: 20px;
  background: rgba(240, 238, 238, 0.62);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.modal-section h4 {
  margin: 0 0 16px;
  color: var(--brand-navy);
  text-transform: uppercase;
  font-size: 15px;
}

.term-list,
.note-builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.term-row,
.note-row {
  display: grid;
  gap: 12px;
  align-items: end;
  padding: 14px;
  border-radius: 18px;
  background: white;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.term-row {
  grid-template-columns: 1.1fr 0.7fr 0.7fr 0.78fr 0.55fr auto;
}

.note-row {
  grid-template-columns: 0.8fr 0.9fr 1.4fr 0.8fr 0.7fr 0.8fr auto;
}

.tiny-button {
  padding: 10px 12px;
  border-radius: 12px;
  border: 0;
  background: rgba(237, 51, 56, 0.08);
  color: var(--brand-red-dark);
  font-weight: 700;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.pill-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(240, 238, 238, 0.95);
  color: var(--brand-navy);
  font-size: 13px;
  font-weight: 700;
}

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

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(12px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1220px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    min-height: auto;
    padding-bottom: 16px;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .dashboard-grid,
  .review-grid,
  .summary-grid,
  .metrics-grid,
  .master-grid,
  .pivot-summary-grid,
  .pivot-slicer-grid,
  .pivot-layout {
    grid-template-columns: 1fr 1fr;
  }

  .review-session-grid {
    grid-template-columns: 1fr;
  }

  .filters-row,
  .pivot-control-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .term-row,
  .note-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .auth-shell,
  .dashboard-grid,
  .review-grid,
  .review-session-grid,
  .summary-grid,
  .metrics-grid,
  .master-grid,
  .pivot-summary-grid,
  .pivot-slicer-grid,
  .pivot-layout,
  .pivot-control-grid,
  .filters-row,
  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .topbar-actions,
  .helper-row,
  .modal-footer,
  .review-header {
    flex-direction: column;
    align-items: stretch;
  }

  .content-shell {
    padding-inline: 14px;
  }

  .panel,
  .chart-panel,
  .table-panel,
  .review-card {
    padding: 18px;
  }

  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 18px;
  }

  .auth-hero {
    min-height: 360px;
  }
}
