:root {
  --bg: #f3f6f5;
  --panel: #ffffff;
  --ink: #172321;
  --muted: #6b7b78;
  --line: #dfe8e6;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --brand-soft: #dff5f1;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #b45309;
  --warning-soft: #fef3c7;
  --success: #15803d;
  --success-soft: #dcfce7;
  --info: #2563eb;
  --info-soft: #dbeafe;
  --shadow: 0 12px 40px rgba(15, 50, 44, 0.08);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: var(--bg); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell { min-height: 100vh; }
.loading-screen, .login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(circle at 15% 15%, rgba(15, 118, 110, 0.12), transparent 32%),
    radial-gradient(circle at 85% 85%, rgba(37, 99, 235, 0.10), transparent 35%),
    var(--bg);
}
.loading-screen { align-content: center; gap: 16px; color: var(--muted); }
.brand-mark {
  width: 58px; height: 58px; border-radius: 18px;
  display: grid; place-items: center;
  color: #fff; font-weight: 800; font-size: 25px;
  background: linear-gradient(145deg, #0f766e, #115e59);
  box-shadow: 0 14px 30px rgba(15, 118, 110, 0.28);
}
.login-card {
  width: min(960px, 100%);
  display: grid; grid-template-columns: 1.05fr 0.95fr;
  background: rgba(255,255,255,0.96);
  border: 1px solid rgba(255,255,255,0.8);
  border-radius: 28px; overflow: hidden; box-shadow: var(--shadow);
}
.login-hero {
  padding: 54px;
  color: #fff;
  background: linear-gradient(150deg, #0f766e 0%, #115e59 62%, #134e4a 100%);
  position: relative; overflow: hidden;
}
.login-hero::after {
  content: ""; position: absolute; width: 280px; height: 280px; border-radius: 50%;
  right: -90px; bottom: -110px; background: rgba(255,255,255,0.1);
}
.login-hero h1 { font-size: 32px; line-height: 1.25; margin: 28px 0 14px; }
.login-hero p { color: rgba(255,255,255,0.82); line-height: 1.8; margin: 0; }
.login-points { display: grid; gap: 12px; margin-top: 32px; }
.login-point { display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,0.92); }
.login-point span { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; background: rgba(255,255,255,0.18); }
.login-panel { padding: 46px; }
.login-panel h2 { margin: 0 0 8px; font-size: 24px; }
.login-panel > p { margin: 0 0 24px; color: var(--muted); line-height: 1.7; }
.account-list { display: grid; gap: 10px; }
.account-button {
  width: 100%; border: 1px solid var(--line); background: #fff; border-radius: 14px;
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between;
  text-align: left; transition: .2s ease;
}
.account-button:hover { border-color: var(--brand); background: var(--brand-soft); transform: translateY(-1px); }
.account-button strong { display: block; margin-bottom: 3px; }
.account-button small { color: var(--muted); }
.account-role { font-size: 12px; padding: 5px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); white-space: nowrap; }

