:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --text: #1d232b;
  --text-muted: #5d6875;
  --border: #e3e6eb;
  --accent: #2f6fdf;
  --series2: #1f9d74;
  --error: #c0392b;
  --font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111418;
    --surface: #1b2027;
    --text: #e6e9ee;
    --text-muted: #9aa4b1;
    --border: #2a313a;
    --accent: #6b9bff;
    --series2: #3cc597;
    --error: #ff6b5e;
  }
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-family);
  font-size: 14px;
  line-height: 1.5;
  font-variant-numeric: tabular-nums;
  min-height: 100vh;
}

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.login-wrapper {
  width: 100%;
  max-width: 360px;
}

.login-card {
  padding: 24px;
}

.login-card h1 {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}

.login-card .field {
  margin-bottom: 16px;
}

.login-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-muted);
}

.login-card input[type="password"] {
  width: 100%;
  height: 44px;
  padding: 8px 12px;
  font-size: 15px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.error {
  color: var(--error);
  font-size: 13px;
  margin-bottom: 12px;
  text-align: center;
}

.container {
  width: 100%;
  max-width: 1100px;
  margin: 0 auto;
  padding: 12px 16px 32px;
}

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

.topbar h1 {
  font-size: 20px;
  font-weight: 700;
}

.filters-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  display: flex;
  gap: 12px;
  padding: 8px 0 12px;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.filter-group label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

select {
  height: 44px;
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
  color: var(--text);
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #ffffff;
  border: none;
}

.btn-logout {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}

#error {
  color: var(--error);
  font-size: 13px;
  margin-bottom: 12px;
  padding: 10px 12px;
  border: 1px solid var(--error);
  border-radius: 6px;
  background: rgba(192, 57, 43, 0.08);
}

#error[hidden] {
  display: none;
}

.cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}

#card-today {
  grid-column: 1 / -1;
}

.cards-grid .card {
  margin-bottom: 0;
  padding: 12px;
}

.card-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.card-stat {
  display: flex;
  flex-direction: column;
}

.views-count {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.1;
  color: var(--text);
}

.views-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 1px;
}

.visitors-count {
  display: flex;
  align-items: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}

.dot-green {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--series2);
  margin-right: 6px;
  flex-shrink: 0;
}

.time-note {
  font-size: 12px;
  color: var(--text-muted);
}

.chart-section h2,
.top-section h2,
.embed-section h2 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.chart-title-wrap {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.chart-legend {
  display: flex;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-views {
  background: var(--accent);
}

.dot-visitors {
  background: var(--series2);
}

#chart-daily {
  width: 100%;
}

#chart-daily svg {
  display: block;
}

.bar {
  fill: var(--accent);
}

.line {
  fill: none;
  stroke: var(--series2);
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.grid {
  stroke: var(--border);
  stroke-width: 1;
}

.axis-label,
.axis-num {
  font-size: 11px;
  fill: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.two-columns {
  display: flex;
  flex-direction: column;
}

@media (min-width: 720px) {
  .cards-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
  }
  #card-today {
    grid-column: auto;
  }
  .cards-grid .card {
    padding: 16px;
  }
  .views-count {
    font-size: 28px;
  }
  .two-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }
}

.rank-list {
  list-style: none;
}

.rank-list li {
  position: relative;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  border-radius: 4px;
  overflow: hidden;
  margin-bottom: 4px;
}

.rank-list li.empty {
  color: var(--text-muted);
  font-size: 13px;
  justify-content: flex-start;
}

.rank-list .bar {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  background: var(--accent);
  opacity: 0.12;
  z-index: 1;
}

.rank-list .label {
  position: relative;
  z-index: 2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 12px;
  font-size: 13px;
}

.rank-list .num {
  position: relative;
  z-index: 2;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
}

.embed-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.embed-name {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.embed-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

code.embed {
  flex: 1;
  display: block;
  padding: 8px 10px;
  font-size: 12px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: pre-wrap;
  word-break: break-all;
}

.embed-domain {
  font-weight: 400;
  color: var(--text-muted);
}

.btn-copy {
  flex-shrink: 0;
  min-height: 36px;
  padding: 0 12px;
  font-size: 12px;
}

.footer {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 16px;
}
