/* 信桥管理后台 · 通用组件：按钮、表单控件、标签、提示条、面板、指标、表格。 */

/* ---------- 按钮 ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: var(--control);
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
}
.btn:hover {
  background: var(--hover);
  border-color: #b3bec3;
  text-decoration: none;
}
.btn:active {
  background: #e6ebed;
}
.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-strong);
  border-color: var(--brand-strong);
}
.btn-primary:active {
  background: #06565a;
  border-color: #06565a;
}
.btn-danger {
  border-color: #e6c3c7;
  color: var(--danger);
}
.btn-danger:hover {
  background: var(--danger-soft);
  border-color: #d9a3a9;
}
.btn-danger:active {
  background: #f5dcdf;
}
.btn-danger-solid {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-danger-solid:hover {
  background: var(--danger-strong);
  border-color: var(--danger-strong);
}
.btn-sm {
  height: var(--control-sm);
  padding: 0 10px;
  border-radius: 7px;
  font-size: 13px;
}
.btn-block {
  width: 100%;
}
.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.55;
  cursor: not-allowed;
}
.btn-stop::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: currentColor;
}
.btn-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--brand);
  font-size: inherit;
  cursor: pointer;
}
.btn-link:hover {
  text-decoration: underline;
}
.btn-link.danger {
  color: var(--danger);
}

/* ---------- 表单控件 ---------- */
input,
select,
textarea {
  width: 100%;
  min-width: 0;
  height: var(--control);
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
}
input::placeholder,
textarea::placeholder {
  color: var(--ink-3);
  opacity: 1;
}
input:hover,
select:hover,
textarea:hover {
  border-color: #b3bec3;
}
input:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input:disabled,
select:disabled,
textarea:disabled {
  border-color: var(--line);
  background: var(--subtle);
  color: var(--ink-3);
  cursor: not-allowed;
}
textarea {
  height: auto;
  min-height: 96px;
  padding: 9px 12px;
  font: 13px/1.7 var(--mono);
  resize: vertical;
}
select {
  appearance: none;
  padding-right: 34px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2366777e' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 16px;
  cursor: pointer;
}
input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  padding: 0;
  margin: 0;
  flex: none;
  accent-color: var(--brand);
  cursor: pointer;
}
input[type="checkbox"]:focus,
input[type="radio"]:focus {
  box-shadow: none;
}
input[type="checkbox"]:focus-visible,
input[type="radio"]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

.field {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.field > label,
.field > legend {
  display: block;
  margin-bottom: 6px;
  padding: 0;
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
}
.hint {
  display: block;
  margin-top: 6px;
  color: var(--ink-3);
  font-size: 12px;
  line-height: 1.6;
}
.hint ul {
  margin: 0;
  padding-left: 18px;
}
.errorlist {
  margin: 6px 0 0;
  padding: 0;
  list-style: none;
  color: var(--danger);
  font-size: 13px;
}
form > .errorlist {
  margin: 0 0 16px;
  padding: 10px 14px;
  border: 1px solid #f0d3d7;
  border-radius: var(--radius);
  background: var(--danger-soft);
}
.field.has-error input,
.field.has-error select,
.field.has-error textarea {
  border-color: var(--danger);
}
/* 布尔字段：开关 */
.field-switch {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 10px;
}
.field-switch > label {
  margin: 0;
  cursor: pointer;
}
.field-switch .hint,
.field-switch .errorlist {
  grid-column: 2;
}
.field-switch input[type="checkbox"] {
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: #c3cdd1;
}
.field-switch input[type="checkbox"]::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 2px rgb(23 38 44 / 0.25);
}
.field-switch input[type="checkbox"]:checked {
  background: var(--brand);
}
.field-switch input[type="checkbox"]:checked::before {
  transform: translateX(16px);
}
/* 单选 / 多选列表（Django 输出 div > div > label > input） */
.field-choices > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.field-choices label {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 0;
  font-weight: 400;
  cursor: pointer;
}

