:root {
  color-scheme: light;
  font-family: Inter, "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  color: #142d48;
  background: #f5f8fc;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 300px; }
[hidden] { display: none !important; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .55; }
a { color: inherit; }
h1, h2, p { margin: 0; }

.topbar {
  min-height: 56px;
  background: #0b1828;
  color: #f3f7fd;
  display: flex;
  align-items: center;
  gap: clamp(14px, 5vw, 90px);
  padding: 0 clamp(12px, 2vw, 34px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-size: 18px; font-weight: 760; white-space: nowrap; text-decoration: none; }
.brand img { display: block; border-radius: 5px; }
.topbar nav, .account { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 15px; }
.topbar button { background: transparent; color: inherit; border: 0; padding: 14px 8px; white-space: nowrap; }
.topbar nav button { border-bottom: 3px solid transparent; }
.topbar nav button[aria-current] { font-weight: 700; border-color: #6aa8ff; }
.account { margin-left: auto; font-size: 13px; }

.login {
  width: min(424px, calc(100% - 32px));
  margin: min(18vh, 170px) auto 0;
  padding: 35px 28px;
  background: #fff;
  border: 1px solid #dce6f1;
  border-radius: 12px;
  text-align: center;
}
.login h1 { font-size: 25px; }
.login p { min-height: 22px; color: #4c5f77; margin: 14px 0 23px; }
.login-actions { display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 10px 16px; }
.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  min-height: 36px;
  border: 1px solid transparent;
  border-radius: 5px;
  background: #1d65da;
  color: white;
  text-decoration: none;
  white-space: nowrap;
}
.primary:hover { background: #1857bc; }

.dashboard {
  padding: 0 clamp(8px, 1.2vw, 20px) 22px;
  background: linear-gradient(110deg, #1383ce 0%, #0b4cb8 85%);
}
.dashboard > h1 {
  padding: 16px 0;
  text-align: center;
  color: #fff;
  font-size: clamp(19px, 2vw, 29px);
}
.filter-bar, .chart-card {
  padding: 12px 15px;
  border-radius: 8px;
  background: #fff;
  margin-bottom: 9px;
}
.filter-bar { display: flex; gap: 8px 12px; flex-wrap: wrap; align-items: end; position: relative; }
.filter-bar label, .filter-bar legend { font-size: 12px; font-weight: 600; color: #314760; }
.filter-bar label, #upload-form > label { display: grid; gap: 5px; }
.date-range, .month-range-fields { display: flex; align-items: center; gap: 5px; min-width: 0; padding: 0; margin: 0; border: 0; }
.filter-bar legend { margin-bottom: 5px; padding: 0; }
.filter-bar select { width: clamp(132px, 13vw, 224px); }
select, input {
  min-height: 34px;
  padding: 5px 8px;
  background: #f7faff;
  border: 1px solid #d7e1ee;
  border-radius: 5px;
  color: #142d48;
}
.filter-bar .primary { margin-left: auto; }
.model-filter { position: relative; min-width: 0; }
.model-filter summary {
  display: grid;
  gap: 5px;
  list-style: none;
  font-size: 12px;
  font-weight: 600;
  color: #314760;
}
.model-filter summary::-webkit-details-marker { display: none; }
.model-filter-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: clamp(132px, 13vw, 224px);
  min-height: 34px;
  padding: 5px 10px;
  border: 1px solid #d7e1ee;
  border-radius: 5px;
  background: #f7faff;
  color: #142d48;
  font-weight: 400;
}
.model-filter-trigger::after {
  content: "";
  flex: 0 0 6px;
  height: 6px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
}
.model-filter[open] .model-filter-trigger { border-color: #7cabe9; }
.model-filter-value { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-filter-panel {
  position: absolute;
  z-index: 5;
  inset-block-start: calc(100% + 6px);
  inset-inline-start: 0;
  width: 256px;
  padding: 10px;
  border: 1px solid #d7e1ee;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 6px 18px #142d4826;
}
.model-filter-search { width: 100%; font-size: 16px; }
.model-filter-options {
  margin-block: 6px;
  max-height: min(220px, 38vh);
  overflow: auto;
  overscroll-behavior: contain;
}
.model-filter-options label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 400;
  overflow-wrap: anywhere;
}
.model-filter-options label:hover { background: #f1f6fc; }
.model-filter-options input { flex: none; width: 16px; height: 16px; min-height: 0; margin: 0; accent-color: #1d65da; }
.model-filter-empty { color: #405b76; font-size: 13px; padding: 7px 6px 12px; }
.model-filter-actions { display: flex; align-items: center; gap: 12px; border-top: 1px solid #e3ebf5; padding-top: 7px; }
.model-filter-clear:disabled { cursor: default; }
.report-status { color: #fff; background: #123f8e; padding: 7px 12px; border-radius: 5px; margin-bottom: 9px; font-size: 13px; }
.report-status:empty, #source-status:empty, #upload-status:empty { display: none; }
.chart-card h2 { font-size: 15px; line-height: 1.45; }
.chart { height: 256px; width: 100%; }
.month-panel { margin-bottom: 0; }
.month-panel h2 { margin-bottom: 9px; }
.month-panel .filter-bar { padding: 10px; background: #f3f7fd; border: 1px solid #e0e9f5; }
.month-panel .month-range-fields select { width: 5rem; }
.month-panel h3 { margin: 12px 0 3px; font-size: 14px; }
#month-query-status:empty { display: none; }
.annual-note { color: #405b76; font-size: 13px; line-height: 1.6; }
.chart-range {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding-inline: 56px;
  font-size: 11px;
  line-height: 1.5;
  color: #425d7b;
  font-variant-numeric: tabular-nums;
}
summary { cursor: pointer; color: #234971; }

.workspace {
  display: grid;
  grid-template-columns: minmax(170px, 225px) minmax(0, 1fr);
  min-height: calc(100vh - 56px);
}
.workspace aside { background: #fff; padding: 20px 9px; border-right: 1px solid #e0e9f2; }
.workspace aside button { width: 100%; min-height: 42px; border: 0; text-align: left; border-radius: 5px; background: transparent; color: #163451; padding: 8px 12px; }
.workspace aside button[aria-current] { color: #1c62db; background: #ecf3ff; font-weight: 650; }
.workspace-body { min-width: 0; padding: 24px clamp(12px, 2vw, 32px); background: linear-gradient(145deg, #eaf4fd, #f8fbff 260px); }
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
.section-header h1 { margin: 5px 0 0; font-size: 24px; }
.breadcrumb { color: #4c657f; font-size: 13px; }
.table-scroll { overflow: auto; }
table { border-collapse: collapse; width: 100%; margin: 10px 0; text-align: left; font-size: 14px; background: white; }
th, td { padding: 10px 12px; border-bottom: 1px solid #e3ebf5; white-space: nowrap; }
th { background: #f1f6fc; color: #334a64; }
td { font-variant-numeric: tabular-nums; }
.text-button { background: transparent; color: #1b59b8; border: 0; padding: 4px 0; }
.history { margin-top: 22px; }
#history-rows { color: #4c5f77; padding-left: 20px; }
#source-status, #upload-status { color: #2d526f; margin-top: 12px; font-size: 14px; overflow-wrap: anywhere; }

.permissions { min-height: calc(100vh - 56px); }
.permissions-intro { margin: 8px 0 20px; color: #415c76; font-size: 14px; line-height: 1.6; }
.permission-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; font-size: 14px; }
.permission-toolbar label { font-weight: 600; }
.permission-toolbar input { width: min(280px, 100%); background: #fff; }
.permission-toolbar input::placeholder { color: #526a84; }
.permission-count { color: #415c76; }
.permission-status { color: #214a6b; margin-top: 12px; font-size: 14px; }
.permission-status[data-error="true"] { color: #982a30; }
.permission-status:empty { display: none; }
.permission-table-wrap { margin-top: 12px; border: 1px solid #dce6f1; border-radius: 8px; background: #fff; }
.permission-table { margin: 0; }
.permission-table th:last-child { width: 45%; }
.permission-table tr:last-child td { border-bottom: 0; }
.permission-table td { white-space: normal; }
.permission-name, .permission-department { display: block; overflow-wrap: anywhere; }
.permission-name { font-weight: 650; }
.permission-department { margin-top: 3px; color: #415c76; font-size: 12px; }
.permission-controls { display: flex; flex-wrap: wrap; gap: 6px 10px; align-items: center; }
.permission-controls select { min-width: 106px; }
.permission-save { min-height: 34px; padding: 4px 10px; }
.permission-owner { font-weight: 650; color: #194d9a; }
.permission-empty { padding: 20px 12px; font-size: 14px; color: #415c76; }
.permissions :is(input, select, button):focus-visible { outline: 2px solid #245fc1; outline-offset: 2px; }

dialog { border: 1px solid #bccfe2; border-radius: 10px; max-width: min(530px, calc(100vw - 24px)); width: 100%; padding: 20px; color: inherit; }
dialog::backdrop { background: #11274078; }
dialog h2 { font-size: 18px; }
#close-upload { border: 0; background: #eff5fc; border-radius: 4px; padding: 6px 10px; color: #233f5b; }
#upload-form > label { margin-top: 15px; }
.dialog-actions { display: flex; justify-content: end; gap: 10px; margin-top: 18px; }

@media (max-width: 900px) {
  .model-filter { position: static; }
  .model-filter-panel { inset-inline: 10px; width: auto; }
}

@media (max-width: 660px) {
  .topbar { flex-wrap: wrap; gap: 0 12px; padding-block: 5px; }
  .topbar nav { order: 3; width: 100%; }
  .topbar nav button { padding-block: 7px; }
  .topbar .account button { padding: 7px 0 7px 4px; }
  .filter-bar { padding: 10px; }
  .filter-bar .primary { margin-left: 0; }
  .date-range { flex-basis: 100%; }
  .date-range input { min-width: 0; width: min(43%, 160px); }
  .filter-bar select, .model-filter-trigger { width: min(39vw, 210px); }
  .month-range-fields { flex-basis: 100%; }
  .month-panel .filter-bar > :is(label, .model-filter) { flex: 1 1 calc(50% - 8px); min-width: 0; }
  .month-panel .filter-bar > label select, .month-panel .model-filter-trigger { width: 100%; min-width: 0; }
  .model-filter-options label { min-height: 42px; }
  .month-panel .primary { min-height: 40px; }
  .month-panel table { font-size: 12px; }
  .month-panel :is(th, td) { padding: 8px 6px; }
  .chart-card { padding: 10px 6px; }
  .chart { height: 256px; }
  .chart-range { padding-inline: 48px; }
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .workspace aside { display: flex; flex-wrap: wrap; padding: 8px; gap: 4px; }
  .workspace aside button { width: auto; padding-inline: 8px; min-height: 36px; font-size: 12px; }
  .permission-toolbar input { width: min(188px, 62vw); }
  .permission-table th:last-child { width: 50%; }
  .permission-table th, .permission-table td { padding: 8px; }
}
