:root {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --text: #172033;
  --muted: #697386;
  --line: #d8dee8;
  --primary: #1667d9;
  --primary-dark: #0f4fa8;
  --ok: #0d8f63;
  --warn: #b35c00;
  --bad: #b42318;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0;
}

button, .button {
  border: 0;
  background: var(--primary);
  color: #fff;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
button:hover, .button:hover { background: var(--primary-dark); }
button.ghost {
  background: transparent;
  color: #dce6f8;
  border: 1px solid rgba(255,255,255,.2);
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  min-height: 36px;
  font: inherit;
  background: #fff;
}
textarea { resize: vertical; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
h1, h2, h3 { margin: 0; color: var(--text); }
h1 { font-size: 24px; }
h2 { font-size: 22px; }
h3 { font-size: 16px; }
pre {
  white-space: pre-wrap;
  word-break: break-word;
  background: #111827;
  color: #e5e7eb;
  border-radius: 6px;
  padding: 12px;
  max-height: 260px;
  overflow: auto;
}

.hidden { display: none !important; }
.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-panel {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px;
  display: grid;
  gap: 18px;
  box-shadow: 0 18px 50px rgba(24,39,75,.08);
}
.hint { color: var(--muted); font-size: 13px; margin: 0; }
.error { color: var(--bad); min-height: 20px; margin: 0; }

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 220px 1fr;
}
.sidebar {
  background: #111827;
  color: #fff;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.brand { font-weight: 700; font-size: 18px; }
.user {
  font-size: 13px;
  color: #cbd5e1;
  line-height: 1.6;
}
nav { display: grid; gap: 8px; }
nav button {
  background: transparent;
  justify-content: flex-start;
  color: #dce6f8;
}
nav button.active, nav button:hover {
  background: rgba(255,255,255,.12);
}
.main { padding: 24px; overflow: auto; }
.view { display: grid; gap: 18px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.metric-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}
.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}
.metric strong { display: block; font-size: 24px; margin-top: 4px; }
.filters, .edit-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}
#dashboardGroupFilter {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
}
.check-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
}
.check-chip input {
  width: auto;
  min-height: auto;
}
.group-shortcuts {
  display: flex;
  flex-wrap: wrap;
}
.group-shortcuts button.active {
  background: var(--text);
  color: #fff;
  border-color: var(--text);
}
.claim-bar, .assign-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  flex-wrap: wrap;
}
.claim-bar span, .assign-bar span {
  color: var(--muted);
  font-size: 13px;
}
.claim-bar select {
  width: 110px;
}
.assign-bar input, .assign-bar select {
  width: 170px;
}
.inline-select {
  min-width: 110px;
  padding: 5px 8px;
  min-height: 30px;
}
.row-note {
  white-space: normal;
  min-width: 220px;
  max-width: 420px;
  line-height: 1.5;
}
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #eef2f7;
  color: #334155;
}
.status-pill.active {
  background: #e7f5ef;
  color: var(--ok);
}
.status-pill.done {
  background: #eaf2ff;
  color: var(--primary);
}
.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  display: grid;
  gap: 14px;
}
.narrow { max-width: 560px; }
.grid-two {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 16px;
}
.table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}
th, td {
  border-bottom: 1px solid var(--line);
  padding: 9px 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 13px;
  white-space: nowrap;
}
th {
  background: #eef2f7;
  color: #334155;
  font-weight: 600;
  position: sticky;
  top: 0;
}
tr:hover td { background: #f8fafc; }
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}
.check input { width: auto; min-height: auto; }
.actions { display: flex; gap: 12px; flex-wrap: wrap; }
.mini-btn {
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
}
dialog {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  width: min(460px, calc(100% - 32px));
}
dialog::backdrop { background: rgba(15,23,42,.45); }
#callForm { padding: 18px; display: grid; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; }

@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: static; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .main { padding: 14px; }
  table { min-width: 760px; }
}
