:root {
  color-scheme: light;
  --bg: #f6f7f8;
  --panel: #ffffff;
  --ink: #1f262e;
  --muted: #66727f;
  --line: #d9dee5;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-soft: #dff3f0;
  --warn: #9a3412;
  --ok: #166534;
  --shadow: 0 10px 30px rgba(31, 38, 46, 0.08);
}

* {
  box-sizing: border-box;
}

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

button,
input,
select {
  font: inherit;
}

.app {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 260px;
}

.mark {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  line-height: 1.2;
}

h2 {
  font-size: 16px;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.controls {
  display: flex;
  align-items: end;
  justify-content: flex-end;
  gap: 10px;
  flex-wrap: wrap;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  height: 38px;
  min-width: 112px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 0 10px;
}

button {
  height: 38px;
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0 14px;
  cursor: pointer;
}

button:hover {
  background: var(--accent-strong);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

button.secondary,
.icon-btn {
  border-color: var(--line);
  background: #fff;
  color: var(--ink);
}

button.secondary:hover,
.icon-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

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

.status-grid div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.status-grid strong {
  display: block;
  margin-top: 5px;
  font-size: 20px;
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.split {
  display: grid;
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: 14px;
}

.panel {
  min-height: 560px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.panel header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 50px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
}

.icon-btn {
  height: 32px;
  padding: 0 10px;
}

.code-table {
  display: grid;
  align-content: start;
  gap: 10px;
  max-height: 620px;
  overflow: auto;
  padding: 14px;
}

.account-editor {
  display: block;
  width: calc(100% - 28px);
  height: 620px;
  min-height: 560px;
  margin: 14px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.7;
  white-space: pre;
  overflow-wrap: normal;
}

.account-editor:focus {
  outline: 2px solid var(--accent-soft);
  border-color: var(--accent);
}

.empty {
  color: var(--muted);
  place-items: center;
}

.code-row {
  display: grid;
  grid-template-columns: minmax(170px, 1.1fr) minmax(88px, 0.55fr) minmax(132px, 0.8fr) minmax(140px, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.code-row strong,
.row-source {
  overflow-wrap: anywhere;
}

.row-code {
  display: inline-block;
  min-width: 82px;
  border-radius: 6px;
  background: #eef1f4;
  padding: 5px 7px;
  color: #26313b;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
}

.row-time,
.row-source {
  color: var(--muted);
  font-size: 12px;
}

.badge {
  min-width: 72px;
  text-align: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: #eef1f4;
  color: var(--muted);
  font-size: 12px;
}

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

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

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  color: var(--ink);
}

@media (max-width: 900px) {
  .toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls {
    justify-content: start;
  }

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

  .account-editor {
    min-height: 420px;
  }

  .code-row {
    grid-template-columns: 1fr;
    align-items: start;
  }
}
