:root {
  --bg: #f2f5f9;
  --bg-alt: #e8eef6;
  --panel: #ffffff;
  --line: #dde5f0;
  --ink: #122236;
  --ink-soft: #4b5e77;
  --accent: #0b7a75;
  --accent-soft: #d7f2ef;
  --blue: #0e4f9e;
  --blue-soft: #dce9fb;
  --positive: #137a44;
  --negative: #c33333;
  --shadow: 0 18px 42px -30px rgba(12, 31, 58, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Sora", "Avenir Next", "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 0%, #d9e8ff 0%, transparent 36%),
    radial-gradient(circle at 88% 14%, #d4efe4 0%, transparent 34%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-alt) 100%);
}

.top-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 4px;
  z-index: 50;
  background: rgba(13, 79, 158, 0.12);
}

#refreshProgressBar {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, #0e4f9e 0%, #28a5a0 100%);
  transition: width 120ms linear;
}

.layout {
  width: min(1240px, 94vw);
  margin: 2rem auto 2.4rem;
}

.hero {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(239, 247, 255, 0.95));
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.8rem 1rem;
  box-shadow: var(--shadow);
  margin-bottom: 0.9rem;
}

.eyebrow {
  display: inline-block;
  margin: 0;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid #a7bddd;
  background: #eef5ff;
  letter-spacing: 0.08rem;
  font-size: 0.73rem;
  color: #284b75;
}

h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.2vw, 2.45rem);
  line-height: 1.15;
}

h2 {
  margin: 0;
  font-size: 1.15rem;
}

h3 {
  margin: 0;
  font-size: 1.05rem;
}

.subtitle {
  margin: 0;
  color: var(--ink-soft);
  font-size: 1rem;
}

.hero-meta {
  margin-top: 0.7rem;
  display: flex;
  align-items: flex-start;
  justify-content: flex-start;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.config-mini {
  margin: 0.32rem 0 0;
  color: #5e7190;
  font-size: 0.72rem;
  line-height: 1.35;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 1.05rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

form section {
  margin-bottom: 1rem;
  padding-bottom: 0.9rem;
  border-bottom: 1px dashed var(--line);
}

form section:last-of-type {
  margin-bottom: 0.55rem;
}

.manual-config > summary {
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  color: var(--ink-soft);
}

.manual-config[open] > summary {
  margin-bottom: 0.75rem;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: 0.95rem;
  color: var(--ink-soft);
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  padding: 0.62rem 0.68rem;
  border: 1px solid #c7d4e5;
  border-radius: 0.6rem;
  background: #fff;
  color: var(--ink);
  font-size: 0.98rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(18, 84, 170, 0.14);
}

.grid-two {
  margin-top: 0.7rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.72rem;
}

.help {
  margin: 0.35rem 0 0.25rem;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

.actions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.inline-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.94rem;
  color: var(--ink-soft);
}

.inline-toggle input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

button {
  border: 0;
  border-radius: 0.65rem;
  padding: 0.72rem 1.05rem;
  color: #fff;
  background: linear-gradient(125deg, var(--blue) 0%, #2870ca 100%);
  cursor: pointer;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 120ms ease, filter 120ms ease;
  touch-action: manipulation;
}

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

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

#statusText {
  margin: 0;
  font-size: 0.95rem;
  color: var(--ink-soft);
  flex: 1 1 280px;
}

.stats-grid {
  margin-top: 0.9rem;
  display: flex;
  gap: 0.72rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scrollbar-width: thin;
}

.stat-card {
  flex: 0 0 min(220px, 76vw);
  border: 1px solid var(--line);
  border-radius: 0.78rem;
  background: linear-gradient(170deg, #fff, #f6faff);
  padding: 0.78rem;
}

.stat-label {
  margin: 0;
  font-size: 0.9rem;
  color: var(--ink-soft);
}

.stat-value {
  margin: 0.35rem 0 0;
  font-size: 1.28rem;
  font-weight: 700;
}

#profitCard.positive .stat-value {
  color: var(--positive);
}

#profitCard.negative .stat-value {
  color: var(--negative);
}

.chart-grid {
  margin-top: 0.95rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.chart-card {
  border: 1px solid var(--line);
  border-radius: 0.85rem;
  padding: 0.75rem;
  background: linear-gradient(155deg, #fff, #f7faff);
}

.chart-head {
  margin-bottom: 0.45rem;
}

.chart-head p {
  margin: 0.22rem 0 0;
  color: var(--ink-soft);
  font-size: 0.92rem;
}

#spendRevenueChart,
#profitByDayChart {
  width: 100%;
  height: auto;
  border: 1px solid #e1e8f2;
  border-radius: 0.65rem;
  background: #fff;
}

.notes {
  margin-top: 0.9rem;
}

.notes p {
  margin: 0.24rem 0;
  color: var(--ink-soft);
  font-size: 0.96rem;
}

#dailySummarySection {
  margin-top: 0.85rem;
}

#dailySummarySection h3 {
  margin-bottom: 0.45rem;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 0.72rem;
  background: #fff;
}

