/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --forest-600: #4E7A5C;
  --forest-700: #3C5F47;
  --forest-500: #5F8F6D;
  --forest-100: #C8DFCE;
  --forest-50:  #EBF4EE;
  --gray-50:  #F4F6F3;
  --gray-100: #ECEEE9;
  --gray-200: #DDE0D8;
  --gray-300: #C8CCC4;
  --gray-400: #9BA39A;
  --gray-500: #6B7569;
  --gray-700: #3A3F38;
  --gray-900: #1A1F18;
  --red-600:  #C43B3B;
  --red-100:  #FAE0E0;
  --green-600:#2D8A52;
  --green-100:#C8EDD8;
  --amber-600:#C47A1A;
  --amber-50: #FEF8EE;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 4px rgba(0,0,0,.07), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.09), 0 2px 4px rgba(0,0,0,.05);
  --shadow-lg: 0 8px 24px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.05);
}

html { font-size: 16px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.5;
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.app-header {
  background: linear-gradient(135deg, var(--forest-700) 0%, var(--forest-600) 100%);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 12px rgba(78,122,92,.4);
}

.header-inner {
  max-width: 780px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 58px;
  gap: 12px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #fff;
  font-weight: 700;
  font-size: 1.1rem;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.nav { display: flex; gap: 4px; }

.nav-btn {
  background: transparent;
  border: none;
  color: rgba(255,255,255,.72);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 6px 13px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.nav-btn:hover  { background: rgba(255,255,255,.14); color: #fff; }
.nav-btn.active { background: rgba(255,255,255,.22); color: #fff; font-weight: 600; }

/* ── Main layout ─────────────────────────────────────────────────────────── */
.main-content {
  max-width: 780px;
  margin: 0 auto;
  padding: 28px 20px 56px;
}

.view { display: none; }
.view.active { display: block; }

.view-header { margin-bottom: 22px; }
.view-header h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--gray-900);
  letter-spacing: -0.02em;
}
.view-sub { color: var(--gray-500); font-size: 0.875rem; margin-top: 3px; }

kbd {
  display: inline-block;
  font-family: inherit;
  font-size: 0.75rem;
  padding: 1px 5px;
  background: rgba(0,0,0,.06);
  border: 1px solid var(--gray-300);
  border-radius: 4px;
  line-height: 1.5;
}

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
  border: 1px solid var(--gray-100);
}

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.form-group:last-child { margin-bottom: 0; }

label {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.required { color: var(--red-600); }
.optional  { color: var(--gray-400); font-weight: 400; font-size: 0.75rem; }

.char-counter {
  font-size: 0.75rem;
  font-weight: 400;
  color: var(--gray-400);
  margin-left: auto;
}
.char-counter--warn { color: var(--amber-600); }

.field-error {
  font-size: 0.8125rem;
  color: var(--red-600);
  min-height: 1.2em;
  margin-top: 4px;
}

.field-warning {
  font-size: 0.8125rem;
  color: var(--amber-600);
  min-height: 1.2em;
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
input[type="search"],
select,
textarea {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.9375rem;
  color: var(--gray-900);
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
  width: 100%;
  outline: none;
  font-family: inherit;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--forest-600);
  box-shadow: 0 0 0 3px rgba(78,122,92,.14);
}

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

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%236B7569' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.fieldset {
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}
.fieldset legend {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--gray-700);
  padding: 0 6px;
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn-primary, .btn-secondary, .btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s, box-shadow .15s;
  white-space: nowrap;
  font-family: inherit;
  letter-spacing: 0.01em;
}

.btn-primary  { background: var(--forest-600); color: #fff; box-shadow: 0 1px 3px rgba(78,122,92,.3); }
.btn-primary:hover:not(:disabled)  { background: var(--forest-700); box-shadow: 0 2px 6px rgba(78,122,92,.35); transform: translateY(-1px); }
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-secondary { background: #fff; color: var(--gray-700); border: 1.5px solid var(--gray-200); }
.btn-secondary:hover:not(:disabled) { background: var(--gray-50); border-color: var(--gray-300); }

.btn-danger  { background: var(--red-600); color: #fff; }
.btn-danger:hover:not(:disabled)  { background: #a83030; }

.btn-primary:disabled,
.btn-secondary:disabled,
.btn-danger:disabled  { opacity: .5; cursor: not-allowed; }

.btn-sm { padding: 5px 12px; font-size: 0.8125rem; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-400);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 0.875rem;
  transition: color .15s, background .15s;
}
.btn-icon:hover { color: var(--red-600); background: var(--red-100); }

/* ── Status messages ─────────────────────────────────────────────────────── */
.status-msg { font-size: 0.875rem; padding: 0; border-radius: 8px; transition: all .2s; }
.status-msg:not(:empty) { padding: 10px 14px; margin-top: 4px; }
.status-msg.success { background: var(--green-100); color: var(--green-600); }
.status-msg.error   { background: var(--red-100);   color: var(--red-600);   }

/* ── Assignee picker ─────────────────────────────────────────────────────── */
.assignee-add-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  align-items: center;
}
.assignee-add-row select { flex: 1; min-width: 0; }

.assignee-manual-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: center;
}
.assignee-manual-row input { flex: 1; min-width: 0; }

.assignee-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 36px;
  padding: 4px 0;
}

.chips-placeholder {
  font-size: 0.875rem;
  color: var(--gray-400);
  align-self: center;
  font-style: italic;
}

.assignee-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--forest-50);
  border: 1px solid var(--forest-100);
  border-radius: 999px;
  padding: 3px 10px 3px 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--forest-700);
  animation: chip-in .15s ease;
}

