* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  color: #202938;
  background: #f5f7fa;
  font-family: "Microsoft YaHei", Arial, sans-serif;
}

.hidden { display: none !important; }

.login-view {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 20px;
}

.compliance-footer {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  padding: 12px 20px;
  color: #667085;
  font-size: 12px;
  line-height: 1.6;
  text-align: center;
}

.compliance-footer a { color: inherit; }

.login-card {
  width: min(380px, 100%);
  padding: 26px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 44px rgba(40, 52, 74, 0.12);
}

h1, h2, h3, p { margin: 0; }

.login-card h1 {
  font-size: 24px;
  margin-bottom: 6px;
}

.login-card p,
.panel-head p,
.topbar p {
  color: #667085;
  font-size: 13px;
}

label {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  color: #576174;
  font-size: 13px;
}

input, select, button {
  height: 34px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  padding: 0 11px;
  font: inherit;
}

input, select {
  min-width: 120px;
  color: #202938;
  background: #fff;
}

button {
  border-color: transparent;
  color: #fff;
  background: #2563eb;
  cursor: pointer;
}

button:hover { filter: brightness(0.96); }

.ghost-btn {
  color: #253044;
  background: #fff;
  border-color: #cfd8e3;
}

.form-message {
  min-height: 18px;
  margin-top: 10px;
  color: #c0362c;
  font-size: 13px;
}

