:root {
  color-scheme: light;
  --bg: #eef2f6;
  --panel: #ffffff;
  --text: #1d2733;
  --muted: #66758a;
  --line: #dbe3ec;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; color: var(--text); background: var(--bg); }
a { color: inherit; text-decoration: none; }
button, input, textarea, select { font: inherit; }

/* ===================== Public Pages ===================== */

.public-page {
  min-height: 100vh;
  background: #f5f5f7;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  display: flex;
  flex-direction: column;
}
.public-page::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 25% 10%, rgba(59,130,246,.07), transparent),
    radial-gradient(ellipse 60% 50% at 75% 30%, rgba(147,51,234,.05), transparent),
    radial-gradient(ellipse 90% 40% at 50% 100%, rgba(59,130,246,.04), transparent);
  pointer-events: none;
  z-index: 0;
}

.download-shell {
  position: relative;
  z-index: 1;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 10vh 20px 48px;
  flex: 1;
}

.download-panel {
  width: min(100%, 560px);
  background: rgba(255,255,255,.72);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255,255,255,.6);
  border-radius: 20px;
  box-shadow:
    0 0 0 .5px rgba(0,0,0,.04),
    0 2px 4px rgba(0,0,0,.02),
    0 8px 16px rgba(0,0,0,.04),
    0 24px 48px rgba(0,0,0,.06),
    0 48px 80px rgba(0,0,0,.04);
  padding: 40px 38px 36px;
  animation: panelIn .5s cubic-bezier(.16,1,.3,1) both;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.download-panel .brand {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 18px;
  opacity: .85;
}
.download-panel .brand svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.download-panel h1 {
  font-size: 32px;
  font-weight: 800;
  line-height: 1.15;
  letter-spacing: -.025em;
  margin: 0 0 18px;
  color: #1d1d1f;
}

.meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px 16px;
  border-radius: 10px;
  background: rgba(0,0,0,.025);
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 4px;
}
.meta-row strong {
  color: #1d1d1f;
  text-align: right;
  font-weight: 650;
}

.section-title {
  margin: 24px 0 14px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: #86868b;
}

.channel-list { display: grid; gap: 8px; }

.download-row {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  padding: 13px 16px;
  border: 1px solid rgba(0,0,0,.06);
  border-radius: 12px;
  background: rgba(255,255,255,.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  text-decoration: none;
  color: inherit;
  transition: border-color .2s ease, box-shadow .2s ease, transform .2s ease, background .2s ease;
}
.download-row:hover {
  border-color: rgba(0,122,255,.35);
  background: rgba(255,255,255,.85);
  box-shadow:
    0 4px 8px rgba(0,122,255,.06),
    0 12px 28px rgba(0,122,255,.08);
  transform: translateY(-1px);
}
.download-row:active {
  transform: translateY(0);
  box-shadow: 0 1px 4px rgba(0,122,255,.06);
}

.download-row[data-channel-type="cos"] {
  border-color: rgba(0,122,255,.12);
  background: rgba(255,255,255,.78);
}

.channel-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
  color: #fff;
  transition: transform .2s ease;
}
.download-row:hover .channel-icon { transform: scale(1.06); }

