:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #263244;
  background: #f4f6fa;
  --primary: #1677ff;
  --primary-dark: #0958d9;
  --border: #e4e8ef;
  --muted: #748094;
  --panel: #ffffff;
  --success: #15803d;
  --warning: #b45309;
  --danger: #b91c1c;
  --shadow: 0 10px 30px rgba(31, 45, 61, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; background: #f4f6fa; }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 48px;
  background:
    radial-gradient(circle at 20% 20%, rgba(22, 119, 255, 0.16), transparent 32%),
    linear-gradient(135deg, #f7faff 0%, #eef3fb 100%);
}
.login-card {
  width: 430px;
  padding: 36px;
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 24px 60px rgba(31, 64, 117, 0.16);
}
.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #1677ff, #69b1ff);
  color: white;
  font-weight: 800;
  letter-spacing: 1px;
}
.eyebrow { margin: 20px 0 6px; color: var(--primary); font-size: 12px; font-weight: 700; letter-spacing: .08em; }
.login-card h1 { margin: 0; font-size: 25px; }
.login-help, .security-note { color: var(--muted); line-height: 1.7; }
.login-card form { display: grid; gap: 9px; margin-top: 24px; }
.login-card form label { margin-top: 8px; font-weight: 600; }
.security-note { margin: 18px 0 0; font-size: 12px; }
.form-error { margin: 4px 0; color: var(--danger); font-size: 13px; }