@keyframes chip-in {
  from { opacity: 0; transform: scale(.85); }
  to   { opacity: 1; transform: scale(1);   }
}

.chip-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.625rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.chip-avatar--sm {
  width: 18px;
  height: 18px;
  font-size: 0.5625rem;
}

.chip-label { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--forest-500);
  font-size: 0.625rem;
  line-height: 1;
  padding: 2px;
  border-radius: 50%;
  transition: color .15s, background .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.chip-remove:hover { color: var(--red-600); background: var(--red-100); }

/* ── Queue ───────────────────────────────────────────────────────────────── */
.queue-card { background: var(--forest-50); border: 1.5px solid var(--forest-100); }

.queue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.queue-header h3 { font-size: 1rem; color: var(--forest-700); font-weight: 700; }

.queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #fff;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 0.875rem;
  gap: 8px;
  border: 1px solid var(--gray-100);
}
.queue-item:last-child { margin-bottom: 0; }

.queue-item-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.queue-recipients { color: var(--gray-500); font-size: 0.8125rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Team ────────────────────────────────────────────────────────────────── */
.team-toolbar { margin-bottom: 16px; }

.team-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  border-bottom: 1px solid var(--gray-100);
  gap: 12px;
}
.team-row:last-child { border-bottom: none; }

.team-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.team-info > div { display: flex; flex-direction: column; gap: 1px; min-width: 0; }

.team-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.team-name  { font-weight: 600; font-size: 0.9375rem; color: var(--gray-900); }
.team-email { font-size: 0.8125rem; color: var(--gray-500); }
.team-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ── Dashboard stats ─────────────────────────────────────────────────────── */
.dash-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 22px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
  cursor: pointer;
  transition: box-shadow .15s, transform .15s;
  border: 1.5px solid var(--gray-100);
  position: relative;
  overflow: hidden;
}
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gray-200);
  border-radius: var(--radius) var(--radius) 0 0;
}
.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.stat-card:focus-visible { outline: 2px solid var(--forest-600); outline-offset: 2px; }

