:root {
  color-scheme: light;
  font-family:
    Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: #17191d;
  background: #f4f6f8;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f4f6f8;
}

button,
input,
select,
textarea {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

.topbar {
  width: 100%;
  background: #ffffff;
  border-bottom: 1px solid #dfe3e8;
}

.topbar-inner {
  width: min(1180px, calc(100% - 40px));
  min-height: 76px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand,
.account,
.service-state,
.form-row,
.toggle-row,
.section-heading,
.form-actions {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
}

.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.35;
  font-weight: 700;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #17191d;
  color: #ffffff;
  font-size: 22px;
  font-weight: 800;
}

.brand-mark-small {
  width: 40px;
  height: 40px;
  font-size: 18px;
}

.service-state {
  gap: 6px;
  margin-top: 3px;
  color: #5d6672;
  font-size: 12px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #16833b;
}

.account {
  gap: 12px;
  color: #5d6672;
  font-size: 14px;
}

.app-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 24px;
  border-bottom: 1px solid #d9dee5;
}

.tab-button {
  min-width: 96px;
  height: 42px;
  padding: 0 16px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: #66707d;
  font-weight: 600;
}

.tab-button:hover {
  color: #17191d;
}

.tab-button.active {
  color: #17191d;
  border-bottom-color: #2563eb;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

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

.metric-card {
  min-height: 118px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: #ffffff;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
}

.metric-label {
  color: #66707d;
  font-size: 13px;
  font-weight: 600;
}

.metric-value {
  font-size: 32px;
  line-height: 1;
  font-weight: 750;
}

.content-section {
  margin-top: 34px;
  padding-top: 28px;
  border-top: 1px solid #d9dee5;
}

.content-section-first {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.section-heading {
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.section-heading h2 {
  margin: 0;
  font-size: 19px;
  line-height: 1.4;
}

.section-meta {
  margin: 4px 0 0;
  color: #747d89;
  font-size: 13px;
}

.button {
  min-height: 38px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 650;
}

.button-primary {
  background: #2563eb;
  color: #ffffff;
}

.button-primary:hover {
  background: #1d4ed8;
}

.button-secondary {
  background: #ffffff;
  border-color: #cbd2da;
  color: #272b31;
}

.button-secondary:hover,
.button-quiet:hover {
  background: #f0f2f5;
}

.button-quiet {
  min-height: 34px;
  padding: 0 11px;
  background: transparent;
  border-color: #d8dde3;
  color: #3e4650;
}

.button-danger {
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  background: #ffffff;
  border-color: #efc5c5;
  color: #b42318;
}

.button-full {
  width: 100%;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
  background: #ffffff;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 50px;
  padding: 10px 14px;
  text-align: left;
  border-bottom: 1px solid #e8ebef;
  font-size: 13px;
  white-space: nowrap;
}

th {
  color: #66707d;
  background: #fafbfc;
  font-weight: 650;
}

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

.empty-cell {
  height: 86px;
  text-align: center;
  color: #7b8490;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 650;
}

.status-completed {
  background: #e7f5eb;
  color: #126b32;
}

.status-running,
.status-pending {
  background: #e9f1ff;
  color: #1d55b7;
}

.status-failed {
  background: #fdecec;
  color: #a52222;
}

.form-grid {
  width: min(760px, 100%);
  display: grid;
  gap: 10px;
}

label {
  color: #3f4751;
  font-size: 13px;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #cbd2da;
  border-radius: 6px;
  background: #ffffff;
  color: #17191d;
  outline: none;
}

input,
select {
  height: 40px;
  padding: 0 11px;
}

textarea {
  min-height: 120px;
  padding: 11px;
  line-height: 1.55;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-row {
  align-items: end;
  gap: 20px;
}

.form-row > div {
  flex: 1;
}

.toggle-row {
  min-height: 40px;
  gap: 9px;
}

.toggle-row input {
  width: 18px;
  height: 18px;
  margin: 0;
}

.form-actions {
  gap: 10px;
  margin-top: 12px;
}

.broadcast-button-state {
  width: min(760px, 100%);
  margin-top: 8px;
  padding: 16px 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid #d9dee5;
  border-bottom: 1px solid #d9dee5;
}

.broadcast-button-state strong {
  display: block;
  font-size: 13px;
}

.preview-keyboard-compact {
  margin-top: 8px;
}

.button-editor-header,
.button-editor-row {
  display: grid;
  grid-template-columns: 84px minmax(140px, 0.7fr) minmax(240px, 1.3fr) 42px;
  gap: 10px;
  align-items: center;
}

.button-editor-header {
  margin-top: 26px;
  padding: 0 2px 8px;
  color: #66707d;
  font-size: 12px;
  font-weight: 650;
}

.button-editor {
  display: grid;
  gap: 10px;
}

.button-editor-row input {
  min-width: 0;
}

.button-preview {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #d9dee5;
}

.preview-keyboard {
  width: min(520px, 100%);
  margin-top: 10px;
  display: grid;
  gap: 7px;
}

.preview-row {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 7px;
}

.preview-button {
  min-height: 36px;
  display: grid;
  place-items: center;
  padding: 7px 10px;
  border: 1px solid #b8c9ec;
  border-radius: 6px;
  background: #eff5ff;
  color: #2457a7;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: min(360px, calc(100% - 48px));
  min-height: 42px;
  padding: 11px 14px;
  display: none;
  align-items: center;
  border-radius: 6px;
  background: #17191d;
  color: #ffffff;
  font-size: 13px;
  box-shadow: 0 10px 30px rgba(24, 28, 34, 0.18);
}

.toast.show {
  display: flex;
}

.toast.error {
  background: #a52222;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
  background: #eef1f4;
}

.login-shell {
  width: min(420px, 100%);
}

.login-panel {
  padding: 32px;
  background: #ffffff;
  border: 1px solid #d9dee5;
  border-radius: 8px;
}

.login-panel .brand-mark {
  margin-bottom: 22px;
}

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

.login-label {
  margin: 5px 0 24px;
  color: #69727e;
  font-size: 14px;
}

.login-form {
  display: grid;
  gap: 9px;
}

.login-form input {
  margin-bottom: 7px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: #b42318;
  font-size: 13px;
}

@media (max-width: 760px) {
  .topbar-inner,
  .app-shell {
    width: min(100% - 24px, 1180px);
  }

  .topbar-inner {
    min-height: 68px;
  }

  .account > span {
    display: none;
  }

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

  .tabs {
    overflow-x: auto;
  }

  .tab-button {
    min-width: 88px;
  }

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

  .form-row {
    align-items: stretch;
    flex-direction: column;
  }

  .broadcast-button-state {
    flex-direction: column;
  }

  .broadcast-button-state .button {
    width: 100%;
  }

  .button-editor-header {
    display: none;
  }

  .button-editor-row {
    grid-template-columns: 70px minmax(0, 1fr) 42px;
  }

  .button-editor-row .button-url {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .button-editor-row .button-danger {
    grid-column: 3;
    grid-row: 1;
  }

  .table-wrap {
    border-radius: 6px;
  }

  table {
    min-width: 680px;
  }
}

@media (max-width: 440px) {
  .brand h1 {
    font-size: 16px;
  }

  .brand-mark-small {
    width: 36px;
    height: 36px;
  }

  .metrics-grid {
    gap: 10px;
  }

  .metric-card {
    min-height: 102px;
    padding: 15px;
  }

  .metric-value {
    font-size: 27px;
  }

  .section-heading {
    flex-direction: column;
  }

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

  .login-panel {
    padding: 24px;
  }
}
