:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-2: #263449;
  --border: #334155;
  --text: #f1f5f9;
  --text-dim: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --green-dim: #14532d;
  --red: #ef4444;
  --red-dim: #450a0a;
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

button, input, select {
  font-family: inherit;
  color: inherit;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(14px + var(--safe-top)) 18px 14px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.app-header__title {
  font-weight: 700;
  font-size: 1.05rem;
}

.app-header__date {
  color: var(--text-dim);
  font-size: 0.85rem;
}

.view-root {
  flex: 1;
  padding: 16px 16px calc(96px + var(--safe-bottom));
  max-width: 640px;
  width: 100%;
  margin: 0 auto;
}

.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
  z-index: 20;
}

.bottom-nav__btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 4px;
  background: none;
  border: none;
  font-size: 0.72rem;
  color: var(--text-dim);
  cursor: pointer;
}

.bottom-nav__icon {
  font-size: 1.25rem;
  line-height: 1;
}

.bottom-nav__btn.active {
  color: var(--accent);
}

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

.card h2 {
  margin: 0 0 12px;
  font-size: 1rem;
  font-weight: 600;
}

.card h3 {
  margin: 0 0 8px;
  font-size: 0.9rem;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.checklist {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s, border-color 0.15s;
}

.check-row.done {
  background: var(--green-dim);
  border-color: var(--green);
}

.check-row.locked {
  cursor: default;
  opacity: 0.85;
}

.tick {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--red-dim);
  border: 2px solid var(--red);
  color: var(--red);
  font-weight: 700;
  font-size: 0.85rem;
}

.tick.done {
  background: var(--green);
  border-color: var(--green);
  color: #06280f;
}

.check-row__label {
  flex: 1;
  font-size: 0.95rem;
}

.check-row__sub {
  font-size: 0.78rem;
  color: var(--text-dim);
}

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

.counter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.counter__btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

.counter__value {
  min-width: 2.4ch;
  text-align: center;
  font-size: 1.15rem;
  font-weight: 700;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  border: none;
  background: var(--accent);
  color: #04202b;
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  width: 100%;
}

.btn.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn.danger {
  background: var(--red-dim);
  color: var(--red);
  border: 1px solid var(--red);
}

.btn.small {
  width: auto;
  padding: 8px 14px;
  font-size: 0.85rem;
}

.agent-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 10px;
  background: var(--surface-2);
  margin-bottom: 8px;
}

.agent-row__info { flex: 1; min-width: 0; }

.agent-row__name {
  font-weight: 600;
  font-size: 0.95rem;
}

.agent-row__channel {
  font-size: 0.78rem;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field label {
  font-size: 0.82rem;
  color: var(--text-dim);
}

.field input, .field select {
  padding: 11px 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 0.95rem;
}

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

.stat-tile {
  background: var(--surface-2);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}

.stat-tile__value {
  font-size: 1.4rem;
  font-weight: 700;
}

.stat-tile__label {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 2px;
}

.progress-bar {
  height: 10px;
  border-radius: 6px;
  background: var(--surface-2);
  overflow: hidden;
  margin-top: 8px;
}

.progress-bar__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.progress-bar__fill.complete {
  background: var(--green);
}

.mix-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 0.85rem;
}

.mix-row__label {
  width: 42%;
  flex-shrink: 0;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mix-row__bar-wrap {
  flex: 1;
  background: var(--surface-2);
  border-radius: 6px;
  overflow: hidden;
  height: 16px;
}

.mix-row__bar {
  height: 100%;
  background: var(--accent);
  border-radius: 6px;
}

.mix-row__count {
  min-width: 2ch;
  text-align: right;
}

.empty-state {
  color: var(--text-dim);
  font-size: 0.88rem;
  text-align: center;
  padding: 18px 8px;
}

.streak-hero {
  display: flex;
  align-items: baseline;
  gap: 8px;
  justify-content: center;
  margin-bottom: 6px;
}

.streak-hero__num {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--green);
}

.streak-hero__unit {
  color: var(--text-dim);
  font-size: 0.95rem;
}

.heat-row {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.heat-cell {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--red-dim);
  border: 1px solid var(--red);
}

.heat-cell.done {
  background: var(--green);
  border-color: var(--green);
}

.heat-cell.future {
  background: transparent;
  border: 1px dashed var(--border);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(88px + var(--safe-bottom));
  transform: translate(-50%, 20px);
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 30;
  max-width: 90%;
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.tab-row {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
  overflow-x: auto;
}

.tab-row__btn {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
  font-size: 0.82rem;
  cursor: pointer;
}

.tab-row__btn.active {
  background: var(--accent);
  color: #04202b;
  border-color: var(--accent);
  font-weight: 600;
}

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

.text-dim { color: var(--text-dim); }

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

@media (min-width: 640px) {
  .view-root { padding-top: 22px; }
}