.channel-icon.icon-cos {
  background: linear-gradient(135deg, #007AFF, #5856D6);
  box-shadow: 0 2px 8px rgba(0,122,255,.25);
}
.channel-icon.icon-cloud {
  background: linear-gradient(135deg, #34C759, #30D158);
  box-shadow: 0 2px 8px rgba(52,199,89,.25);
}
.channel-icon.icon-link {
  background: linear-gradient(135deg, #FF9500, #FF6B00);
  box-shadow: 0 2px 8px rgba(255,149,0,.25);
}
.channel-icon svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.channel-main { min-width: 0; }
.channel-title {
  display: block;
  font-weight: 650;
  font-size: 15px;
  color: #1d1d1f;
  overflow-wrap: anywhere;
  line-height: 1.3;
}
.row-action {
  color: #fff;
  background: linear-gradient(180deg, #007AFF 0%, #0066D6 100%);
  border-radius: 8px;
  padding: 8px 18px;
  font-weight: 650;
  font-size: 13.5px;
  white-space: nowrap;
  letter-spacing: .01em;
  box-shadow: 0 1px 3px rgba(0,122,255,.2), 0 4px 8px rgba(0,122,255,.12);
  transition: all .2s ease;
}
.download-row:hover .row-action {
  background: linear-gradient(180deg, #0077ED 0%, #005EC4 100%);
  box-shadow: 0 2px 6px rgba(0,122,255,.25), 0 6px 14px rgba(0,122,255,.16);
}

.support-text, .error-message, .empty {
  color: #86868b;
  line-height: 1.75;
  font-size: 13.5px;
}
.support-text { margin-top: 20px; text-align: center; }

.error-page-icon {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: rgba(255,59,48,.08);
  color: #FF3B30;
  margin-bottom: 14px;
}
.error-page-icon svg {
  width: 26px;
  height: 26px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---- Download modal ---- */

.download-modal[hidden] { display: none; }
.download-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  animation: modalIn .25s cubic-bezier(.16,1,.3,1) both;
}
.download-modal.modal-exit {
  animation: modalOut .2s ease both;
}
@keyframes modalIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
@keyframes modalOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
.download-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,.32);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.download-modal__dialog {
  position: relative;
  width: min(100%, 340px);
  padding: 28px 30px 24px;
  border-radius: 14px;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  border: 1px solid rgba(255,255,255,.6);
  box-shadow:
    0 0 0 .5px rgba(0,0,0,.04),
    0 8px 24px rgba(0,0,0,.08),
    0 32px 64px rgba(0,0,0,.12);
  text-align: center;
  animation: dialogIn .3s cubic-bezier(.16,1,.3,1) both;
}
@keyframes dialogIn {
  from { opacity: 0; transform: scale(.94) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.download-modal__dialog .modal-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #34C759, #30D158);
  color: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 4px 14px rgba(52,199,89,.3);
}
.download-modal__dialog .modal-icon svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.download-modal__dialog h2 {
  margin: 0 0 6px;
  font-size: 18px;
  font-weight: 700;
  color: #1d1d1f;
  letter-spacing: -.01em;
}
.download-modal__dialog p {
  margin: 0 0 22px;
  color: #86868b;
  font-size: 14px;
  line-height: 1.6;
}
.download-modal__button {
  min-width: 120px;
  border: 0;
  border-radius: 8px;
  padding: 10px 22px;
  color: #fff;
  background: linear-gradient(180deg, #007AFF, #0066D6);
  font-weight: 650;
  font-size: 14px;
  letter-spacing: .01em;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,122,255,.2), 0 4px 8px rgba(0,122,255,.12);
  transition: all .2s ease;
}
.download-modal__button:hover {
  background: linear-gradient(180deg, #0077ED, #005EC4);
  box-shadow: 0 2px 6px rgba(0,122,255,.25), 0 6px 14px rgba(0,122,255,.16);
}
.download-modal__button:active {
  transform: scale(.97);
}

.public-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 16px 20px 24px;
  color: #aeaeb2;
  font-size: 12px;
  letter-spacing: .02em;
}

/* ===================== Admin Layout ===================== */

.tds-admin {
  min-height: 100vh;
  background:
    linear-gradient(90deg, #e8eef6 0, #f1f5f9 12%, #f1f5f9 88%, #e8eef6 100%);
  color: #0f172a;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
.tds-admin a { text-decoration: none; }

/* ---- Login ---- */

.tds-admin-login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,235,.08), transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(124,58,237,.06), transparent 50%),
    linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
}
.login-card {
  width: min(100%, 420px);
  padding: 40px 36px;
  background: #fff;
  border: 1px solid rgba(226,232,240,.8);
  border-radius: 16px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.04),
    0 4px 12px rgba(0,0,0,.04),
    0 16px 48px rgba(0,0,0,.08);
}
.login-card h1 {
  margin: 16px 0 4px;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #0f172a;
}
.login-card p {
  margin: 0 0 28px;
  color: #64748b;
  font-size: 14px;
}

/* ---- Sidebar ---- */

.admin-layout {
  min-height: 100vh;
  width: min(100%, 1860px);
  margin: 0 auto;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr);
  overflow-x: hidden;
}
.admin-sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 20px 14px;
  color: #64748b;
  background: rgba(255,255,255,.94);
  border-right: 1px solid #e2e8f0;
  box-shadow: 10px 0 28px rgba(15,23,42,.04);
  backdrop-filter: blur(14px);
  overflow-y: auto;
}
.admin-sidebar form {
  margin-top: auto;
  flex-shrink: 0;
}
.admin-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 10px 24px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 8px;
}
.admin-brand strong {
  display: block;
  color: #0f172a;
  line-height: 1.15;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -.01em;
}
.admin-brand span {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 500;
  margin-top: 2px;
}
.brand-mark,
.login-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  font-weight: 900;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(37,99,235,.4);
  flex-shrink: 0;
}

