:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --panel-muted: #f3f5f7;
  --text: #18212b;
  --muted: #6b7682;
  --line: #dfe4ea;
  --line-soft: #edf0f3;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --danger: #b42318;
  --success: #147a45;
  --warning: #9a5b13;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(24, 33, 43, 0.04);
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  overflow-x: hidden;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  max-width: 100%;
}

.app-sidebar {
  width: 240px;
  background: #ffffff;
  border-right: 1px solid var(--line);
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.app-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px 14px;
  border-bottom: 1px solid var(--line-soft);
}

.app-brand__mark {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
}

.app-brand strong,
.app-sidebar__footer strong {
  display: block;
  font-weight: 500;
}

.app-brand > div,
.app-sidebar__footer > div {
  min-width: 0;
}

.app-brand strong,
.app-brand small,
.app-sidebar__footer strong,
.app-sidebar__footer small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-brand small,
.app-sidebar__footer small,
.muted {
  color: var(--muted);
}

.app-nav {
  display: grid;
  gap: 2px;
}

.app-nav__link {
  color: var(--text);
  padding: 8px 9px;
  border-radius: 5px;
  font-weight: 500;
}

.app-nav__link:hover,
.app-nav__link--active {
  background: var(--panel-muted);
  text-decoration: none;
}

.app-sidebar__footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--line-soft);
}

.app-main {
  width: calc(100% - 240px);
  padding: 24px;
}

.app-main > .grid,
.app-main > .panel,
.app-main > .toolbar,
.app-main > .selection-bar,
.app-main > form.panel {
  margin-bottom: var(--space-4);
}

.auth-main {
  width: 100%;
  display: grid;
  place-items: center;
  padding: 24px;
}

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

.page-header--compact {
  margin-bottom: 14px;
}

.page-header h1,
.page-header h2 {
  margin: 0 0 3px;
  font-weight: 500;
  letter-spacing: 0;
}

.page-header h1 {
  font-size: 24px;
}

.page-header h2 {
  font-size: 18px;
}

.page-header p {
  margin: 0;
  color: var(--muted);
}

.panel,
.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.panel {
  padding: 16px;
}

.auth-card {
  width: min(400px, 100%);
  padding: 26px;
}

.auth-card h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
}

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

.auth-card__brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-card__secondary-action {
  margin-top: 10px;
}

.auth-form {
  gap: 12px;
}

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

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

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

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

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
}

.metric small {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}

.metric strong {
  font-size: 22px;
  font-weight: 500;
}

.metric__value {
  min-height: 32px;
  display: flex;
  align-items: center;
}

.table-wrap {
  overflow-x: auto;
}

.payment-plan {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--panel);
}

.payment-plan__scroll {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
}

.payment-plan__table {
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
  width: max-content;
  min-width: 100%;
}

.payment-plan__table th,
.payment-plan__table td {
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
  font-size: 12px;
  line-height: 1.2;
  min-width: 88px;
  max-width: 88px;
  height: 38px;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: right;
  vertical-align: middle;
  scroll-snap-align: start;
}

.payment-plan__label {
  position: sticky;
  left: 0;
  z-index: 4;
  min-width: 172px !important;
  max-width: 172px !important;
  text-align: left !important;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line);
  color: var(--muted);
  font-weight: 500;
}

.payment-plan__year {
  text-align: center !important;
  background: #f7f9fb;
  color: #4b5563;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
}

.payment-plan__month {
  color: #5b6674;
  font-weight: 600;
}

.payment-plan__cell--paid {
  background: #eefaf3;
  color: #166534;
}

.payment-plan__cell--partial {
  background: #fff8e6;
  color: #8a5a00;
}

.payment-plan__cell--overdue {
  background: #fff1f2;
  color: #b42318;
}

.payment-plan__cell--future {
  background: #ffffff;
  color: var(--text);
}

.payment-plan__cell--current {
  box-shadow: inset 0 3px 0 var(--primary);
}

.payment-plan__status-dot {
  border-radius: 999px;
  display: inline-block;
  height: 9px;
  width: 9px;
}

.payment-plan__status-dot--paid {
  background: #16a34a;
}

.payment-plan__status-dot--partial {
  background: #d97706;
}

.payment-plan__status-dot--overdue {
  background: #dc2626;
}

.payment-plan__status-dot--future {
  background: #94a3b8;
}

.panel--warning {
  border-color: #f1c96b;
  background: #fffaf0;
}

.table-panel {
  padding: 0;
  overflow: hidden;
}

