:root {
  --td-brand: #0052d9;
  --td-brand-hover: #266fe8;
  --td-brand-active: #003cab;
  --td-brand-light: #ecf2fe;
  --td-success: #2ba471;
  --td-success-bg: #e3f9e9;
  --td-warning: #e37318;
  --td-warning-bg: #fff1e9;
  --td-error: #d54941;
  --td-error-bg: #fff0ed;
  --td-bg: #f3f3f3;
  --td-bg-container: #ffffff;
  --td-bg-secondary: #f9f9f9;
  --td-text: #000000e6;
  --td-text-secondary: #00000099;
  --td-text-placeholder: #00000066;
  --td-border: #dcdcdc;
  --td-border-light: #e7e7e7;
  --td-shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 2px 8px rgba(0, 0, 0, 0.04);
  --td-shadow-card: 0 1px 3px rgba(0, 0, 0, 0.05), 0 4px 16px rgba(0, 0, 0, 0.04);
  --td-radius: 6px;
  --td-radius-lg: 9px;
  --font: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", "Segoe UI", sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, "Microsoft YaHei", monospace;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  color: var(--td-text);
  background: var(--td-bg);
  -webkit-font-smoothing: antialiased;
  line-height: 1.5;
}

a {
  color: var(--td-brand);
  text-decoration: none;
}

a:hover { color: var(--td-brand-hover); }

/* ========== App shell ========== */
.app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  height: 56px;
  background: var(--td-bg-container);
  border-bottom: 1px solid var(--td-border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(145deg, #266fe8 0%, #0052d9 55%, #003cab 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.02em;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0, 82, 217, 0.28);
}

.brand-text {
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--td-text);
  line-height: 1.3;
}

.brand-sub {
  font-size: 12px;
  color: var(--td-text-secondary);
  line-height: 1.3;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-text {
  height: 32px;
  padding: 0 12px;
  border: 0;
  background: transparent;
  color: var(--td-text-secondary);
  font-family: var(--font);
  font-size: 13px;
  border-radius: var(--td-radius);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.btn-text:hover {
  background: rgba(0, 0, 0, 0.04);
  color: var(--td-text);
}

.app-main {
  width: min(880px, calc(100% - 40px));
  margin: 0 auto;
  padding: 24px 0 48px;
  flex: 1;
}

.page-title {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-desc {
  margin: 0 0 20px;
  font-size: 13px;
  color: var(--td-text-secondary);
}

/* ========== Cards ========== */
.card {
  background: var(--td-bg-container);
  border: 1px solid var(--td-border-light);
  border-radius: var(--td-radius-lg);
  box-shadow: var(--td-shadow-card);
  overflow: hidden;
}

.card + .card { margin-top: 16px; }

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--td-border-light);
}

.card-title {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
}

.card-body { padding: 20px; }

/* ========== Status ========== */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 500;
  line-height: 1;
}

.tag-success {
  color: var(--td-success);
  background: var(--td-success-bg);
}

.tag-warning {
  color: var(--td-warning);
  background: var(--td-warning-bg);
}

.tag-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}

.live-panel {
  background: var(--td-bg-secondary);
  border: 1px solid var(--td-border-light);
  border-radius: var(--td-radius);
  padding: 16px;
}

.live-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--td-text-secondary);
  font-weight: 500;
}

.live-url {
  margin: 0;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-all;
  color: var(--td-text);
}

.live-url.is-empty {
  color: var(--td-text-placeholder);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--td-border-light);
  font-size: 12px;
  color: var(--td-text-secondary);
}

.meta-row code {
  font-family: var(--mono);
  font-size: 12px;
  padding: 1px 6px;
  border-radius: 4px;
  background: #fff;
  border: 1px solid var(--td-border-light);
  color: var(--td-text);
}

/* ========== Form ========== */
.field { margin-bottom: 16px; }

.field:last-child { margin-bottom: 0; }

label {
  display: block;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--td-text);
}

.field-tip {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--td-text-secondary);
  line-height: 1.5;
}

input[type="text"],
input[type="password"],
input[type="url"] {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--td-border);
  border-radius: var(--td-radius);
  background: #fff;
  color: var(--td-text);
  font-family: var(--font);
  font-size: 14px;
  transition: border-color .15s ease, box-shadow .15s ease;
}

