:root {
  color-scheme: light;
  --bg: #eef5ff;
  --bg-soft: #f7fbff;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #dbe3ee;
  --primary: #1463d8;
  --primary-hover: #0f4fac;
  --accent: #0f9f8f;
  --accent-soft: #e7faf6;
  --warm: #f59e0b;
  --danger: #b42318;
  --ok: #067647;
  --warn: #b54708;
  --shadow: 0 18px 45px rgba(15, 23, 42, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #e9f3ff 0%, var(--bg) 42%, #f8fbff 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

.front-shell {
  width: min(860px, calc(100vw - 32px));
}

.admin-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  width: min(1320px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0;
}

.sidebar {
  position: sticky;
  top: 24px;
  align-self: start;
  min-height: calc(100vh - 48px);
  border: 1px solid rgba(20, 99, 216, 0.14);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--shadow);
  padding: 16px;
}

.sidebar-brand {
  display: grid;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 14px;
  margin-bottom: 14px;
}

.sidebar-brand strong {
  color: #0f2f5f;
  font-size: 20px;
}

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

.side-nav {
  display: grid;
  gap: 8px;
}

.side-link {
  justify-content: start;
  width: 100%;
  background: #f4f8ff;
  color: #263b5c;
  box-shadow: none;
  text-align: left;
}

.side-link:hover:not(:disabled),
.side-link.active {
  background: var(--primary);
  color: #ffffff;
}

.admin-main {
  min-width: 0;
}

.admin-view {
  display: none;
}

.admin-view.active {
  display: block;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
  border: 1px solid rgba(20, 99, 216, 0.14);
  border-radius: 8px;
  background: linear-gradient(135deg, #ffffff 0%, #f2f8ff 58%, #ecfdf8 100%);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.2;
  color: #0f2f5f;
}

h2 {
  font-size: 16px;
}

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

.actions,
.submit-row,
.result-head,
.inline-actions,
.link-grid,
.address-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: 16px;
}

.single-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(360px, 0.78fr);
  gap: 16px;
}

.front-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.admin-grid.lower {
  align-items: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}

.cdk-output {
  align-self: stretch;
}

.grid {
  display: grid;
  gap: 14px;
  margin-bottom: 14px;
}

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

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

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

.grid.cdk-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
}

label {
  display: grid;
  gap: 7px;
}

.address-tools {
  align-items: end;
  margin-bottom: 14px;
}

.address-tools label {
  flex: 1;
  min-width: 0;
}

label span,
summary {
  color: #263b5c;
  font-size: 13px;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid #c2d2e8;
  border-radius: 6px;
  color: var(--text);
  background: var(--bg-soft);
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  outline: none;
}

input {
  height: 38px;
  padding: 0 10px;
}

textarea {
  min-height: 100px;
  padding: 10px;
  resize: vertical;
}

textarea::placeholder,
input::placeholder {
  color: #8a9bb3;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(19, 104, 216, 0.15);
  background: #ffffff;
}

details {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 12px;
}

summary {
  cursor: pointer;
  list-style-position: outside;
}

.advanced-grid {
  margin-top: 14px;
}

.proxy-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 8px;
}

.compact-notice {
  margin-top: 10px;
  padding: 9px 11px;
  font-size: 12px;
}

button {
  height: 38px;
  border: 0;
  border-radius: 6px;
  padding: 0 14px;
  color: #ffffff;
  background: var(--primary);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 8px 16px rgba(20, 99, 216, 0.16);
}

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

button.secondary {
  background: #475569;
  box-shadow: none;
}

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

button.danger:hover:not(:disabled) {
  background: #8f1c13;
}

.small-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 12px;
  white-space: nowrap;
  box-shadow: none;
}

.inline-actions {
  justify-content: flex-end;
}

.accent,
.actions button {
  background: var(--accent);
  box-shadow: 0 8px 16px rgba(15, 159, 143, 0.14);
}

.accent:hover:not(:disabled),
.actions button:hover:not(:disabled) {
  background: #0b8276;
}

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

.submit-row {
  justify-content: flex-end;
  margin-top: 16px;
}

.result-panel {
  min-width: 0;
  margin-top: 16px;
}

.compact-result pre {
  min-height: 220px;
}

.result-head {
  justify-content: space-between;
  margin-bottom: 14px;
}

.pill {
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 750;
  background: #e6eef8;
  color: #334155;
}

.pill.ok {
  background: var(--accent-soft);
  color: var(--ok);
}

.pill.err {
  background: #fee4e2;
  color: var(--danger);
}

.pill.busy {
  background: #fef0c7;
  color: var(--warn);
}

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

