:root {
  color-scheme: light;
  --ink: #17211f;
  --muted: #68736f;
  --subtle: #8d9894;
  --surface: #ffffff;
  --surface-soft: #f5f7f5;
  --canvas: #eef2ef;
  --border: #d9e0dc;
  --border-strong: #bfc9c4;
  --accent: #12665a;
  --accent-hover: #0d554b;
  --accent-soft: #e4f2ed;
  --danger: #a63a32;
  --danger-soft: #f9e9e7;
  --warning: #8a5b15;
  --warning-soft: #f8efd9;
  --success: #1d6a43;
  --success-soft: #e3f2e9;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --shadow: 0 1px 2px rgb(23 33 31 / 5%), 0 8px 24px rgb(23 33 31 / 5%);
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  clip-path: inset(50%) !important;
}

html {
  min-width: 320px;
  background: var(--canvas);
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(1.65rem, 2.8vw, 2.25rem);
  line-height: 1.18;
  letter-spacing: -0.035em;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.08rem;
  letter-spacing: -0.018em;
}

h3 {
  margin-bottom: 4px;
  font-size: 0.96rem;
}

p {
  color: var(--muted);
  line-height: 1.65;
}

.eyebrow {
  margin-bottom: 7px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.auth-shell {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgb(18 102 90 / 4%) 1px, transparent 1px),
    linear-gradient(rgb(18 102 90 / 4%) 1px, transparent 1px),
    var(--canvas);
  background-size: 32px 32px;
}

.auth-panel {
  width: min(100%, 430px);
  padding: 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  flex: 0 0 auto;
  border-radius: 9px;
  color: #fff;
  background: var(--accent);
  font-size: 1rem;
  font-weight: 800;
}

.auth-copy {
  margin-bottom: 26px;
}

.auth-panel form,
.field {
  display: grid;
  gap: 8px;
}

label {
  color: #34413c;
  font-size: 0.86rem;
  font-weight: 650;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  transition:
    border-color 140ms ease,
    box-shadow 140ms ease;
}

input {
  min-height: 42px;
  padding: 9px 12px;
}

textarea {
  min-height: 112px;
  padding: 11px 12px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 0;
  box-shadow: 0 0 0 3px rgb(18 102 90 / 13%);
}

input::placeholder,
textarea::placeholder {
  color: var(--subtle);
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 680;
  transition:
    background-color 140ms ease,
    border-color 140ms ease,
    color 140ms ease;
}

.button:focus-visible,
.tab:focus-visible,
.channel-select:focus-visible,
.text-button:focus-visible {
  outline: 3px solid rgb(18 102 90 / 22%);
  outline-offset: 2px;
}

.button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.button-primary {
  color: #fff;
  background: var(--accent);
}

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

.button-secondary {
  border-color: var(--border-strong);
  color: var(--ink);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.button-quiet {
  border-color: transparent;
  color: var(--muted);
  background: transparent;
}

.button-quiet:hover:not(:disabled) {
  color: var(--ink);
  background: var(--surface-soft);
}

.button-block {
  width: 100%;
  margin-top: 4px;
}

.auth-note {
  margin: 18px 0 0;
  color: var(--subtle);
  font-size: 0.76rem;
  text-align: center;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
}

.field-help,
.limit-hint {
  margin: 0;
  color: var(--subtle);
  font-size: 0.75rem;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  border-bottom: 1px solid var(--border);
  background: rgb(255 255 255 / 95%);
  backdrop-filter: blur(12px);
}

.header-inner,
.main-shell {
  width: min(100% - 40px, 1180px);
  margin: 0 auto;
}

.header-inner {
  display: flex;
  min-height: 68px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.header-actions,
.inline-actions,
.form-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-name {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 760;
}

.brand-caption {
  margin: 1px 0 0;
  color: var(--subtle);
  font-size: 0.75rem;
}

.system-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--subtle);
}

.system-status.is-ready .status-dot {
  background: var(--success);
}

.system-status.is-warning .status-dot {
  background: var(--warning);
}

.main-shell {
  padding: 38px 0 80px;
}

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 22px;
  margin-bottom: 26px;
}

.page-heading p:last-child {
  margin-bottom: 0;
}

.tabs {
  display: flex;
  gap: 18px;
  margin-bottom: 18px;
  border-bottom: 1px solid var(--border);
}

.tab {
  position: relative;
  padding: 10px 2px 12px;
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 680;
}

.tab::after {
  position: absolute;
  right: 0;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: transparent;
  content: "";
}

.tab.is-active {
  color: var(--ink);
}

.tab.is-active::after {
  background: var(--accent);
}