/* ---- Nav menu ---- */

.admin-menu {
  display: grid;
  align-content: start;
  gap: 6px;
  flex: 0 0 auto;
}
.admin-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  color: #475569;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 14px;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
}
.admin-menu a svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: .62;
  transition: opacity .18s ease;
}
.admin-menu a:hover {
  color: #2563eb;
  background: #eff6ff;
  border-color: #dbeafe;
}
.admin-menu a:hover svg {
  opacity: 1;
}
.admin-menu a.active {
  color: #2563eb;
  background: #eff6ff;
  border-color: #bfdbfe;
  font-weight: 700;
}
.admin-menu a.active svg {
  opacity: 1;
  color: #2563eb;
}

/* Logout button in sidebar */
.admin-sidebar form .btn-outline-secondary {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  color: #475569;
  background: #fff;
  font-weight: 600;
  font-size: 14px;
  padding: 9px 12px;
  transition: color .18s ease, background .18s ease, border-color .18s ease;
  cursor: pointer;
}
.admin-sidebar form .btn-outline-secondary:hover {
  background: #fef2f2;
  border-color: #fecaca;
  color: #dc2626;
}
.admin-sidebar form .btn-outline-secondary svg {
  width: 16px;
  height: 16px;
  opacity: .6;
}

/* ---- Main content area ---- */

.admin-main {
  min-width: 0;
  padding: 32px 32px 32px 16px;
  overflow-y: auto;
}

/* ---- Topbar ---- */

.admin-topbar {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 18px;
  margin-bottom: 24px;
  padding: 18px 24px;
  background: rgba(255,255,255,.8);
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.03),
    0 4px 12px rgba(0,0,0,.03);
  backdrop-filter: blur(12px);
}
.admin-topbar h1 {
  margin: 0;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -.02em;
  color: #0f172a;
}
.admin-topbar > div:not(.admin-topbar-actions) {
  min-width: 0;
}
.admin-topbar .text-secondary {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}

/* ---- Actions bar ---- */

.admin-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}
.admin-actions-left {
  justify-content: flex-start;
}
.admin-topbar-actions {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

/* ---- Cards ---- */

.admin-card {
  max-width: 100%;
  overflow-x: hidden;
  padding: 24px;
  margin-bottom: 20px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  box-shadow:
    0 1px 2px rgba(0,0,0,.03),
    0 2px 8px rgba(0,0,0,.02),
    0 4px 16px rgba(0,0,0,.03);
}
.tds-admin .admin-card > .row,
.tds-admin .admin-card > form.row,
.tds-admin .channel-edit.row {
  margin-left: 0;
  margin-right: 0;
}
.tds-admin .admin-card > .row > *,
.tds-admin .admin-card > form.row > *,
.tds-admin .channel-edit.row > * {
  min-width: 0;
}
.tds-admin .form-control,
.tds-admin .form-select {
  min-width: 0;
}
.admin-card h2 {
  margin: 0 0 16px;
  font-size: 18px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.01em;
}
.card-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.card-title-row h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -.01em;
}
.risk-summary,
.risk-help-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.risk-summary > div,
.risk-help-grid > div {
  padding: 16px;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  background: #f8fafc;
}
.risk-summary span,
.risk-help-grid span {
  display: block;
  color: #64748b;
  font-size: 13px;
  line-height: 1.6;
}
.risk-summary strong,
.risk-help-grid strong {
  display: block;
  color: #0f172a;
  font-size: 15px;
  font-weight: 750;
}