.stat-value {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1;
  color: var(--gray-900);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
.stat-label {
  font-size: 0.6875rem;
  color: var(--gray-500);
  margin-top: 6px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
}
.stat-card.stat-overdue { border-color: var(--red-100); }
.stat-card.stat-overdue::before { background: var(--red-600); }
.stat-card.stat-overdue .stat-value { color: var(--red-600); }
.stat-card.stat-soon    { border-color: #FDE68A; }
.stat-card.stat-soon::before { background: var(--amber-600); }
.stat-card.stat-soon    .stat-value  { color: var(--amber-600); }
.stat-card.stat-upcoming { border-color: var(--forest-100); }
.stat-card.stat-upcoming::before { background: var(--forest-600); }
.stat-card.stat-upcoming .stat-value { color: var(--forest-600); }

/* ── Filter tabs ─────────────────────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 16px;
  border-bottom: 1.5px solid var(--gray-200);
}

.filter-tab {
  background: none;
  border: none;
  border-bottom: 2.5px solid transparent;
  padding: 8px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-500);
  cursor: pointer;
  margin-bottom: -1.5px;
  transition: color .15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: inherit;
  white-space: nowrap;
}
.filter-tab:hover { color: var(--gray-900); }
.filter-tab.active { color: var(--forest-600); border-bottom-color: var(--forest-600); font-weight: 600; }

.tab-badge {
  background: var(--gray-100);
  color: var(--gray-500);
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
}
.filter-tab.active .tab-badge { background: var(--forest-100); color: var(--forest-700); }

/* ── Status badges ───────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.status-badge--overdue   { background: var(--red-100);    color: var(--red-600); }
.status-badge--due-today { background: #FEF3C7;           color: #92400E; }
.status-badge--due-soon  { background: var(--amber-50);   color: var(--amber-600); border: 1px solid #FDE68A; }
.status-badge--upcoming  { background: var(--forest-50);  color: var(--forest-700); }
.status-badge--no-date   { background: var(--gray-100);   color: var(--gray-500); }

/* ── History / Dashboard ─────────────────────────────────────────────────── */
.history-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.history-search-input { flex: 1; }

.history-card {
  padding: 16px 18px;
  border: 1.5px solid var(--gray-100);
  border-left-width: 4px;
  border-radius: var(--radius);
  margin-bottom: 10px;
  background: #fff;
  transition: box-shadow .15s, transform .1s;
}
.history-card:hover { box-shadow: var(--shadow-md); transform: translateX(1px); }
.history-card:last-child { margin-bottom: 0; }

.history-card--overdue   { border-left-color: var(--red-600); }
.history-card--due-today { border-left-color: #D97706; }
.history-card--due-soon  { border-left-color: var(--amber-600); }
.history-card--upcoming  { border-left-color: var(--forest-600); }
.history-card--no-date   { border-left-color: var(--gray-300); }
.history-card--done      { border-left-color: var(--green-600); }

/* ── Done / completed state ──────────────────────────────────────────────── */
.history-card.is-done { background: var(--gray-50); }
.history-card.is-done .history-title { text-decoration: line-through; color: var(--gray-400); }
.history-card.is-done .history-desc  { opacity: .55; }
.history-card.is-done .history-due-pill { opacity: .45; }
.status-badge--done { background: var(--green-100); color: var(--green-600); }

.history-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.history-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}

.history-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--gray-900);
}

.history-due-pill {
  font-size: 0.75rem;
  color: var(--gray-500);
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  padding: 2px 10px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}

.history-desc {
  font-size: 0.8125rem;
  color: var(--gray-500);
  margin-bottom: 10px;
  line-height: 1.5;
}

.history-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.history-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.history-time {
  font-size: 0.75rem;
  color: var(--gray-400);
  white-space: nowrap;
}

.history-recipients {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.history-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  padding: 2px 9px 2px 3px;
  font-size: 0.8125rem;
  color: var(--gray-700);
}

.empty-state {
  color: var(--gray-400);
  text-align: center;
  padding: 32px 0;
  font-size: 0.9375rem;
}

.empty-state-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 48px 0 36px;
  color: var(--gray-400);
  font-size: 0.9375rem;
}

.empty-state-block svg {
  opacity: 0.4;
}

/* ── All-day / time controls ─────────────────────────────────────────────── */
.all-day-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 16px;
  min-height: 38px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}
.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--forest-600);
  cursor: pointer;
  flex-shrink: 0;
}

