* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f6fb;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: #ffffff;
  --text: #0f172a;
  --muted: #64748b;
  --border: rgba(148, 163, 184, 0.22);
  --primary: #2563eb;
  --primary-soft: rgba(37, 99, 235, 0.12);
  --secondary: #e2e8f0;
  --success: #16a34a;
  --danger: #dc2626;
  --shadow: 0 18px 40px rgba(15, 23, 42, 0.08);
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, 0.14), transparent 22%),
    linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
  color: var(--text);
}

[hidden] {
  display: none !important;
}

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

a {
  color: inherit;
  text-decoration: none;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card,
.panel,
.quick-card {
  background: var(--panel);
  backdrop-filter: blur(14px);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 255, 255, 0.7);
}

.login-card {
  width: 100%;
  max-width: 460px;
  padding: 36px 32px 32px;
}

.stack-gap {
  display: grid;
  gap: 16px;
}

.login-hero {
  text-align: center;
  display: grid;
  gap: 8px;
}

.login-hero h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: -0.03em;
}

.login-subtitle {
  margin: 0;
  font-size: 14px;
}

label span {
  display: block;
  font-size: 14px;
  margin-bottom: 8px;
  color: #475569;
}

input,
select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid #d6dfeb;
  border-radius: 12px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.95);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.password-field {
  position: relative;
}

.password-field input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 10px;
  background: transparent;
  color: #64748b;
  box-shadow: none;
}

.password-toggle:hover {
  background: rgba(148, 163, 184, 0.12);
  transform: translateY(-50%);
}

.compact-field span {
  display: block;
  font-size: 13px;
  margin-bottom: 6px;
}

.small-text {
  font-size: 12px;
  line-height: 1.5;
}

.field-hint {
  margin: 6px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}

input:focus,
select:focus {
  outline: none;
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.14);
  border-color: var(--primary);
}

.layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
}

.sidebar {
  background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
  color: #f8fafc;
  padding: 28px 22px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.2px;
}

.nav-menu {
  display: grid;
  gap: 10px;
}

.nav-item {
  padding: 13px 14px;
  border-radius: 14px;
  color: #cbd5e1;
  transition: all 0.18s ease;
}

.nav-item.active,
.nav-item:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  transform: translateX(2px);
}

.main-content {
  padding: 28px;
}