.workspace-grid {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.channel-sidebar,
.editor-panel,
.table-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.channel-sidebar {
  position: sticky;
  top: 88px;
  overflow: hidden;
}

.section-heading,
.editor-heading,
.table-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.channel-sidebar > .section-heading {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.channel-sidebar h2,
.editor-heading h2,
.table-heading h2 {
  margin: 0;
}

.count-badge {
  min-width: 24px;
  padding: 2px 7px;
  border-radius: 999px;
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 0.74rem;
  text-align: center;
}

.channel-list {
  margin: 0;
  padding: 6px;
  list-style: none;
}

.channel-list li + li {
  margin-top: 2px;
}

.channel-select {
  display: grid;
  width: 100%;
  grid-template-columns: 9px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.channel-select:hover {
  background: var(--surface-soft);
}

.channel-select.is-active {
  background: var(--accent-soft);
}

.channel-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border-strong);
}

.channel-indicator.is-enabled {
  background: var(--success);
}

.channel-copy {
  min-width: 0;
}

.channel-name {
  display: block;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-state {
  display: block;
  overflow: hidden;
  margin-top: 2px;
  color: var(--subtle);
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.7rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.channel-qr-icon {
  color: var(--subtle);
  font-size: 0.68rem;
}

.empty-list {
  padding: 20px 16px 24px;
  text-align: center;
}

.empty-list p {
  margin-bottom: 8px;
  font-size: 0.84rem;
}

.text-button {
  padding: 0;
  border: 0;
  color: var(--accent);
  background: transparent;
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 700;
}

.editor-panel {
  overflow: hidden;
}

.editor-panel > form {
  padding: 24px;
}

.editor-heading {
  margin-bottom: 22px;
}

.switch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 650;
  user-select: none;
}

.switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.switch-track {
  position: relative;
  width: 34px;
  height: 20px;
  border-radius: 999px;
  background: var(--border-strong);
  transition: background-color 140ms ease;
}

.switch-track::after {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
  content: "";
  transition: transform 140ms ease;
}

.switch input:checked + .switch-track {
  background: var(--accent);
}

.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}

.switch input:focus-visible + .switch-track {
  outline: 3px solid rgb(18 102 90 / 22%);
  outline-offset: 2px;
}

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

.field-span-2 {
  grid-column: span 2;
}

.form-section {
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
}

.form-section .section-heading {
  margin-bottom: 13px;
}

.form-actions {
  margin-top: 24px;
}

.form-actions .button {
  min-width: 108px;
}

#delete-channel-button {
  margin-left: auto;
  color: var(--danger);
}

.qr-section {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px;
  gap: 24px;
  padding: 24px;
  border-top: 1px solid var(--border);
  background: var(--surface-soft);
}

.technical-list {
  display: grid;
  gap: 11px;
  margin: 18px 0;
}

.technical-list div {
  display: grid;
  grid-template-columns: 78px minmax(0, 1fr);
  gap: 10px;
}

.technical-list dt {
  color: var(--subtle);
  font-size: 0.73rem;
}

.technical-list dd {
  overflow-wrap: anywhere;
  margin: 0;
  color: #34413c;
  font-size: 0.76rem;
}

.mono {
  font-family: "SFMono-Regular", Consolas, monospace;
}

.qr-preview {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
}

.qr-preview img,
.qr-placeholder {
  width: 160px;
  height: 160px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: #fff;
}

.qr-preview img {
  object-fit: contain;
}

.qr-placeholder {
  display: grid;
  place-items: center;
  border-style: dashed;
  color: var(--subtle);
  background: transparent;
  font-size: 0.78rem;
}

.qr-preview a {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 650;
}

.table-card {
  overflow: hidden;
}

.table-heading {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}

.table-heading p {
  margin: 0;
  font-size: 0.78rem;
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
}

th,
td {
  padding: 13px 18px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--subtle);
  background: #fafbfa;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.03em;
}

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

td {
  color: #3d4945;
}

.status-badge {
  display: inline-flex;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 700;
  white-space: nowrap;
}

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

.status-failed {
  color: var(--danger);
  background: var(--danger-soft);
}

.status-ignored {
  color: var(--warning);
  background: var(--warning-soft);
}

.empty-table {
  padding: 64px 24px;
  text-align: center;
}

.empty-table h3 {
  margin-bottom: 4px;
}

.empty-table p {
  margin: 0;
  font-size: 0.84rem;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100vw - 48px));
  padding: 12px 15px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow);
  font-size: 0.84rem;
}

.toast.is-error {
  border-color: #e4bdb9;
  color: var(--danger);
  background: var(--danger-soft);
}

@media (max-width: 860px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .channel-sidebar {
    position: static;
  }

  .channel-list {
    display: flex;
    overflow-x: auto;
  }

  .channel-list li {
    min-width: 210px;
  }

  .channel-list li + li {
    margin-top: 0;
  }

  .qr-section {
    grid-template-columns: 1fr;
  }

  .qr-preview {
    justify-items: start;
  }
}

@media (max-width: 640px) {
  .header-inner,
  .main-shell {
    width: min(100% - 28px, 1180px);
  }

  .header-inner {
    min-height: 62px;
  }

  .brand-caption,
  .system-status {
    display: none;
  }

  .main-shell {
    padding-top: 26px;
  }

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

  .page-heading .button {
    width: 100%;
  }

  .editor-panel > form,
  .qr-section {
    padding: 18px;
  }

  .editor-heading {
    align-items: flex-start;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .field-span-2 {
    grid-column: auto;
  }

  .auth-panel {
    padding: 26px 22px;
  }

  th,
  td {
    padding: 12px 14px;
    white-space: nowrap;
  }

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

  #delete-channel-button {
    margin-left: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
