:root {
  --navy-950: #0b1526;
  --navy-900: #101d34;
  --navy-800: #16294a;
  --navy-700: #1d3a63;
  --blue-600: #2563eb;
  --blue-500: #3b82f6;
  --blue-50: #eff6ff;
  --slate-900: #0f172a;
  --slate-700: #334155;
  --slate-500: #64748b;
  --slate-300: #cbd5e1;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --white: #ffffff;
  --green-600: #16a34a;
  --green-50: #f0fdf4;
  --amber-600: #d97706;
  --amber-50: #fffbeb;
  --red-600: #dc2626;
  --red-50: #fef2f2;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  font-size: 14px;
  line-height: 1.5;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- App shell ---------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 232px;
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--navy-950), var(--navy-900));
  color: #cdd7e6;
  display: flex;
  flex-direction: column;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-brand .mark {
  width: 34px; height: 34px; border-radius: 8px;
  background: linear-gradient(135deg, var(--blue-500), #1d4ed8);
  color: #fff; font-weight: 700; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-brand .title { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-brand .subtitle { font-size: 11px; color: #93a3bb; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }
.nav-group-label {
  font-size: 11px; color: #6b7f9c; text-transform: uppercase;
  letter-spacing: .06em; padding: 14px 10px 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: 8px; color: #cdd7e6;
  font-size: 13.5px; margin-bottom: 2px;
}
.nav-item:hover { background: rgba(255,255,255,.06); text-decoration: none; }
.nav-item.active { background: var(--blue-600); color: #fff; }

/* A 业务 parent whose group is open. Lighter than .active so the parent and the
   exact page inside it stay tellable apart. */
.nav-item.open { background: rgba(255,255,255,.09); color: #fff; }

/* Sub-pages of the currently open 业务 group; rendered only while that group
   is active (see navSections in internal/web/context.go). */
.nav-sub { margin: 2px 0 6px 12px; border-left: 1px solid rgba(255,255,255,.10); padding-left: 8px; }
.nav-sub .nav-item { font-size: 12.5px; padding: 7px 10px; color: #a9b8cc; }

.sidebar-foot { padding: 14px 18px; font-size: 11px; color: #5c6f8a; border-top: 1px solid rgba(255,255,255,.08); }

/* ---------- Main column ---------- */
.main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  height: 58px; flex-shrink: 0;
  background: #fff; border-bottom: 1px solid var(--slate-200);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px;
}
.topbar-title { font-size: 16px; font-weight: 600; color: var(--slate-900); }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--slate-700); }
.topbar-user .avatar {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--blue-50); color: var(--blue-600);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px;
}
.role-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--blue-50); color: var(--blue-600); font-weight: 600;
}
.logout-btn { color: var(--slate-500); font-size: 13px; }

.content { padding: 22px; flex: 1; }
.content-header { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 16px; flex-wrap: wrap; gap: 8px; }
.content-header h1 { font-size: 19px; margin: 0; font-weight: 700; }
.content-header .desc { color: var(--slate-500); font-size: 13px; margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card-pad { padding: 18px 20px; }
.card-title { font-size: 14px; font-weight: 600; margin: 0 0 12px; color: var(--slate-900); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat-tile { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); }
.stat-tile .label { font-size: 12.5px; color: var(--slate-500); margin-bottom: 8px; }
.stat-tile .value { font-size: 26px; font-weight: 700; color: var(--slate-900); }
.stat-tile .value small { font-size: 13px; font-weight: 500; color: var(--slate-500); margin-left: 4px; }
.stat-tile .hint { font-size: 12px; color: var(--slate-500); margin-top: 6px; }

.grid-2 { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left; font-weight: 600; color: var(--slate-500);
  font-size: 12px; text-transform: uppercase; letter-spacing: .03em;
  padding: 10px 14px; border-bottom: 1px solid var(--slate-200); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--slate-100); color: var(--slate-900); }
table.data tbody tr:hover { background: var(--slate-50); }
table.data tbody tr:last-child td { border-bottom: none; }
.cell-muted { color: var(--slate-500); }
.cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }

/* ---------- Dense data grid (RPA 数据调用, mirrors the production layout) ---------- */
table.grid { width: 100%; border-collapse: collapse; font-size: 13px; }
table.grid th {
  background: var(--slate-50); color: var(--slate-700); font-weight: 600;
  padding: 9px 10px; border: 1px solid var(--slate-200); white-space: nowrap; text-align: center;
}
table.grid td {
  padding: 8px 10px; border: 1px solid var(--slate-200); color: var(--slate-900);
  white-space: nowrap; text-align: center;
}
table.grid td.left { text-align: left; }
table.grid tbody tr:nth-child(even) { background: #fbfcfe; }
table.grid tbody tr:hover { background: var(--blue-50); }
table.grid .ellipsis { display: inline-block; max-width: 150px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }
table.grid .num { text-align: right; font-variant-numeric: tabular-nums; }

/* Inline filter row: no labels, matching the single-line production search bar */
.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 14px 16px; }
.filter-bar .input { width: auto; min-width: 140px; padding: 7px 10px; font-size: 13px; }
.filter-bar .input.wide { min-width: 240px; }
.filter-bar .sep { color: var(--slate-300); }

/* 今日/本月/累计 counters shown as one line above the grid */
.stat-inline { display: flex; flex-wrap: wrap; gap: 18px; margin: 14px 0; font-size: 13px; color: var(--slate-700); }
.stat-inline b { color: var(--red-600); font-weight: 700; }
.stat-inline .muted b { color: var(--slate-900); }

/* 发起采集 panel, collapsed by default so the grid stays the focus */
.launch-panel { border: 1px solid var(--slate-200); border-radius: var(--radius); background: #fff; box-shadow: var(--shadow); }
.launch-panel > summary { padding: 11px 16px; cursor: pointer; font-size: 13.5px; font-weight: 600; color: var(--blue-600); list-style: none; }
.launch-panel > summary::-webkit-details-marker { display: none; }
.launch-panel[open] > summary { border-bottom: 1px solid var(--slate-200); }

/* Key/value summary block (RPA task detail header) */
.info-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px 22px; }
.info-grid .k { font-size: 12px; color: var(--slate-500); margin-bottom: 3px; }
.info-grid .v { font-size: 13.5px; word-break: break-all; }

/* ---------- Collection timeline (RPA task detail) ---------- */
.timeline { list-style: none; margin: 0; padding: 4px 0 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--slate-200); }
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: ''; position: absolute; left: -7px; top: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: #fff; border: 2px solid var(--slate-300);
}
.timeline li.done::before { border-color: var(--green-600); background: var(--green-600); }
.timeline li.active::before { border-color: var(--blue-600); background: var(--blue-600); }
.timeline li.failed::before { border-color: var(--red-600); background: var(--red-600); }
.timeline .step-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.timeline .step-name { font-size: 13.5px; font-weight: 600; }
.timeline .step-time { font-size: 12.5px; color: var(--slate-500); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.timeline .step-detail { font-size: 12.5px; color: var(--slate-500); margin-top: 4px; }

/* ---------- Section tabs (task detail / field dictionary) ---------- */
.tabs { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 1px solid var(--slate-200); margin-bottom: 14px; }
.tabs a { padding: 9px 14px; font-size: 13.5px; color: var(--slate-500); border-bottom: 2px solid transparent; font-weight: 600; }
.tabs a:hover { text-decoration: none; color: var(--slate-700); }
.tabs a.active { color: var(--blue-600); border-bottom-color: var(--blue-600); }

/* ---------- Field dictionary ---------- */
.field-group { margin-bottom: 18px; }
.field-group-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; padding: 12px 16px; border-bottom: 1px solid var(--slate-200); }
.field-group-head .table-name { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; color: var(--blue-600); }
.field-group-head .cn { font-size: 14px; font-weight: 600; }
.field-group-head .count { font-size: 12px; color: var(--slate-500); margin-left: auto; }
.sample-cell { max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--slate-500); }

/* ---------- Tags / badges ---------- */
.tag { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.tag-blue { background: var(--blue-50); color: var(--blue-600); }
.tag-green { background: var(--green-50); color: var(--green-600); }
.tag-amber { background: var(--amber-50); color: var(--amber-600); }
.tag-red { background: var(--red-50); color: var(--red-600); }
.tag-gray { background: var(--slate-100); color: var(--slate-500); }

/* ---------- Forms / buttons ---------- */
.form-row { margin-bottom: 14px; }
.form-row label { display: block; font-size: 12.5px; color: var(--slate-700); margin-bottom: 6px; font-weight: 600; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid var(--slate-300); border-radius: 8px;
  font-size: 13.5px; background: #fff; color: var(--slate-900); font-family: inherit;
}
.input:focus, select.input:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px var(--blue-50); }
.search-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 18px; }
.search-bar .form-row { margin-bottom: 0; min-width: 180px; }