.layout { min-height: 100vh; display: grid; grid-template-columns: 242px 1fr; }
.sidebar {
  position: sticky; top: 0; height: 100vh; padding: 22px 16px;
  color: #d9f2ee; background: #103d39; display: flex; flex-direction: column;
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 4px 8px 22px; }
.sidebar-brand .brand-mark { width: 40px; height: 40px; border-radius: 12px; font-size: 18px; }
.sidebar-brand strong { display: block; color: #fff; font-size: 16px; }
.sidebar-brand small { color: rgba(217,242,238,0.62); }
.nav-list { display: grid; gap: 6px; }
.nav-button {
  border: 0; background: transparent; color: rgba(217,242,238,0.75);
  padding: 12px 13px; border-radius: 11px; display: flex; align-items: center; gap: 11px;
  text-align: left; transition: .18s ease;
}
.nav-button:hover, .nav-button.active { background: rgba(255,255,255,0.10); color: #fff; }
.nav-button .nav-icon { width: 22px; text-align: center; }
.sidebar-footer { margin-top: auto; padding: 12px 8px 0; color: rgba(217,242,238,0.55); font-size: 12px; line-height: 1.7; }
.main { min-width: 0; }
.topbar {
  min-height: 74px; padding: 14px 28px; display: flex; align-items: center; justify-content: space-between;
  gap: 20px; background: rgba(255,255,255,0.94); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5; backdrop-filter: blur(14px);
}
.page-title h1 { margin: 0; font-size: 21px; }
.page-title p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.tenant-select, .ghost-button, .primary-button, .danger-button, .small-button {
  border: 1px solid var(--line); border-radius: 10px; background: #fff; padding: 9px 12px;
}
.tenant-select { max-width: 220px; }
.ghost-button:hover { border-color: var(--brand); color: var(--brand); }
.primary-button { background: var(--brand); border-color: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-dark); }
.danger-button { background: var(--danger); border-color: var(--danger); color: #fff; }
.small-button { padding: 6px 9px; font-size: 12px; }
.user-chip { display: flex; gap: 9px; align-items: center; padding-left: 8px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; background: linear-gradient(145deg, #0f766e, #2563eb); font-weight: 700; }
.user-chip strong { display: block; font-size: 13px; }
.user-chip small { color: var(--muted); }

.content { padding: 26px 28px 48px; }
.card-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 15px; }
.stat-card, .panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: 0 5px 20px rgba(15,50,44,0.035);
}
.stat-card { padding: 19px; }
.stat-card .label { color: var(--muted); font-size: 13px; }
.stat-card .value { font-size: 31px; font-weight: 800; margin-top: 10px; }
.stat-card .hint { color: var(--muted); font-size: 12px; margin-top: 6px; }
.panel { margin-top: 18px; overflow: hidden; }
.panel-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.panel-head h2 { margin: 0; font-size: 16px; }
.panel-head p { margin: 5px 0 0; color: var(--muted); font-size: 12px; }
.panel-body { padding: 18px 20px; }
.toolbar { display: flex; gap: 9px; align-items: center; flex-wrap: wrap; }
.empty { padding: 42px 20px; text-align: center; color: var(--muted); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 13px 14px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; font-size: 13px; }
th { color: var(--muted); font-weight: 600; background: #fafcfb; }
tr:last-child td { border-bottom: 0; }
.cell-title { font-weight: 650; margin-bottom: 4px; }
.cell-sub { color: var(--muted); font-size: 12px; line-height: 1.55; }
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 8px; border-radius: 999px; font-size: 12px; white-space: nowrap; }
.badge.pending { color: var(--warning); background: var(--warning-soft); }
.badge.approved, .badge.published, .badge.active { color: var(--success); background: var(--success-soft); }
.badge.rejected, .badge.machine_rejected, .badge.disabled, .badge.hidden { color: var(--danger); background: var(--danger-soft); }
.badge.high { color: var(--danger); background: var(--danger-soft); }
.badge.medium { color: var(--warning); background: var(--warning-soft); }
.badge.low { color: var(--info); background: var(--info-soft); }
.action-row { display: flex; gap: 7px; flex-wrap: wrap; }
.snapshot { max-width: 420px; white-space: pre-wrap; line-height: 1.65; }
.reason-list { margin: 7px 0 0; padding-left: 17px; color: var(--muted); font-size: 12px; line-height: 1.6; }
.detail-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.detail-item { padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #fcfefd; }
.detail-item label { display: block; color: var(--muted); font-size: 12px; margin-bottom: 6px; }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(10, 31, 28, 0.45); display: grid; place-items: center; padding: 18px; }
.modal { width: min(560px, 100%); background: #fff; border-radius: 20px; box-shadow: 0 24px 80px rgba(0,0,0,.22); overflow: hidden; }
.modal-head { padding: 18px 20px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.modal-head h3 { margin: 0; }
.modal-body { padding: 20px; }
.modal-actions { padding: 16px 20px; border-top: 1px solid var(--line); display: flex; justify-content: flex-end; gap: 9px; }
.field { display: grid; gap: 7px; margin-bottom: 14px; }
.field label { font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; outline: none; }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(15,118,110,.10); }
.toast { position: fixed; z-index: 50; right: 24px; bottom: 24px; padding: 12px 16px; color: #fff; background: #103d39; border-radius: 12px; box-shadow: var(--shadow); }
.toast.error { background: #991b1b; }
.form-error { color: var(--danger); font-size: 12px; margin-top: 8px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; word-break: break-all; }
.split { display: flex; gap: 12px; justify-content: space-between; align-items: flex-start; }
.muted { color: var(--muted); }

@media (max-width: 1050px) {
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .login-card { grid-template-columns: 1fr; }
  .login-hero { padding: 34px; }
}
@media (max-width: 780px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 15px; }
  .nav-list { display: flex; overflow-x: auto; }
  .nav-button { white-space: nowrap; }
  .sidebar-footer { display: none; }
  .topbar { position: static; padding: 14px 16px; flex-wrap: wrap; }
  .content { padding: 18px 14px 40px; }
  .card-grid { grid-template-columns: 1fr; }
  .topbar-actions { width: 100%; flex-wrap: wrap; }
  .tenant-select { flex: 1; max-width: none; }
}

.config-input {
  width: 130px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
}
.form-hint {
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--muted);
  background: #f5f8f7;
  font-size: 12px;
  line-height: 1.6;
}

.readiness-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.readiness-card {
  padding: 18px;
  border: 1px solid var(--line);
  border-left-width: 6px;
  border-radius: 14px;
  background: #fff;
}
.readiness-card.ready { border-left-color: var(--success); }
.readiness-card.warning { border-left-color: var(--warning); }
.readiness-card.fail { border-left-color: var(--danger); }
.readiness-card p { margin: 10px 0 0; color: var(--muted); line-height: 1.6; }
@media (max-width: 780px) {
  .readiness-grid { grid-template-columns: 1fr; }
}

.admin-login-form { display: grid; gap: 10px; margin-bottom: 18px; }
.login-field {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}
.login-submit { justify-content: center; background: var(--brand); border-color: var(--brand); color: #fff; }
.login-divider { text-align: center; color: var(--muted); font-size: 13px; margin: 18px 0; }
