.ui-panel {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 1rem;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  min-width: 0;
  color: #334155;
  font-size: .875rem;
  box-shadow: 0 1px 2px #0000000d;
}

.ui-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 0;
  line-height: 1.25;
}

.ui-subtitle {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: .75rem;
  color: #0f172a;
}

.ui-field {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid #cbd5e1;
  border-radius: .75rem;
  padding: .65rem 1rem;
  font: inherit;
  font-size: .875rem;
  color: #334155;
  box-shadow: 0 1px 2px #0000000d;
  background: white;
  margin: .35rem 0 1rem;
  font-weight: 400;
}

.ui-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: .45rem;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: .75rem;
  font-size: .875rem;
  padding: .6rem 1rem;
  background: #4f46e5;
  color: white;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: background-color .15s, box-shadow .15s;
  box-shadow: 0 1px 2px #0000000d;
}

.ui-button.secondary {
  background: white;
  color: #334155;
  border-color: #cbd5e1;
}

.ui-button.danger { background: #dc2626; }
.ui-button.success { background: #059669; }
.ui-button.success:hover { background: #047857; }
.ui-button.ghost { background: transparent; color: #4338ca; border-color: transparent; box-shadow: none; }
.ui-button.ghost:hover { background: #eef2ff; }
.ui-button.sm { min-height: 36px; padding: .35rem .7rem; font-size: .8125rem; }

.ui-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .65rem;
  align-items: center;
  margin: 1rem 0;
}

.ui-muted {
  color: #64748b;
  font-size: .875rem;
}

.ui-error {
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: .75rem;
  padding: 1rem;
  margin-bottom: 1rem;
}

.ui-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.ui-metric {
  border: 1px solid #e2e8f0;
  border-radius: .75rem;
  padding: 1rem;
  background: white;
  font-size: .875rem;
  color: #64748b;
}

.ui-metric strong {
  display: block;
  font-size: 1.5rem;
  margin: .25rem 0;
  color: #0f172a;
}

.ui-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
  table-layout: fixed;
}

.ui-table.is-fluid { table-layout: auto; }

.ui-table th, .ui-table td {
  padding: .8rem;
  border-bottom: 1px solid #e2e8f0;
  text-align: left;
  vertical-align: top;
}

.ui-table th {
  color: #64748b;
  font-weight: 600;
  background: #f8fafc;
}

.ui-table a:not([class]) {
  color: #4f46e5;
  text-decoration: underline;
}

.ui-scroll {
  overflow-x: auto;
}

.ui-badge {
  display: inline-block;
  padding: .25rem .65rem;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: .8rem;
  font-weight: 600;
  white-space: nowrap;
}

.ui-badge.paid, .ui-badge.sent {
  background: #d1fae5;
  color: #065f46;
}

.ui-badge.review, .ui-badge.uncertain {
  background: #fef3c7;
  color: #92400e;
}

.ui-badge.partially_paid {
  background: #e0e7ff;
  color: #3730a3;
}

.ui-badge.failed, .ui-badge.cancelled {
  background: #fee2e2;
  color: #b91c1c;
}

.ui-filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 145px), 1fr));
  gap: .75rem;
  align-items: end;
}

.ui-filters .ui-field {
  margin-bottom: 0;
}

.ui-wrap {
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.ui-item {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: end;
}

@media (max-width: 640px) {
  .ui-item {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .ui-item > :first-child {
    grid-column: 1 / -1;
  }

  .ui-responsive thead {
    display: none;
  }

  .ui-responsive, .ui-responsive tbody, .ui-responsive tr {
    display: block;
  }

  .ui-responsive tr {
    border-bottom: 1px solid #cbd5e1;
    padding: .5rem 0;
  }

  .ui-responsive td {
    display: grid;
    grid-template-columns: 7rem minmax(0, 1fr);
    gap: .5rem;
    border: 0;
    padding: .5rem 0;
    overflow-wrap: anywhere;
  }

  .ui-responsive td::before {
    content: attr(data-label);
    color: #64748b;
    font-size: .8rem;
  }

  .ui-responsive td > * {
    grid-column: 2;
  }

  .ui-responsive td > br {
    display: none;
  }

  .ui-responsive td > input[type=checkbox] {
    justify-self: start;
  }

  .ui-responsive .ui-badge {
    justify-self: start;
  }

  .ui-panel {
    padding: 1rem;
  }
}

.ui-panel label, .ui-field-label {
  font-size: .875rem;
  font-weight: 600;
  color: #334155;
}

.ui-panel input, .ui-panel textarea, .ui-panel select {
  font-family: inherit;
}

.ui-field::placeholder {
  color: #94a3b8;
}

.ui-field:focus {
  outline: 2px solid #c7d2fe;
  outline-offset: 0;
  border-color: #6366f1;
}

.ui-field:disabled {
  cursor: not-allowed;
  background: #f1f5f9;
  color: #64748b;
}

.ui-button:hover {
  background: #4338ca;
}

.ui-button.secondary:hover {
  background: #f8fafc;
}

.ui-button.danger:hover {
  background: #b91c1c;
}

.ui-button:focus-visible, .ui-panel a:focus-visible {
  outline: 2px solid #6366f1;
  outline-offset: 3px;
}

.ui-button:disabled {
  opacity: .6;
  cursor: wait;
}

.ui-table td {
  overflow-wrap: anywhere;
}

@media (min-width: 1024px) {
  .ui-title {
    font-size: 1.875rem;
  }
}

.ui-search .ui-field {
  margin: 0;
}

.ui-dialog { width: min(56rem, calc(100vw - 2rem)); max-width: none; max-height: calc(100dvh - 2rem); margin: auto; padding: 0; border: 0; border-radius: 1rem; color: #334155; box-shadow: 0 24px 64px #0f172a55; }
.ui-dialog::backdrop { background: #0f172a99; backdrop-filter: blur(2px); }
.ui-dialog-shell { position: relative; max-height: calc(100dvh - 2rem); overflow-y: auto; padding: 1.5rem; background: white; }
.ui-dialog-close { position: sticky; top: 0; z-index: 2; display: flex; margin-left: auto; width: 2.5rem; height: 2.5rem; align-items: center; justify-content: center; border-radius: .75rem; background: white; color: #64748b; font-size: 1.75rem; line-height: 1; cursor: pointer; box-shadow: 0 1px 4px #0002; }
.ui-dialog-close:hover { background: #f1f5f9; color: #0f172a; }
.ui-dialog-close:focus-visible { outline: 2px solid #6366f1; outline-offset: 2px; }
.ui-dialog-loading { min-height: 12rem; display: grid; place-items: center; color: #64748b; }

@media (max-width: 640px) {
  .ui-dialog { width: calc(100vw - 1rem); max-height: calc(100dvh - 1rem); }
  .ui-dialog-shell { max-height: calc(100dvh - 1rem); padding: 1rem; }
}
