:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --text: #1b1f27;
  --muted: #6b7280;
  --accent: #2f6fed;
  --urgent: #d64545;
  --border: #e5e7eb;
  color-scheme: light;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

main {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 2rem;
  padding-top: env(safe-area-inset-top);
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1rem 0.5rem;
}

.topbar h1 {
  font-size: 1.4rem;
  margin: 0;
  flex: 1;
}

.icon-btn {
  border: none;
  background: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  line-height: 1;
  color: var(--text);
}

.customer-list {
  list-style: none;
  margin: 0.5rem 0;
  padding: 0 0.75rem;
}

.customer-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--surface);
  border-radius: 12px;
  padding: 0.9rem 1rem;
  margin-bottom: 0.6rem;
  cursor: pointer;
  border: 1px solid var(--border);
}

.customer-row:active {
  background: #f0f1f3;
}

.customer-row-main {
  flex: 1;
  min-width: 0;
}

.customer-row-name {
  font-weight: 600;
  margin: 0 0 0.15rem;
}

.customer-row-status {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badges {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--urgent);
  display: inline-block;
}

.calendar-icon {
  font-size: 1.1rem;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  margin-top: 3rem;
  padding: 0 1rem;
}

.status-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0.5rem 1rem 1rem;
  padding: 1.1rem;
}

.status-card p {
  margin: 0;
  font-size: 1.1rem;
  line-height: 1.5;
}

.next-step-card {
  background: #eef4ff;
  border: 1px solid #c9dcff;
  border-left: 4px solid var(--accent);
  border-radius: 12px;
  margin: 0 1rem 1rem;
  padding: 1.1rem;
}

.next-step-card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--accent);
}

#next-step-description {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 600;
}

.muted {
  color: var(--muted);
  margin: 0.15rem 0;
  font-size: 0.92rem;
}

.secondary-btn {
  margin-top: 0.8rem;
  border: 1px solid var(--accent);
  background: var(--surface);
  color: var(--accent);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-size: 0.9rem;
  cursor: pointer;
}

.link-btn {
  display: block;
  width: calc(100% - 2rem);
  margin: 1rem 1rem 0;
  background: none;
  border: none;
  color: var(--muted);
  text-decoration: underline;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.original-email {
  margin: 0.75rem 1rem 0;
  padding: 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.original-email pre {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 0.88rem;
  margin: 0.4rem 0 0;
}

.login-view {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 1.5rem;
}

.login-card {
  width: 100%;
  max-width: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 1.3rem;
  text-align: center;
}

.login-card input {
  font-size: 1rem;
  padding: 0.7rem 0.8rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.login-error {
  color: var(--urgent);
  font-size: 0.88rem;
  margin: 0;
}

.primary-btn {
  border: none;
  background: var(--accent);
  color: #fff;
  border-radius: 8px;
  padding: 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.row-delete-btn {
  border: none;
  background: none;
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.25rem;
  line-height: 1;
  flex-shrink: 0;
}

.row-delete-btn:active {
  color: var(--urgent);
}

.notes-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 0 1rem 1rem;
  padding: 1.1rem;
}

.notes-card h2 {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.notes-card textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  padding: 0.6rem 0.7rem;
}

.notes-feed {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.notes-feed li {
  border-top: 1px solid var(--border);
  padding-top: 0.6rem;
}

.notes-feed .note-date {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
  margin-bottom: 0.2rem;
}

.notes-feed .note-text {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.92rem;
}

.notes-feed-empty {
  color: var(--muted);
  font-size: 0.88rem;
  margin: 1rem 0 0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #14161b;
    --surface: #1e2128;
    --text: #f2f3f5;
    --muted: #9aa0aa;
    --border: #2c3038;
    color-scheme: dark;
  }
  .next-step-card {
    background: #182339;
    border-color: #2c3f66;
  }
}