.panel {
  padding: 24px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.page-stack {
  display: grid;
  gap: 24px;
}

.sidebar-card {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  padding: 16px;
}

.sidebar-card h3,
.quick-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.stats-grid,
.quick-grid,
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.compact-summary-card {
  padding: 18px 20px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  min-width: 0;
}

.summary-label {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.summary-value {
  display: block;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  min-width: 0;
  overflow-wrap: anywhere;
}

.quick-card {
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.quick-card::after {
  content: "";
  position: absolute;
  inset: auto -30px -40px auto;
  width: 120px;
  height: 120px;
  border-radius: 999px;
  background: radial-gradient(circle, rgba(37, 99, 235, 0.16), transparent 70%);
}

.stat-value {
  margin: 0;
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

button {
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, opacity 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}

.primary-btn {
  background: linear-gradient(135deg, #2563eb 0%, #3b82f6 100%);
  color: #ffffff;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
}

.secondary-btn {
  background: #e5e7eb;
  color: #111827;
}

.muted {
  color: var(--muted);
}

.sidebar .muted,
.sidebar-card .muted {
  color: #cbd5e1;
}

.error-text,
.error-banner {
  color: #b91c1c;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 12px;
  padding: 12px 14px;
}

.success-text {
  color: #166534;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: 12px;
  padding: 12px 14px;
}

.warning-banner {
  color: #92400e;
  background: #fffbeb;
  border: 1px solid #fcd34d;
  border-radius: 12px;
  padding: 12px 14px;
}

.info-banner {
  color: #1d4ed8;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 12px;
  padding: 12px 14px;
}

.info-banner p {
  margin: 8px 0 0;
}

.hint-list {
  margin: 0;
  padding-left: 18px;
  color: #4b5563;
  display: grid;
  gap: 8px;
}

.captcha-row {
  display: grid;
  grid-template-columns: 1fr 120px auto;
  gap: 12px;
  align-items: end;
}

.captcha-image {
  width: 120px;
  height: 42px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: #ffffff;
}

.table-wrap {
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.7);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: transparent;
}

th,
td {
  padding: 13px 14px;
  border-bottom: 1px solid rgba(226, 232, 240, 0.9);
  text-align: left;
  white-space: nowrap;
}

thead th {
  background: rgba(248, 250, 252, 0.96);
  font-weight: 700;
  color: #334155;
}

tbody tr:hover {
  background: rgba(37, 99, 235, 0.035);
}

.empty-cell {
  text-align: center;
  color: #6b7280;
}

.filter-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto auto;
  gap: 12px;
  align-items: end;
}

.filter-panel {
  padding: 16px 18px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(248, 250, 252, 0.96) 0%, rgba(241, 245, 249, 0.92) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.filter-field span {
  display: block;
  font-size: 13px;
  color: #4b5563;
  margin-bottom: 6px;
}

.filter-field input {
  width: 100%;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.summary-text {
  font-size: 13px;
  color: #64748b;
  min-height: 18px;
}

.nested-panel {
  box-shadow: none;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.72);
}

.overview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.kv-list {
  display: grid;
  gap: 10px;
}

.kv-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #f8fafc;
}

.kv-key {
  color: #64748b;
  font-size: 13px;
}

.kv-value {
  text-align: right;
}

.compact-filter-bar {
  grid-template-columns: 220px 220px auto;
}

.operation-filter-bar {
  grid-template-columns: 180px 180px minmax(180px, 240px) auto;
}

.user-filter-bar {
  grid-template-columns: 220px 180px auto;
}

.operation-filter-bar .filter-field:last-of-type input {
  max-width: 240px;
}

.chart-section {
  display: grid;
  gap: 14px;
}

.chart-card {
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.92) 0%, rgba(248,250,252,0.92) 100%);
  padding: 14px;
}

.chart-svg {
  width: 100%;
  height: auto;
  display: block;
}

.chart-grid-line {
  stroke: rgba(148, 163, 184, 0.28);
  stroke-dasharray: 4 4;
}

.chart-axis-line {
  stroke: rgba(100, 116, 139, 0.4);
}

.chart-axis-text {
  fill: #64748b;
  font-size: 11px;
}

.chart-axis-left {
  text-anchor: end;
}

.chart-axis-bottom {
  text-anchor: middle;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  padding-top: 10px;
}

.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #475569;
  font-size: 13px;
}

.chart-legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
}

.chart-empty {
  border: 1px dashed rgba(148, 163, 184, 0.45);
  border-radius: 16px;
  padding: 36px 16px;
  text-align: center;
  color: #64748b;
  background: rgba(248, 250, 252, 0.7);
}

.bar-chart-list {
  display: grid;
  gap: 12px;
}

.bar-row {
  display: grid;
  gap: 8px;
}

.bar-row-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
}

.hero-banner {
  display: grid;
  grid-template-columns: 1.3fr 0.7fr;
  gap: 16px;
  padding: 22px;
  border-radius: 24px;
  background: linear-gradient(135deg, #0f172a 0%, #1d4ed8 55%, #60a5fa 100%);
  color: #eff6ff;
}

.hero-banner .muted {
  color: rgba(239, 246, 255, 0.82);
}

.hero-metrics {
  display: grid;
  gap: 12px;
}

.hero-metric {
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.14);
}

.hero-metric strong {
  display: block;
  font-size: 24px;
  margin-top: 6px;
}