pre {
  min-height: 260px;
  max-height: 520px;
  overflow: auto;
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #111827;
  color: #d7f4ff;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}

.notice {
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 14px;
  font-size: 14px;
  line-height: 1.5;
}

.notice.muted {
  background: #f8fbff;
  color: var(--muted);
}

.notice.ok {
  background: var(--accent-soft);
  border-color: #a9eadf;
  color: var(--ok);
}

.notice.err {
  background: #fff1f0;
  border-color: #ffc9c4;
  color: var(--danger);
}

.notice.busy {
  background: #fff8e6;
  border-color: #f8d890;
  color: var(--warn);
}

.status-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #ffffff;
  box-shadow: var(--shadow);
}

.status-card span {
  display: block;
  margin-bottom: 6px;
  font-size: 18px;
  font-weight: 800;
}

.status-card p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.5;
}

.status-card.ok {
  border-color: #a9eadf;
  background: #f1fffb;
}

.status-card.err {
  border-color: #ffc9c4;
  background: #fff7f6;
}

.status-card.busy {
  border-color: #f8d890;
  background: #fffaf0;
}

.submission-panel {
  min-width: 0;
}

.list-box {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.list-item {
  display: grid;
  height: auto;
  min-height: 64px;
  width: 100%;
  gap: 4px;
  align-items: center;
  justify-items: start;
  border: 1px solid #dbe3ee;
  border-radius: 8px;
  padding: 10px 12px;
  background: #f8fbff;
  color: var(--text);
  box-shadow: none;
  text-align: left;
}

.list-item.split {
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.cdk-list-item {
  grid-template-columns: auto minmax(0, 1fr) auto;
}

.cdk-check {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--primary);
}

.submission-list {
  max-height: 300px;
}

.record-list {
  max-height: 620px;
}

.submission-item {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
}

.upload-record-item {
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
}

.submission-item.success {
  border-color: #a9eadf;
  background: #f1fffb;
}

.upload-record-item.success {
  border-color: #a9eadf;
  background: #f1fffb;
}

.submission-item.failed {
  border-color: #ffc9c4;
  background: #fff7f6;
}

.upload-record-item.failed {
  border-color: #ffc9c4;
  background: #fff7f6;
}

.record-status {
  display: inline-grid;
  min-width: 50px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  background: #e6eef8;
  color: #334155;
}

.record-status.success {
  background: var(--accent-soft);
  color: var(--ok);
}

.record-status.failed {
  background: #fee4e2;
  color: var(--danger);
}

.submission-main {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.list-main {
  display: grid;
  width: 100%;
  height: auto;
  min-height: 42px;
  gap: 4px;
  justify-items: start;
  padding: 0;
  background: transparent;
  color: var(--text);
  box-shadow: none;
  text-align: left;
}

.list-main:hover:not(:disabled),
.list-item:hover {
  background: #eef8ff;
  color: var(--text);
}

.list-item:hover {
  border-color: #bad5f7;
}

.list-item strong,
.list-main strong {
  font-size: 13px;
  letter-spacing: 0;
}

.list-item span,
.list-main span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.copy-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid #a9eadf;
  border-radius: 8px;
  background: #f1fffb;
  padding: 14px;
}

.copy-box.batch {
  align-items: stretch;
  flex-direction: column;
}

.copy-box.muted {
  align-items: flex-start;
  flex-direction: column;
  border-color: #dbe3ee;
  background: #f8fbff;
}

.copy-value {
  display: grid;
  min-width: 0;
  gap: 4px;
}

.copy-value strong,
.copy-box strong {
  color: #0f2f5f;
  font-size: 16px;
  word-break: break-word;
}

.copy-value span,
.copy-box span {
  color: var(--muted);
  font-size: 13px;
}

.batch-code-list {
  display: grid;
  gap: 8px;
  max-height: 220px;
  overflow: auto;
}

.batch-copy-text {
  min-height: 96px;
  max-height: 150px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: #0f2f5f;
  background: #ffffff;
  resize: vertical;
}

.batch-code-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid #dbe3ee;
  border-radius: 6px;
  background: #ffffff;
  padding: 8px;
}

.batch-code-row code {
  color: #0f2f5f;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  word-break: break-word;
}

.empty-state {
  border: 1px dashed #c7d5e8;
  border-radius: 8px;
  padding: 16px;
  color: var(--muted);
  background: #f8fbff;
  font-size: 14px;
}

@media (max-width: 920px) {
  .admin-shell,
  .workspace,
  .single-workspace,
  .admin-grid,
  .grid.two,
  .grid.three,
  .grid.four,
  .grid.cdk-row {
    grid-template-columns: 1fr;
  }

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

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

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

  .actions {
    width: 100%;
  }

  .inline-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .address-tools {
    align-items: stretch;
    flex-direction: column;
  }

  .actions button {
    flex: 1;
  }

  .list-item.split,
  .copy-box {
    grid-template-columns: 1fr;
    align-items: stretch;
    flex-direction: column;
  }
}
