/* triage — mobile-first, no framework yet (Material Web Components layered on later) */

:root {
  --bg: #f7f7f8;
  --surface: #ffffff;
  --text: #1a1a1a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --warn: #d97706;
  --danger: #b91c1c;
  --success: #16a34a;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

* { 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 Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 16px;
}

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

header.app-header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
}

header.app-header .subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.flash {
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 14px;
}

.flash-notice {
  background: #ecfeff;
  border: 1px solid #a5f3fc;
  color: #0e7490;
}

.flash-alert {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 48px 16px;
}

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

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.task-card .title {
  font-size: 16px;
  font-weight: 600;
  margin: 0 0 6px 0;
}

.task-card .description {
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 12px 0;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-card .badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}

.badge {
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f3f4f6;
  color: #374151;
  border: 1px solid var(--border);
}

.badge.company { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }
.badge.client  { background: #f5f3ff; color: #6d28d9; border-color: #ddd6fe; }
.badge.billing { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.badge.source  { background: #f1f5f9; color: #475569; border-color: #cbd5e1; }

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
}

.actions form { margin: 0; }

.actions button {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.actions button:active { transform: translateY(1px); }

.actions .ignore   { color: var(--danger);  border-color: #fecaca; background: #fef2f2; }
.actions .snooze   { color: var(--warn);    border-color: #fde68a; background: #fffbeb; }
.actions .schedule { color: var(--success); border-color: #bbf7d0; background: #f0fdf4; }

.actions button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #f3f4f6;
  color: var(--muted);
  border-color: var(--border);
}
.actions button:disabled:active { transform: none; }

.actions.actions-2 { grid-template-columns: 1fr 1fr; }

/* Stacked action group — Ignore + optional "+ block" affordance below */
.action-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.action-stack form { margin: 0; }

.actions .block-sender {
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 500;
  color: #6b7280;
  background: transparent;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  width: 100%;
  text-align: center;
  -webkit-tap-highlight-color: transparent;
}

.actions .block-sender:hover {
  color: var(--danger);
  border-color: #fecaca;
  background: #fef2f2;
}

.actions .block-sender:active { transform: translateY(1px); }

/* Needs-attention state on a task card -------------------------------------- */
.task-card.needs-attention {
  border-color: #fde68a;
  background: #fffdf5;
  box-shadow: 0 1px 3px rgba(217, 119, 6, 0.10), 0 1px 2px rgba(217, 119, 6, 0.06);
}

/* Sync-failed state — task came back to triage after Todoist failure --------- */
.task-card.sync-failed {
  border-color: #fecaca;
  background: #fffbfb;
  box-shadow: 0 1px 3px rgba(185, 28, 28, 0.10), 0 1px 2px rgba(185, 28, 28, 0.06);
}

.error-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.error-banner .error-icon { font-size: 14px; line-height: 1; }
.error-banner .error-text { line-height: 1.35; }

.warning-banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  background: #fef3c7;
  border: 1px solid #fde68a;
  color: #92400e;
  font-size: 13px;
  padding: 8px 10px;
  border-radius: 8px;
  margin-bottom: 10px;
}

.warning-banner .warning-icon {
  font-size: 14px;
  line-height: 1;
}

.warning-banner .warning-text { line-height: 1.35; }

.form-actions-inline { margin-top: 0; }

.submit.submit-sm {
  padding: 8px 14px;
  font-size: 14px;
}

/* Unified card edit accordion ---------------------------------------------- */
.prefill-form-wrapper {
  margin-bottom: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fafc;
}

/* When the parent card needs attention, the accordion takes on a yellow
   theme to underline that this is the unblock-Schedule action. */
.task-card.needs-attention .prefill-form-wrapper {
  border-color: #fde68a;
  background: #fffbeb;
}

.task-card.needs-attention .prefill-toggle-label { color: #92400e; }
.task-card.needs-attention .prefill-toggle::before { color: #d97706; }
.task-card.needs-attention .prefill-form { border-top-color: #fde68a; }

.prefill-toggle {
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: #475569;
  list-style: none;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
}

.prefill-toggle::-webkit-details-marker { display: none; }
.prefill-toggle::before {
  content: "▸";
  display: inline-block;
  transition: transform 0.15s ease;
  color: #94a3b8;
}
details[open] > .prefill-toggle::before { transform: rotate(90deg); }

.prefill-toggle-label {
  font-weight: 600;
  color: #334155;
}

.prefill-toggle-summary {
  color: #64748b;
  font-size: 12px;
  font-weight: 400;
}

.prefill-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  padding-top: 0;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.prefill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding-top: 10px;
}

.field-full { grid-column: 1 / -1; }

.prefill-form .field label {
  font-size: 12px;
  color: #64748b;
}

.prefill-form input[type="number"],
.prefill-form input[type="datetime-local"],
.prefill-form input[type="text"],
.prefill-form .select {
  padding: 8px 10px;
  font-size: 14px;
}

/* Header row with right-aligned nav links ----------------------------------- */
.header-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
}

.header-nav { display: flex; gap: 8px; align-items: center; }
.header-nav form { margin: 0; }

/* Sync button — sits on the header next to nav-links. Visually a
   primary button so it stands out as the main "give me new tasks"
   affordance. */
.sync-button {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-family: inherit;
  -webkit-tap-highlight-color: transparent;
}
.sync-button:active { transform: translateY(1px); }
.sync-button[disabled] { opacity: 0.6; cursor: progress; }

.nav-link {
  display: inline-flex;
  align-items: center;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
}

.nav-link.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  text-align: center;
}

/* Tier badges --------------------------------------------------------------- */
.badge.tier-paying_customer { background: #fdf4ff; color: #86198f; border-color: #f5d0fe; }
.badge.tier-vip             { background: #fff7ed; color: #9a3412; border-color: #fed7aa; }
.badge.tier-family          { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.badge.tier-friend          { background: #ecfeff; color: #155e75; border-color: #a5f3fc; }
.badge.tier-normal          { background: #f3f4f6; color: #374151; border-color: var(--border); }

/* Forms --------------------------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.form-help {
  font-size: 13px;
  color: var(--muted);
  background: #f9fafb;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}

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

.field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.field input[type="text"],
.field input[type="email"],
.field textarea,
.field .select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 15px;
  font-family: inherit;
  -webkit-appearance: none;
}

.field textarea {
  resize: vertical;
  min-height: 72px;
}

.field input:focus,
.field textarea:focus,
.field .select:focus {
  outline: 2px solid var(--primary);
  outline-offset: -1px;
  border-color: var(--primary);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 4px;
}

.submit {
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: white;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.submit:active { transform: translateY(1px); }
