:root {
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e2e8f0;
  --line-2: #cbd5e1;
  --bg: #eef2f7;
  --card: #ffffff;
  --primary: #2563eb;
  --primary-2: #1d4ed8;
  --primary-soft: #eff6ff;
  --ok: #059669;
  --ok-soft: #ecfdf5;
  --warn: #d97706;
  --warn-soft: #fffbeb;
  --bad: #dc2626;
  --bad-soft: #fef2f2;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.10);
  --shadow-sm: 0 4px 16px rgba(15, 23, 42, 0.06);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

.hidden {
  display: none !important;
}

/* ============================ 登录页 ============================ */

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 20px;
  background:
    radial-gradient(900px 500px at 15% 15%, rgba(37, 99, 235, 0.20), transparent 60%),
    radial-gradient(800px 500px at 85% 85%, rgba(14, 165, 233, 0.16), transparent 60%),
    #0b1220;
}

.login-shell {
  width: min(1040px, 100%);
  min-height: 610px;
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.45);
  animation: rise 0.55s ease both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.brand-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 46px 36px;
  color: #e2e8f0;
  background:
    radial-gradient(700px 420px at 110% -10%, rgba(56, 189, 248, 0.34), transparent 60%),
    radial-gradient(500px 380px at -20% 110%, rgba(37, 99, 235, 0.45), transparent 65%),
    linear-gradient(145deg, #0b1220 0%, #111c34 48%, #0e2a4d 100%);
}

.brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.08) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.85), transparent 85%);
  pointer-events: none;
}

.brand-panel::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  right: -160px;
  bottom: -170px;
  border-radius: 50%;
  border: 1px solid rgba(125, 211, 252, 0.18);
  box-shadow: 0 0 0 48px rgba(125, 211, 252, 0.04),
    0 0 0 96px rgba(125, 211, 252, 0.03);
  pointer-events: none;
}

.brand-top,
.brand-copy,
.brand-points,
.brand-foot {
  position: relative;
  z-index: 1;
}

.brand-top {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-logo,
.mini-logo {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  color: #fff;
  font-weight: 800;
  font-size: 22px;
  letter-spacing: -1px;
  background: linear-gradient(145deg, #3b82f6, #0ea5e9);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.35);
}

.brand-name {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.4px;
}

.brand-sub {
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 1.6px;
  color: #94a3b8;
  text-transform: uppercase;
}

.brand-copy {
  margin-top: 12px;
}

.eyebrow {
  margin: 0 0 18px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 3px;
  color: #38bdf8;
}

.brand-copy h1 {
  margin: 0;
  font-size: clamp(32px, 3.4vw, 46px);
  line-height: 1.18;
  letter-spacing: -1.2px;
  color: #f8fafc;
}

.brand-desc {
  max-width: 380px;
  margin: 22px 0 0;
  font-size: 14.5px;
  line-height: 1.85;
  color: #94a3b8;
}

.brand-points {
  list-style: none;
  margin: 26px 0 0;
  padding: 0;
  display: grid;
  gap: 13px;
  font-size: 13.5px;
  color: #cbd5e1;
}

.brand-points li {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-points .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #38bdf8;
  box-shadow: 0 0 0 5px rgba(56, 189, 248, 0.12);
}

.brand-foot {
  font-size: 11px;
  letter-spacing: 1.4px;
  color: #64748b;
  text-transform: uppercase;
}

.login-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 44px 44px 26px;
  background: #fff;
}

.login-card-inner {
  margin: auto 0;
}

.mini-logo {
  width: 42px;
  height: 42px;
  margin-bottom: 24px;
  font-size: 20px;
}

.login-card h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.6px;
}

.login-sub {
  margin: 8px 0 28px;
  font-size: 14px;
  color: var(--muted);
}

.btn {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s ease, background 0.15s ease,
    box-shadow 0.15s ease, border-color 0.15s ease;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  color: #fff;
  background: linear-gradient(145deg, #2563eb, #1d4ed8);
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.28);
}