.table-panel > .page-header {
  margin-bottom: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.import-section {
  border-left-width: 3px;
}

.import-section--review {
  border-left-color: #d97706;
}

.import-section--ready {
  border-left-color: var(--success);
}

.import-section--excluded {
  border-left-color: #64748b;
}

.import-section--error {
  border-left-color: var(--danger);
}

.hidden-form-stack {
  display: none;
}

.review-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  background: #ffffff;
}

.review-table {
  min-width: 2220px;
  table-layout: fixed;
}

.review-table th,
.review-table td {
  vertical-align: middle;
}

.review-table th {
  white-space: normal;
}

.review-table td {
  height: 54px;
}

.review-table__col--id {
  width: 112px;
}

.review-table__col--transaction {
  width: 150px;
}

.review-table__col--date {
  width: 136px;
}

.review-table__col--reference {
  width: 190px;
}

.review-table__col--money {
  width: 116px;
}

.review-table__col--person {
  width: 180px;
}

.review-table__col--email {
  width: 220px;
}

.review-table__col--phone {
  width: 150px;
}

.review-table__col--code {
  width: 140px;
}

.review-table__col--status {
  width: 150px;
}

.review-table__col--status-text {
  width: 140px;
}

.review-table__col--reason {
  width: 220px;
}

.review-table__col--approve {
  width: 82px;
}

.review-table__sticky {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--panel);
  box-shadow: 1px 0 0 var(--line-soft);
}

.review-table__issues {
  color: var(--muted);
  font-size: 13px;
}

.review-table__changed td {
  background: #fffaf0;
}

.review-table__changed .review-table__sticky {
  background: #fffaf0;
}

.review-table__pending-save td,
.review-table__pending-save .review-table__sticky {
  background: #fffbeb;
}

.review-table__save-error td,
.review-table__save-error .review-table__sticky {
  background: #fff3f3;
}

.import-row--needs-review td,
.import-row--needs-review .review-table__sticky {
  background: #fffbeb;
}

.import-row--ready td,
.import-row--ready .review-table__sticky {
  background: #fbfefc;
}

.review-table .table-input {
  min-width: 0;
}

.table-input {
  width: 100%;
  min-width: 150px;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 7px 8px;
  background: transparent;
  font: inherit;
}

.table-input:focus {
  border-color: #7aa7d9;
  background: #ffffff;
  outline: none;
  box-shadow: 0 0 0 2px rgba(34, 119, 199, 0.12);
}

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

.button--compact {
  padding: 7px 10px;
}

.center {
  text-align: center;
}

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

th,
td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

th {
  color: #56616d;
  font-size: 12px;
  font-weight: 500;
  background: #fafbfc;
}

tbody tr:hover {
  background: #fbfcfd;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.data-table {
  min-width: 980px;
}

.select-cell {
  width: 42px;
  text-align: center;
}

.table-link {
  color: var(--text);
  font-weight: 500;
}

.number-cell {
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

.document-upload-cell {
  display: grid;
  gap: 8px;
  min-width: 260px;
}

.document-upload-cell--compact {
  min-width: 180px;
  gap: 5px;
}

.document-upload-cell__status {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 8px;
  align-items: center;
}

.document-upload-cell__status small {
  color: var(--muted);
}

.document-upload-cell__issue {
  flex-basis: 100%;
  color: var(--warning) !important;
}

.document-upload-cell--compact .document-upload-cell__issue {
  max-width: 220px;
}

.document-upload-cell__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.document-upload-cell__actions .hint {
  margin: 0;
}

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

.inline-upload-form .inline-file-input {
  width: min(230px, 100%);
  min-height: 32px;
  padding: 5px 7px;
  font-size: 13px;
}

.document-upload-cell--compact .inline-upload-form {
  gap: 4px;
}

.document-upload-cell--compact .inline-upload-form .inline-file-input {
  width: 150px;
  font-size: 12px;
}

.empty-row {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
}

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

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.modal-launcher {
  display: inline-flex;
}

.actions > form {
  display: inline-flex;
  margin: 0;
}

.actions > .button,
.actions > button,
.actions > input[type="submit"],
.actions > form > button,
.actions > form > input[type="submit"] {
  flex: 0 0 auto;
  width: auto;
}

.button,
button,
input[type="submit"] {
  border: 1px solid transparent;
  border-radius: 5px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  padding: 7px 11px;
  width: auto;
  max-width: 100%;
  font: inherit;
  font-weight: 500;
  white-space: nowrap;
}

.button:hover,
button:hover,
input[type="submit"]:hover {
  background: var(--primary-strong);
  text-decoration: none;
}

.button:disabled,
button:disabled,
input[type="submit"]:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.button--secondary {
  background: #ffffff;
  border-color: var(--line);
  color: var(--text);
}

.button--secondary:hover {
  background: var(--panel-muted);
}

.button--ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.button--ghost:hover {
  background: var(--panel-muted);
  color: var(--text);
}

.button--danger {
  background: var(--danger);
}

.button--full {
  width: 100%;
}

button.button--full,
input[type="submit"].button--full {
  width: 100%;
}

form.panel {
  display: grid;
  gap: 14px;
  max-width: 1040px;
}

form.panel > .actions {
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
  padding-top: 14px;
}

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

.form-grid--compact {
  gap: 10px 12px;
}

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

.field--full {
  grid-column: 1 / -1;
}

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

.field--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
}