.btn {
  display: inline-flex; align-items: center; gap: 6px; justify-content: center;
  padding: 9px 16px; border-radius: 8px; font-size: 13.5px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer; font-family: inherit;
}
.btn-primary { background: var(--blue-600); color: #fff; }
.btn-primary:hover { background: #1d4ed8; text-decoration: none; }
.btn-outline { background: #fff; color: var(--slate-700); border-color: var(--slate-300); }
.btn-outline:hover { border-color: var(--slate-500); text-decoration: none; }
.btn-sm { padding: 5px 11px; font-size: 12.5px; }
.btn-danger { background: var(--red-50); color: var(--red-600); border-color: #fecaca; }

/* ---------- Alerts ---------- */
.alert { padding: 11px 15px; border-radius: 8px; font-size: 13px; margin-bottom: 16px; }
.alert-error { background: var(--red-50); color: var(--red-600); border: 1px solid #fecaca; }
.alert-success { background: var(--green-50); color: var(--green-600); border: 1px solid #bbf7d0; }
.alert-info { background: var(--blue-50); color: var(--blue-600); border: 1px solid #bfdbfe; }

/* ---------- Pagination ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; align-items: center; }
.pagination a, .pagination span { padding: 6px 11px; border-radius: 6px; font-size: 13px; border: 1px solid var(--slate-200); color: var(--slate-700); }
.pagination .current { background: var(--blue-600); color: #fff; border-color: var(--blue-600); }

/* ---------- Permission matrix ---------- */
table.matrix { border-collapse: collapse; width: 100%; font-size: 13px; }
table.matrix th, table.matrix td { border: 1px solid var(--slate-200); padding: 10px 12px; text-align: center; }
table.matrix th { background: var(--slate-50); font-weight: 600; }
table.matrix td:first-child, table.matrix th:first-child { text-align: left; background: var(--slate-50); font-weight: 600; }
table.matrix input[type=checkbox] { width: 16px; height: 16px; accent-color: var(--blue-600); }

/* ---------- Login page ---------- */
.login-page {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 20% 20%, #16294a, #0b1526 60%);
}
.login-card { width: 380px; background: #fff; border-radius: 14px; padding: 34px 32px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login-brand { display: flex; align-items: center; gap: 10px; margin-bottom: 22px; }
.login-brand .mark { width: 38px; height: 38px; border-radius: 9px; background: linear-gradient(135deg, var(--blue-500), #1d4ed8); color: #fff; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.login-brand .name { font-size: 16px; font-weight: 700; }
.login-brand .sub { font-size: 12px; color: var(--slate-500); }
.login-card h2 { font-size: 15px; margin: 0 0 18px; color: var(--slate-700); font-weight: 600; }
.login-submit { width: 100%; margin-top: 6px; padding: 11px; }
.login-hint { margin-top: 18px; padding: 12px 14px; background: var(--slate-50); border-radius: 8px; font-size: 12px; color: var(--slate-500); line-height: 1.7; }
.login-hint b { color: var(--slate-700); }

/* ---------- Score meters (dimension breakdown bars) ---------- */
.meter-row { display: grid; grid-template-columns: 140px 1fr 42px; align-items: center; gap: 12px; margin-bottom: 14px; }
.meter-row:last-child { margin-bottom: 0; }
.meter-label { font-size: 13px; color: var(--slate-700); }
.meter-track { height: 10px; border-radius: 5px; background: var(--blue-50); overflow: hidden; }
.meter-fill { height: 100%; border-radius: 5px; background: var(--blue-600); }
.meter-value { font-size: 13px; font-weight: 600; color: var(--slate-900); text-align: right; }

.score-ring-wrap { display: flex; align-items: center; gap: 20px; }
.score-ring-num { font-size: 40px; font-weight: 700; color: var(--slate-900); line-height: 1; }
.score-ring-num small { font-size: 14px; font-weight: 500; color: var(--slate-500); }

/* ---------- Utility ---------- */
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-muted { color: var(--slate-500); }
.flex { display: flex; } .items-center { align-items: center; } .gap-8 { gap: 8px; }
.empty-state { text-align: center; padding: 40px 20px; color: var(--slate-500); font-size: 13.5px; }