.all-day-row .form-group { margin-bottom: 0; flex: 1; max-width: 160px; }
.all-day-row .form-group label { font-size: 0.8125rem; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(3px);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 28px;
  width: 100%;
  max-width: 420px;
  animation: modal-in .18s ease;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(6px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal h3 { font-size: 1.125rem; margin-bottom: 20px; font-weight: 700; letter-spacing: -0.01em; }

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 540px) {
  .form-row { grid-template-columns: 1fr; }
  .header-inner { padding: 0 14px; }
  .card { padding: 18px 16px; }
  .main-content { padding: 20px 14px 48px; }
  .nav-btn { padding: 6px 9px; font-size: 0.8125rem; }
  .assignee-add-row { flex-wrap: wrap; }
  .dash-stats { grid-template-columns: repeat(2, 1fr); }
  .history-card-top { flex-direction: column; gap: 6px; }
  .history-card-bottom { flex-direction: column; align-items: flex-start; }
  .history-actions { width: 100%; justify-content: space-between; }
  .filter-tabs { overflow-x: auto; padding-bottom: 1px; }
  .all-day-row { flex-wrap: wrap; }
  .history-sort-select { display: none; }
  .history-toolbar { flex-wrap: wrap; }
  .card-menu { right: auto; left: 0; }
}

/* ── Done stat card ──────────────────────────────────────────────────────── */
.stat-card.stat-done { border-color: var(--green-100); }
.stat-card.stat-done::before { background: var(--green-600); }
.stat-card.stat-done .stat-value { color: var(--green-600); }

/* ── Affirm button (green-tinted secondary) ──────────────────────────────── */
.btn--affirm {
  color: var(--green-600) !important;
  border-color: #86EFAC !important;
}
.btn--affirm:hover:not(:disabled) { background: var(--green-100) !important; }

/* ── Alert tab badge (overdue count on Active tab) ───────────────────────── */
.tab-badge--alert { background: var(--red-100) !important; color: var(--red-600) !important; }

/* ── Completed timestamp ─────────────────────────────────────────────────── */
.history-completed-time {
  font-size: 0.75rem;
  color: var(--green-600);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Send count badge ────────────────────────────────────────────────────── */
.send-count-badge {
  display: inline-block;
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--gray-400);
}

/* ── Overflow menu ───────────────────────────────────────────────────────── */
.card-menu-wrapper {
  position: relative;
}

.btn-overflow {
  color: var(--gray-400);
  padding: 5px 6px;
  border-radius: 6px;
  transition: color .15s, background .15s;
}
.btn-overflow:hover { color: var(--gray-700); background: var(--gray-100); }

.card-menu {
  display: none;
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  background: #fff;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 180px;
  z-index: 50;
  overflow: hidden;
  padding: 4px 0;
  animation: menu-in .12s ease;
}

@keyframes menu-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card-menu.is-open { display: block; }

.card-menu__item {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: none;
  padding: 9px 14px;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--gray-700);
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  gap: 6px;
  transition: background .1s;
}
.card-menu__item:hover { background: var(--gray-50); }
.card-menu__item--danger { color: var(--red-600); }
.card-menu__item--danger:hover { background: var(--red-100); }

.card-menu__divider {
  height: 1px;
  background: var(--gray-100);
  margin: 4px 0;
}

/* ── Task notes ──────────────────────────────────────────────────────────── */
.task-notes {
  margin: 4px 0 10px;
}

.task-notes__preview {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 8px 10px;
  background: var(--gray-50);
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-100);
}

.notes-icon {
  color: var(--gray-400);
  flex-shrink: 0;
  margin-top: 1px;
}

