:root {
  color-scheme: light;
  --text: #202238;
  --muted: #65697e;
  --line: #e6e7f0;
  --primary: #5945cb;
  --primary-dark: #4834b5;
  --sidebar: #1b1b30;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: #f7f7fc;
  color: var(--text);
  font-synthesis: none;
  -webkit-font-smoothing: antialiased;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 320px; min-height: 100vh; }
button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; }
button:focus-visible, a:focus-visible, input:focus-visible {
  outline: 2px solid #7865ec;
  outline-offset: 3px;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  width: 224px;
  padding: 30px 17px 21px;
  color: #fff;
  background: var(--sidebar);
}
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 10px;
  color: inherit;
  text-decoration: none;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .03em;
}
.brand-mark {
  display: grid;
  width: 35px;
  height: 35px;
  place-items: center;
  background: #6c57e5;
  border-radius: 9px;
}
.bell {
  position: relative;
  width: 14px;
  height: 13px;
  border: 1.5px solid currentColor;
  border-radius: 7px 7px 2px 2px;
}
.bell::after {
  position: absolute;
  bottom: -5px;
  left: 4px;
  width: 4px;
  height: 2px;
  border-radius: 0 0 2px 2px;
  background: currentColor;
  content: "";
}
.navigation { margin-top: 45px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  min-height: 44px;
  padding: 9px 12px;
  color: #b8bbd2;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  font-size: 14px;
}
.nav-item:hover { color: #fff; background: #27273f; }
.nav-item[aria-current="page"] { color: #fff; background: #39305f; font-weight: 600; }
.nav-item[aria-current="page"] .nav-icon, .nav-item[aria-current="page"] .grid-icon { color: #b9aafa; }
#module-links { margin-top: 8px; display: grid; gap: 4px; }
.grid-icon {
  flex: 0 0 16px;
  height: 16px;
  background: linear-gradient(currentColor, currentColor) 0 0 / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 10px 0 / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 0 10px / 6px 6px no-repeat,
    linear-gradient(currentColor, currentColor) 10px 10px / 6px 6px no-repeat;
}
.nav-icon { flex: 0 0 16px; font-size: 19px; line-height: 1; text-align: center; }
.sidebar-exit { margin-top: auto; }
.sidebar-exit .nav-item { font-size: 13px; }
main { max-width: 1710px; margin-left: 224px; padding: 42px clamp(24px, 4vw, 60px) 46px; }
.page-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 25px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(24px, 3.3vw, 33px); line-height: 1.25; font-weight: 750; letter-spacing: -.025em; }
h2 { font-size: 17px; font-weight: 700; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 40px;
  padding: 8px 14px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.primary { color: #fff; background: var(--primary); }
.primary:hover:not(:disabled) { background: var(--primary-dark); }
.primary:disabled { color: #6a6387; background: #eeebf7; border-color: #e5dff3; }
.sync-icon { display: inline-block; font-size: 19px; line-height: 1; }
.is-syncing .sync-icon { animation: rotate .9s linear infinite; }
@keyframes rotate { to { transform: rotate(360deg); } }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 17px; }
.metric, .sources, .records { background: #fff; border: 1px solid var(--line); border-radius: 12px; }
.metric { min-height: 126px; padding: 17px 19px; }
.metric-label { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.metric-icon {
  display: grid;
  flex: 0 0 27px;
  height: 27px;
  place-items: center;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 750;
}
.active-icon { color: #a53d29; background: #fff0eb; }
.new-icon { color: #5843b8; background: #f0ecff; }
.closed-icon { color: #216f57; background: #e7f6ef; }
.metric strong { display: block; margin-top: 12px; font-size: 33px; font-weight: 700; line-height: 1; font-variant-numeric: tabular-nums; }

.sources { margin-bottom: 19px; overflow: hidden; }
.source-row { display: flex; align-items: center; justify-content: space-between; gap: 13px; padding: 12px 17px; min-height: 54px; font-size: 13px; }
.source-row + .source-row { border-top: 1px solid var(--line); }
.source-identity, .source-info { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.source-info { justify-content: flex-end; color: var(--muted); font-size: 12px; }
.provider { color: var(--muted); }
.source-state { display: inline-flex; align-items: center; gap: 6px; border-radius: 20px; padding: 4px 8px; background: #f0eff6; color: #5b5672; }
.source-state::before { width: 6px; height: 6px; border-radius: 50%; background: currentColor; content: ""; }
.source-state[data-state="ready"] { color: #216e54; background: #e9f7ef; }
.source-state[data-state="stale"], .source-state[data-state="error"] { color: #943a23; background: #fff0e9; }
.feedback { margin: 0 0 17px; padding: 11px 14px; border-radius: 8px; background: #efecfb; color: #4c398e; font-size: 13px; }
.feedback[data-error="true"] { color: #943a23; background: #fff0e9; }

.records { overflow: hidden; }
.records-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 17px 8px; }
.search { position: relative; width: min(100%, 236px); }
.search input {
  width: 100%;
  min-height: 37px;
  padding: 7px 10px 7px 33px;
  color: var(--text);
  border: 1px solid #dedfea;
  border-radius: 7px;
  background: #fff;
  font-size: 13px;
}
.search input::placeholder { color: #6a6e83; }
.search-icon { position: absolute; left: 11px; top: 11px; width: 12px; height: 12px; border: 1.5px solid #73768b; border-radius: 50%; pointer-events: none; }
.search-icon::after { position: absolute; top: 8px; left: 8px; width: 5px; height: 1.5px; transform: rotate(45deg); background: #73768b; content: ""; }
.filters { display: flex; gap: 18px; padding: 0 17px; }
.tab { padding: 9px 1px 10px; border: 0; border-bottom: 2px solid transparent; color: var(--muted); background: transparent; font-size: 13px; }
.tab[aria-pressed="true"] { color: var(--primary-dark); border-bottom-color: var(--primary); font-weight: 700; }
.table-scroll { position: relative; overflow-x: auto; }
table { width: 100%; min-width: 655px; border-collapse: collapse; text-align: left; font-size: 13px; }
th { padding: 12px 14px; color: #5d6077; background: #f7f7fb; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 650; white-space: nowrap; }
td { padding: 11px 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
td:first-child, th:first-child { padding-left: 17px; }
td:nth-child(4), td:nth-child(5) { white-space: nowrap; font-variant-numeric: tabular-nums; }
td:last-child { width: 43px; text-align: right; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: #fbfaff; }
.sort-mark { color: #7466ad; }
.text-button { border: 0; padding: 0; background: transparent; color: var(--primary-dark); font-weight: 650; text-align: left; overflow-wrap: anywhere; }
.text-button:hover { text-decoration: underline; }
.empty { display: grid; justify-items: center; align-content: center; gap: 8px; min-height: 228px; padding: 24px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty strong { color: var(--text); font-size: 15px; }
#empty-note:empty { display: none; }
.empty-icon { display: grid; width: 51px; height: 51px; margin-bottom: 5px; place-items: center; border-radius: 15px; background: #f0edfb; color: #7764c8; }
.empty-lines { display: block; position: relative; width: 19px; height: 22px; border: 1.5px solid currentColor; border-radius: 4px; }
.empty-lines::after { position: absolute; top: 5px; left: 4px; width: 8px; height: 1.5px; background: currentColor; box-shadow: 0 4px currentColor, 0 8px currentColor; content: ""; }
.records-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 49px; padding: 8px 17px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px; }
.pagination { display: flex; align-items: center; gap: 8px; }
.icon-button { display: inline-grid; place-items: center; width: 28px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 6px; color: var(--primary-dark); background: #fff; font-size: 20px; line-height: 1; }
.icon-button:hover:not(:disabled) { background: #f2effc; }
.icon-button:disabled { color: #858598; background: #f8f8fb; }

dialog { width: min(460px, calc(100vw - 32px)); max-height: calc(100vh - 36px); padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--text); background: #fff; box-shadow: 0 18px 65px #19163340; }
dialog::backdrop { background: #1b1b305f; }
.dialog-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 21px 22px 16px; border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin-top: 6px; overflow-wrap: anywhere; font-size: 22px; }
.detail-source { color: var(--primary-dark); font-size: 12px; }
dl { margin: 0; padding: 9px 22px 20px; }
.detail-row { display: flex; justify-content: space-between; align-items: baseline; gap: 15px; padding: 10px 0; font-size: 13px; }
.detail-row + .detail-row { border-top: 1px solid #f0f0f5; }
dt { color: var(--muted); }
dd { margin: 0; text-align: right; overflow-wrap: anywhere; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.login-page {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: 20px;
  background: radial-gradient(ellipse at 50% 30%, #efecfb, #f7f7fc 65%);
}
.login-card {
  width: min(100%, 390px);
  margin: 0;
  padding: clamp(24px, 7vw, 34px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fff;
  box-shadow: 0 16px 44px #2420440a;
}
.login-brand { display: flex; align-items: center; gap: 11px; font-size: 15px; font-weight: 700; }
.login-brand .brand-mark { color: #fff; }
.login-card h1 { margin: 22px 0 16px; font-size: 27px; }
.login-form, .login-setup { display: grid; gap: 14px; }
.login-form label { display: grid; gap: 6px; font-size: 13px; font-weight: 600; }
.login-form input {
  width: 100%;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid #dedfea;
  border-radius: 7px;
  color: var(--text);
  background: #fff;
  font-size: 16px;
}
.login-form button { margin-top: 3px; }
.login-setup p { color: var(--muted); font-size: 14px; line-height: 1.65; }
.login-setup a { justify-self: start; text-decoration: none; }
.login-error {
  margin-bottom: 14px;
  padding: 8px 10px;
  border-radius: 6px;
  color: #943a23;
  background: #fff0e9;
  font-size: 13px;
}

@media (max-width: 760px) {
  .sidebar { position: relative; width: auto; padding: 13px 16px 9px; }
  .brand { padding: 0; }
  .brand-mark { width: 30px; height: 30px; }
  .navigation, #module-links { display: flex; flex-wrap: wrap; gap: 5px; }
  .navigation { margin-top: 9px; }
  #module-links { margin-top: 0; }
  .nav-item { min-height: 36px; width: auto; padding: 7px 9px; font-size: 13px; }
  .sidebar-exit { position: absolute; top: 9px; right: 14px; }
  main:not(.login-card) { margin-left: 0; padding: 23px 16px; }
}

@media (max-width: 460px) {
  .page-header { margin-bottom: 17px; }
  .metrics { gap: 7px; }
  .metric { min-height: 91px; padding: 9px 8px; }
  .metric-label { gap: 4px; font-size: 10px; }
  .metric-icon { flex-basis: 17px; height: 17px; border-radius: 4px; font-size: 11px; }
  .metric strong { font-size: 26px; }
  .source-row { align-items: flex-start; flex-direction: column; gap: 7px; }
  .source-info { justify-content: flex-start; }
  .records-header { padding-inline: 12px; }
  .records-header h2 { white-space: nowrap; }
  .search { max-width: 180px; }
}

@media (prefers-reduced-motion: reduce) {
  .is-syncing .sync-icon { animation: none; }
}