.form-panel {
  max-width: 880px;
}
.form-section + .form-section {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}
.form-section > h2 {
  margin-bottom: 14px;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px 20px;
}
.form-grid.single {
  grid-template-columns: minmax(0, 1fr);
  max-width: 420px;
}
.field-wide {
  grid-column: 1 / -1;
}
.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.form-actions.start {
  justify-content: flex-start;
  border-top: 0;
  padding-top: 0;
  margin-top: 18px;
}
/* 一行内的小表单：字段与按钮底部对齐 */
.form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px;
}
.form-row .field {
  flex: 0 1 180px;
}
.form-row label {
  color: var(--ink-2);
  font-weight: 400;
}
.form-row .errorlist {
  flex-basis: 100%;
}
.form-row > a {
  margin-left: 4px;
  font-size: 13px;
  line-height: var(--control);
}
.panel > .form-row {
  margin-top: 16px;
}
.panel > form.form-row:not(.filters) {
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
/* 密码确认 + 执行按钮：拼成一个控件 */
.confirm-group {
  display: flex;
}
.confirm-group input {
  width: 172px;
  border-radius: var(--radius) 0 0 var(--radius);
}
.confirm-group .btn {
  margin-left: -1px;
  border-radius: 0 var(--radius) var(--radius) 0;
}
.confirm-group input:focus {
  position: relative;
  z-index: 1;
}
.confirm-group.sm input {
  width: 132px;
  height: var(--control-sm);
  padding: 0 10px;
  border-radius: 7px 0 0 7px;
  font-size: 13px;
}
.confirm-group.sm .btn {
  border-radius: 0 7px 7px 0;
}

/* ---------- 标签 / 提示条 ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 6px;
  background: var(--hover);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
}
.badge.ok,
.status-simulated,
.status-delivered {
  background: var(--brand-soft);
  color: var(--brand-strong);
}
.badge.warn,
.status-unknown {
  background: var(--warn-soft);
  color: var(--warn);
}
.badge.bad,
.status-failed,
.status-blocked,
.status-cancelled,
.status-expired {
  background: var(--danger-soft);
  color: var(--danger);
}
.status-pending,
.status-claimed,
.status-sending,
.status-accepted {
  background: var(--info-soft);
  color: var(--info);
}
.notice {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 10px 14px;
  border: 1px solid #d3e8e6;
  border-radius: var(--radius);
  background: var(--brand-soft);
  color: #1d5f63;
  font-size: 13px;
}
.notice p {
  flex-basis: 100%;
  color: inherit;
}
.notice > a:last-child,
.notice > .btn:last-child {
  margin-left: auto;
}
.notice.info {
  border-color: var(--line);
  background: var(--subtle);
  color: var(--ink-2);
}
.notice.warn,
.notice.warning {
  border-color: #f1e0b0;
  background: var(--warn-soft);
  color: #6f4a00;
}
.notice.error {
  border-color: #f0d3d7;
  background: var(--danger-soft);
  color: var(--danger-strong);
}

/* ---------- 面板 / 指标 ---------- */
.panel {
  padding: 20px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--canvas);
}
/* 面板内的直接子元素统一用同一个间距排开 */
.panel > * + * {
  margin-top: 12px;
}
.panel > .panel-head + * {
  margin-top: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 14px;
}
.panel-head p {
  margin-top: 2px;
  font-size: 13px;
}
.panel-head > a,
.panel-head > .muted {
  flex: none;
  font-size: 13px;
  line-height: 22px;
}
.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}
.grid-2.stretch {
  align-items: stretch;
}
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 20px;
}
.cards.three {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}
.card {
  display: flex;
  flex-direction: column;
}
.card > .badge {
  align-self: flex-start;
}
.card > p {
  font-size: 13px;
}
.card > .card-foot {
  display: flex;
  justify-content: space-between;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  font-size: 13px;
}
.card > dl {
  margin-bottom: 16px;
}
.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--brand-soft);
  color: var(--brand-strong);
  font-weight: 600;
}
.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}
.card-title > div {
  min-width: 0;
  flex: 1;
}
.card-title .mono {
  display: block;
  color: var(--ink-3);
  font-size: 12px;
  overflow-wrap: anywhere;
}
/* 指标：一个带分隔线的整体，而不是一排独立卡片 */
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--line);
  overflow: hidden;
}
.stats.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.stat {
  min-width: 0;
  padding: 16px 20px;
  background: var(--canvas);
}
.stat-label {
  display: block;
  color: var(--ink-2);
  font-size: 13px;
}
.stat-value {
  display: block;
  margin: 6px 0 4px;
  font-size: 28px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}