.daily-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

.daily-table th,
.daily-table td {
  text-align: right;
  padding: 0.62rem 0.7rem;
  border-bottom: 1px solid #e6edf6;
  font-size: 0.94rem;
}

.daily-table th:first-child,
.daily-table td:first-child {
  text-align: left;
}

.daily-table tbody tr:nth-child(odd) {
  background: #fbfdff;
}

.daily-table thead th {
  position: sticky;
  top: 0;
  background: #ecf3ff;
}

.daily-table tfoot th {
  border-top: 2px solid #cad8ea;
  background: #eaf1fc;
  border-bottom: 0;
}

details {
  margin-top: 0.75rem;
}

summary {
  cursor: pointer;
  font-weight: 600;
}

pre {
  margin: 0.55rem 0 0;
  max-height: 360px;
  overflow: auto;
  padding: 0.72rem;
  border: 1px solid #d9e3f1;
  border-radius: 0.7rem;
  background: #f5f9ff;
  font-size: 0.86rem;
}

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

@media (max-width: 840px) {
  .layout {
    width: min(1240px, 95vw);
    margin-top: 1rem;
  }

  .hero {
    padding: 0.72rem 0.82rem;
  }

  .panel {
    padding: 0.92rem;
  }

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

  .actions {
    flex-direction: column;
    align-items: flex-start;
  }

  #statusText {
    flex: 1 1 auto;
    width: 100%;
  }

  button {
    width: 100%;
  }
}

@media (max-width: 680px) {
  h1 {
    font-size: 1.38rem;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  .config-mini {
    font-size: 0.68rem;
  }

  .stats-grid {
    gap: 0.6rem;
  }

  .stat-card {
    flex-basis: min(230px, 82vw);
    padding: 0.64rem;
  }

  .stat-value {
    font-size: 1.16rem;
  }

  .chart-card {
    padding: 0.58rem;
  }

  .chart-head p {
    font-size: 0.88rem;
  }

  .daily-table {
    min-width: 0;
    border-collapse: separate;
    border-spacing: 0;
  }

  .daily-table thead,
  .daily-table tfoot {
    display: none;
  }

  .daily-table tbody {
    display: grid;
    gap: 0.58rem;
    padding: 0.55rem;
  }

  .daily-table tbody tr {
    display: block;
    border: 1px solid #d9e4f2;
    border-radius: 0.62rem;
    overflow: hidden;
    background: #fff;
  }

  .daily-table tbody td {
    display: flex;
    justify-content: space-between;
    gap: 0.85rem;
    text-align: left;
    border-bottom: 1px dashed #e2eaf5;
    padding: 0.54rem 0.58rem;
    font-size: 0.91rem;
  }

  .daily-table tbody td::before {
    content: attr(data-label);
    color: #5a6f87;
    font-weight: 600;
    flex: 0 0 46%;
  }

  .daily-table tbody td:last-child {
    border-bottom: 0;
  }
}
