:root {
  --bg: #1a2840;
  --surface: #223355;
  --surface-2: #2a3f66;
  --surface-3: #1e2f50;
  --accent: #ff6b35;
  --accent-dim: rgba(255, 107, 53, 0.15);
  --text: #f0f4f8;
  --text-dim: #8899bb;
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --border: #2d4070;
  --radius: 12px;
  --radius-sm: 8px;
  --font: system-ui, -apple-system, "Segoe UI", sans-serif;
  --shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

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

html, body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ─── Header ─────────────────────────────────────────────────────────────── */

header {
  background: var(--surface-3);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.header-inner h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.header-inner h1 span {
  color: var(--accent);
}

#month-selector {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
}

#month-selector:focus {
  border-color: var(--accent);
}

/* ─── Main layout ────────────────────────────────────────────────────────── */

main#app {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 32px;
}

section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow);
}

.section-title {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 20px;
}

/* ─── Two-column zone ────────────────────────────────────────────────────── */

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

/* ─── Hero zone ──────────────────────────────────────────────────────────── */

#hero-zone {
  background: linear-gradient(135deg, var(--surface) 0%, var(--surface-3) 100%);
  border-color: var(--accent);
  border-width: 1px;
  text-align: center;
  padding: 48px 28px;
}

.hero-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.hero-amount {
  font-size: clamp(48px, 8vw, 80px);
  font-weight: 800;
  letter-spacing: -2px;
  color: var(--text);
  line-height: 1;
  margin-bottom: 4px;
}

.hero-amount .currency {
  font-size: 0.5em;
  font-weight: 600;
  vertical-align: top;
  margin-top: 12px;
  display: inline-block;
  color: var(--accent);
}

.hero-target {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 24px;
}

.hero-target strong {
  color: var(--text);
}

.progress-bar-wrap {
  background: var(--surface-2);
  border-radius: 100px;
  height: 12px;
  margin: 0 auto 12px;
  max-width: 480px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 100px;
  background: var(--accent);
  transition: width 0.4s ease;
  min-width: 4px;
}

.progress-bar-fill.on-track { background: var(--good); }
.progress-bar-fill.behind   { background: var(--warn); }

.hero-pct {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
  padding: 4px 12px;
  border-radius: 100px;
  text-transform: uppercase;
}

.hero-badge.on-track { background: rgba(52,211,153,0.15); color: var(--good); }
.hero-badge.behind   { background: rgba(251,191,36,0.15);  color: var(--warn); }
.hero-badge.at-risk  { background: rgba(248,113,113,0.15); color: var(--bad);  }
.hero-badge.no-data  { background: var(--surface-2);       color: var(--text-dim); }

.hero-meta {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 12px;
}

/* ─── Metric rows (channel) ──────────────────────────────────────────────── */

.metric-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 8px;
  flex-wrap: wrap;
}

.metric-row:last-of-type { border-bottom: none; }

.metric-label {
  font-size: 14px;
  color: var(--text-dim);
  flex: 1;
}

.metric-value {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  min-width: 80px;
  text-align: right;
}

.metric-total-row {
  display: flex;
  justify-content: space-between;
  padding: 14px 0 0;
  margin-top: 6px;
  border-top: 2px solid var(--border);
  font-weight: 700;
}

.edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}

.edit-btn:hover { color: var(--accent); background: var(--accent-dim); }

.inline-edit-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.inline-input {
  background: var(--surface-2);
  border: 1px solid var(--accent);
  color: var(--text);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 15px;
  font-family: inherit;
  width: 100px;
  text-align: right;
  outline: none;
}

.clear-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  transition: color 0.15s;
}

.clear-btn:hover { color: var(--bad); }

/* ─── Client cards (agency) ──────────────────────────────────────────────── */

.client-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.client-card {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  position: relative;
  min-height: 120px;
}

.client-card.empty {
  display: flex;
  align-items: center;
  justify-content: center;
  border-style: dashed;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}

.client-card.empty:hover {
  border-color: var(--accent);
  background: var(--accent-dim);
}

.add-client-btn {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0;
  font-family: inherit;
}

.add-client-btn:hover { color: var(--accent); }

.client-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 6px;
  padding-right: 48px;
}

.client-tier-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 100px;
  background: var(--accent-dim);
  color: var(--accent);
  margin-bottom: 8px;
}

.client-revenue {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
  margin-bottom: 4px;
}

.client-renewal {
  font-size: 12px;
  color: var(--text-dim);
}

.client-renewal.soon { color: var(--warn); }

.client-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 4px;
}

.client-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-dim);
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  line-height: 1;
}

.client-actions button:hover { color: var(--accent); }
.client-actions .remove-btn:hover { color: var(--bad); }

/* Client add form */
.client-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.client-form input,
.client-form select {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
  outline: none;
}

.client-form input:focus,
.client-form select:focus { border-color: var(--accent); }

.client-form-actions {
  display: flex;
  gap: 8px;
}

.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  flex: 1;
}

.btn-primary:hover { filter: brightness(1.1); }

.btn-ghost {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-dim);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  font-family: inherit;
}

.btn-ghost:hover { border-color: var(--text-dim); color: var(--text); }