label {
  color: #384451;
  font-size: 13px;
  font-weight: 500;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

input[type="submit"] {
  width: auto;
}

input[type="file"] {
  padding: 6px 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  outline: none;
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--text);
  background: #f8fafc;
  cursor: not-allowed;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

.readonly-field {
  min-height: 34px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 7px 9px;
  color: var(--muted);
  background: #fafbfc;
}

.hint {
  color: var(--muted);
  font-size: 12px;
}

.toolbar {
  margin-bottom: 12px;
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 10px;
}

.filter-bar .field {
  flex: 0 1 160px;
  gap: 4px;
  min-width: 140px;
}

.filter-bar .filter-field--search {
  flex-basis: 260px;
}

.filter-bar .filter-field--wide {
  flex-basis: 230px;
}

.filter-bar label {
  color: var(--muted);
  font-size: 12px;
}

.filter-bar input,
.filter-bar select {
  min-height: 32px;
  padding: 6px 8px;
  font-size: 13px;
}

.filter-bar input[type="submit"],
.filter-bar .button {
  min-height: 32px;
  padding: 6px 10px;
}

.filter-actions,
.toolbar-actions {
  display: flex;
  gap: 6px;
  align-items: end;
  flex: 0 0 auto;
  margin-left: auto;
}

.filter-actions .button--ghost,
.toolbar-actions .button--ghost {
  color: var(--muted);
}

.selection-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 9px 12px;
  margin-bottom: 10px;
}

.selection-bar [data-bulk-messaging-target="count"] {
  font-weight: 500;
}

.flash-stack {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
}

.flash,
.alert {
  border: 1px solid var(--line);
  border-radius: 7px;
  box-shadow: 0 12px 28px rgba(15, 23, 42, 0.12);
  padding: 9px 11px;
  font-size: 13px;
  line-height: 1.38;
  font-weight: 400;
}

.flash--notice {
  background: #f3fbf6;
  border-color: #cdebd8;
  color: #17643a;
}

.flash--alert,
.alert--error {
  background: #fff3f3;
  border-color: #f2c9c9;
  color: #9f1d24;
}

.alert--warning {
  background: #fff7e8;
  color: var(--warning);
}

.alert ul {
  margin: 8px 0 0;
  padding-left: 20px;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eef2f6;
  color: #394653;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.25;
  white-space: nowrap;
  vertical-align: middle;
}

.badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: currentColor;
  flex: 0 0 auto;
}

.badge--active,
.badge--approved,
.badge--sent,
.badge--generated,
.badge--applied {
  background: #e9f7ef;
  color: var(--success);
}

.badge--failed,
.badge--canceled,
.badge--archived,
.badge--disabled {
  background: #fdecec;
  color: var(--danger);
}

.badge--scheduled,
.badge--pending-approval,
.badge--review-required,
.badge--needs-review,
.badge--processing-stalled {
  background: #fff3df;
  color: var(--warning);
}

.badge--uploaded,
.badge--queued,
.badge--processing {
  background: #eef6ff;
  color: #2277c7;
}

.badge--not-uploaded {
  background: #eef2f6;
  color: #64748b;
}

.badge--ready-for-import {
  background: #e9f7ef;
  color: var(--success);
}

.detail-list {
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 8px 16px;
}

.detail-list dt {
  color: var(--muted);
}

.detail-list dd {
  margin: 0;
}

.tabs {
  display: flex;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}

.tabs a {
  color: var(--text);
  padding: 9px 10px;
  font-weight: 500;
}

.tabs a:hover {
  background: var(--panel-muted);
  text-decoration: none;
}