.notes-preview-text {
  font-size: 0.8125rem;
  color: var(--gray-500);
  line-height: 1.5;
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.notes-edit-icon {
  color: var(--gray-300);
  padding: 2px 4px;
  flex-shrink: 0;
  margin-top: -1px;
}
.notes-edit-icon:hover { color: var(--forest-600); background: var(--forest-50); }

.task-notes__edit { display: flex; flex-direction: column; gap: 8px; }

.notes-textarea {
  width: 100%;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 0.875rem;
  color: var(--gray-900);
  font-family: inherit;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  min-height: 56px;
  background: #fff;
}
.notes-textarea:focus {
  border-color: var(--forest-600);
  box-shadow: 0 0 0 3px rgba(78,122,92,.14);
}

.notes-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ── Edit mode banner (compose view) ─────────────────────────────────────── */
#edit-mode-banner { margin-bottom: 12px; }

.edit-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--forest-50);
  border: 1.5px solid var(--forest-100);
  border-radius: var(--radius);
  padding: 10px 16px;
  font-size: 0.875rem;
  color: var(--forest-700);
  flex-wrap: wrap;
}
.edit-banner strong { font-weight: 600; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.edit-banner svg { color: var(--forest-500); flex-shrink: 0; }

/* ── Sort select ─────────────────────────────────────────────────────────── */
.history-sort-select {
  width: auto;
  flex-shrink: 0;
  font-size: 0.8125rem;
  padding: 8px 28px 8px 10px;
  background-position: right 8px center;
}

/* ── PWA install banner ───────────────────────────────────────────────────── */
#install-banner {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  padding: 12px 20px;
  border-radius: 12px;
  font-size: 0.875rem;
  display: none;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  white-space: nowrap;
}
#install-banner.show { display: flex; }
#install-banner button { background: var(--forest-600); border: none; color: #fff; padding: 6px 14px; border-radius: 6px; font-size: 0.8125rem; font-weight: 600; cursor: pointer; }
#install-banner .dismiss { background: none; color: var(--gray-400); padding: 6px; }

/* ── Priority badge (future use) ─────────────────────────────────────────── */
.priority-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}
.priority-badge--high   { background: #FEE2E2; color: #B91C1C; }
.priority-badge--medium { background: #FEF9C3; color: #92400E; }
.priority-badge--low    { background: var(--forest-50); color: var(--forest-700); }

/* ── 3-column form row ───────────────────────────────────────────────────── */
.form-row--3 {
  grid-template-columns: 1fr 1fr 1fr;
}
@media (max-width: 540px) {
  .form-row--3 { grid-template-columns: 1fr; }
}

/* ── Template bar ────────────────────────────────────────────────────────── */
.template-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 18px;
  padding: 10px 14px;
  background: var(--forest-50);
  border: 1px solid var(--forest-100);
  border-radius: var(--radius-sm);
  flex-wrap: wrap;
}
.template-select { flex: 1; min-width: 0; }

/* ── Tag input (compose) ─────────────────────────────────────────────────── */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  min-height: 42px;
  cursor: text;
  background: #fff;
  transition: border-color .15s, box-shadow .15s;
}
.tag-input-wrap:focus-within {
  border-color: var(--forest-600);
  box-shadow: 0 0 0 3px rgba(78,122,92,.14);
}
.tag-input-wrap #tag-input {
  border: none !important;
  box-shadow: none !important;
  padding: 2px 4px;
  min-width: 120px;
  flex: 1;
  background: transparent;
  font-size: 0.875rem;
}
.tag-input-wrap #tag-input:focus {
  border: none !important;
  box-shadow: none !important;
}

/* ── Tag chips (shared) ──────────────────────────────────────────────────── */
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #EDE9FE;
  border: 1px solid #C4B5FD;
  color: #5B21B6;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  color: #7C3AED;
  font-size: 0.6rem;
  padding: 1px 2px;
  border-radius: 50%;
  line-height: 1;
  transition: color .15s, background .15s;
  display: flex;
  align-items: center;
}
.tag-chip-remove:hover { color: var(--red-600); background: var(--red-100); }