.stat-value small {
  margin: 0 3px;
  color: var(--ink-3);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0;
}
.stat-value.text {
  font-size: 20px;
  line-height: 1.75;
  letter-spacing: 0;
}
.stat-value.off {
  color: var(--danger);
}
.stat-hint {
  color: var(--ink-3);
  font-size: 12px;
}
dl {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr);
  gap: 8px 16px;
  margin: 0;
  font-size: 13px;
}
dt {
  color: var(--ink-3);
}
dd {
  margin: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
/* 列间距用内边距而不是 gap，分隔线才能连成一条 */
dl.detail {
  gap: 0;
}
dl.detail dt,
dl.detail dd {
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
dl.detail dd {
  padding-left: 16px;
}
dl.detail dt:last-of-type,
dl.detail dd:last-of-type {
  border-bottom: 0;
}

/* ---------- 表格 / 列表 ---------- */
/* 内容比容器宽时可横向滚动；两侧的阴影只在该方向还有内容时出现，提示可以滑动。 */
.table-wrap {
  overflow-x: auto;
  background:
    linear-gradient(to right, var(--canvas) 40%, rgb(255 255 255 / 0)) left / 32px 100% no-repeat local,
    linear-gradient(to left, var(--canvas) 40%, rgb(255 255 255 / 0)) right / 32px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgb(23 38 44 / 0.14), rgb(23 38 44 / 0)) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgb(23 38 44 / 0.14), rgb(23 38 44 / 0)) right / 10px 100% no-repeat scroll;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  white-space: nowrap;
  font-size: 13px;
}
th {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 12px;
  font-weight: 500;
}
td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
th:first-child,
td:first-child {
  padding-left: 0;
}
th:last-child,
td:last-child {
  padding-right: 0;
}
tbody tr:last-child td {
  border-bottom: 0;
}
td strong {
  font-weight: 600;
}
td.num,
th.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
td.end,
th.end {
  text-align: right;
}
td .actions {
  flex-wrap: nowrap;
}
td.end .actions {
  justify-content: flex-end;
}
.empty {
  padding: 32px 16px;
  color: var(--ink-3);
  font-size: 13px;
  text-align: center;
  white-space: normal;
}
p.empty {
  padding: 20px 0 8px;
}
.list-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.list-row:last-of-type {
  border-bottom: 0;
}
.list-row > .badge {
  margin-left: auto;
}
.list-row small {
  flex: none;
  color: var(--ink-3);
  font-size: 12px;
}
.usage {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
progress {
  appearance: none;
  flex: none;
  width: 120px;
  height: 6px;
  border: 0;
  border-radius: 999px;
  background: var(--hover);
  overflow: hidden;
}
progress::-webkit-progress-bar {
  background: var(--hover);
}
progress::-webkit-progress-value {
  border-radius: 999px;
  background: var(--brand);
}
progress::-moz-progress-bar {
  border-radius: 999px;
  background: var(--brand);
}
.panel > .filters {
  margin-top: 0;
}
.filters {
  margin-bottom: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: 13px;
}
.pagination > span {
  margin-right: auto;
}
