@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

:root {
  --bg: #020304;
  --bg-soft: rgba(7, 10, 12, 0.92);
  --panel: rgba(11, 14, 18, 0.9);
  --panel-strong: rgba(5, 7, 9, 0.97);
  --line: rgba(109, 241, 222, 0.14);
  --text: #eef7f6;
  --muted: #88a0a4;
  --accent: #6df1de;
  --accent-soft: rgba(109, 241, 222, 0.12);
  --warn: #ffd27a;
  --danger: #ff8d92;
  --success: #8ff0ab;
  --shadow: 0 30px 90px rgba(0, 0, 0, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top left, rgba(109, 241, 222, 0.09), transparent 28%),
    radial-gradient(circle at top right, rgba(109, 241, 222, 0.05), transparent 22%),
    radial-gradient(circle at bottom, rgba(12, 24, 26, 0.24), transparent 35%),
    linear-gradient(180deg, #060708 0%, #020304 100%);
  color: var(--text);
}

body {
  font-family: "Space Grotesk", "Noto Sans SC", sans-serif;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.018) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(180deg, rgba(255,255,255,0.14), transparent 82%);
}

.app-shell {
  width: min(1080px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 48px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 2px 12px;
  animation: rise-in 420ms ease;
}

.topbar-row {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.view-switch {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
}

.view-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.88rem;
  transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.view-link:hover {
  color: var(--text);
  transform: translateY(-1px);
}

.view-link.active {
  color: #021010;
  background: linear-gradient(90deg, #6df1de, #8df7e9);
  box-shadow: 0 10px 24px rgba(109, 241, 222, 0.18);
}

.panel-kicker {
  margin: 0 0 8px;
  font-size: 12px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.meta-pill,
.status-pill,
.tiny-note,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.022);
  color: var(--text);
  font-size: 0.85rem;
}

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

.workspace {
  display: grid;
  gap: 14px;
  margin-top: 18px;
}

.panel {
  position: relative;
  overflow: hidden;
  background: linear-gradient(180deg, var(--panel) 0%, var(--panel-strong) 100%);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: rise-in 640ms ease both;
}

.panel::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(109, 241, 222, 0.12), transparent);
}

.control-panel,
.scheduler-panel,
.summary-panel,
.accounts-panel,
.logs-panel,
.stats-breakdown-panel,
.stats-detail-panel,
.stats-trend-panel,
.stats-errors-panel,
.stats-accounts-panel,
.stats-hero-panel,
.stats-logs-panel,
.history-hero-panel,
.history-list-panel {
  padding: 18px;
}

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

.panel-head h2 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.05;
}

.status-pill.idle {
  color: var(--muted);
}

.status-pill.running {
  color: var(--accent);
  background: rgba(109, 241, 222, 0.08);
  box-shadow: 0 0 0 1px rgba(109, 241, 222, 0.14), 0 0 18px rgba(109, 241, 222, 0.12);
}

.status-pill.finished {
  color: var(--success);
}

.status-pill.stopping,
.status-pill.stopped {
  color: var(--warn);
}

.status-pill.error {
  color: var(--danger);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field,
.toggle-stack {
  grid-column: span 2;
}

.field.half {
  grid-column: span 1;
}

.field span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.9rem;
}

.field input,
.field select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.025);
  color: var(--text);
  padding: 13px 14px;
  font: inherit;
  outline: none;
  transition: border-color 160ms ease, transform 160ms ease, background 160ms ease;
}

.field input:focus,
.field select:focus {
  border-color: rgba(109, 241, 222, 0.45);
  background: rgba(109, 241, 222, 0.06);
  transform: translateY(-1px);
}

.toggle-stack {
  display: grid;
  gap: 10px;
  padding: 8px 0 4px;
}

.scheduler-toggle-stack {
  align-content: start;
}

.scheduler-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-size: 0.94rem;
}

