:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --text: #17202a;
  --muted: #667085;
  --line: #d9e0e7;
  --accent: #0f766e;
  --accent-strong: #0b5f59;
  --warn: #b45309;
  --bad: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #111827;
}
.login-screen.hidden { display: none; }
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border-radius: 8px;
  background: white;
}
.login-brand { color: var(--text); margin-bottom: 4px; }
.error { color: var(--bad); min-height: 20px; }
.userbar {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: flex-end;
}
.user-chip {
  border-radius: 6px;
  padding: 8px 11px;
  background: #eef2f6;
  color: #344054;
  font-weight: 700;
}
.forbidden { display: none !important; }
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr); min-height: 100vh; }
.sidebar {
  background: #111827;
  color: white;
  padding: 24px 18px;
}
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 28px; }
.brand strong { font-size: 22px; }
.brand span { display: block; color: #b6c0cc; font-size: 13px; margin-top: 2px; }
.mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--accent);
  font-weight: 800;
}
nav { display: grid; gap: 8px; }
.nav {
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #d8dee7;
  text-align: left;
  padding: 11px 12px;
  cursor: pointer;
}
.nav.active, .nav:hover { background: #243244; color: white; }

main {
  min-width: 0;
  padding: 28px;
}
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}
h1, h2 { margin: 0; letter-spacing: 0; }
h1 { font-size: 28px; }
h2 { font-size: 18px; }
p { color: var(--muted); margin: 6px 0 0; }
.badge {
  border-radius: 6px;
  padding: 8px 11px;
  background: #e7f6f3;
  color: var(--accent-strong);
  font-weight: 700;
  white-space: nowrap;
}

.view { display: none; }
.view.active { display: grid; gap: 18px; }
.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(150px, 1fr));
  gap: 14px;
}
.metric, .panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.metric { padding: 16px; }
.metric span { color: var(--muted); display: block; font-size: 13px; }
.metric strong { display: block; font-size: 30px; margin-top: 5px; }
.panel {
  min-width: 0;
  padding: 18px;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}
.actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.toolbar-input {
  min-width: 240px;
}
.actions select {
  min-width: 220px;
}

button {
  border: 1px solid var(--line);
  background: white;
  border-radius: 6px;
  padding: 9px 12px;
  cursor: pointer;
  color: var(--text);
}
button.primary, form button[type="submit"] {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
  font-weight: 700;
}
button:hover { filter: brightness(0.98); }

.form { display: grid; gap: 14px; }
.grid.two { display: grid; grid-template-columns: repeat(2, minmax(220px, 1fr)); gap: 12px; }
.grid.three { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  font: inherit;
  color: var(--text);
  background: white;
}
.check { display: flex; align-items: center; gap: 8px; color: var(--text); }
.check input { width: auto; }
.inline { grid-template-columns: 1fr 180px auto; align-items: end; }
.subhead { margin-top: 18px; }

.pack-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-bottom: 10px;
}
.pack-row button { height: 40px; }

.table { display: grid; gap: 8px; }
.row, .list-item, .customer-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto auto;
  gap: 12px;
  align-items: center;
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
.customer-item { grid-template-columns: 1fr auto auto auto; }
.row:first-child, .list-item:first-child, .customer-item:first-child { border-top: 0; }
.muted { color: var(--muted); }
.data-grid {
  width: 100%;
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.data-grid table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  background: white;
}
.compact-grid table { min-width: 680px; }
.data-grid th,
.data-grid td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}
.data-grid th {
  color: #475467;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  cursor: pointer;
  white-space: nowrap;
}
.data-grid td {
  font-size: 14px;
}
.data-grid tbody tr {
  cursor: pointer;
}
.data-grid tbody tr:hover {
  background: #f8fbfb;
}
.data-grid tr:last-child td {
  border-bottom: 0;
}
.data-grid button {
  margin-left: 6px;
}
.token {
  display: inline-block;
  margin-top: 6px;
  max-width: 420px;
  overflow-wrap: anywhere;
  color: #344054;
  background: #eef2f6;
  border-radius: 6px;
  padding: 5px 7px;
  font-family: Consolas, monospace;
  font-size: 12px;
}
.pill {
  border-radius: 999px;
  padding: 5px 9px;
  background: #eef2f6;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}
.pill.ok { background: #e7f6f3; color: var(--accent-strong); }
.pill.warn { background: #fff7ed; color: var(--warn); }
.pill.bad { background: #fef3f2; color: var(--bad); }
.result {
  display: block;
  max-width: 100%;
  min-width: 0;
  overflow-x: auto;
  overflow-y: auto;
  background: #101828;
  color: #e7edf6;
  border-radius: 8px;
  padding: 14px;
  line-height: 1.45;
  white-space: pre;
}
.result.compact:empty { display: none; }
.result.compact { margin: 14px 0; }
code { background: #eef2f6; padding: 2px 5px; border-radius: 4px; }

.modal {
  width: min(760px, calc(100vw - 36px));
  max-height: calc(100vh - 36px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--text);
  background: white;
  box-shadow: 0 24px 80px rgba(16, 24, 40, 0.28);
}
.modal.wide {
  width: min(1180px, calc(100vw - 36px));
}
.modal.small {
  width: min(560px, calc(100vw - 36px));
}
.modal::backdrop {
  background: rgba(17, 24, 39, 0.55);
}
.modal-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: start;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: white;
}
.modal > .form,
.dialog-body,
.linked-data {
  padding: 18px;
}
.dialog-body {
  display: grid;
  gap: 16px;
}
.dialog-message {
  margin: 0;
  color: var(--text);
}
.actions.end {
  justify-content: flex-end;
}
.token-output {
  width: 100%;
  min-height: 92px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 11px;
  color: var(--text);
  background: #f8fafc;
  font: 13px/1.5 Consolas, monospace;
  overflow-wrap: anywhere;
}
.transaction-detail {
  display: grid;
  gap: 18px;
  padding: 18px;
}
.detail-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(160px, 1fr));
  gap: 12px;
}
.detail-box {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.detail-box span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}
.detail-box strong {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
}
.detail-section {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.detail-section h3 {
  margin: 0;
  font-size: 16px;
}
.detail-table {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}
.detail-table table {
  width: 100%;
  min-width: 880px;
  border-collapse: collapse;
}
.detail-table th,
.detail-table td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
.detail-table th {
  color: #475467;
  background: #f8fafc;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}
.xml-panel {
  max-width: 100%;
  max-height: 360px;
  overflow: auto;
  margin: 0;
  padding: 14px;
  border-radius: 8px;
  background: #101828;
  color: #e7edf6;
  font: 12px/1.45 Consolas, monospace;
  white-space: pre;
}
.empty-detail {
  color: var(--muted);
  margin: 0;
}
.linked-data {
  display: grid;
  gap: 16px;
}
.subpanel {
  min-width: 0;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  .metrics, .grid.two, .grid.three, .inline, .pack-row, .row, .list-item, .customer-item { grid-template-columns: 1fr; }
  .detail-summary { grid-template-columns: 1fr; }
  .topbar { flex-direction: column; }
  .panel-head, .actions { align-items: stretch; flex-direction: column; }
  .toolbar-input, .actions select { min-width: 0; }
}