input[type="url"] {
  font-family: var(--mono);
  font-size: 13px;
  height: auto;
  min-height: 44px;
  padding: 10px 12px;
  line-height: 1.5;
  resize: vertical;
}

input::placeholder { color: var(--td-text-placeholder); }

input:hover { border-color: #bbb; }

input:focus {
  outline: none;
  border-color: var(--td-brand);
  box-shadow: 0 0 0 2px rgba(0, 82, 217, 0.14);
}

.actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 4px;
}

.btn {
  appearance: none;
  border: 0;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--td-radius);
  background: var(--td-brand);
  color: #fff;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background .15s ease, box-shadow .15s ease;
  box-shadow: 0 2px 6px rgba(0, 82, 217, 0.22);
}

.btn:hover { background: var(--td-brand-hover); }

.btn:active { background: var(--td-brand-active); }

.btn-block { width: 100%; }

.btn-secondary {
  background: #fff;
  color: var(--td-text);
  border: 1px solid var(--td-border);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--td-bg-secondary);
  border-color: #bbb;
  color: var(--td-text);
}

/* ========== Alert ========== */
.alert {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--td-radius);
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid transparent;
}

.alert-icon {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  border-radius: 50%;
  flex-shrink: 0;
}

.alert-ok {
  background: var(--td-success-bg);
  border-color: #b7e6c5;
  color: #2a6b4a;
}

.alert-ok .alert-icon { background: var(--td-success); }

.alert-err {
  background: var(--td-error-bg);
  border-color: #f5c4c0;
  color: #9b2c2c;
}

.alert-err .alert-icon { background: var(--td-error); }

/* ========== Login ========== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--td-bg);
}

.login-aside {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(800px 500px at 20% 20%, rgba(38, 111, 232, 0.35), transparent 55%),
    radial-gradient(700px 480px at 80% 80%, rgba(0, 60, 171, 0.4), transparent 50%),
    linear-gradient(155deg, #031a40 0%, #062a63 45%, #0a3d8f 100%);
  color: #fff;
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.login-aside::after {
  content: "";
  position: absolute;
  inset: auto -20% -30% 10%;
  height: 55%;
  background: radial-gradient(circle at 30% 30%, rgba(255,255,255,0.08), transparent 55%);
  pointer-events: none;
}

.aside-brand {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.aside-brand .brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  font-size: 13px;
}

.aside-brand .brand-name {
  color: #fff;
  font-size: 16px;
}

.aside-brand .brand-sub {
  color: rgba(255, 255, 255, 0.65);
}

.aside-hero {
  position: relative;
  z-index: 1;
  max-width: 420px;
}

.aside-hero h2 {
  margin: 0 0 12px;
  font-size: 32px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
}

.aside-hero p {
  margin: 0;
  font-size: 15px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.72);
}

.aside-points {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 10px;
  margin-top: 28px;
}

.aside-point {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(255, 255, 255, 0.82);
}

.aside-point i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #7eb0ff;
  flex-shrink: 0;
}

.login-panel {
  display: grid;
  place-items: center;
  padding: 32px 24px;
  background: #fff;
}

.login-box {
  width: min(380px, 100%);
}

.login-box h1 {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
}

.login-box .lead {
  margin: 0 0 28px;
  font-size: 13px;
  color: var(--td-text-secondary);
}

.login-foot {
  margin-top: 24px;
  text-align: center;
  font-size: 12px;
  color: var(--td-text-placeholder);
}

@media (max-width: 900px) {
  .login-page { grid-template-columns: 1fr; }
  .login-aside { display: none; }
  .login-panel { background: var(--td-bg); }
  .login-box {
    background: #fff;
    border: 1px solid var(--td-border-light);
    border-radius: var(--td-radius-lg);
    box-shadow: var(--td-shadow-card);
    padding: 28px 24px;
  }
}

@media (max-width: 640px) {
  .app-header { padding: 0 16px; }
  .app-main { width: calc(100% - 24px); padding-top: 16px; }
  .brand-sub { display: none; }
  .card-body { padding: 16px; }
}