/* ---- Metric cards ---- */

.metric-card {
  display: block;
  min-height: 118px;
  padding: 22px 24px;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  background: #fff;
  box-shadow:
    0 1px 2px rgba(0,0,0,.03),
    0 2px 8px rgba(0,0,0,.02),
    0 4px 16px rgba(0,0,0,.03);
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
  text-decoration: none;
  color: inherit;
}
.metric-card:hover {
  transform: translateY(-2px);
  border-color: #bfdbfe;
  box-shadow:
    0 4px 8px rgba(37,99,235,.06),
    0 12px 32px rgba(37,99,235,.1);
}
.metric-card .metric-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  margin-bottom: 14px;
}
.metric-card .metric-icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 2;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.metric-card .metric-icon.icon-blue { background: #eff6ff; color: #2563eb; }
.metric-card .metric-icon.icon-green { background: #ecfdf5; color: #10b981; }
.metric-card .metric-icon.icon-amber { background: #fffbeb; color: #f59e0b; }
.metric-card span {
  display: block;
  color: #64748b;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: .02em;
  margin-bottom: 6px;
}
.metric-card strong {
  display: block;
  color: #0f172a;
  font-size: 32px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: -.03em;
}

.compact-metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 180px));
  gap: 10px;
  margin-bottom: 14px;
}
.compact-metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 58px;
  padding: 12px 14px;
  border: 1px solid #e2e8f0;
  border-left: 4px solid #2563eb;
  border-radius: 10px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(0,0,0,.03), 0 2px 8px rgba(0,0,0,.02);
}
.compact-metric:hover {
  border-color: #bfdbfe;
  box-shadow: 0 4px 14px rgba(37,99,235,.08);
}
.compact-metric span {
  color: #64748b;
  font-size: 13px;
  font-weight: 650;
}
.compact-metric strong {
  color: #0f172a;
  font-size: 24px;
  line-height: 1;
  font-weight: 800;
}
.compact-metric-blue { border-left-color: #2563eb; }
.compact-metric-green { border-left-color: #10b981; }

/* ---- Tables ---- */

.tds-admin .table {
  font-size: 14px;
  margin-bottom: 0;
}
.tds-admin .table thead th {
  background: #f8fafc;
  border-bottom: 2px solid #e2e8f0;
  color: #475569;
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 12px 14px;
  white-space: nowrap;
}
.tds-admin .table tbody td {
  padding: 13px 14px;
  border-bottom: 1px solid #f1f5f9;
  vertical-align: middle;
  color: #334155;
}
.tds-admin .table tbody tr {
  transition: background .15s ease;
}
.tds-admin .table tbody tr:hover td {
  background: #f8fafc;
}
.tds-admin .table code {
  color: #1d4ed8;
  background: #eff6ff;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 13px;
  font-family: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* ---- Forms ---- */

.tds-admin .form-label,
.tds-admin-login .form-label {
  display: block;
  color: #334155;
  font-weight: 600;
  font-size: 13.5px;
  margin-bottom: 6px;
  letter-spacing: .01em;
}
.tds-admin .form-check-label {
  display: inline-block;
  color: #334155;
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 0;
}
.tds-admin .form-control,
.tds-admin .form-select,
.tds-admin-login .form-control {
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #0f172a;
  background: #fff;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.tds-admin .form-control:focus,
.tds-admin .form-select:focus,
.tds-admin-login .form-control:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
  outline: none;
}
.tds-admin .form-control::placeholder,
.tds-admin-login .form-control::placeholder {
  color: #94a3b8;
  font-weight: 400;
}
.tds-admin .form-select {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%2364748b' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
  padding-right: 36px;
}
.tds-admin .form-check-input {
  width: 2.5em;
  height: 1.25em;
  padding: 0;
  cursor: pointer;
}
.tds-admin textarea.form-control {
  resize: vertical;
  min-height: 80px;
}
.platform-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.platform-checks .form-check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  margin: 0;
  padding: 9px 13px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  background: #fff;
}
.platform-checks .form-check-input {
  width: 1em;
  height: 1em;
  margin: 0;
  padding: 0;
  border-radius: .25em;
}

/* ---- Buttons ---- */

.tds-admin .btn,
.tds-admin-login .btn {
  border-radius: 10px;
  font-weight: 650;
  font-size: 14px;
  transition: all .18s ease;
  letter-spacing: .01em;
}
.tds-admin .btn-primary,
.tds-admin-login .btn-primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: none;
  box-shadow: 0 2px 4px rgba(37,99,235,.15), 0 4px 12px rgba(37,99,235,.12);
  color: #fff;
  padding: 9px 18px;
}
.tds-admin .btn-primary:hover,
.tds-admin-login .btn-primary:hover {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  box-shadow: 0 4px 8px rgba(37,99,235,.2), 0 8px 24px rgba(37,99,235,.15);
  transform: translateY(-1px);
  color: #fff;
}
.tds-admin .btn-primary:active,
.tds-admin-login .btn-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(37,99,235,.15);
}
.tds-admin .btn-outline-secondary {
  border: 1.5px solid #e2e8f0;
  color: #475569;
  background: #fff;
  font-weight: 650;
}
.tds-admin .btn-outline-secondary:hover {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}
.tds-admin .btn-outline-primary {
  border: 1.5px solid #bfdbfe;
  color: #2563eb;
  background: #fff;
  font-weight: 650;
}
.tds-admin .btn-outline-primary:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
}
.tds-admin .btn-outline-danger {
  border: 1.5px solid #fecaca;
  color: #dc2626;
  background: #fff;
  font-weight: 650;
}
.tds-admin .btn-outline-danger:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #b91c1c;
}

