:root {
  color-scheme: light;
  --background: #f4f6f8;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --text: #17212b;
  --muted: #647180;
  --border: #dce2e8;
  --primary: #183b56;
  --primary-hover: #102d43;
  --positive: #12704a;
  --negative: #a13b30;
  --focus: #3273dc;
  --shadow: 0 8px 30px rgba(20, 35, 50, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--background);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(20px, 5vw, 64px);
  background: var(--primary);
  color: #ffffff;
}

.topbar h1 {
  margin: 2px 0 0;
  font-size: clamp(1.5rem, 3vw, 2.2rem);
}

.eyebrow {
  margin: 0;
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.72;
}

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

.page {
  width: min(1480px, calc(100% - 32px));
  margin: 28px auto 56px;
}

.panel {
  margin-bottom: 22px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.2rem;
}

.muted {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.filter-panel,
.section-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
}

.filter-row,
.inline-controls,
.transaction-filters {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 600;
}

input {
  min-height: 40px;
  padding: 8px 11px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid #bcc7d1;
  border-radius: 8px;
}

input:focus-visible,
button:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--focus) 35%, transparent);
  outline-offset: 2px;
}

.button {
  min-height: 40px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-weight: 700;
}

.button:disabled {
  cursor: wait;
  opacity: 0.65;
}

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

.button-primary:hover {
  background: var(--primary-hover);
}

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

.topbar .button-secondary {
  border-color: rgba(255, 255, 255, 0.55);
}

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

.summary-card {
  display: grid;
  gap: 7px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.summary-card span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.summary-card strong {
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.summary-card small {
  color: var(--muted);
}

.status {
  padding: 7px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
}

.status-online {
  color: #d9ffef;
  background: rgba(35, 166, 108, 0.28);
}

.status-loading {
  color: #fff6cf;
  background: rgba(224, 171, 35, 0.28);
}

.status-offline {
  color: #ffe0dc;
  background: rgba(206, 75, 60, 0.28);
}

.segmented {
  display: inline-flex;
  padding: 3px;
  background: #eaf0f4;
  border-radius: 9px;
}

.segment {
  padding: 8px 12px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 7px;
  font-weight: 700;
}

.segment.active {
  color: var(--primary);
  background: #ffffff;
  box-shadow: 0 1px 5px rgba(20, 35, 50, 0.12);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
}

.checkbox-label input {
  min-height: auto;
}

.table-wrap {
  margin-top: 18px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 10px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

th,
td {
  padding: 11px 13px;
  text-align: left;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}

th {
  position: sticky;
  top: 0;
  color: #4b5967;
  background: var(--surface-soft);
  font-size: 0.77rem;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

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

tbody tr:hover {
  background: #f8fafb;
}

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

.positive {
  color: var(--positive);
}

.negative {
  color: var(--negative);
}

.empty-state,
.loading-state {
  padding: 30px;
  color: var(--muted);
  text-align: center;
}

.table-action {
  padding: 6px 9px;
  color: var(--primary);
  background: #ffffff;
  border: 1px solid #b8c4ce;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 700;
}

.dialog {
  width: min(520px, calc(100% - 30px));
  padding: 24px;
  border: 0;
  border-radius: 14px;
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.3);
}

.dialog::backdrop {
  background: rgba(12, 22, 31, 0.66);
  backdrop-filter: blur(2px);
}

.dialog h2 {
  margin-top: 0;
}

.dialog form {
  display: grid;
  gap: 16px;
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
}

.details-dialog {
  width: min(920px, calc(100% - 30px));
  max-height: 85vh;
  overflow: auto;
}

.dialog-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.icon-button {
  width: 38px;
  height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.8rem;
  line-height: 1;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.detail-item {
  padding: 12px;
  background: var(--surface-soft);
  border-radius: 8px;
}

.detail-item span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
}

.error {
  margin: 0;
  color: var(--negative);
  font-weight: 700;
}

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: min(440px, calc(100% - 40px));
  padding: 13px 16px;
  color: #ffffff;
  background: #243746;
  border-radius: 9px;
  box-shadow: var(--shadow);
}

@media (max-width: 980px) {
  .cards {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .filter-panel,
  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

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

@media (max-width: 620px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: space-between;
  }

  .page {
    width: min(100% - 20px, 1480px);
    margin-top: 12px;
  }

  .panel {
    padding: 16px;
  }

  .cards {
    grid-template-columns: 1fr;
  }

  .filter-row,
  .inline-controls,
  .transaction-filters {
    align-items: stretch;
    flex-direction: column;
  }

  .filter-row > *,
  .inline-controls > *,
  .transaction-filters > * {
    width: 100%;
  }

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