.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.log-env {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 12px;
  color: #475569;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

.operation-log-table th,
.operation-log-table td {
  max-width: 160px;
}

.log-detail {
  position: relative;
  display: inline-flex;
  align-items: center;
  max-width: 100%;
}

.log-ellipsis {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-popover {
  position: absolute;
  left: 0;
  top: calc(100% + 8px);
  z-index: 20;
  min-width: 220px;
  max-width: 420px;
  padding: 10px 12px;
  border-radius: 12px;
  background: #0f172a;
  color: #f8fafc;
  box-shadow: 0 16px 40px rgba(15, 23, 42, 0.24);
  line-height: 1.5;
  white-space: normal;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease;
}

.log-detail:hover .log-popover {
  opacity: 1;
  transform: translateY(0);
}

.log-detail-link .log-ellipsis {
  color: #2563eb;
  font-weight: 600;
}

.log-time {
  color: #475569;
  font-variant-numeric: tabular-nums;
}

.log-result {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 52px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
}

.log-result.success {
  color: #166534;
  background: #dcfce7;
}

.log-result.fail {
  color: #b91c1c;
  background: #fee2e2;
}

.operation-log-table tbody tr {
  height: 54px;
}

.operation-log-table td {
  vertical-align: middle;
}

.activity-report-table .activity-group-head {
  text-align: center;
  font-size: 14px;
}

.activity-report-table .count-group-head {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
}

.activity-report-table .duration-group-head {
  background: rgba(124, 58, 237, 0.12);
  color: #6d28d9;
}

.activity-report-table .count-sub-head {
  background: rgba(219, 234, 254, 0.78);
}

.activity-report-table .duration-sub-head {
  background: rgba(237, 233, 254, 0.85);
}

.split-activity-table td:not(:first-child) {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.split-activity-table .count-sub-head {
  color: #1d4ed8;
}

.split-activity-table .duration-sub-head {
  color: #6d28d9;
}

.activity-key-bucket-head {
  position: relative;
  box-shadow: inset 0 -2px 0 rgba(37, 99, 235, 0.18);
}

.activity-key-bucket-cell {
  background: rgba(248, 250, 252, 0.92);
  font-weight: 600;
  color: #0f172a;
}

.activity-date-cell {
  font-weight: 600;
  color: #334155;
  background: #ffffff !important;
}

.retention-single-value-table td:not(:first-child) {
  min-width: 90px;
  white-space: nowrap;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.retention-single-value-table td:first-child,
.retention-single-value-table th:first-child {
  position: sticky;
  left: 0;
  background: #fff;
  z-index: 1;
}

.retention-date-cell {
  font-weight: 600;
  color: #334155;
  background: #fff !important;
}

.retention-key-head {
  color: #1d4ed8;
  background: rgba(37, 99, 235, 0.08);
}

.retention-cell {
  border-radius: 10px;
  border: 1px solid rgba(148, 163, 184, 0.18);
}


.retention-cell-keyday {
  box-shadow: inset 0 0 0 1px rgba(30, 64, 175, 0.10);
}

.retention-rate {
  font-size: 13px;
  font-weight: 700;
  color: #0f172a;
}

.retention-count {
  margin-top: 2px;
  font-size: 11px;
  color: #475569;
}

.table-pagination {
  display: flex;
  justify-content: flex-end;
}

.pagination-inner {
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.38);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}

.modal-card {
  width: 100%;
  max-width: 420px;
  padding: 24px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
}

.sidebar > .secondary-btn {
  width: 100%;
}

@media (max-width: 1100px) {
  .overview-grid,
  .stats-grid,
  .quick-grid,
  .hero-banner {
    grid-template-columns: 1fr;
  }

  .summary-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 960px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    gap: 16px;
  }

  .main-content,
  .panel,
  .login-card {
    padding: 16px;
  }

  .panel-header,
  .captcha-row,
  .stats-grid,
  .quick-grid,
  .overview-grid,
  .hero-banner {
    grid-template-columns: 1fr;
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-bar {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 640px) {
  .filter-bar,
  .compact-filter-bar,
  .operation-filter-bar {
    grid-template-columns: 1fr;
  }

  .button-row {
    width: 100%;
  }

  .button-row .primary-btn,
  .button-row .secondary-btn {
    flex: 1 1 auto;
  }

  .summary-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .compact-summary-card {
    padding: 16px;
  }

  .summary-label {
    font-size: 12px;
    margin-bottom: 6px;
  }

  .summary-value {
    font-size: clamp(22px, 7vw, 28px);
  }
}