.form-message.success { color: #0f6f43; }
.form-message.error { color: #a8231c; }

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 28px;
  background: #fff;
  border-bottom: 1px solid #e3e8ef;
}

.topbar h1 { font-size: 22px; }
.topbar p { margin-top: 5px; }

main {
  max-width: 1600px;
  margin: 0 auto;
  padding: 18px 28px 42px;
}

.toolbar {
  display: grid;
  grid-template-columns: auto repeat(2, minmax(142px, 0.7fr)) minmax(148px, 0.8fr) 190px minmax(140px, 0.7fr);
  gap: 10px;
  align-items: end;
  padding: 12px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.toolbar label { margin: 0; }

.toolbar select:disabled {
  color: #7b8494;
  cursor: not-allowed;
  background: #f4f6f8;
}

.dashboard-message {
  min-height: 34px;
  margin-top: 10px;
  padding: 8px 12px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: #576174;
  background: transparent;
  font-size: 13px;
}

.dashboard-message:empty {
  display: none;
}

.dashboard-message.loading {
  color: #334e7d;
  border-color: #c8d8f5;
  background: #f1f6ff;
}

.dashboard-message.success {
  color: #0f6f43;
  border-color: #bfe5d0;
  background: #eef9f3;
}

.dashboard-message.warning {
  color: #8a4b00;
  border-color: #f0d49a;
  background: #fff8e8;
}

.dashboard-message.error {
  color: #a8231c;
  border-color: #f1b9b4;
  background: #fff1ef;
}

.date-presets {
  display: inline-flex;
  height: 34px;
  padding: 3px;
  border: 1px solid #cfd8e3;
  border-radius: 6px;
  background: #f6f8fb;
}

.preset-btn {
  height: 26px;
  color: #465166;
  border: 0;
  background: transparent;
}

.preset-btn.is-active {
  color: #fff;
  background: #2563eb;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(120px, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.business-summary {
  grid-template-columns: repeat(7, minmax(130px, 1fr));
}

.summary-grid div {
  min-height: 78px;
  padding: 13px 14px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.summary-grid span {
  display: block;
  color: #667085;
  font-size: 12px;
}

.summary-grid strong {
  display: block;
  margin-top: 9px;
  font-size: 24px;
  line-height: 1;
}

.business-summary strong {
  font-size: 22px;
}

.section-grid {
  display: grid;
  grid-template-columns: minmax(420px, 0.9fr) minmax(520px, 1.1fr);
  gap: 14px;
  align-items: start;
}

.panel {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.03);
}

.section-grid .panel {
  margin-top: 0;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
}

.panel h2 { font-size: 17px; }
.panel h3 { font-size: 15px; }
.panel-head p { margin-top: 5px; }
.panel-section-title { margin-bottom: 10px; }

.dialog-body {
  padding: 18px;
}

.modal-form {
  display: grid;
  gap: 12px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  color: #667085;
  font-size: 12px;
}

.rank-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.rank-tab {
  height: 30px;
  color: #465166;
  background: #f6f8fb;
  border: 1px solid #cfd8e3;
}

.rank-tab.is-active {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

.rank-number {
  color: #667085;
  font-weight: 700;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
}

.dot.ok { background: #14804a; }
.dot.multi { background: #a15c00; }
.dot.pending { background: #c0362c; }
.dot.idle { background: #47708f; }
.dot.unchecked { background: #98a2b3; }

.calendar-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-height: 34px;
  padding: 8px 10px;
  color: #59657a;
  font-size: 12px;
  background: #f7f9fc;
  border-top: 1px solid #edf1f5;
  border-bottom: 1px solid #edf1f5;
}

.calendar-summary span {
  white-space: nowrap;
}

.calendar-summary strong {
  color: #202938;
  font-size: 13px;
}

.calendar-summary .summary-danger { color: #a8231c; }

.table-wrap { overflow: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  padding: 9px 10px;
  border-bottom: 1px solid #edf1f5;
  text-align: left;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  color: #59657a;
  background: #f7f9fc;
}

.calendar-table th:first-child,
.calendar-table td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #fff;
}

.calendar-table th:nth-child(2),
.calendar-table td:nth-child(2) {
  position: sticky;
  left: 76px;
  z-index: 2;
  background: #fff;
}

.calendar-table th:first-child,
.calendar-table th:nth-child(2) {
  background: #f7f9fc;
}

.account-cell { font-weight: 700; }

.title-cell {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-label,
.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 26px;
  padding: 0 9px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
}

.status-pill {
  cursor: default;
}

.status-pill[data-session-ids]:not([data-session-ids=""]) {
  cursor: pointer;
}

button.status-pill[data-session-ids]:not([data-session-ids=""]):hover {
  filter: brightness(0.97);
}

button.status-pill:focus-visible {
  outline: 2px solid #2563eb;
  outline-offset: 2px;
}

.status-ok {
  color: #0f6f43;
  background: #e8f5ee;
  border-color: #b8dfca;
}

.status-pending {
  color: #a8231c;
  background: #fff0ef;
  border-color: #f2c8c4;
}

.status-multi {
  color: #8a4b00;
  background: #fff4df;
  border-color: #ebd09f;
}

.status-idle {
  color: #355c78;
  background: #edf4f8;
  border-color: #c7d9e4;
}

.status-unchecked {
  color: #59657a;
  background: #f2f4f7;
  border-color: #d8dde5;
}

.link-btn {
  height: auto;
  padding: 0;
  color: #2563eb;
  background: transparent;
  border: 0;
}

.empty-state {
  display: grid;
  gap: 6px;
  place-items: center;
  min-height: 120px;
  color: #667085;
  border: 1px dashed #cfd8e3;
  border-radius: 8px;
  background: #fafbfd;
}

.empty-state strong {
  color: #344054;
  font-size: 15px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(240px, 1fr));
  gap: 16px;
}

.admin-grid form {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
}

.admin-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.admin-grid form .form-message {
  margin: 0;
}

.mini-table {
  overflow: auto;
}

.mini-table table {
  background: #fff;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.65;
}

.raw-json {
  margin-top: 14px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fbfcfe;
}

.raw-json summary {
  cursor: pointer;
  color: #445066;
  font-weight: 700;
}

dialog {
  width: min(1460px, 96vw);
  max-height: 88vh;
  border: 0;
  border-radius: 8px;
  padding: 0;
  overflow: auto;
  box-shadow: 0 24px 70px rgba(26, 35, 50, 0.28);
}

dialog::backdrop { background: rgba(17, 24, 39, 0.42); }

.dialog-head {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  background: #fff;
  border-bottom: 1px solid #e3e8ef;
}

.dialog-head h2 { font-size: 19px; }
.dialog-head p { margin-top: 5px; color: #667085; font-size: 13px; }

#detailContent {
  padding: 16px 18px 18px;
  background: #f5f7fa;
}

.session-overview,
.detail-card,
.detail-metric-panel {
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fff;
}

.session-overview {
  margin-bottom: 12px;
  padding: 18px;
}

.session-overview-head {
  padding-bottom: 16px;
  border-bottom: 1px solid #edf1f5;
}

.session-overview-title > span {
  display: block;
  margin-bottom: 6px;
  color: #e13b5a;
  font-size: 12px;
  font-weight: 700;
}

.session-overview-title h3 {
  color: #172033;
  font-size: 20px;
  line-height: 1.35;
}

.session-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 22px;
  margin-top: 10px;
  color: #344054;
  font-size: 13px;
}

.session-meta span {
  display: inline-flex;
  gap: 6px;
}

.session-meta b {
  color: #8a94a6;
  font-weight: 400;
}

.detail-metric-panels {
  display: grid;
  grid-template-columns: repeat(3, minmax(260px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.detail-metric-panel {
  padding: 16px;
  border: 0;
  border-radius: 6px;
  background: #f7f9fc;
}

.detail-panel-title,
.detail-card-head h3 {
  color: #202938;
  font-size: 15px;
  font-weight: 700;
}

.detail-panel-title {
  position: relative;
  padding-left: 11px;
}

.detail-panel-title::before {
  position: absolute;
  top: 2px;
  bottom: 2px;
  left: 0;
  width: 3px;
  border-radius: 2px;
  background: #9aa4b2;
  content: "";
}

.metric-panel-revenue .detail-panel-title::before { background: #e13b5a; }
.metric-panel-traffic .detail-panel-title::before { background: #3b82f6; }
.metric-panel-interaction .detail-panel-title::before { background: #18a66a; }

.detail-metric-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(82px, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.detail-metric-grid div {
  min-height: 62px;
  padding: 8px 4px;
}

.detail-metric-grid span,
.conversion-flow span,
.audience-facts span {
  display: block;
  color: #667085;
  font-size: 12px;
}

.detail-metric-grid strong {
  display: flex;
  align-items: baseline;
  flex-wrap: nowrap;
  gap: 3px;
  margin-top: 7px;
  color: #111827;
  font-size: 23px;
  line-height: 1;
}

.detail-metric-grid strong small {
  color: #344054;
  font-size: 12px;
  font-weight: 600;
}

.detail-two-col {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.detail-card {
  min-height: 240px;
  padding: 14px;
}

.detail-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.audience-profile {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
}

.audience-bars {
  display: grid;
  gap: 12px;
}

.audience-bar-row {
  display: grid;
  grid-template-columns: 68px 1fr 56px;
  gap: 10px;
  align-items: center;
  font-size: 12px;
}

.audience-bar-row div {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #edf1f5;
}

.audience-bar-row i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: #22c55e;
}

.audience-bar-row strong {
  color: #202938;
  font-size: 12px;
  text-align: right;
}

.audience-facts,
.conversion-flow {
  display: grid;
  gap: 10px;
}

.audience-facts div,
.conversion-flow div {
  min-height: 54px;
  padding: 10px;
  border-radius: 8px;
  background: #f7f9fc;
}

.audience-facts strong,
.conversion-flow strong {
  display: block;
  margin-top: 6px;
  color: #202938;
  font-size: 15px;
}

.conversion-flow {
  grid-template-columns: repeat(2, minmax(120px, 1fr));
}

.detail-section {
  margin-bottom: 14px;
}

.detail-section h3 {
  margin-bottom: 10px;
}

.metric-grid,
.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(160px, 1fr));
  gap: 10px;
}

.metric-grid div,
.info-grid div {
  min-height: 64px;
  padding: 10px;
  border: 1px solid #e3e8ef;
  border-radius: 8px;
  background: #fbfcfe;
}

.metric-grid span,
.info-grid span {
  display: block;
  color: #667085;
  font-size: 12px;
  margin-bottom: 7px;
}

.metric-grid strong,
.info-grid strong {
  color: #202938;
  font-size: 15px;
  word-break: break-word;
}

pre {
  max-height: 70vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

@media (max-width: 1100px) {
  .summary-grid { grid-template-columns: repeat(3, minmax(120px, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }
  .toolbar { grid-template-columns: repeat(3, minmax(160px, 1fr)); }
  .detail-two-col { grid-template-columns: 1fr; }
  .metric-grid,
  .info-grid { grid-template-columns: repeat(2, minmax(160px, 1fr)); }
}

@media (max-width: 900px) {
  .detail-metric-panels { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  main { padding: 14px; }
  .summary-grid { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .section-grid { grid-template-columns: 1fr; }
  .admin-grid,
  .audience-profile,
  .metric-grid,
  .info-grid { grid-template-columns: 1fr; }
  .conversion-flow { grid-template-columns: repeat(2, minmax(120px, 1fr)); }
  .toolbar { grid-template-columns: 1fr; }
  .toolbar > label,
  .toolbar > button,
  .date-presets { width: 100%; }
  input, select { width: 100%; }
}