.btn-primary:hover:not(:disabled) {
  background: linear-gradient(145deg, #1d4ed8, #1e40af);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.34);
}

.btn-block {
  width: 100%;
  padding: 14px 18px;
  font-size: 15px;
}

.btn-ghost {
  color: var(--ink-2);
  background: #fff;
  border-color: var(--line);
}

.btn-ghost:hover:not(:disabled) {
  border-color: var(--line-2);
  background: #f8fafc;
}

.btn-sm {
  padding: 8px 13px;
  font-size: 13px;
  border-radius: 10px;
}

.login-hint {
  margin: 20px 0 0;
  text-align: center;
  font-size: 12.5px;
  line-height: 1.75;
  color: var(--muted);
}

.env-badge {
  margin-top: 18px;
  padding: 9px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px dashed var(--line);
  text-align: center;
  font-size: 12px;
  color: var(--muted);
}

.login-card-foot {
  padding-top: 22px;
  border-top: 1px solid var(--line);
  text-align: center;
  font-size: 11.5px;
  color: #94a3b8;
}

.alert {
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  margin-bottom: 18px;
}

.alert.error {
  color: #991b1b;
  background: var(--bad-soft);
  border: 1px solid #fecaca;
}

.alert.warn {
  color: #92400e;
  background: var(--warn-soft);
  border: 1px solid #fde68a;
}

.alert.info {
  color: #1e40af;
  background: var(--primary-soft);
  border: 1px solid #bfdbfe;
}

/* ============================ 工作台 ============================ */

.app-page {
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(37, 99, 235, 0.07), transparent 60%),
    var(--bg);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  height: 66px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 max(20px, env(safe-area-inset-left)) 0 max(20px, env(safe-area-inset-right));
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-logo.small {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  font-size: 18px;
  box-shadow: 0 6px 16px rgba(14, 165, 233, 0.26);
}

.topbar-title {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
  min-width: 0;
}

.topbar-title strong {
  font-size: 14.5px;
  letter-spacing: -0.2px;
}

.topbar-title span {
  font-size: 11.5px;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-mock {
  color: #92400e;
  background: #fef3c7;
  border: 1px solid #fcd34d;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 999px;
  background: #f8fafc;
  border: 1px solid var(--line);
  max-width: 240px;
}

.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  background: linear-gradient(145deg, #3b82f6, #0ea5e9);
}

.user-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace {
  width: min(1240px, 100%);
  margin: 0 auto;
  padding: 26px max(20px, env(safe-area-inset-left)) 48px max(20px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, 0.88fr);
  gap: 22px;
  align-items: start;
}

.panel {
  background: var(--card);
  border: 1px solid rgba(226, 232, 240, 0.9);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid #f1f5f9;
}

.panel-head.compact {
  align-items: center;
  padding-bottom: 16px;
}

.panel-head h1,
.panel-head h2 {
  margin: 0;
  font-size: 19px;
  letter-spacing: -0.35px;
}

.panel-head p {
  margin: 6px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
}

.panel-tag {
  flex: none;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.6px;
  color: #1e40af;
  background: var(--primary-soft);
  border: 1px solid #dbeafe;
  text-transform: uppercase;
}

.form-panel,
.list-panel {
  min-height: 420px;
}

#configHint,
#templateError {
  margin: 18px 24px 0;
}

.approval-form {
  padding: 22px 24px 8px;
  display: grid;
  gap: 18px;
}

.form-placeholder {
  padding: 36px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
}

.field label .required {
  color: var(--bad);
  margin-left: 3px;
}

.field input[type="text"],
.field input[type="number"],
.field input[type="date"],
.field input[type="datetime-local"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 13px;
  font-size: 14px;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.7;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: #93c5fd;
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.12);
}

.field-help {
  margin: 0;
  font-size: 11.5px;
  color: #94a3b8;
}

.selector-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.selector-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 13px;
  color: var(--ink-2);
  background: #fff;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.selector-option:hover {
  border-color: var(--line-2);
  background: #f8fafc;
}

.selector-option input {
  accent-color: var(--primary);
  margin: 0;
}

.selector-option.checked {
  border-color: #93c5fd;
  background: var(--primary-soft);
  color: #1e40af;
}

.tips-block {
  padding: 12px 14px;
  border-radius: 11px;
  background: #f8fafc;
  border: 1px dashed var(--line-2);
  font-size: 12.5px;
  line-height: 1.7;
  color: var(--muted);
}

.unsupported {
  padding: 12px 14px;
  border-radius: 11px;
  background: var(--warn-soft);
  border: 1px solid #fde68a;
  font-size: 12.5px;
  color: #92400e;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 24px 24px;
  border-top: 1px solid #f1f5f9;
}

.form-status {
  font-size: 12.5px;
  color: var(--muted);
}

.list-panel {
  position: sticky;
  top: 88px;
}