.toggle input {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.action-row {
  grid-column: span 2;
  display: grid;
  gap: 10px;
  margin-top: 6px;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

#start-button,
#scheduler-save-button {
  appearance: none;
  border: none;
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  color: #031016;
  background: linear-gradient(90deg, #6df1de, #92f7eb);
  box-shadow: 0 14px 38px rgba(109, 241, 222, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

#start-button:hover,
#scheduler-save-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 42px rgba(109, 241, 222, 0.28);
}

#start-button:disabled,
#scheduler-save-button:disabled {
  opacity: 0.46;
  transform: none;
  box-shadow: none;
}

.secondary-button {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 14px 18px;
  font: inherit;
  font-weight: 700;
  color: var(--text);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.secondary-button:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.22);
}

.secondary-button:disabled {
  opacity: 0.42;
  transform: none;
}

.submit-hint,
.run-message {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

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

.metric {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.045);
}

.metric span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.metric strong {
  font-size: 1.25rem;
}

.progress-rail {
  position: relative;
  width: 100%;
  height: 12px;
  margin: 16px 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  overflow: hidden;
}

.progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #54e0d1, #86eee0);
  box-shadow: 0 0 24px rgba(109, 241, 222, 0.22);
  transition: width 300ms ease;
}

.accounts-list,
.logs-list {
  display: grid;
  gap: 10px;
}

.account-row,
.log-row {
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.045);
}

.scheduler-meta-grid {
  grid-column: span 2;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.scheduler-meta-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.scheduler-log-wrap {
  margin-top: 18px;
}

.panel-head.compact {
  margin-bottom: 12px;
}

.account-row {
  display: grid;
  gap: 6px;
}

.account-topline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.92rem;
}

.account-id {
  color: var(--accent);
  font-weight: 700;
}

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

.state-running,
.state-oauth,
.state-token {
  color: var(--accent);
}

.state-waiting,
.state-preparing {
  color: var(--warn);
}

.state-stopped {
  color: var(--warn);
}

.state-success,
.state-finished {
  color: var(--success);
}

.state-fail,
.state-error {
  color: var(--danger);
}

.account-detail {
  color: var(--muted);
  font-size: 0.88rem;
}

.account-time {
  color: rgba(212, 226, 248, 0.68);
  font-size: 0.8rem;
}

.log-row {
  font-family: "Noto Sans SC", sans-serif;
  color: #d9e5fb;
  font-size: 0.9rem;
  line-height: 1.5;
}

.stats-workspace {
  grid-template-columns: 1fr;
}

.history-workspace {
  grid-template-columns: 1fr;
}

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

.metric small {
  display: block;
  margin-top: 6px;
  color: rgba(212, 226, 248, 0.68);
  font-size: 0.8rem;
}

.metric.spotlight {
  background:
    radial-gradient(circle at top left, rgba(109, 241, 222, 0.1), transparent 54%),
    rgba(255, 255, 255, 0.03);
}

.breakdown-list,
.stats-grid {
  display: grid;
  gap: 10px;
}

.breakdown-row,
.stat-block {
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.045);
}

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

.breakdown-label {
  font-size: 0.92rem;
  font-weight: 700;
}

.breakdown-bar {
  position: relative;
  height: 10px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.06);
}

.breakdown-fill {
  height: 100%;
  border-radius: inherit;
  min-width: 10px;
}

.breakdown-foot {
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.tone-success {
  color: var(--success);
}

.breakdown-fill.tone-success {
  background: linear-gradient(90deg, rgba(143, 240, 171, 0.95), rgba(77, 228, 207, 0.85));
}

.tone-danger {
  color: var(--danger);
}

.breakdown-fill.tone-danger {
  background: linear-gradient(90deg, rgba(255, 141, 146, 0.95), rgba(255, 196, 138, 0.85));
}

.tone-warn {
  color: var(--warn);
}

.breakdown-fill.tone-warn {
  background: linear-gradient(90deg, rgba(255, 210, 122, 0.95), rgba(255, 170, 122, 0.82));
}

.tone-accent {
  color: var(--accent);
}

.breakdown-fill.tone-accent {
  background: linear-gradient(90deg, rgba(77, 228, 207, 0.95), rgba(136, 213, 255, 0.85));
}

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

.breakdown-fill.tone-muted {
  background: linear-gradient(90deg, rgba(155, 176, 202, 0.85), rgba(91, 109, 134, 0.75));
}

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

.stat-block span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.84rem;
}

.stat-block strong {
  font-size: 1.05rem;
  line-height: 1.2;
}

.trend-shell {
  display: grid;
  gap: 12px;
}

.trend-chart {
  min-height: 180px;
  border-radius: 20px;
  padding: 10px;
  background:
    radial-gradient(circle at top left, rgba(109, 241, 222, 0.07), transparent 52%),
    rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.045);
}