/* ---- Alerts ---- */

.tds-admin .alert-danger,
.tds-admin-login .alert-danger {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 14px;
}
.tds-admin .alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 14px;
}
.tds-admin .alert-notice,
.tds-admin .alert-success {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 14px;
}

/* ---- Badges ---- */

.tds-admin .badge.text-bg-success {
  background: #ecfdf5 !important;
  color: #065f46 !important;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .02em;
}
.tds-admin .badge.text-bg-secondary {
  background: #f1f5f9 !important;
  color: #475569 !important;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .02em;
}
.tds-admin .badge.text-bg-light {
  background: #f1f5f9 !important;
  color: #475569 !important;
  font-weight: 650;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
}
.tds-admin .badge.text-bg-danger {
  background: #fef2f2 !important;
  color: #dc2626 !important;
  font-weight: 700;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  letter-spacing: .02em;
}

/* ---- Channel edit sections ---- */

.channel-edit {
  padding: 20px 20px 20px 22px;
  border: 1px solid #e8ecf1;
  border-left: 4px solid #2563eb;
  border-radius: 12px;
  background: #fafbfd;
  margin-bottom: 14px;
}
.channel-edit-compact {
  display: grid;
  grid-template-columns:
    minmax(112px, .9fr)
    minmax(112px, .9fr)
    minmax(220px, 1.7fr)
    minmax(220px, 1.7fr)
    56px
    92px
    118px;
  align-items: end;
  column-gap: 8px;
  row-gap: 8px;
  padding: 12px 14px 10px 16px;
  margin-bottom: 8px;
  border-radius: 10px;
}
.tds-admin .channel-edit-compact.row {
  margin-left: 0;
  margin-right: 0;
}
.tds-admin .channel-edit-compact.row > * {
  width: auto;
  max-width: none;
  padding-left: 0;
  padding-right: 0;
}
.channel-edit-compact .form-label {
  margin-bottom: 4px;
  color: #64748b;
  font-size: 12px;
}
.channel-edit-compact .form-control,
.channel-edit-compact .form-select {
  min-height: 34px;
  padding: 6px 9px;
  border-radius: 8px;
  font-size: 13px;
}
.channel-edit-compact .channel-enabled {
  align-self: end;
}
.channel-edit-compact .channel-enabled .form-check {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  padding-left: 0;
  white-space: nowrap;
}
.channel-edit-compact .channel-enabled .form-check-input {
  float: none;
  flex: 0 0 auto;
  margin: 0;
}
.channel-edit-compact .channel-enabled .form-check-label {
  flex: 0 0 auto;
}
.channel-edit-compact .channel-sort {
  max-width: none;
}
.channel-edit-compact .channel-sort .form-control {
  padding-left: 7px;
  padding-right: 5px;
}
.channel-edit-compact .channel-actions {
  align-items: end;
  justify-content: flex-start;
}
.channel-edit-compact .channel-actions .btn {
  min-height: 34px;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
}
.channel-unsaved-row {
  display: none;
  grid-column: 1 / -1;
}
.channel-edit-compact.is-dirty .channel-unsaved-row {
  display: block;
  margin-top: -2px;
}
.channel-unsaved {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 2px 8px;
  border-radius: 6px;
  background: #fff7ed;
  color: #c2410c;
  font-size: 12px;
  font-weight: 700;
}
.channel-edit[data-channel-type="cos"] { border-left-color: #2563eb; }
.channel-edit[data-channel-type="baidu"] { border-left-color: #f59e0b; }
.channel-edit[data-channel-type="quark"] { border-left-color: #8b5cf6; }
.channel-edit[data-channel-type="123pan"] { border-left-color: #10b981; }
.channel-edit[data-channel-type="other"] { border-left-color: #94a3b8; }

/* ---- Action buttons ---- */

.action-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.action-btns form {
  display: inline;
}

/* ---- Form section titles ---- */

.form-section-title {
  grid-column: 1 / -1;
  margin-top: 8px;
  margin-bottom: 2px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #94a3b8;
  padding-bottom: 6px;
  border-bottom: 1px solid #f1f5f9;
}

/* ---- Empty states ---- */

.empty-state {
  text-align: center;
  padding: 48px 20px;
}
.empty-state svg {
  width: 48px;
  height: 48px;
  color: #cbd5e1;
  margin-bottom: 12px;
}
.empty-state p {
  color: #94a3b8;
  font-size: 14px;
  margin: 0;
  line-height: 1.6;
}

/* ---- Success messages ---- */

.tds-admin .alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  border-radius: 10px;
  padding: 12px 16px;
  font-weight: 500;
  font-size: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---- Metric card accents ---- */

.metric-card {
  border-left: 4px solid transparent;
  transition: transform .22s ease, box-shadow .22s ease, border-color .22s ease;
}
.metric-card.metric-card-blue { border-left-color: #2563eb; }
.metric-card.metric-card-green { border-left-color: #10b981; }
.metric-card.metric-card-amber { border-left-color: #f59e0b; }

/* ---- Better pagination ---- */

.pager-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid #f1f5f9;
  margin-top: 4px;
}
.pager-info {
  color: #64748b;
  font-size: 13px;
  font-weight: 500;
}
.pager-info strong {
  color: #0f172a;
  font-weight: 700;
}
.pager-buttons {
  display: flex;
  gap: 6px;
}

/* ---- Responsive ---- */

@media (max-width: 760px) {
  .download-panel { padding: 24px 18px; }
  .download-panel h1 { font-size: 24px; }
  .meta-row { display: grid; }
  .meta-row strong { text-align: left; }
  .download-row { grid-template-columns: 34px minmax(0, 1fr) auto; }
  .admin-layout { grid-template-columns: 1fr; }
  .admin-layout { width: 100%; }
  .admin-sidebar {
    position: static;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 16px;
  }
  .admin-brand {
    border-bottom: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }
  .admin-menu {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 4px;
  }
  .admin-menu a {
    min-height: 36px;
    font-size: 13px;
    padding: 7px 10px;
  }
  .admin-menu a svg {
    display: none;
  }
  .admin-sidebar form {
    margin-top: 0;
  }
  .admin-main { padding: 16px; }
  .admin-topbar {
    flex-direction: column;
    align-items: flex-start;
    padding: 16px;
  }
  .metric-card { min-height: auto; padding: 16px; }
  .metric-card strong { font-size: 24px; }
  .compact-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .admin-card { padding: 16px; }
  .channel-edit { padding: 16px 16px 16px 18px; }
  .channel-edit-compact {
    display: grid;
    grid-template-columns: 1fr;
  }
  .risk-summary,
  .risk-help-grid {
    grid-template-columns: 1fr;
  }
  .tds-admin .row.g-3 { gap: 8px; }
}

@media (max-width: 500px) {
  .admin-menu a { font-size: 12px; padding: 6px 8px; }
}
