:root {
  color-scheme: light;
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #68738a;
  --line: #dfe5ef;
  --primary: #315efb;
  --primary-dark: #2348ca;
  --success: #17825c;
  --danger: #c43d4b;
  --warning: #c57a13;
  --shadow: 0 12px 32px rgba(35, 54, 93, .09);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: radial-gradient(circle at 10% 0%, #e6eeff 0, transparent 32rem), var(--bg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.shell { max-width: 1500px; margin: 0 auto; padding: 22px; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-bottom: 18px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px;
  color: white; background: linear-gradient(145deg, #315efb, #6b45e8); font-weight: 800;
  box-shadow: var(--shadow);
}
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 2px; font-size: 22px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }
.muted { color: var(--muted); }
.panel {
  background: color-mix(in srgb, var(--panel) 96%, transparent);
  border: 1px solid rgba(223,229,239,.9); border-radius: 16px; padding: 18px;
  box-shadow: var(--shadow);
}
.login-wrap { min-height: 78vh; display: grid; place-items: center; }
.login-card { width: min(430px, 100%); padding: 30px; }
.login-card .brand { margin-bottom: 22px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: minmax(0, 1.35fr) minmax(340px, .65fr); }
.grid.admin { grid-template-columns: minmax(520px, 1fr) minmax(460px, .9fr); }
.toolbar { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.toolbar.between { justify-content: space-between; }
.filter-panel { margin-bottom: 16px; }
.labeler-stats-panel, .personal-stats-panel { margin-bottom: 16px; }
.labeler-stats-panel h2, .personal-stats-panel h2 { margin-bottom: 2px; }
.compact-select { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.compact-select select { height: 36px; border: 1px solid var(--line); border-radius: 9px; padding: 0 9px; background: #fff; }
.compact-table { margin-top: 14px; max-height: 260px; }
.filter-grid {
  display: grid; grid-template-columns: repeat(3, minmax(120px, .8fr)) minmax(170px, 1.2fr) minmax(155px, 1fr) auto;
  align-items: end; gap: 12px;
}
.filter-field { display: grid; gap: 6px; min-width: 0; color: #465069; font-weight: 650; }
.filter-field input, .filter-field select {
  width: 100%; min-width: 0; height: 42px; border: 1px solid var(--line); border-radius: 10px;
  padding: 0 11px; color: var(--text); background: #fff; outline: none;
}
.filter-field input:focus, .filter-field select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px #315efb1f;
}
.filter-actions { display: flex; align-items: center; gap: 9px; }
.filter-actions .btn { height: 42px; white-space: nowrap; }
.bulk-toolbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 10px 0; padding: 10px 12px; border-radius: 11px; background: #eef5f1;
}
.bulk-toolbar label { display: flex; align-items: center; gap: 7px; font-weight: 650; }
.bulk-toolbar input, .row-select { width: 16px; height: 16px; accent-color: var(--success); }
.btn {
  border: 0; border-radius: 10px; padding: 9px 14px; font-weight: 650;
  color: white; background: var(--primary); transition: .15s ease;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); }
.btn.secondary { color: var(--text); background: #e9eef7; }
.btn.secondary:hover { background: #dce4f1; }
.btn.success { background: var(--success); }
.btn.danger { background: var(--danger); }
.btn.warning { background: var(--warning); }
.btn.small { padding: 6px 10px; font-size: 12px; }
.btn:disabled { cursor: not-allowed; opacity: .55; transform: none; }
.field { margin-bottom: 14px; }
.field label { display: block; margin-bottom: 6px; color: #465069; font-weight: 650; }
.field input, .field select, .field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px;
  color: var(--text); background: #fff; outline: none;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #315efb1f; }
.field textarea { min-height: 100px; resize: vertical; }
.inline-fields { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.radio-row { display: flex; gap: 18px; padding: 8px 0; }
.radio-row label { display: flex; align-items: center; gap: 6px; margin: 0; }
.alert { padding: 10px 12px; border-radius: 10px; margin: 10px 0; background: #eef2f8; }
.alert.danger { color: #8b2130; background: #fdecef; }
.alert.success { color: #126646; background: #e7f7f0; }
.alert.warning { color: #86500c; background: #fff4df; }
.badge { display: inline-flex; align-items: center; padding: 3px 8px; border-radius: 99px; font-size: 12px; background: #e9eef7; }
.badge.pending { color: #5d6677; }
.badge.submitted { color: #81530b; background: #fff0cf; }
.badge.approved { color: #126646; background: #dff5eb; }
.badge.rejected { color: #8b2130; background: #fde3e7; }
.media-frame { background: #101521; border-radius: 14px; padding: 10px; }
video { display: block; width: 100%; max-height: 52vh; border-radius: 9px; background: #000; }
.trajectory-wrap { margin-top: 12px; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fbfcff; }
.trajectory-wrap canvas { width: 100%; height: 240px; display: block; }
.sample-strip { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px; }
.sample-pill {
  flex: 0 0 auto; border: 1px solid var(--line); background: white; color: var(--text);
  padding: 7px 10px; border-radius: 9px;
}
.sample-pill.active { color: white; border-color: var(--primary); background: var(--primary); }
.event-list { display: grid; gap: 8px; }
.event-row { display: grid; grid-template-columns: 110px 1fr auto; gap: 8px; }
.event-row input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px; }
.meta-line { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.table-wrap { overflow: auto; max-height: 56vh; border: 1px solid var(--line); border-radius: 12px; }
.pager { display: flex; justify-content: flex-end; align-items: center; gap: 10px; padding: 12px 2px 2px; }
.pager label { display: flex; align-items: center; gap: 6px; color: var(--muted); }
.pager select { height: 32px; border: 1px solid var(--line); border-radius: 8px; padding: 0 8px; background: #fff; }
table { width: 100%; border-collapse: collapse; background: white; }
th, td { padding: 10px 11px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { position: sticky; top: 0; z-index: 1; background: #f2f5fa; color: #4d5870; }
tr.clickable:hover { background: #f5f8ff; cursor: pointer; }
.stats { display: grid; grid-template-columns: repeat(6, minmax(110px, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat { background: white; border: 1px solid var(--line); border-radius: 12px; padding: 13px; }
.stat strong { display: block; font-size: 22px; }
.detail-panel { position: sticky; top: 14px; max-height: calc(100vh - 30px); overflow: auto; }
.json-diff { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
pre {
  margin: 0; padding: 12px; border-radius: 10px; overflow: auto; max-height: 280px;
  color: #dfe9ff; background: #182033; font: 12px/1.55 ui-monospace, SFMono-Regular, Menlo, monospace;
}
.empty { padding: 36px 18px; text-align: center; color: var(--muted); }
.toast {
  position: fixed; right: 22px; bottom: 22px; z-index: 20; min-width: 260px; max-width: 460px;
  padding: 12px 14px; border-radius: 11px; color: white; background: #243149; box-shadow: var(--shadow);
}
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 18px 0 10px; }
.section-title h3 { margin: 0; }
.account-dialog {
  width: min(520px, calc(100vw - 28px)); max-height: min(720px, calc(100vh - 40px));
  border: 1px solid var(--line); border-radius: 18px; padding: 22px; color: var(--text); background: #fff;
  box-shadow: 0 24px 70px rgba(25, 39, 76, .24);
}
.account-dialog::backdrop { background: rgba(20, 30, 52, .42); backdrop-filter: blur(3px); }
.dialog-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; margin-bottom: 20px; }
.dialog-heading h2 { margin-bottom: 2px; }
.icon-btn { border: 0; border-radius: 9px; padding: 2px 10px; color: var(--muted); background: #eef2f8; font-size: 24px; line-height: 1.3; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; }
.account-list { display: grid; gap: 8px; max-height: 210px; overflow: auto; }
.account-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #f8faff; }
.account-main { display: grid; gap: 2px; min-width: 0; }
.account-main .muted { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-actions { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.switch-row { display: flex; align-items: center; gap: 8px; margin: 4px 0 18px; font-weight: 650; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--success); }
.personal-stat-totals { display: flex; align-items: center; gap: 22px; color: var(--muted); }
.personal-stat-totals strong { margin-left: 5px; color: var(--text); font-size: 22px; }
.daily-stat-strip { display: grid; grid-template-columns: repeat(7, minmax(70px, 1fr)); gap: 8px; margin-top: 14px; }
.daily-stat-item { padding: 9px; border: 1px solid var(--line); border-radius: 10px; text-align: center; background: #f8faff; }
.daily-stat-item strong { display: block; font-size: 18px; }
@media (max-width: 1050px) {
  .grid.two, .grid.admin { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .filter-actions { grid-column: 1 / -1; justify-content: flex-end; }
  .detail-panel { position: static; max-height: none; }
  .stats { grid-template-columns: repeat(3, 1fr); }
  .daily-stat-strip { grid-template-columns: repeat(4, minmax(70px, 1fr)); }
}
@media (max-width: 640px) {
  .shell { padding: 12px; }
  .topbar { align-items: flex-start; }
  .inline-fields, .json-diff { grid-template-columns: 1fr; }
  .filter-grid { grid-template-columns: 1fr; }
  .filter-actions { grid-column: auto; }
  .filter-actions .btn { flex: 1; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .daily-stat-strip { grid-template-columns: repeat(2, minmax(70px, 1fr)); }
  .personal-stat-totals { gap: 10px; }
  .event-row { grid-template-columns: 90px 1fr; }
  .event-row button { grid-column: 1 / -1; }
}
