:root {
  font-family: "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  color: #172033;
  background: #eef2f6;
  font-synthesis: none;
  --bg: #eef2f6;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #d9e1ea;
  --line-strong: #c8d3df;
  --text: #172033;
  --muted: #657386;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #15803d;
  --warning: #b45309;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
input, select, textarea {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 7px 9px;
}
textarea { resize: vertical; line-height: 1.5; }
input[type="color"] { padding: 3px; }
input:focus, select:focus, textarea:focus, button:focus-visible {
  outline: 3px solid #bfdbfe;
  outline-offset: 1px;
}

.app-shell { min-height: 100vh; display: grid; grid-template-columns: 238px minmax(0, 1fr); }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  border-right: 1px solid #d0dae6;
  background: #101827;
  color: #e5edf8;
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.brand { display: flex; gap: 11px; align-items: center; padding: 4px 5px 14px; border-bottom: 1px solid rgba(255,255,255,.1); }
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
}
.brand strong { display: block; font-size: 15px; }
.brand span:last-child { display: block; margin-top: 3px; color: #9fb0c5; font-size: 12px; }
.nav-tabs { display: grid; gap: 7px; }
.nav-tab {
  border: 1px solid transparent;
  background: transparent;
  color: #c9d5e6;
  text-align: left;
  border-radius: 7px;
  padding: 11px 12px;
}
.nav-tab[aria-current="page"] { background: #1d2a3f; border-color: #32435d; color: #fff; }
.sidebar-status { margin-top: auto; display: grid; gap: 5px; color: #9fb0c5; font-size: 12px; }
.sidebar-status strong { color: #fff; font-size: 13px; }

.workspace { min-width: 0; padding: 24px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 11px; font-weight: 700; }
h1 { margin: 0; font-size: 24px; line-height: 1.25; }
h2 { margin: 0; font-size: 15px; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }
.last-sync { color: var(--muted); font-size: 12px; white-space: nowrap; }
.view { display: grid; gap: 16px; }
.view[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.metric {
  min-height: 82px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 15px;
  display: grid;
  gap: 8px;
}
.metric span { color: var(--muted); font-size: 12px; }
.metric strong { font-size: 26px; line-height: 1; font-variant-numeric: tabular-nums; }

.toolbar-band {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
.button {
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  background: #fff;
}
.button.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.button.primary:hover { background: var(--primary-dark); }
.button.secondary { border-color: var(--line-strong); color: #2e3b4e; }
.button.secondary:hover { background: #f1f5f9; }
.button.danger { border-color: #fecaca; color: var(--danger); background: #fff7f7; }
.button.danger:hover { background: #fee2e2; }
.segmented { display: inline-flex; border: 1px solid var(--line-strong); border-radius: 7px; overflow: hidden; background: #fff; }
.segmented button {
  min-height: 36px;
  border: 0;
  border-right: 1px solid var(--line-strong);
  background: #fff;
  padding: 8px 12px;
  color: #344256;
}
.segmented button:last-child { border-right: 0; }
.segmented button[data-active="true"] { background: #dbeafe; color: #1d4ed8; font-weight: 700; }

.panel-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.panel-grid.wide { grid-template-columns: minmax(0, .85fr) minmax(0, 1.15fr); }
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  min-width: 0;
}
.panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 13px;
}
.panel-heading span, .dialog-note { color: var(--muted); font-size: 12px; }
.heading-actions { display: flex; gap: 8px; }

.field-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 11px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid label, .list-editor label {
  display: grid;
  gap: 5px;
  color: #344256;
  font-size: 12px;
  min-width: 0;
}
.field-grid .full { grid-column: 1 / -1; }
.checkbox { display: flex !important; align-items: center; gap: 8px; min-height: 36px; }
.checkbox input, .check-list input { width: auto; min-height: auto; }
.check-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 14px; }
.check-list label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #334155; }

.online-list { display: grid; gap: 8px; }
.online-row {
  min-height: 40px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
}
.online-row strong, .online-row span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-row span:not(.status-dot), .online-row small { color: var(--muted); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); }
.empty-state { color: var(--muted); text-align: center; padding: 28px 12px; font-size: 13px; }
.empty-state.inline { padding: 10px; margin: 0; text-align: left; }

.list-editor { display: grid; gap: 9px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; }
.chip {
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1e40af;
  padding: 4px 9px;
  font-size: 12px;
}
.mark-tools { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 10px; margin-bottom: 11px; align-items: end; }
.mark-add { grid-template-columns: minmax(130px, 1fr) minmax(120px, 1fr) 110px 58px auto; margin-bottom: 12px; }

.filters { padding-bottom: 12px; }
.filters-grid { grid-template-columns: repeat(6, minmax(120px, 1fr)); }
.form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; }
.filter-count { color: var(--muted); font-size: 13px; }
.data-actions select { width: min(420px, 100%); }
.table-panel { padding: 0; overflow: hidden; }
.table-scroll { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 12px; white-space: nowrap; }
th, td { border-top: 1px solid var(--line); padding: 10px 12px; text-align: left; vertical-align: middle; }
th { color: var(--muted); background: var(--panel-soft); font-weight: 650; }
td { color: #263447; }
td:nth-child(6) { max-width: 280px; overflow: hidden; text-overflow: ellipsis; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--primary);
  padding: 0;
  font-weight: 650;
  text-decoration: none;
}
.link-button:hover { text-decoration: underline; }
.color-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 1px solid rgba(0,0,0,.18); vertical-align: -2px; }

dialog {
  width: min(760px, calc(100vw - 28px));
  border: 0;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 24px 60px rgba(15, 23, 42, .24);
}
dialog::backdrop { background: rgba(15, 23, 42, .42); }
.dialog-panel { padding: 16px; }
.dialog-note { margin: -4px 0 12px; line-height: 1.6; }
.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(360px, calc(100vw - 36px));
  background: #111827;
  color: #fff;
  padding: 11px 13px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: 0 16px 40px rgba(15,23,42,.2);
  z-index: 10;
}
.toast[data-type="success"] { background: #14532d; }
.toast[data-type="error"] { background: #991b1b; }

body[data-layout="compact"] .panel { padding: 11px; }
body[data-layout="compact"] th,
body[data-layout="compact"] td { padding: 7px 9px; }
body[data-layout="compact"] .metric { min-height: 68px; padding: 12px; }

@media (max-width: 1100px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    display: grid;
    grid-template-columns: minmax(180px, auto) 1fr auto;
    align-items: center;
  }
  .brand { border-bottom: 0; padding-bottom: 4px; }
  .nav-tabs { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .sidebar-status { margin-top: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-grid, .panel-grid.wide { grid-template-columns: 1fr; }
  .filters-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
  .workspace { padding: 16px; }
  .sidebar { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .topbar-actions { width: 100%; justify-content: space-between; }
  .metric-grid, .field-grid, .field-grid.two, .filters-grid, .check-list { grid-template-columns: 1fr; }
  .mark-tools, .mark-add { grid-template-columns: 1fr; }
  .toolbar-band { align-items: stretch; }
  .toolbar-band > * { width: 100%; }
  .segmented { width: 100%; }
  .segmented button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}
