:root {
  color-scheme: light;
  --ink: #17202b;
  --muted: #657385;
  --line: #d9e1ea;
  --soft: #f4f7fa;
  --panel: #ffffff;
  --panel-2: #f9fbfd;
  --green: #1f7a55;
  --green-bg: #e6f5ee;
  --blue: #255f9f;
  --blue-bg: #e8f1fc;
  --amber: #9a6400;
  --amber-bg: #fff2d8;
  --red: #b42318;
  --red-bg: #fde8e7;
  --shadow: 0 12px 26px rgba(23, 32, 43, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background: var(--soft);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.ledgerShell {
  width: min(1760px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 18px 0 28px;
}

.ledgerTopbar,
.panelHeader,
.filterBar,
.ledgerActions,
.statusTabs {
  display: flex;
  align-items: flex-start;
}

.ledgerTopbar {
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1.2;
  font-weight: 780;
  letter-spacing: 0;
}

p,
small,
.panelHeader span,
.metricCard span,
.itemMeta,
.sourceMeta {
  color: var(--muted);
}

#ledgerSubtitle {
  margin-top: 7px;
  font-size: 13px;
}

.ledgerActions {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.ledgerButton,
.statusTab {
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  font-size: 12px;
  font-weight: 760;
}

.ledgerButton {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 74px;
  padding: 0 12px;
}

.metricGrid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.metricCard {
  min-height: 86px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.metricCard strong {
  display: block;
  font-size: 27px;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metricCard span {
  display: block;
  margin-top: 9px;
  font-size: 12px;
  font-weight: 720;
}

.metricCard small {
  display: block;
  margin-top: 5px;
  font-size: 11px;
}

.ledgerLayout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 410px;
  gap: 12px;
  align-items: start;
}

.ledgerPanel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.primaryPanel {
  overflow: hidden;
}

.panelHeader {
  justify-content: space-between;
  gap: 16px;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
}

.panelHeader.compact {
  padding-bottom: 10px;
}

.panelHeader strong {
  display: block;
  font-size: 15px;
  line-height: 1.2;
}

.panelHeader span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
}

.statusTabs {
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.statusTab {
  min-width: 58px;
  min-height: 30px;
  padding: 0 10px;
  color: var(--muted);
  background: var(--panel-2);
}

.statusTab.active {
  color: var(--blue);
  border-color: rgba(37, 95, 159, 0.35);
  background: var(--blue-bg);
}

.filterBar {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 190px 220px;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  background: var(--panel-2);
}

.filterBar label {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.filterBar span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 740;
}

.filterBar input,
.filterBar select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  padding: 0 10px;
  font-size: 13px;
}

.itemTable,
.sourceTable {
  display: grid;
}

.tableHead,
.itemRow,
.sourceRow {
  display: grid;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.tableHead {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 38px;
  padding: 0 14px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 11px;
  font-weight: 780;
}

.itemTable .tableHead,
.itemRow {
  grid-template-columns: 142px 150px minmax(280px, 1fr) 112px 180px;
}

.itemRows {
  max-height: 660px;
  overflow: auto;
}

.itemRow,
.sourceRow {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}

.itemRow:last-child,
.sourceRow:last-child {
  border-bottom: 0;
}

.titleCell {
  min-width: 0;
}

.titleCell strong,
.sourceMain strong,
.sentItem strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-size: 13px;
  line-height: 1.34;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.titleCell a,
.sentItem a {
  color: var(--blue);
  font-size: 12px;
  font-weight: 740;
  text-decoration: none;
}

.itemMeta,
.sourceMeta {
  display: block;
  margin-top: 5px;
  overflow: hidden;
  font-size: 11px;
  line-height: 1.3;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 780;
  white-space: nowrap;
}

.badge.ok,
.badge.sent {
  color: var(--green);
  background: var(--green-bg);
}

.badge.notice {
  color: var(--blue);
  background: var(--blue-bg);
}

.badge.pending,
.badge.warn,
.badge.handled {
  color: var(--amber);
  background: var(--amber-bg);
}

.badge.error,
.badge.failed {
  color: var(--red);
  background: var(--red-bg);
}

.badge.neutral {
  color: var(--muted);
  background: var(--panel-2);
}

.timeMain {
  display: block;
  color: var(--ink);
  font-size: 12px;
  font-weight: 780;
  line-height: 1.35;
}

.sideStack {
  display: grid;
  gap: 12px;
}

.compactList,
.sentList {
  display: grid;
  max-height: 318px;
  overflow: auto;
}

.compactItem,
.sentItem {
  display: grid;
  gap: 5px;
  padding: 11px 14px;
  border-bottom: 1px solid var(--line);
}

.compactItem:last-child,
.sentItem:last-child {
  border-bottom: 0;
}

.compactItem span,
.sentItem span {
  color: var(--muted);
  font-size: 11px;
}

.emptyState {
  padding: 20px 14px;
  color: var(--muted);
  font-size: 13px;
}

.hourlyChart {
  display: grid;
  gap: 8px;
  padding: 12px 14px 14px;
}

.hourRow {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr) 42px;
  align-items: center;
  gap: 8px;
  font-size: 11px;
}

.hourTrack {
  position: relative;
  height: 12px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel-2);
}

.hourBar {
  height: 100%;
  min-width: 2px;
  border-radius: 8px;
  background: var(--blue);
}

.lowerGrid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 500px;
  gap: 12px;
  margin-top: 12px;
  align-items: start;
}

.sourceTable .tableHead,
.sourceRow {
  grid-template-columns: 150px minmax(180px, 1fr) 80px 70px 70px 90px;
}

.sourceRows {
  max-height: 520px;
  overflow: auto;
}

.sourceMain {
  min-width: 0;
}

@media (max-width: 1260px) {
  .metricGrid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

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

@media (max-width: 820px) {
  .ledgerTopbar,
  .panelHeader {
    display: grid;
  }

  .ledgerActions,
  .statusTabs {
    justify-content: flex-start;
  }

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

  .itemTable .tableHead,
  .sourceTable .tableHead {
    display: none;
  }

  .itemRow,
  .sourceRow {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
