:root {
  color: #24282f;
  background: #f4f6f8;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-synthesis: none;
  letter-spacing: 0;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-width: 320px;
  margin: 0;
  background: #f4f6f8;
}

button,
input {
  font: inherit;
  letter-spacing: 0;
}

button {
  cursor: pointer;
}

button:focus-visible,
input:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(22, 93, 255, 0.22);
  outline-offset: 2px;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid #dfe3e8;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 3px 16px rgba(31, 39, 51, 0.06);
}

.header-inner,
.project-nav,
.report-inner,
.app-footer {
  width: min(1500px, calc(100% - 48px));
  margin: 0 auto;
}

.header-inner {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.brand-mark {
  width: 38px;
  height: 38px;
  flex: 0 0 38px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3px;
  padding: 8px;
  border-radius: 7px;
  background: #20252d;
}

.brand-mark i {
  width: 5px;
  border-radius: 1px 1px 0 0;
  background: #ffffff;
}

.brand-mark i:nth-child(1) { height: 9px; }
.brand-mark i:nth-child(2) { height: 16px; background: #61a5fa; }
.brand-mark i:nth-child(3) { height: 21px; background: #ffb45f; }

.brand h1 {
  margin: 0 0 3px;
  color: #20242b;
  font-size: 20px;
  line-height: 1.25;
}

.brand p {
  margin: 0;
  color: #7b838e;
  font-size: 12px;
}

.refresh-button,
.primary-button,
.secondary-button {
  height: 38px;
  border-radius: 6px;
  border: 0;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.refresh-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid #d8dde4;
  background: #ffffff;
  color: #303640;
}

.refresh-button span {
  font-size: 19px;
  line-height: 1;
}

.refresh-button:hover,
.secondary-button:hover {
  background: #f0f3f6;
}

.refresh-button:active,
.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.refresh-button[disabled],
.primary-button[disabled],
.secondary-button[disabled] {
  cursor: wait;
  opacity: 0.58;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-actions form {
  margin: 0;
}

.signed-in-user {
  max-width: 140px;
  overflow: hidden;
  color: #7b838e;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-link {
  height: 36px;
  display: inline-flex;
  align-items: center;
  border: 0;
  border-radius: 6px;
  padding: 0 10px;
  background: transparent;
  color: #505863;
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}

.header-link:hover {
  background: #f0f3f6;
  color: #20252d;
}

.logout-button {
  cursor: pointer;
}

.account-label-short {
  display: none;
}

.project-nav {
  min-height: 42px;
  display: flex;
  align-items: flex-end;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
}

.project-nav::-webkit-scrollbar {
  display: none;
}

.project-link {
  position: relative;
  height: 42px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0 14px;
  color: #69717d;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
}

.project-link::after {
  content: "";
  position: absolute;
  right: 12px;
  bottom: 0;
  left: 12px;
  height: 3px;
  border-radius: 2px 2px 0 0;
  background: transparent;
}

.project-link:hover,
.project-link.active {
  color: #20252d;
}

.project-link.active::after {
  background: #2468f2;
}

.project-link i,
.connection-badge i {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #aeb5bf;
}

.project-link.online i,
.connection-badge.online i {
  background: #159455;
}

.project-link.error i,
.connection-badge.error i {
  background: #e5484d;
}

#reports {
  display: block;
}

.report-section {
  scroll-margin-top: 118px;
  padding: 34px 0 42px;
  border-bottom: 1px solid #dfe3e8;
}

.report-section[data-theme="warm"] {
  background: #fff8f1;
}

.report-section[data-theme="cool"] {
  background: #f3f6fa;
}

.report-section[data-theme="summary"] {
  background: #f5f8f6;
}

.project-heading {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.project-identity {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 13px;
}

.project-monogram {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  border-radius: 7px;
  font-size: 15px;
  font-weight: 800;
}

[data-theme="warm"] .project-monogram {
  background: #ffe3c6;
  color: #a84f00;
}

[data-theme="cool"] .project-monogram {
  background: #dce9fb;
  color: #1856a7;
}

[data-theme="summary"] .project-monogram {
  background: #dcefe4;
  color: #176b42;
}

[data-theme="summary"] table {
  min-width: 520px;
}

[data-theme="summary"] th:first-child,
[data-theme="summary"] td:first-child {
  width: 50%;
}

.title-line {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.title-line h2 {
  margin: 0;
  color: #252a31;
  font-size: 23px;
  line-height: 1.3;
}

.project-description {
  margin: 4px 0 0;
  color: #7f8792;
  font-size: 13px;
}

.connection-badge {
  height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  padding: 0 9px;
  border: 1px solid #dce1e7;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.7);
  color: #737b86;
  font-size: 12px;
}

.connection-badge.online {
  border-color: #bfe3cf;
  color: #137b49;
}

.connection-badge.error {
  border-color: #f2c8c8;
  color: #b5363b;
}

.updated-time {
  flex: 0 0 auto;
  color: #8b929c;
  font-size: 12px;
}

.month-tools {
  min-height: 70px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid #dfe3e8;
  border-radius: 8px;
  background: #ffffff;
}

.month-tools label {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #414750;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.month-input {
  width: 152px;
  height: 38px;
  padding: 0 10px;
  border: 1px solid #d6dbe1;
  border-radius: 6px;
  background: #ffffff;
  color: #303640;
}

.primary-button {
  background: #2468f2;
  color: #ffffff;
}

[data-theme="warm"] .primary-button {
  background: #165dff;
}

.primary-button:hover {
  background: #1857d8;
}

.secondary-button {
  background: #edf0f4;
  color: #3c434d;
}

.data-panel {
  border: 1px solid #e1e5ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 5px 16px rgba(32, 39, 48, 0.04);
}

.table-panel {
  min-height: 316px;
  overflow: hidden;
}

.loading-state,
.error-state {
  min-height: 314px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 28px;
  color: #7b838e;
  text-align: center;
  font-size: 14px;
}

.error-state strong {
  color: #303640;
  font-size: 16px;
}

.error-message {
  max-width: 620px;
  color: #8a929d;
  line-height: 1.6;
}

.error-state .retry-button {
  margin-top: 4px;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #dbe1e8;
  border-top-color: #2468f2;
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.table-scroll {
  overflow-x: auto;
}

table {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  table-layout: fixed;
}

th,
td {
  height: 62px;
  padding: 12px 20px;
  border-bottom: 1px solid #edf0f3;
  text-align: center;
}

th {
  height: 54px;
  background: #f7f8fa;
  color: #616975;
  font-size: 13px;
  font-weight: 650;
}

[data-theme="warm"] th {
  background: #fff9f3;
}

th:first-child,
td:first-child {
  width: 28%;
  text-align: left;
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #fafbfd;
}

.range-name {
  display: block;
  margin-bottom: 4px;
  color: #30353d;
  font-size: 15px;
  font-weight: 750;
}

.range-date {
  display: block;
  color: #969da7;
  font-size: 12px;
}

.metric-value {
  font-size: 20px;
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.report-note {
  margin: 12px 1px 22px;
  color: #858d98;
  font-size: 12px;
  line-height: 1.6;
}

.trend-panel {
  padding: 20px;
}

.trend-header {
  min-height: 34px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 12px;
}

.trend-header h3 {
  margin: 3px 0 0;
  color: #353b44;
  font-size: 17px;
}

.trend-legend {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.legend-button {
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 0;
  padding: 3px 0;
  background: transparent;
  color: #636b76;
  font-size: 12px;
}

.legend-button i {
  width: 23px;
  height: 3px;
  border-radius: 2px;
}

.legend-button.muted {
  opacity: 0.34;
}

.chart-wrap {
  position: relative;
  width: 100%;
  height: 360px;
}

.trend-chart {
  display: block;
  width: 100%;
  height: 360px;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 156px;
  padding: 10px 12px;
  border: 1px solid #dfe3e8;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 6px 20px rgba(31, 39, 51, 0.12);
  pointer-events: none;
  color: #343a43;
  font-size: 12px;
}

.tooltip-date {
  display: block;
  margin-bottom: 7px;
  font-weight: 750;
}

.tooltip-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 5px;
}

.tooltip-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #747c87;
}

.tooltip-label i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.tooltip-value {
  font-weight: 750;
  font-variant-numeric: tabular-nums;
}

.app-footer {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: #8a929d;
  font-size: 12px;
}

.auth-page,
.settings-page {
  min-height: 100vh;
  background: #f1f4f7;
}

.auth-page {
  display: grid;
  place-items: center;
  padding: 28px 16px;
}

.auth-shell {
  width: min(100%, 420px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 24px;
}

.auth-brand h1 {
  margin: 0 0 3px;
  color: #20242b;
  font-size: 21px;
}

.auth-brand p,
.auth-heading p,
.settings-heading p {
  margin: 0;
  color: #808894;
  font-size: 13px;
}

.auth-panel,
.settings-panel {
  border: 1px solid #dfe4ea;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(31, 39, 51, 0.08);
}

.auth-panel {
  padding: 30px;
}

.auth-heading {
  margin-bottom: 24px;
}

.auth-heading h2,
.settings-heading h1 {
  margin: 0 0 6px;
  color: #252a31;
  font-size: 22px;
}

.auth-form {
  display: grid;
  gap: 17px;
}

.auth-form label {
  display: grid;
  gap: 7px;
  color: #424952;
  font-size: 13px;
  font-weight: 700;
}

.auth-form label small {
  margin-left: 5px;
  color: #959ca6;
  font-size: 11px;
  font-weight: 400;
}

.auth-form input:not([type="hidden"]) {
  width: 100%;
  height: 42px;
  border: 1px solid #d5dbe2;
  border-radius: 6px;
  padding: 0 12px;
  background: #ffffff;
  color: #272c33;
}

.auth-form input:not([type="hidden"]):focus {
  border-color: #2468f2;
  outline: 3px solid rgba(36, 104, 242, 0.13);
}

.auth-submit {
  width: 100%;
  height: 42px;
  margin-top: 3px;
}

.form-alert {
  margin-bottom: 18px;
  border: 1px solid #efc2c4;
  border-radius: 6px;
  padding: 10px 12px;
  background: #fff3f3;
  color: #b5363b;
  font-size: 13px;
  line-height: 1.5;
}

.form-alert.success {
  border-color: #bce1cb;
  background: #f0fbf5;
  color: #137b49;
}

.auth-footer {
  margin: 18px 0 0;
  color: #969da7;
  text-align: center;
  font-size: 12px;
}

.settings-header {
  border-bottom: 1px solid #dfe3e8;
  background: #ffffff;
}

.settings-header-inner {
  width: min(760px, calc(100% - 32px));
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin: 0 auto;
  color: #808894;
  font-size: 12px;
}

.back-link {
  color: #365f9c;
  text-decoration: none;
  font-size: 13px;
  font-weight: 650;
}

.settings-main {
  width: min(600px, calc(100% - 32px));
  margin: 48px auto;
}

.settings-heading {
  margin-bottom: 18px;
}

.settings-panel {
  padding: 28px;
}

.form-divider {
  height: 1px;
  margin: 2px 0;
  background: #e7ebef;
}

[hidden] {
  display: none !important;
}

@media (max-width: 760px) {
  .header-inner,
  .project-nav,
  .report-inner,
  .app-footer {
    width: min(100% - 28px, 1500px);
  }

  [data-theme="summary"] table {
    min-width: 100%;
  }

  .header-inner {
    min-height: 66px;
    gap: 12px;
  }

  .brand-mark {
    width: 32px;
    height: 32px;
    flex-basis: 32px;
    padding: 7px;
  }

  .brand h1 {
    font-size: 16px;
  }

  .brand p {
    display: none;
  }

  .brand {
    gap: 8px;
  }

  .refresh-button {
    width: 38px;
    padding: 0;
    justify-content: center;
    overflow: hidden;
    color: transparent;
  }

  .header-actions {
    gap: 2px;
  }

  .signed-in-user,
  .header-actions .logout-button {
    display: none;
  }

  .header-link {
    width: 42px;
    justify-content: center;
    padding: 0;
    color: #4e5661;
    font-size: 12px;
  }

  .account-label-long {
    display: none;
  }

  .account-label-short {
    display: inline;
  }

  .refresh-button span {
    position: absolute;
    color: #303640;
  }

  .report-section {
    scroll-margin-top: 108px;
    padding: 25px 0 32px;
  }

  .project-heading {
    align-items: flex-start;
    gap: 12px;
  }

  .project-monogram {
    width: 40px;
    height: 40px;
    flex-basis: 40px;
  }

  .title-line {
    align-items: flex-start;
    flex-direction: column;
    gap: 5px;
  }

  .title-line h2 {
    font-size: 20px;
  }

  .updated-time {
    max-width: 92px;
    text-align: right;
    line-height: 1.45;
  }

  .month-tools {
    flex-wrap: wrap;
    padding: 13px;
  }

  .month-tools label {
    width: 100%;
    justify-content: space-between;
  }

  .month-input {
    width: min(190px, 62%);
  }

  .query-button,
  .current-button {
    flex: 1;
  }

  .trend-panel {
    padding: 15px 12px 12px;
  }

  .trend-header {
    flex-direction: column;
    gap: 10px;
  }

  .trend-legend {
    justify-content: flex-start;
  }

  .chart-wrap,
  .trend-chart {
    height: 300px;
  }

  .app-footer {
    min-height: 66px;
    align-items: flex-start;
    justify-content: center;
    flex-direction: column;
    gap: 4px;
    padding: 14px 0;
  }

  .auth-panel,
  .settings-panel {
    padding: 22px;
  }

  .settings-main {
    margin-top: 30px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