.modal {
  width: min(760px, calc(100vw - 32px));
  max-height: min(780px, calc(100vh - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 16px 40px rgba(24, 33, 43, 0.16);
}

.modal::backdrop {
  background: rgba(24, 33, 43, 0.28);
}

.modal--form {
  width: min(720px, calc(100vw - 32px));
}

.modal__header,
.modal__actions {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
}

.modal__header {
  border-bottom: 1px solid var(--line-soft);
}

.modal__header h2 {
  margin: 0 0 3px;
  font-size: 18px;
  font-weight: 500;
}

.modal__header p {
  margin: 0;
  color: var(--muted);
}

.modal__body {
  padding: 16px;
  overflow: auto;
}

.modal-form {
  display: grid;
  gap: 14px;
}

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

.modal-form > .actions {
  border-top: 1px solid var(--line-soft);
  margin-top: 2px;
  padding-top: 14px;
}

.terms-modal {
  display: grid;
  gap: 12px;
}

.terms-modal__summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.terms-modal__summary > div {
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  background: #fbfcfd;
  padding: 10px;
}

.terms-modal__summary small,
.quick-term-card small {
  display: block;
  color: var(--muted);
}

.terms-modal__summary strong {
  font-weight: 500;
}

.quick-term-card {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  padding: 12px;
}

.quick-term-card--new {
  background: #fbfcfd;
}

.quick-term-card__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.quick-term-card__header small {
  margin-top: 3px;
  max-width: 560px;
}

.quick-term-form {
  display: grid;
  gap: 10px;
}

.quick-term-form__grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.quick-term-form__actions {
  justify-content: flex-end;
}

.modal__actions {
  padding: 14px 0 0;
  justify-content: flex-end;
}

.form-error:empty {
  display: none;
}

.form-error {
  color: var(--danger);
  margin: 0 0 12px;
}

.review-box {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: #ffffff;
}

.review-box h3 {
  margin: 14px 0 8px;
  font-size: 15px;
  font-weight: 500;
}

.review-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text);
}

@media (max-width: 1100px) {
  .filter-actions,
  .toolbar-actions {
    margin-left: 0;
    align-items: center;
  }
}

@media (max-width: 900px) {
  .flash-stack {
    right: 12px;
    bottom: 12px;
    width: min(340px, calc(100vw - 24px));
  }

  .app-shell {
    display: block;
  }

  .app-sidebar {
    width: 100%;
    height: auto;
    position: sticky;
    z-index: 30;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 10px 12px 8px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px 12px;
    align-items: center;
    background: rgba(255, 255, 255, 0.98);
    box-shadow: 0 1px 2px rgba(24, 33, 43, 0.04);
    top: 0;
  }

  .app-brand {
    min-width: 0;
    border-bottom: 0;
    padding: 0;
  }

  .app-brand__mark {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    font-size: 13px;
  }

  .app-nav {
    grid-column: 1 / -1;
    display: flex;
    gap: 4px;
    max-width: 100%;
    margin: 0;
    padding: 2px 0 3px;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-x: contain;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .app-nav::-webkit-scrollbar {
    display: none;
  }

  .app-nav__link {
    flex: 0 0 auto;
    scroll-snap-align: start;
    scroll-margin-inline: 12px;
    padding: 7px 8px;
    text-align: center;
    white-space: nowrap;
    line-height: 1.2;
  }

  .app-sidebar__footer {
    grid-column: 2;
    grid-row: 1;
    margin: 0;
    padding: 0;
    border-top: 0;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 8px;
  }

  .app-sidebar__footer strong {
    max-width: 140px;
  }

  .app-sidebar__footer small {
    display: none;
  }

  .app-sidebar__footer form {
    display: inline-flex;
    margin: 0;
  }

  .app-sidebar__footer .button,
  .app-sidebar__footer .button--full {
    width: auto;
    min-height: 30px;
    padding: 5px 10px;
  }

  .app-main {
    width: 100%;
    padding: 16px 14px 24px;
  }

  .grid--2,
  .grid--3,
  .grid--4,
  .form-grid,
  .terms-modal__summary,
  .quick-term-form__grid {
    grid-template-columns: 1fr;
  }

  .filter-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-bar .field,
  .filter-bar .filter-field--search,
  .filter-bar .filter-field--wide {
    min-width: 0;
  }

  .filter-actions,
  .toolbar-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .page-header,
  .selection-bar,
  .modal__header {
    display: grid;
  }

  .detail-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .app-sidebar {
    gap: 8px;
  }

  .app-sidebar__footer > div {
    display: none;
  }

  .app-main {
    padding: 14px 12px 22px;
  }

  .page-header {
    gap: 10px;
    margin-bottom: 14px;
  }

  .page-header h1 {
    font-size: 22px;
  }

  .panel,
  .metric,
  .review-box {
    padding: 14px;
  }

  .table-panel {
    padding: 0;
  }

  .filter-bar {
    grid-template-columns: 1fr;
  }

  .filter-actions > *,
  .toolbar-actions > * {
    flex: 1 1 0;
  }
}