/* ── Tag chips on history cards ──────────────────────────────────────────── */
.history-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 2px 0 8px;
}
.tag-chip--card {
  cursor: pointer;
  transition: background .1s, border-color .1s;
  user-select: none;
}
.tag-chip--card:hover { background: #DDD6FE; border-color: #A78BFA; }
.tag-chip--active { background: #7C3AED !important; color: #fff !important; border-color: #7C3AED !important; }

/* ── Tag filter bar (dashboard) ──────────────────────────────────────────── */
.tag-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  padding: 8px 0 12px;
  border-bottom: 1px solid var(--gray-100);
  margin-bottom: 12px;
}
.tag-filter-label {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ── Priority badge ──────────────────────────────────────────────────────── */
.priority-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.625rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  flex-shrink: 0;
}
.priority-badge--high   { background: #FEE2E2; color: #B91C1C; }
.priority-badge--medium { background: #FEF3C7; color: #92400E; }
.priority-badge--low    { background: var(--forest-50); color: var(--forest-700); }

/* ── Overdue aging label ─────────────────────────────────────────────────── */
.overdue-age-label {
  display: inline-flex;
  align-items: center;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.overdue-age--light    { background: var(--red-100); color: #C43B3B; }
.overdue-age--medium   { background: #FCA5A5; color: #7F1D1D; font-weight: 700; }
.overdue-age--critical { background: var(--red-600); color: #fff; font-weight: 800; letter-spacing: 0.02em; }
.history-card--overdue-critical { background: #FFF5F5 !important; }

/* ── Bulk action bar (fixed bottom) ─────────────────────────────────────── */
.bulk-bar {
  display: none;
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 10px 18px;
  gap: 16px;
  align-items: center;
  z-index: 150;
  white-space: nowrap;
  animation: bar-in .18s ease;
}
.bulk-bar.is-visible { display: flex; }
@keyframes bar-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}
.bulk-count { font-size: 0.875rem; font-weight: 600; }
.bulk-actions { display: flex; gap: 8px; }

/* ── Bulk checkbox on cards ──────────────────────────────────────────────── */
.history-card { position: relative; }
.card-select-check {
  position: absolute;
  top: 50%;
  left: 6px;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  accent-color: var(--forest-600);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  z-index: 2;
}
.history-card:hover .card-select-check,
.history-card.is-selected .card-select-check { opacity: 1; }
.history-card.is-selected {
  outline: 2px solid var(--forest-600);
  outline-offset: -2px;
  background: var(--forest-50) !important;
}
.history-card.is-selected.is-done { background: var(--forest-50) !important; }
/* Shift card content right when checkbox visible */
.history-card:hover .card-content,
.history-card.is-selected .card-content { padding-left: 20px; }
.card-content { transition: padding-left .15s; }

/* ── Calendar view ───────────────────────────────────────────────────────── */
.calendar-view {
  border: 1px solid var(--gray-100);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
  background: var(--gray-50);
}
.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.cal-title {
  font-weight: 700;
  font-size: 1rem;
  color: var(--gray-900);
  letter-spacing: -0.01em;
}
.cal-nav-btn {
  color: var(--gray-500) !important;
  padding: 6px !important;
  border-radius: var(--radius-sm) !important;
}
.cal-nav-btn:hover { color: var(--gray-900) !important; background: var(--gray-200) !important; }

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.cal-day-name {
  text-align: center;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  padding: 4px 0 8px;
  letter-spacing: 0.05em;
}
.cal-cell {
  min-height: 52px;
  padding: 5px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--gray-200);
  background: #fff;
  cursor: pointer;
  transition: background .12s, border-color .12s;
  position: relative;
}
.cal-cell:hover { background: var(--forest-50); border-color: var(--forest-100); }
.cal-cell--empty { background: transparent !important; border-color: transparent !important; cursor: default; }
.cal-cell--today { border-color: var(--forest-600) !important; background: var(--forest-50) !important; }
.cal-cell--today .cal-day-num { color: var(--forest-700); font-weight: 800; }
.cal-cell--selected { background: var(--forest-100) !important; border-color: var(--forest-600) !important; }
.cal-cell--selected .cal-day-num { color: var(--forest-700); font-weight: 800; }

.cal-day-num {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--gray-700);
  line-height: 1;
  margin-bottom: 4px;
}
.cal-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  margin-top: 2px;
}
.cal-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.cal-dot--overdue  { background: var(--red-600); }
.cal-dot--soon     { background: var(--amber-600); }
.cal-dot--upcoming { background: var(--forest-600); }
.cal-dot--done     { background: var(--green-600); }

.cal-date-filter-active {
  font-size: 0.8125rem;
  color: var(--forest-600);
  font-weight: 500;
  padding: 4px 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 540px) {
  .cal-cell { min-height: 38px; padding: 3px 3px; }
  .cal-day-num { font-size: 0.6875rem; }
  .cal-dot { width: 4px; height: 4px; }
  .cal-grid { gap: 2px; }
  .calendar-view { padding: 12px 10px; }
}
