:root {
  --color-carbon: #1c2430;
  --color-ink: #27313f;
  --color-muted: #667085;
  --color-soft: #f6f8fb;
  --color-panel: #ffffff;
  --color-line: #d9e1ea;
  --color-blue: #1f6feb;
  --color-green: #138a52;
  --color-amber: #b7791f;
  --color-red: #c2413a;
  --color-teal: #0f766e;
  --shadow-subtle: 0 10px 28px rgba(28, 36, 48, 0.08);
  --font-ui: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--color-soft);
}

body {
  margin: 0;
  color: var(--color-carbon);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
  font-weight: 700;
}

h2 {
  font-size: 15px;
  line-height: 1.25;
  font-weight: 700;
}

p {
  color: var(--color-muted);
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 20;
  width: 248px;
  padding: 18px 14px;
  background: #17202b;
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 6px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2f81f7;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
}

.brand strong {
  display: block;
  font-size: 14px;
}

nav {
  display: grid;
  gap: 4px;
}

.nav-btn {
  width: 100%;
  min-height: 38px;
  border: 0;
  border-radius: 8px;
  padding: 9px 10px;
  background: transparent;
  color: #cbd5e1;
  cursor: pointer;
  font: inherit;
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255, 255, 255, 0.07);
  color: #ffffff;
}

.nav-btn.active {
  background: #263445;
  color: #ffffff;
  box-shadow: inset 3px 0 0 #4ea1ff;
}

.session-bar {
  margin: auto 4px 0;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  display: grid;
  gap: 8px;
  color: #cbd5e1;
  font-size: 12px;
}

.session-bar a {
  color: #ffffff;
  text-decoration: none;
  font-weight: 700;
}

.shell {
  min-height: 100vh;
  margin-left: 248px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--color-line);
  backdrop-filter: blur(16px);
}

#view-subtitle {
  margin-top: 3px;
  font-size: 13px;
}

.status-strip {
  display: flex;
  align-items: center;
  gap: 10px;
}

button {
  min-height: 34px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  padding: 7px 12px;
  background: #ffffff;
  color: var(--color-ink);
  cursor: pointer;
  font: inherit;
  font-weight: 650;
}

button:hover {
  border-color: #9bb6d8;
  background: #f8fbff;
}

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

button.link-btn {
  min-height: auto;
  border: 0;
  padding: 0;
  background: transparent;
  color: var(--color-blue);
}

.status-dot {
  min-width: 78px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 5px 10px;
  background: #e8f5ee;
  color: var(--color-green);
  font-size: 12px;
  font-weight: 700;
}

.status-dot.error {
  background: #fff0ee;
  color: var(--color-red);
}

.alerts,
.content {
  width: min(100%, 1560px);
  margin: 0 auto;
  padding: 24px 28px;
}

.alerts {
  padding-bottom: 0;
}

.alerts:empty {
  display: none;
}

.content {
  display: grid;
  gap: 18px;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 12px;
}

.search-field {
  min-width: min(360px, 100%);
  display: grid;
  gap: 5px;
}

.search-field span {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

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

.metric {
  min-height: 108px;
  padding: 18px;
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 8px;
  box-shadow: var(--shadow-subtle);
}

.metric strong {
  display: block;
  margin-bottom: 8px;
  color: var(--color-carbon);
  font-size: 26px;
  line-height: 1.1;
  font-weight: 800;
  overflow-wrap: anywhere;
}

.metric span {
  color: var(--color-muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.panel {
  background: var(--color-panel);
  border: 1px solid var(--color-line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow-subtle);
}

.panel-head {
  min-height: 48px;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-line);
  background: #fbfcfe;
}

.form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  padding: 16px;
  background: #ffffff;
  border-bottom: 1px solid var(--color-line);
  align-items: end;
}

.form label {
  display: grid;
  gap: 5px;
}

.form label span {
  color: var(--color-muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.form button {
  justify-self: start;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--color-line);
  border-radius: 8px;
  padding: 8px 10px;
  background: #ffffff;
  color: var(--color-carbon);
  font: inherit;
}

textarea {
  min-height: 132px;
  grid-column: 1 / -1;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid rgba(31, 111, 235, 0.18);
  border-color: var(--color-blue);
}

.table-wrap {
  width: 100%;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th,
td {
  max-width: 280px;
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid #edf1f5;
  vertical-align: middle;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f3f6fa;
  color: #435063;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

td {
  color: #2f3a48;
  white-space: nowrap;
}

tbody tr:hover {
  background: #f8fbff;
}

.pill {
  display: inline-flex;
  min-height: 22px;
  align-items: center;
  border-radius: 999px;
  padding: 3px 9px;
  background: #eef2f7;
  color: #465467;
  font-size: 12px;
  font-weight: 750;
}

.pill.active,
.pill.delivered,
.pill.approved,
.pill.ok,
.pill.settled,
.pill.posted {
  background: #e6f7ee;
  color: var(--color-green);
}

.pill.scheduled,
.pill.pending,
.pill.received,
.pill.open {
  background: #fff7df;
  color: var(--color-amber);
}

.pill.archived,
.pill.void,
.pill.disabled {
  background: #eef2f7;
  color: #596579;
}

.pill.failed,
.pill.rejected,
.pill.dead,
.pill.mismatch {
  background: #fff0ee;
  color: var(--color-red);
}

.pill.processing,
.pill.retrying,
.pill.provider_credit {
  background: #e6f8f6;
  color: var(--color-teal);
}

.alert {
  padding: 12px 14px;
  background: #fff7df;
  border: 1px solid #f6d98f;
  border-radius: 8px;
  color: #805700;
  font-weight: 650;
}

@media (max-width: 1120px) {
  .sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    min-height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
  }

  .brand {
    flex: 0 0 auto;
    padding-bottom: 0;
    border-bottom: 0;
  }

  nav {
    display: flex;
    flex: 1 0 auto;
  }

  .nav-btn {
    width: auto;
    white-space: nowrap;
  }

  .shell {
    margin-left: 0;
  }

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

@media (max-width: 680px) {
  body {
    font-size: 13px;
  }

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

  .alerts,
  .content {
    padding-left: 12px;
    padding-right: 12px;
  }

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

  th,
  td {
    padding: 9px 10px;
  }
}