/* Agency total row */
.agency-total {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.agency-total-label {
  font-size: 13px;
  color: var(--text-dim);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.agency-total-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--good);
}

/* ─── Chart zone ─────────────────────────────────────────────────────────── */

#chart-zone canvas {
  max-height: 320px;
}

/* ─── Milestones ─────────────────────────────────────────────────────────── */

.milestone-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.milestone-row:last-child { border-bottom: none; }

.milestone-check {
  width: 20px;
  height: 20px;
  accent-color: var(--good);
  cursor: pointer;
  flex-shrink: 0;
}

.milestone-title {
  flex: 1;
  font-size: 15px;
}

.milestone-title.done {
  text-decoration: line-through;
  color: var(--text-dim);
}

.milestone-date {
  font-size: 12px;
  color: var(--good);
  flex-shrink: 0;
}

/* ─── Entry zone (collapsible) ───────────────────────────────────────────── */

details#entry-zone {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

details#entry-zone summary {
  padding: 20px 28px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  text-transform: uppercase;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

details#entry-zone summary:hover { color: var(--text); }
details#entry-zone summary::before { content: '▶'; font-size: 10px; transition: transform 0.2s; }
details#entry-zone[open] summary::before { transform: rotate(90deg); }

.entry-form-inner {
  padding: 0 28px 28px;
}

.entry-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 24px;
}

.entry-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.entry-field label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.entry-field input,
.entry-field textarea {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  outline: none;
  width: 100%;
}

.entry-field input:focus,
.entry-field textarea:focus { border-color: var(--accent); }

.entry-field textarea {
  min-height: 80px;
  resize: vertical;
  grid-column: span 2;
}

.entry-field-full { grid-column: span 2; }

.entry-divider {
  grid-column: span 2;
  border: none;
  border-top: 1px solid var(--border);
  margin: 8px 0;
}

/* ─── Metric row layout update (right-side group) ───────────────────────── */

.metric-row-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* ─── Quick-add chips ────────────────────────────────────────────────────── */

.quick-chips {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.quick-chip {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 7px;
  border-radius: 100px;
  cursor: pointer;
  font-family: inherit;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.quick-chip:hover {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--accent);
}

/* ─── Sparkline ──────────────────────────────────────────────────────────── */

.sparkline-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.sparkline-label {
  font-size: 11px;
  color: var(--text-dim);
  white-space: nowrap;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  min-width: 100px;
}

#sub-sparkline {
  flex: 1;
  max-width: 200px;
  height: 44px;
}

/* ─── Journal section ────────────────────────────────────────────────────── */

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

.journal-saved-indicator {
  font-size: 12px;
  color: var(--good);
  opacity: 0;
  transition: opacity 0.3s;
}

.journal-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  transition: border-color 0.15s;
}

.journal-textarea:focus {
  border-color: var(--accent);
}

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

/* ─── Weekly textarea ────────────────────────────────────────────────────── */

.weekly-textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  resize: vertical;
  outline: none;
}

.weekly-textarea:focus { border-color: var(--accent); }

/* ─── Toast notification ─────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  max-width: 360px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  transform: translateY(16px);
  opacity: 0;
  transition: transform 0.25s ease, opacity 0.25s ease;
  z-index: 1000;
}

.toast.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-error {
  border-color: var(--bad);
  color: var(--bad);
}

/* ─── Auth overlay ───────────────────────────────────────────────────────── */

#auth-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.25s ease;
}

#auth-overlay.auth-unlocking {
  opacity: 0;
  pointer-events: none;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 48px 40px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

@keyframes auth-shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-10px); }
  40%       { transform: translateX(10px); }
  60%       { transform: translateX(-6px); }
  80%       { transform: translateX(6px); }
}

.auth-box.auth-shake {
  animation: auth-shake 0.35s ease;
}

.auth-logo {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.3px;
  margin-bottom: 8px;
}

.auth-logo span {
  color: var(--accent);
}

.auth-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: 28px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#auth-input {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: inherit;
  text-align: center;
  outline: none;
  letter-spacing: 2px;
  width: 100%;
  transition: border-color 0.15s;
}

#auth-input:focus {
  border-color: var(--accent);
}

#auth-input::placeholder {
  letter-spacing: normal;
  color: var(--text-dim);
}

.auth-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 24px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: filter 0.15s;
}

.auth-btn:hover {
  filter: brightness(1.1);
}

.auth-error {
  margin-top: 14px;
  font-size: 13px;
  color: var(--bad);
  min-height: 18px;
}

/* ─── Footer ─────────────────────────────────────────────────────────────── */

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 16px 24px 32px;
  text-align: center;
}

.last-updated {
  font-size: 12px;
  color: var(--text-dim);
}

/* ─── Responsive ─────────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  main#app { padding: 16px; gap: 16px; }
  .two-col { grid-template-columns: 1fr; }
  .client-grid { grid-template-columns: 1fr; }
  .entry-grid { grid-template-columns: 1fr; }
  .entry-field textarea { grid-column: span 1; }
  .entry-field-full { grid-column: span 1; }
  .entry-divider { grid-column: span 1; }
  #hero-zone { padding: 32px 20px; }
  header { padding: 12px 16px; }
}