.approval-list {
  padding: 14px 16px 18px;
  display: grid;
  gap: 10px;
  max-height: 640px;
  overflow: auto;
}

.empty-state {
  padding: 46px 18px;
  text-align: center;
  font-size: 13px;
  line-height: 1.8;
  color: #94a3b8;
  white-space: pre-line;
}

.approval-item {
  border: 1px solid var(--line);
  border-radius: 13px;
  padding: 14px;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.approval-item:hover {
  border-color: #bfdbfe;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.07);
}

.approval-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.approval-title {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.45;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.status {
  flex: none;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.status-pending {
  color: #1d4ed8;
  background: #dbeafe;
}

.status-ok {
  color: #047857;
  background: var(--ok-soft);
}

.status-bad {
  color: #b91c1c;
  background: var(--bad-soft);
}

.status-muted {
  color: #475569;
  background: #f1f5f9;
}

.approval-meta {
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 11.5px;
  color: #94a3b8;
}

.approval-summary {
  margin-top: 8px;
  font-size: 12.5px;
  line-height: 1.65;
  color: var(--ink-2);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.approval-actions {
  margin-top: 11px;
  display: flex;
  gap: 8px;
}

.link-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 12px;
  font-weight: 650;
  color: var(--primary);
  cursor: pointer;
}

.link-btn:hover {
  color: var(--primary-2);
  text-decoration: underline;
}

/* ============================ 弹窗 / Toast ============================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(3px);
}

.modal-card {
  position: relative;
  width: min(680px, 100%);
  max-height: min(82vh, 760px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.3);
  overflow: hidden;
  animation: pop 0.18s ease both;
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.985);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding: 20px 22px 16px;
  border-bottom: 1px solid var(--line);
}

.modal-head h3 {
  margin: 0;
  font-size: 17px;
  letter-spacing: -0.3px;
}

.modal-sub {
  display: block;
  margin-top: 5px;
  font-size: 11.5px;
  color: var(--muted);
}

.icon-btn {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}

.icon-btn:hover {
  background: #f8fafc;
}

.modal-body {
  padding: 20px 22px 24px;
  overflow: auto;
  display: grid;
  gap: 18px;
}

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

.detail-cell {
  padding: 10px 12px;
  border-radius: 10px;
  background: #f8fafc;
  border: 1px solid #f1f5f9;
}

.detail-cell span {
  display: block;
  font-size: 10.5px;
  color: #94a3b8;
  margin-bottom: 4px;
}

.detail-cell strong {
  font-size: 12.5px;
  font-weight: 600;
  word-break: break-all;
}

.detail-section h4 {
  margin: 0 0 10px;
  font-size: 12px;
  letter-spacing: 0.4px;
  color: #94a3b8;
  text-transform: uppercase;
}

.detail-row {
  display: grid;
  grid-template-columns: minmax(90px, 0.36fr) minmax(0, 1fr);
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 12.5px;
  line-height: 1.65;
}

.detail-row:last-child {
  border-bottom: 0;
}

.detail-row .k {
  color: var(--muted);
}

.detail-row .v {
  color: var(--ink-2);
  word-break: break-word;
  white-space: pre-wrap;
}

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

.flow-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 11px;
  border-radius: 10px;
  background: #f8fafc;
  font-size: 12.5px;
}

.flow-item .who {
  font-weight: 600;
  color: var(--ink-2);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 80;
  max-width: min(520px, calc(100vw - 40px));
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
  color: #fff;
  background: #0f172a;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.3);
  animation: toast-in 0.2s ease both;
}

.toast.error {
  background: #991b1b;
}

.toast.success {
  background: #065f46;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 8px);
  }
  to {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

/* ============================ 响应式 ============================ */

@media (max-width: 900px) {
  .login-shell {
    grid-template-columns: 1fr;
    min-height: 0;
  }

  .brand-panel {
    display: none;
  }

  .login-card {
    min-height: 540px;
    padding: 38px 30px 24px;
  }

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

  .list-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar {
    height: 60px;
    padding-left: 14px;
    padding-right: 14px;
  }

  .topbar-title span {
    display: none;
  }

  .user-chip {
    max-width: 132px;
    padding-right: 8px;
  }

  .workspace {
    padding: 16px 14px 40px;
    gap: 16px;
  }

  .panel-head {
    padding: 20px 18px 14px;
  }

  .approval-form {
    padding: 18px 18px 6px;
  }

  .form-actions {
    padding: 14px 18px 20px;
  }

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