:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --sidebar: #18202b;
  --sidebar-text: #e6edf4;
  --sidebar-muted: #93a4b7;
  --text: #172033;
  --muted: #667085;
  --line: #dfe5ee;
  --soft-line: #edf1f5;
  --primary: #1769e0;
  --primary-dark: #1052ad;
  --accent: #16845f;
  --danger: #bd2c2c;
  --danger-dark: #8c2020;
  --ok: #197149;
  --warn: #9a6200;
  --shadow: 0 16px 36px rgba(22, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 14px;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  min-height: 38px;
  border: 0;
  border-radius: 6px;
  background: var(--primary);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
  font-weight: 650;
  white-space: nowrap;
}

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

button:disabled {
  background: #b9c2cf;
  cursor: not-allowed;
}

button.secondary {
  background: #e8eef6;
  color: var(--text);
}

button.secondary:hover {
  background: #dbe3ef;
}

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

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

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

textarea {
  resize: vertical;
}

label span {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(390px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 0 0 22px;
  font-size: 24px;
}

.admin-shell {
  display: grid;
  grid-template-columns: 252px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: var(--sidebar);
  color: var(--sidebar-text);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 20px 14px;
}

.brand {
  display: grid;
  gap: 6px;
  padding: 4px 8px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.brand strong {
  font-size: 18px;
  letter-spacing: 0;
}

.brand span {
  color: var(--sidebar-muted);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.sidebar-nav {
  display: grid;
  gap: 6px;
  padding: 18px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  min-height: 40px;
  border-radius: 8px;
  color: var(--sidebar-muted);
  padding: 0 10px;
  font-weight: 650;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-link.active {
  background: #ffffff;
  color: #18202b;
}

.logout-form {
  margin-top: auto;
  padding: 14px 0 0;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.logout-form button {
  width: 100%;
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.content-header h1,
.panel-title h2 {
  margin: 0;
}

.content-header h1 {
  font-size: 28px;
  line-height: 1.2;
}

.content-header p,
.panel-title span {
  margin: 6px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  margin: 0 0 4px !important;
  color: var(--accent) !important;
  font-size: 12px;
  font-weight: 750;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  max-width: 260px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 750;
  overflow-wrap: anywhere;
}

.status-pill.online {
  border-color: #b7e2cd;
  background: #e7f7ef;
  color: var(--ok);
}

.status-pill.retrying,
.status-pill.pending {
  border-color: #f1d7a8;
  background: #fff6df;
  color: var(--warn);
}

.status-pill.error,
.status-pill.offline {
  border-color: #f4c7c7;
  background: #ffecec;
  color: var(--danger);
}

.notice {
  margin: 0 0 18px;
  border: 1px solid #b6d3ff;
  border-radius: 8px;
  background: #e9f2ff;
  color: #103f7f;
  padding: 12px 14px;
}

.alert {
  border-radius: 6px;
  background: #ffecec;
  color: var(--danger);
  padding: 10px 12px;
}

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

.stats div,
.summary-strip div,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.stats div {
  padding: 16px;
  box-shadow: 0 8px 22px rgba(22, 32, 51, 0.04);
}

.stats span,
.summary-strip span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.stats strong,
.summary-strip strong {
  display: block;
  margin-top: 6px;
  font-size: 28px;
  line-height: 1;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 18px;
}

.grid {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
}

.panel {
  margin-top: 18px;
  padding: 18px;
  box-shadow: 0 10px 28px rgba(22, 32, 51, 0.05);
}

.dashboard-grid .panel {
  margin-top: 0;
}

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

.summary-list {
  display: grid;
  gap: 0;
  margin: 0;
}

.summary-list div {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr);
  gap: 12px;
  border-bottom: 1px solid var(--soft-line);
  padding: 10px 0;
}

.summary-list div:first-child {
  padding-top: 0;
}

.summary-list div:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.summary-list dt {
  color: var(--muted);
  font-weight: 650;
}

.summary-list dd {
  margin: 0;
  color: var(--text);
  overflow-wrap: anywhere;
}

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

.summary-strip div {
  padding: 14px;
  background: #fbfcfe;
}

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

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

.wide {
  grid-column: 1 / -1;
}

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

.pause-form {
  margin-bottom: 14px;
}

.current-issue-panel {
  border-left: 4px solid var(--warn);
}

.current-issue-actions {
  gap: 10px;
  margin-top: 16px;
}

.summary-time {
  font-size: 16px !important;
  line-height: 1.35 !important;
  overflow-wrap: anywhere;
}

.okpay-clear-form {
  margin-top: 12px;
}

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

.check input {
  width: 18px;
  min-height: 18px;
}

.check span {
  margin: 0;
  color: var(--text);
}

.muted-check {
  opacity: 0.75;
}

.hint {
  white-space: pre-line;
  margin: 16px 0 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fafbfe;
  padding: 12px;
  color: var(--muted);
  line-height: 1.6;
}

.hint.compact {
  margin: 0;
}

.table-wrap {
  max-height: calc(100vh - 260px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

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

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #f8fafc;
  color: var(--muted);
  font-size: 13px;
}

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

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 9px;
  background: #edf1f7;
  color: #465369;
  font-weight: 650;
}

.badge.dropped {
  background: #eaf0ff;
  color: #2557a8;
}

.badge.claimed {
  background: #fff3d8;
  color: var(--warn);
}

.badge.drawn {
  background: #e4f7ec;
  color: var(--ok);
}

.badge.redeemed {
  background: #e7edf5;
  color: #526073;
}

.badge.void {
  background: #fde8e8;
  color: var(--danger);
}

.badge.pending,
.badge.processing {
  background: #fff3d8;
  color: var(--warn);
}

.badge.paid {
  background: #e4f7ec;
  color: var(--ok);
}

.badge.failed,
.badge.rejected {
  background: #fde8e8;
  color: var(--danger);
}

.cell-subtext {
  display: block;
  margin-top: 3px;
  color: var(--muted);
}

.wrap-cell {
  min-width: 180px;
  max-width: 320px;
  white-space: normal;
  overflow-wrap: anywhere;
}

.danger-text {
  color: var(--danger) !important;
}

.ledger-table {
  max-height: 420px;
}

.row-actions {
  display: flex;
  gap: 8px;
}

.row-actions button {
  min-height: 32px;
  padding: 0 10px;
}

.events {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}

.events li {
  display: grid;
  grid-template-columns: 170px 1fr;
  gap: 12px;
  border-bottom: 1px solid var(--soft-line);
  padding: 10px 0;
}

.events li:first-child {
  padding-top: 0;
}

.events li:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.events time {
  color: var(--muted);
}

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

.log-box {
  max-height: calc(100vh - 260px);
  overflow: auto;
  margin: 0;
  border: 1px solid #233044;
  border-radius: 8px;
  background: #111827;
  color: #d8e2ef;
  padding: 14px;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
}

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

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

@media (max-width: 820px) {
  .admin-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

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

  .main {
    padding: 20px;
  }

  .content-header,
  .panel-title {
    flex-direction: column;
  }

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

  .summary-list div,
  .events li {
    grid-template-columns: 1fr;
  }

  .row-actions {
    flex-wrap: wrap;
  }
}