.trend-svg {
  width: 100%;
  height: 160px;
  display: block;
}

.trend-grid line {
  stroke: rgba(255, 255, 255, 0.12);
  stroke-width: 0.8;
  stroke-dasharray: 2 3;
}

.trend-line {
  fill: none;
  stroke-width: 2.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.trend-line.done {
  stroke: #65ecd8;
  filter: drop-shadow(0 0 8px rgba(77, 228, 207, 0.32));
}

.trend-line.fail {
  stroke: #ff9aa0;
  filter: drop-shadow(0 0 8px rgba(255, 141, 146, 0.2));
}

.trend-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.legend-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.022);
}

.legend-chip.accent {
  color: var(--accent);
}

.legend-chip.danger {
  color: var(--danger);
}

.trend-empty {
  min-height: 160px;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.92rem;
  text-align: center;
  line-height: 1.5;
}

.ghost-button {
  cursor: pointer;
  background: rgba(255,255,255,0.016);
}

.ghost-button:hover {
  border-color: rgba(77, 228, 207, 0.35);
}

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

.history-list {
  display: grid;
  gap: 14px;
}

.history-card {
  display: grid;
  gap: 14px;
  padding: 16px;
  border-radius: 22px;
  background:
    radial-gradient(circle at top left, rgba(109, 241, 222, 0.06), transparent 42%),
    rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.history-card-head,
.history-card-title,
.history-card-subtitle,
.history-card-meta,
.history-chip-list,
.history-columns,
.history-log-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.history-card-head {
  justify-content: space-between;
  align-items: flex-start;
}

.history-card-title {
  align-items: center;
}

.history-card-subtitle,
.history-card-meta {
  color: var(--muted);
  font-size: 0.86rem;
}

.history-card-subtitle span,
.history-card-meta span {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.04);
}

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

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

.history-section {
  display: grid;
  gap: 10px;
}

.history-section h3 {
  margin: 0;
  font-size: 0.96rem;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.022);
  font-size: 0.82rem;
}

.history-empty-note {
  color: var(--muted);
  font-size: 0.88rem;
}

.history-log-list {
  display: grid;
  gap: 8px;
}

.history-log-line {
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.022);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: #d9e5fb;
  font-size: 0.88rem;
  line-height: 1.45;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (min-width: 860px) {
  .workspace {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: start;
  }

  .stats-workspace {
    grid-template-columns: 1.08fr 0.92fr;
    align-items: start;
  }

  .history-workspace {
    grid-template-columns: 1fr;
  }

  .control-panel {
    grid-column: 1;
  }

  .scheduler-panel {
    grid-column: 1;
  }

  .summary-panel {
    grid-column: 2;
  }

  .accounts-panel {
    grid-column: 2;
  }

  .logs-panel {
    grid-column: 1 / -1;
  }

  .stats-hero-panel {
    grid-column: 1 / -1;
  }

  .stats-breakdown-panel {
    grid-column: 1;
  }

  .stats-trend-panel {
    grid-column: 2;
  }

  .stats-detail-panel {
    grid-column: 1;
  }

  .stats-errors-panel {
    grid-column: 2;
  }

  .stats-accounts-panel {
    grid-column: 1;
  }

  .stats-logs-panel {
    grid-column: 2;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 16px, 100%);
    padding-top: 10px;
  }

  .topbar {
    padding: 2px 0 10px;
  }

  .control-panel,
  .scheduler-panel,
  .summary-panel,
  .accounts-panel,
  .logs-panel,
  .stats-breakdown-panel,
  .stats-detail-panel,
  .stats-trend-panel,
  .stats-errors-panel,
  .stats-accounts-panel,
  .stats-hero-panel,
  .stats-logs-panel,
  .history-hero-panel,
  .history-list-panel {
    padding: 14px;
    border-radius: 20px;
  }

  .control-grid {
    grid-template-columns: 1fr;
  }

  .field,
  .field.half,
  .toggle-stack,
  .action-row,
  .scheduler-meta-grid {
    grid-column: span 1;
  }

  .button-row,
  .metrics,
  .scheduler-meta-grid,
  .stats-metrics,
  .stats-grid,
  .history-metrics,
  .history-columns {
    grid-template-columns: 1fr;
  }

  .view-switch {
    width: 100%;
    justify-content: space-between;
  }

  .view-link {
    flex: 1 1 0;
  }
}