input, textarea, select {
  width: 100%;
  border: 1px solid #d9dee7;
  border-radius: 7px;
  background: white;
  color: #263244;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input, select { height: 38px; padding: 0 11px; }
textarea { padding: 10px 12px; resize: vertical; line-height: 1.55; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
input:focus, textarea:focus, select:focus { border-color: #69b1ff; box-shadow: 0 0 0 3px rgba(22, 119, 255, .1); }
label { display: block; margin-bottom: 7px; color: #3a4657; font-size: 13px; font-weight: 600; }

.button {
  min-height: 36px;
  padding: 0 15px;
  border: 1px solid transparent;
  border-radius: 7px;
  font-weight: 600;
  transition: background .15s, border-color .15s, opacity .15s;
}
.button:disabled { cursor: not-allowed; opacity: .45; }
.button.primary { background: var(--primary); color: white; }
.button.primary:hover:not(:disabled) { background: var(--primary-dark); }
.button.secondary { border-color: #91caff; background: #e6f4ff; color: #0958d9; }
.button.ghost { border-color: #d9dee7; background: white; color: #4a5568; }
.button.small { min-height: 30px; padding: 0 11px; font-size: 12px; }
.button.wide { width: 100%; min-height: 43px; margin-top: 12px; }

.app-shell {
  min-height: 100vh;
  padding: 56px 0 0 216px;
}
.topbar {
  position: fixed;
  z-index: 30;
  inset: 0 0 auto 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: #17233d;
  color: white;
  box-shadow: 0 1px 10px rgba(16, 24, 40, .18);
}
.topbar > div, .topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-divider { width: 1px; height: 18px; background: rgba(255,255,255,.22); }
.pill { padding: 5px 10px; border-radius: 999px; background: rgba(82, 196, 26, .16); color: #d9f7be; font-size: 12px; }
.pill.subtle { background: rgba(255,255,255,.1); color: #d7deea; }
.topbar .button.ghost { border-color: rgba(255,255,255,.3); background: transparent; color: white; }

.sidebar {
  position: fixed;
  z-index: 20;
  left: 0;
  top: 56px;
  bottom: 0;
  width: 216px;
  padding: 18px 12px;
  background: #fff;
  border-right: 1px solid var(--border);
}
.sidebar-title { display: flex; align-items: center; gap: 10px; padding: 5px 8px 20px; }
.sidebar-title small { display: block; margin-top: 3px; color: var(--muted); }
.sidebar-logo { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; background: #e6f4ff; color: var(--primary); font-size: 20px; font-weight: 800; }
.nav-item {
  width: 100%;
  height: 42px;
  margin-bottom: 6px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #4c596b;
  text-align: left;
  font-weight: 600;
}
.nav-item:hover { background: #f4f7fb; }
.nav-item.active { background: #eaf3ff; color: #0958d9; }
.sidebar-foot { position: absolute; left: 20px; right: 16px; bottom: 22px; color: var(--muted); font-size: 12px; }
.status-dot { display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #22c55e; }

.workspace { padding: 20px 22px 44px; }
.loading-panel { min-height: 560px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #d6e7ff; border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.page-view { max-width: 1500px; margin: 0 auto; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 18px; }
.page-header h1 { margin: 3px 0 7px; font-size: 22px; }
.page-header p { margin: 0; color: var(--muted); }
.breadcrumb { font-size: 12px; color: #8b96a8 !important; }
.panel {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: 0 2px 10px rgba(31, 45, 61, .035);
  padding: 18px;
}
.notice, .alert {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid #bae0ff;
  border-radius: 8px;
  background: #f0f8ff;
  color: #245c8f;
  line-height: 1.6;
}
.alert.danger { margin-top: 14px; border-color: #ffccc7; background: #fff2f0; color: var(--danger); }
.two-column { display: grid; grid-template-columns: 1.12fr .88fr; gap: 16px; }
.panel-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 15px; }
.panel-title h2, .table-toolbar h2 { margin: 0 0 5px; font-size: 16px; }
.panel-title p, .table-toolbar p { margin: 0; color: var(--muted); font-size: 13px; }
.count-badge { min-width: 54px; padding: 5px 9px; border-radius: 999px; background: #e6f4ff; color: #0958d9; text-align: center; font-size: 12px; font-weight: 700; }
.count-badge.invalid { background: #fff2f0; color: var(--danger); }
.count-badge.neutral { background: #f2f4f7; color: #5f6b7c; }
.button-row { display: flex; gap: 8px; margin: 10px 0 15px; }
.compact-table { max-height: 390px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.compact-row { display: grid; grid-template-columns: 48px 1fr auto; align-items: center; gap: 10px; padding: 9px 10px; border-bottom: 1px solid #edf0f4; }
.compact-row:last-child { border-bottom: 0; }
.compact-row strong, .dish-cell strong { display: block; font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: #647084; font-size: 12px; }
.mini-actions { display: flex; gap: 4px; }
.icon-button { width: 28px; height: 28px; border: 1px solid #dfe4eb; border-radius: 6px; background: white; color: #536174; }
.chip-list { display: flex; flex-wrap: wrap; gap: 7px; min-height: 36px; }
.chip { display: inline-flex; align-items: center; gap: 7px; padding: 5px 8px; border: 1px solid #d8e8ff; border-radius: 999px; background: #f3f8ff; }
.chip button { border: 0; background: transparent; color: #6b7789; }
.empty-inline { color: var(--muted); font-size: 13px; }
.sticky-actions {
  position: sticky;
  bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 16px;
  padding: 12px 16px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: rgba(255,255,255,.95);
  box-shadow: var(--shadow);
}
.sticky-actions span { color: var(--muted); font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 14px; }
.metric-card { position: relative; overflow: hidden; padding: 15px; border: 1px solid var(--border); border-radius: 9px; background: white; }
.metric-card::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 3px; background: var(--primary); }
.metric-card.success::before { background: var(--success); }
.metric-card.warning::before { background: #f59e0b; }
.metric-card.danger::before { background: var(--danger); }
.metric-card span, .metric-card small { display: block; color: var(--muted); }
.metric-card strong { display: block; margin: 7px 0 3px; font-size: 25px; color: #1f2b3d; }
.filter-panel { display: grid; grid-template-columns: 1.2fr 1fr 1.35fr auto; align-items: end; gap: 12px; margin-bottom: 14px; }
.field label { margin-bottom: 6px; }
.filter-actions { display: flex; gap: 8px; }
.table-panel { padding: 0; overflow: hidden; }
.table-toolbar { display: flex; justify-content: space-between; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; min-width: 1120px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #edf0f4; background: white; text-align: left; vertical-align: middle; font-size: 13px; }
th { position: sticky; top: 0; z-index: 2; background: #f7f9fc; color: #556174; font-weight: 700; white-space: nowrap; }
tbody tr:hover td { background: #f9fbfe; }
.sticky-column { position: sticky; right: 0; z-index: 3; min-width: 130px; box-shadow: -4px 0 8px rgba(31,45,61,.04); }
td.sticky-column { z-index: 1; }
.rank-preview { display: flex; gap: 3px; }
.rank-box { width: 23px; height: 23px; display: grid; place-items: center; border-radius: 5px; background: #e6f4ff; color: #0958d9; font-size: 11px; font-weight: 700; }
.rank-box.loss { background: #f3e8ff; color: #7e22ce; }
.rank-box.template { background: #f2f4f7; color: #5f6b7c; }
.rank-box.fallback { background: #fff7e6; color: #b45309; }
.rank-box.missing { background: #fff1f0; color: #b91c1c; }
.source-line, .tag-line { display: flex; flex-wrap: wrap; gap: 5px; }
.tag { display: inline-block; padding: 3px 7px; border-radius: 999px; background: #f2f4f7; color: #5f6b7c; font-size: 11px; white-space: nowrap; }
.tag.normal { background: #f0fdf4; color: var(--success); }
.tag.warning { background: #fff7e6; color: var(--warning); }
.tag.danger { background: #fff1f0; color: var(--danger); }
.link-button { border: 0; background: transparent; color: var(--primary); font-weight: 600; }
.pagination { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 12px 16px; }
.pagination select { width: 72px; height: 31px; }
.pagination span, .pagination label { color: var(--muted); font-size: 12px; margin: 0; }
.empty-state { padding: 46px; color: var(--muted); text-align: center; }

.drawer-mask { position: fixed; z-index: 70; inset: 0; background: rgba(19, 27, 42, .42); }
.drawer { position: fixed; z-index: 80; top: 0; right: 0; bottom: 0; width: min(1180px, calc(100vw - 100px)); display: flex; flex-direction: column; background: white; box-shadow: -18px 0 45px rgba(19, 27, 42, .2); }
.drawer-header { display: flex; justify-content: space-between; align-items: flex-start; padding: 20px 22px; border-bottom: 1px solid var(--border); }
.drawer-header h2 { margin: 2px 0 6px; }
.drawer-header p { margin: 0; color: var(--muted); }
.drawer-header .eyebrow { color: var(--primary); }
.close-button { width: 34px; height: 34px; border: 1px solid #dfe4eb; border-radius: 8px; background: white; font-size: 22px; color: #667085; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 22px; }
.drawer-summary { margin-bottom: 14px; padding: 11px 13px; border-radius: 8px; background: #f6f8fb; color: #546174; }
.drawer-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 13px 22px; border-top: 1px solid var(--border); }
.reason-cell { min-width: 270px; line-height: 1.55; color: #536174; }

.toast-stack { position: fixed; z-index: 120; right: 24px; top: 72px; display: grid; gap: 9px; }
.toast { max-width: 430px; padding: 11px 14px; border: 1px solid #b7eb8f; border-radius: 8px; background: #f6ffed; color: #237804; box-shadow: var(--shadow); }
.toast.error { border-color: #ffccc7; background: #fff2f0; color: var(--danger); }

