@import url('https://fonts.googleapis.com/css2?family=Cal+Sans&family=DM+Sans:wght@400;500;600;700&display=swap');

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  /* Anka brand palette — Pine Teal primary, Soft Linen canvas, Fiery Terracotta
     for destructive/urgent, Muted Teal as secondary/hover accent.
     Variable names (--navy, --blue, --amber, --green, --red-*) are retained from
     earlier palettes so dependent rules cascade; values below are the new brand. */
  --navy:         #144E47;   /* Pine Teal — primary: nav, buttons, active indicators */
  --navy-dark:    #0D3832;   /* darker pine teal for hover */
  --navy-light:   #2D6B62;
  --blue:         #144E47;   /* alias → Pine Teal (buttons, badges) */
  --blue-hover:   #84AB9E;   /* Muted Teal — hover state / secondary accents */
  --blue-light:   #B8E3E4;   /* Light Blue — info surfaces / My Tasks accent */
  --blue-bg:      #DFF3F4;   /* very light blue tint */
  --amber:        #C5CB47;   /* Golden Sand — highlights / new-item badges */
  --amber-light:  #F2F4C9;
  --amber-bg:     #EEF2B5;
  --amber-dark:   #7A7E1F;
  --red-bg:       #FBDCD2;   /* light terracotta tint */
  --red-text:     #E45938;   /* Fiery Terracotta — destructive / urgent */
  --green:        #84AB9E;   /* Muted Teal — reads as "resolved"/success (brand has no green) */
  --green-bg:     #D9E5E0;
  --orange:       #E45938;   /* alias → Terracotta */
  --orange-bg:    #FBDCD2;
  --text-primary:   #111112; /* Near Black — body */
  --text-secondary: #6B6B67; /* Mid Grey — meta/labels */
  --text-muted:     #9A9A96;
  --text-heading:   #001F3E; /* Prussian Blue — high-emphasis headings */
  --border:       #D9D5CC;   /* Light Grey — dividers */
  --border-light: #E7E3D9;
  --bg:           #FFFFFF;   /* White — cards, forms, side panel */
  --bg-secondary: #EDE9DD;   /* Soft Linen — page/app canvas */
  --bg-hover:     #E3DECF;   /* slightly darker linen for row hover */
  --shadow-sm:    0 1px 2px rgba(20,78,71,0.06);
  --shadow:       0 1px 3px rgba(20,78,71,0.08), 0 1px 2px rgba(20,78,71,0.04);
  --shadow-lg:    0 4px 12px rgba(20,78,71,0.08), 0 10px 30px -10px rgba(20,78,71,0.22);
  --shadow-xl:    0 8px 24px rgba(20,78,71,0.10), 0 20px 48px -12px rgba(20,78,71,0.28);
  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    12px;
  --radius-pill:  999px;
  --font-sans:    'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
  --font-display: 'Cal Sans', 'DM Sans', sans-serif;
  --header-h:     56px;
  --panel-w:      480px;
}

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
#main-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-h);
  background: var(--navy);              /* Pine Teal */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 2px 8px rgba(0,0,0,0.16);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  width: 80px;
  height: auto;
  display: block;
  flex-shrink: 0;
}

.header-title {
  font-family: var(--font-display);     /* Cal Sans */
  font-size: 15px;
  font-weight: 400;
  color: rgba(255,255,255,0.78);        /* subtitle weight — logo is the primary mark */
  letter-spacing: 0.01em;
  white-space: nowrap;
  padding-left: 12px;
  border-left: 1px solid rgba(255,255,255,0.22);
}

.header-actions { display: flex; align-items: center; gap: 12px; }

.btn-manage-team {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px 6px 10px;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.92);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-manage-team:hover { background: rgba(255,255,255,0.18); border-color: rgba(255,255,255,0.32); color: #FFFFFF; }
.btn-manage-team svg { width: 15px; height: 15px; }
.btn-manage-team:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-manage-team.loading svg { animation: rs-spin 0.9s linear infinite; }
@keyframes rs-spin { to { transform: rotate(360deg); } }

.pending-badge {
  display: flex;
  align-items: center;
  gap: 7px;
  background: var(--navy);              /* Pine Teal per brand spec */
  border: 1.5px solid var(--navy-dark);
  color: #FFFFFF;
  padding: 6px 14px 6px 10px;
  border-radius: var(--radius-pill);
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.pending-badge:hover { background: var(--navy-dark); box-shadow: 0 0 0 3px rgba(132,171,158,0.35); }
.pending-badge svg { width: 15px; height: 15px; }

.badge-pill {
  background: rgba(255,255,255,0.2);       /* contrast pill inside Pine Teal badge */
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
}

/* ── Views ───────────────────────────────────────────────────────────────── */
.view { min-height: calc(100vh - var(--header-h)); }
.hidden { display: none !important; }

/* ── Primary Nav ─────────────────────────────────────────────────────────── */
.primary-nav {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 0 16px 0 24px;
  display: flex;
  align-items: center;
  gap: 4px;
}

.nav-btn {
  padding: 14px 20px 12px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  white-space: nowrap;
}
.nav-btn:hover { color: var(--navy); }
.nav-btn.active { color: var(--navy); border-bottom-color: var(--blue); }

/* ── Sub Tabs ────────────────────────────────────────────────────────────── */
.sub-tab-bar {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.sub-tab {
  padding: 9px 16px 8px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.sub-tab:hover { color: var(--text-primary); }
.sub-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* ── New Task Button (in toolbar) ────────────────────────────────────────── */
.btn-new-task {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  padding: 6px 16px;
  background: var(--blue);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn-new-task:hover { background: var(--blue-hover); box-shadow: var(--shadow); }
.btn-new-task svg { width: 14px; height: 14px; }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 300;
  opacity: 0;
  transition: opacity 0.2s;
}
.modal-overlay.visible { opacity: 1; }

.modal {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -48%);
  z-index: 301;
  width: 540px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 64px);
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.2s, transform 0.2s cubic-bezier(0.4,0,0.2,1);
}
.modal.open {
  opacity: 1;
  transform: translate(-50%, -50%);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 16px;
  background: var(--navy);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  flex-shrink: 0;
}
.modal-header-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.modal-header-inner svg { width: 18px; height: 18px; color: #B8E3E4; flex-shrink: 0; }
.modal-header h2 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: white;
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #B8E3E4;
  padding: 3px;
  border-radius: 4px;
  transition: background 0.15s;
  display: flex;
}
.modal-close:hover { background: rgba(255,255,255,0.12); }
.modal-close svg { width: 17px; height: 17px; display: block; }

.modal-body {
  padding: 22px 22px 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  flex: 1;
  min-height: 0;
}

.modal-footer {
  padding: 14px 22px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Manage Team modal ─────────────────────────────────────────────────── */
.mt-body { padding-top: 16px; }
.mt-add-row {
  display: flex;
  gap: 8px;
  padding: 0 22px 10px;
}
.mt-add-row .form-input { flex: 1; }

.mt-member-list {
  list-style: none;
  padding: 0;
  margin: 8px 0 0;
  max-height: 320px;
  overflow-y: auto;
}
.mt-empty {
  padding: 12px 22px;
  font-size: 13px;
  color: var(--text-muted);
}
.mt-member-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 22px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13.5px;
  color: var(--text-primary);
}
.mt-member-row:last-child { border-bottom: none; }
.mt-member-name { flex: 1; }
.mt-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}
.mt-delete-btn:hover { color: #E45938; background: #FBDCD2; }
.mt-delete-btn svg { width: 14px; height: 14px; display: block; }

/* ── Form elements ───────────────────────────────────────────────────────── */
.form-row {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.form-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}

.required { color: #E45938; margin-left: 1px; }
.form-hint { font-weight: 400; color: var(--text-muted); font-size: 12px; }

.form-input {
  width: 100%;
  padding: 8px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-light);
}
.form-input.invalid {
  border-color: #E45938;
  box-shadow: 0 0 0 3px #FBDCD2;
}

.form-textarea { resize: vertical; min-height: 72px; line-height: 1.5; }

.form-select {
  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='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 9px center;
  padding-right: 32px;
  cursor: pointer;
}

.field-error {
  font-size: 12px;
  color: #E45938;
  font-weight: 500;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper {
  padding: 20px 24px 40px;
  overflow-x: auto;
}

#tasks-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  border: 1px solid var(--border);
  table-layout: auto;
}

#tasks-table thead tr {
  background: var(--navy);
}

#tasks-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 12px;
  font-weight: 600;
  color: #D9D5CC;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
  border-right: 1px solid var(--navy-light);
}
#tasks-table th:last-child { border-right: none; }

#tasks-table tbody tr {
  border-bottom: 1px solid var(--border-light);
  cursor: pointer;
  transition: background 0.1s;
}
#tasks-table tbody tr:last-child { border-bottom: none; }
#tasks-table tbody tr:hover { background: var(--bg-hover); }
#tasks-table tbody tr.overdue { background: var(--red-bg); }
#tasks-table tbody tr.overdue:hover { background: #F4C3B1; }

#tasks-table td {
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-primary);
  vertical-align: top;
  border-right: 1px solid var(--border-light);
  max-width: 260px;
}
#tasks-table td:last-child { border-right: none; }

.td-description { font-weight: 500; line-height: 1.45; }
.td-date, .td-deadline { white-space: nowrap; color: var(--text-secondary); font-size: 12.5px; }
.td-deadline.overdue-date { color: var(--red-text); font-weight: 600; }

.td-update { max-width: 200px; color: var(--text-secondary); font-size: 12.5px; line-height: 1.4; }
.td-update-img {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--blue);
  background: var(--blue-light);
  border-radius: 10px;
  padding: 2px 7px 2px 5px;
  white-space: nowrap;
}
.td-update-img svg { width: 12px; height: 12px; flex-shrink: 0; }

/* Row action buttons (Close / Reopen) */
.td-action { width: 1%; white-space: nowrap; padding-right: 12px; }
.row-action-btn {
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, border-color 0.15s;
}
.row-close-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.row-close-btn:hover {
  background: var(--green-bg);
  border-color: var(--green);
  color: var(--green);
}
.row-reopen-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}
.row-reopen-btn:hover {
  background: var(--amber-light);
  border-color: var(--amber);
  color: var(--amber-dark);
}

/* Reopened-task indicator (🔄 before description) */
.reopened-icon {
  font-size: 12px;
  cursor: help;
  opacity: 0.7;
}
.new-reply-badge {
  display: inline-flex;
  align-items: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber-dark);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius-pill);
  padding: 1px 8px;
  margin-right: 6px;
  cursor: help;
  animation: pulse-badge 2s ease-in-out infinite;
}
@keyframes pulse-badge {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.55; }
}

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  font-size: 14px;
  background: var(--bg);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
}

/* ── Priority Badge ──────────────────────────────────────────────────────── */
.priority-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.priority-High   { background: var(--red-bg);    color: var(--red-text);  }   /* Fiery Terracotta */
.priority-Medium { background: var(--amber-bg);  color: var(--amber-dark); }   /* Golden Sand */
.priority-Low    { background: var(--green-bg);  color: var(--navy);       }   /* Muted Teal tint + Pine Teal text */

/* ── Status Badge ────────────────────────────────────────────────────────── */
.status-badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-pill);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}
.status-Open   { background: var(--blue-bg);  color: var(--navy);      }   /* Light Blue tint + Pine Teal text */
.status-Closed { background: var(--green-bg); color: var(--navy-dark); }   /* Muted Teal tint + dark teal text */

/* ── Proposed Action Chip ────────────────────────────────────────────────── */
.pa-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  color: var(--amber-dark);
  padding: 3px 10px 3px 8px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.pa-chip:hover { background: #D9DE6B; }
.pa-chip svg { width: 12px; height: 12px; }

.pa-dash { color: var(--text-muted); }

/* ── Side Panel ──────────────────────────────────────────────────────────── */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.25);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
}
.panel-overlay.visible { opacity: 1; }

.side-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: var(--panel-w);
  height: 100vh;
  background: var(--bg);
  z-index: 201;
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}
.side-panel.open { transform: translateX(0); }

/* All four state containers must fill the remaining panel height as flex children */
#sp-open-view,
#sp-edit-mode,
#sp-closed-view,
#sp-reopen-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* sp-open-view: tabs section fills remaining space and scrolls */
#sp-tabs-section {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* sp-edit-mode: form is scrollable */
#sp-edit-mode { overflow-y: auto; }

.sp-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 18px 20px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--navy);
}

.sp-header-meta { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; }

.sp-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  margin-left: 10px;
}

.sp-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  color: #E7E3D9;
  padding: 4px 11px;
  border-radius: var(--radius);
  font-size: 12.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  white-space: nowrap;
}
.sp-edit-btn:hover { background: rgba(255,255,255,0.2); }
.sp-edit-btn svg { width: 13px; height: 13px; }

.sp-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #B8E3E4;
  flex-shrink: 0;
  border-radius: 4px;
  transition: background 0.15s;
}
.sp-close:hover { background: rgba(255,255,255,0.1); }
.sp-close svg { width: 18px; height: 18px; display: block; }

/* Edit form inside side panel */
.sp-edit-form {
  padding: 16px 20px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 13px;
  background: var(--bg-secondary);
}

.sp-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sp-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.sp-form-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.sp-form-input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  font-family: inherit;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s, box-shadow 0.15s;
  appearance: none;
  -webkit-appearance: none;
}
.sp-form-input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-light);
}
.sp-form-input[readonly] {
  background: var(--bg-secondary);
  color: var(--text-muted);
  cursor: default;
}
.sp-form-textarea { resize: vertical; min-height: 68px; line-height: 1.5; }

.sp-form-select {
  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='%2364748b' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 30px;
  cursor: pointer;
}

.sp-edit-actions {
  display: flex;
  gap: 8px;
  padding-top: 2px;
}

/* ── Closed task summary (State C) ───────────────────────────────────────── */
.sp-closed-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  flex: 1;
}

.sp-closed-title {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
  color: var(--text-primary);
}

.sp-closed-details {
  display: grid;
  grid-template-columns: 110px 1fr;
  gap: 8px 12px;
  font-size: 13px;
}
.sp-closed-details dt {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding-top: 2px;
}
.sp-closed-details dd {
  color: var(--text-primary);
  margin: 0;
  line-height: 1.5;
}

.sp-closed-actions {
  display: flex;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

/* ── Reopen form (State D) ───────────────────────────────────────────────── */
.sp-reopen-body {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  flex: 1;
}

.sp-reopen-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px 12px;
  font-size: 14px;
  font-weight: 700;
  color: var(--navy);
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}
.sp-reopen-heading svg { width: 16px; height: 16px; color: var(--amber-dark); flex-shrink: 0; }

.sp-reopen-fields {
  padding: 14px 20px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
}

.sp-form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 16px;
}

.sp-reopen-log-section {
  padding: 14px 20px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  flex-shrink: 0;
}

.sp-reopen-log {
  max-height: 200px;
  overflow-y: auto;
}

.sp-reopen-note-row {
  padding: 12px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.sp-reopen-actions {
  padding: 12px 20px 18px;
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  background: var(--bg-secondary);
  flex-shrink: 0;
  margin-top: auto;
}

/* Update Log section label */
.sp-section-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border-light);
}

.sp-title {
  padding: 14px 20px 6px;
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 400;
  line-height: 1.4;
  color: var(--text-heading);
  border-bottom: 1px solid var(--border-light);
}

.sp-meta-row {
  padding: 8px 20px 12px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
}
.sp-meta-item {
  font-size: 12.5px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Panel tabs */
.sp-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
}
.sp-tab {
  flex: 1;
  padding: 10px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.sp-tab:hover { color: var(--text-primary); }
.sp-tab.active { color: var(--blue); border-bottom-color: var(--blue); font-weight: 600; }

/* Tab content */
.sp-tab-content {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Update Log */
.sp-notes-empty {
  color: var(--text-muted);
  font-size: 13px;
  padding: 4px 0;
}

.sp-notes-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}
.note-item {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.note-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 5px;
}
.note-author { font-weight: 600; font-size: 12.5px; color: var(--navy); }
.note-time   { font-size: 11.5px; color: var(--text-muted); }
.note-content { font-size: 13px; line-height: 1.5; color: var(--text-primary); display: flex; flex-direction: column; gap: 6px; }
.note-text    { white-space: pre-wrap; word-break: break-word; }
.note-img     { max-width: 100%; max-height: 320px; border-radius: var(--radius); border: 1px solid var(--border); cursor: zoom-in; display: block; }
.note-img:hover { opacity: 0.92; }

/* Note compose area (preview strip + input row) */
.sp-note-compose {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Pasted image preview strip */
.sp-note-img-preview {
  position: relative;
  display: inline-flex;
  align-items: flex-start;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  width: fit-content;
  max-width: 100%;
}
.sp-note-img-preview img {
  max-height: 120px;
  max-width: 100%;
  border-radius: 3px;
  display: block;
}
.sp-note-img-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #E45938;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: white;
}
.sp-note-img-remove svg { width: 11px; height: 11px; }
.sp-note-img-remove:hover { background: #C84422; }

.sp-note-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}
.sp-note-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  color: var(--text-primary);
  transition: border-color 0.15s;
}
.sp-note-input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 2px var(--blue-light); }

/* Proposed action panel */
.pa-block {
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.pa-block-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.pa-block-label svg { width: 13px; height: 13px; }

.pa-reasoning {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
}
.pa-draft {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}
.pa-draft-edit {
  width: 100%;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-primary);
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  padding: 8px;
  resize: vertical;
  min-height: 160px;
  box-shadow: 0 0 0 2px var(--blue-light);
}
.pa-draft-edit:focus { outline: none; }

.pa-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  border: none;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn svg { width: 14px; height: 14px; flex-shrink: 0; }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }

.btn-primary {
  background: var(--blue);
  color: white;
}
.btn-primary:hover { background: var(--blue-hover); box-shadow: var(--shadow); }

.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }

.btn-danger {
  background: #FBDCD2;
  color: var(--red-text);
  border: 1px solid #F4A48F;
}
.btn-danger:hover { background: #F4C3B1; }

.btn-amber {
  background: var(--amber-bg);
  color: #7A7E1F;
  border: 1px solid var(--amber);
}
.btn-amber:hover { background: #D9DE6B; }

.btn-success {
  background: var(--green-bg);
  color: #0D3832;
  border: 1px solid #ADCDC3;
}
.btn-success:hover { background: #C8DBD4; }

/* ── Pending Review ──────────────────────────────────────────────────────── */
.pr-topbar {
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.back-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.back-btn svg { width: 14px; height: 14px; }

.pr-title { font-family: var(--font-display); font-size: 20px; font-weight: 400; letter-spacing: 0; color: var(--text-heading); }
.pr-subtitle { font-size: 13px; color: var(--text-secondary); margin-left: auto; }

.pr-layout {
  display: flex;
  height: calc(100vh - var(--header-h) - 57px);
  overflow: hidden;
}

/* PR Sidebar */
.pr-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--bg);
  overflow-y: auto;
  padding: 12px 0;
}

.pr-section { padding: 0 0 8px; }
.pr-section-header {
  padding: 10px 16px 6px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}
.pr-list { list-style: none; }
.pr-list-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.pr-list-item:hover { background: var(--bg-hover); }
.pr-list-item.active { background: var(--blue-bg); border-left-color: var(--blue); }
.pr-list-item.resolved { opacity: 0.5; cursor: default; }

.pr-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.dot-extracted { background: var(--blue); }
.dot-action    { background: var(--amber); }
.dot-closed    { background: var(--red-text); }

.pr-item-text {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.4;
  color: var(--text-primary);
}
.pr-item-sub {
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.pr-item-badge {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  white-space: nowrap;
}
.pr-item-badge.resolved { background: var(--green-bg); color: var(--green); }
.pr-item-badge.skipped  { background: #EEF2B5; color: #7A7E1F; }

/* PR Panel */
.pr-panel {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  background: var(--bg-secondary);
}

.pr-panel-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
}
.pr-panel-empty svg { width: 48px; height: 48px; opacity: 0.4; }
.pr-panel-empty p { font-size: 14px; }

.pr-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.pr-card-header {
  background: var(--navy);
  padding: 16px 20px;
}
.pr-card-type {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #B8E3E4;
  margin-bottom: 4px;
}
.pr-card-title {
  font-size: 15px;
  font-weight: 700;
  color: white;
  line-height: 1.4;
}

.pr-card-body { padding: 20px; display: flex; flex-direction: column; gap: 16px; }

.pr-field { display: flex; flex-direction: column; gap: 4px; }
.pr-field-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}
.pr-field-value {
  font-size: 13.5px;
  color: var(--text-primary);
  line-height: 1.5;
}
.pr-field-value.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  white-space: pre-wrap;
  font-size: 13px;
}
.pr-field-value.quote {
  background: var(--bg-secondary);
  border-left: 3px solid var(--border);
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  font-style: italic;
  border-radius: 0 var(--radius) var(--radius) 0;
}

.pr-card-actions {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg-secondary);
}

/* AI recommendation block */
.pr-ai-rec {
  background: var(--blue-bg);
  border: 1px solid var(--blue-light);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pr-ai-rec-header {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #144E47;
}
.pr-ai-rec-header svg { width: 14px; height: 14px; flex-shrink: 0; }
.pr-ai-rec-action-badge {
  margin-left: 4px;
  background: #144E47;
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  text-transform: none;
  letter-spacing: 0;
}
.pr-ai-rec-reason {
  font-size: 13px;
  color: #001F3E;
  line-height: 1.55;
}

/* Recommended button — subtle ring to match AI rec block */
.pr-btn-recommended {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}

.pr-skipped-note {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #EEF2B5;
  border: 1px solid #C5CB47;
  border-radius: var(--radius);
  color: #7A7E1F;
  font-size: 12.5px;
  font-weight: 500;
}
.pr-skipped-note svg { width: 16px; height: 16px; flex-shrink: 0; }

.pr-edit-form { gap: 14px; }

.pr-resolved-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--green-bg);
  border: 1px solid #ADCDC3;
  border-radius: var(--radius);
  color: #0D3832;
  font-size: 13px;
  font-weight: 600;
}
.pr-resolved-banner svg { width: 18px; height: 18px; }

/* ── Sign-in overlay ─────────────────────────────────────────────────────── */
#signin-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
#signin-overlay.hidden { display: none; }

/* Refresh button — used in the primary nav and PR topbar */
.btn-refresh {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-refresh:hover { background: var(--bg-hover); border-color: var(--text-muted); color: var(--text-primary); }
.btn-refresh svg { width: 14px; height: 14px; }
.btn-refresh:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-refresh.loading svg { animation: rs-spin 0.9s linear infinite; }

/* In the primary nav, the refresh button sits to the right of the nav tabs
   but to the LEFT of "New Task". margin-left: auto pins it there. */
.primary-nav .btn-refresh { margin-left: auto; }
.primary-nav .btn-new-task { margin-left: 8px; }

/* In the PR topbar it sits after the subtitle, right-aligned. */
.pr-topbar-refresh { margin-left: auto; }

/* Proposed Action preview block in the PR confirm form */
.proposed-action-preview {
  margin-top: 16px;
  background: var(--blue-bg);              /* light-blue tint distinguishes from Source Email */
  border: 1px solid var(--blue-light);
  border-radius: var(--radius);
  overflow: hidden;
}
.proposed-action-preview .source-email-toggle { color: var(--navy); }
.proposed-action-preview .source-email-body {
  background: var(--bg);
  border-top: 1px solid var(--blue-light);
}
.proposed-action-badge {
  margin-left: auto;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  background: var(--blue);
  color: #fff;
  border-radius: var(--radius-pill);
}
.proposed-action-external-badge {
  margin-left: 6px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 7px;
  background: var(--red-text, #c53030);
  color: #fff;
  border-radius: var(--radius-pill);
}
.proposed-action-external-banner {
  background: rgba(197, 48, 48, 0.08);
  border-left: 3px solid var(--red-text, #c53030);
  color: var(--text-primary);
  font-size: 12.5px;
  line-height: 1.5;
  padding: 8px 12px;
  margin-bottom: 12px;
  border-radius: var(--radius-sm);
}
.proposed-action-external-banner strong { color: var(--red-text, #c53030); }
.proposed-action-reasoning {
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-bottom: 10px;
  line-height: 1.5;
}
.proposed-action-reasoning strong { color: var(--text-primary); }
.proposed-action-draft {
  font-family: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 0 0 8px 0;
  white-space: pre-wrap;
  word-break: break-word;
}
.proposed-action-note {
  font-size: 11.5px;
  color: var(--text-muted);
  font-style: italic;
}

/* Inline source meta on task cards — shown below the description */
.td-source-meta {
  margin-top: 4px;
  font-size: 11.5px;
  color: var(--text-secondary);
  font-weight: 400;
  line-height: 1.4;
}
.td-source-link {
  color: var(--blue);
  text-decoration: none;
  font-weight: 500;
}
.td-source-link:hover { text-decoration: underline; }
.td-source-sep { color: var(--text-muted); }

.signin-card {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 48px 40px;
  max-width: 420px;
  width: 90%;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}
.signin-logo-plate {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--navy);              /* Pine Teal — so the white logo reads */
  padding: 16px 26px;
  border-radius: var(--radius-lg);
  margin-bottom: 6px;
}
.signin-logo {
  width: 140px;
  height: auto;
  display: block;
}
.signin-title {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 400;                   /* Cal Sans single weight */
  letter-spacing: 0;
  color: var(--text-heading);         /* Prussian Blue */
  margin: 0;
}
.signin-sub {
  font-size: 13.5px;
  color: var(--text-secondary);
  margin: 0;
}
.signin-btn {
  margin-top: 8px;
  padding: 10px 24px;
  font-size: 14px;
  gap: 8px;
  display: inline-flex;
  align-items: center;
}
.signin-btn svg { width: 16px; height: 16px; }
.signin-error {
  font-size: 12.5px;
  color: #E45938;
  margin: 0;
}
.signin-error.hidden { display: none; }

/* ── User pill in header ─────────────────────────────────────────────────── */
.user-pill {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: var(--radius-pill);
  padding: 5px 13px 5px 9px;
}
.user-pill svg { width: 16px; height: 16px; opacity: 0.8; }
.user-pill.hidden { display: none; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
  background: var(--navy);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s, transform 0.2s;
  max-width: 360px;
  line-height: 1.4;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: var(--green); }
.toast.amber   { background: var(--amber-dark); }
.toast.error   { background: #E45938; }

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #D9D5CC; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9A9A96; }

/* ── Misc ────────────────────────────────────────────────────────────────── */
.divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}

/* SP priority/status in header */
#main-header .priority-badge,
#main-header .status-badge { font-size: 11px; }

.sp-header .priority-badge,
.sp-header .status-badge { font-size: 11.5px; }

/* ── Completed tab: search + month accordion ─────────────────────────────── */
.completed-search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
}
.completed-search-icon {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.completed-search-input {
  flex: 1;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.completed-search-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-bg);
}
.completed-search-input::placeholder { color: var(--text-muted); }
.completed-search-clear {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.completed-search-clear:hover { background: var(--bg-hover); color: var(--text-primary); }
.completed-search-clear svg { width: 14px; height: 14px; }

.completed-accordion {
  padding: 16px 24px 40px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.completed-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

.month-section {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.month-section.hidden-empty { display: none; }

.month-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 14px 18px;
  background: var(--bg);
  border: none;
  border-bottom: 1px solid transparent;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.month-header:hover { background: var(--bg-hover); }
.month-section.expanded .month-header { border-bottom-color: var(--border); }
.month-header-caret {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform 0.2s;
}
.month-section.expanded .month-header-caret { transform: rotate(90deg); }
.month-header-label { flex: 1; }
.month-header-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-secondary);
  padding: 2px 10px;
  border-radius: var(--radius-pill);
}

.month-body { display: none; }
.month-section.expanded .month-body { display: block; }
.month-body table { width: 100%; border-collapse: collapse; }
.month-body thead th {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  text-align: left;
}
.month-body tbody tr { border-bottom: 1px solid var(--border-light); }
.month-body tbody tr:last-child { border-bottom: none; }
.month-body tbody tr:hover { background: var(--bg-hover); cursor: pointer; }
.month-body tbody tr.row-hidden { display: none; }
.month-body td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--text-primary);
  vertical-align: middle;
}

/* Per-row delete button (manager only) */
.btn-delete-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.btn-delete-row svg { width: 14px; height: 14px; }
.btn-delete-row:hover {
  background: #FBDCD2;
  border-color: #F4A48F;
  color: var(--red-text);
}
.btn-delete-row:disabled { opacity: 0.5; cursor: wait; }

.td-actions { white-space: nowrap; text-align: right; }
.td-actions > * + * { margin-left: 6px; }

/* ── Source Email disclosure (Pending Review confirm form) ───────────────── */
.source-email {
  margin-top: 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.source-email-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s;
}
.source-email-toggle:hover { background: var(--bg-hover); }
.source-email-caret {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
  transition: transform 0.2s;
}
.source-email[data-expanded="true"] .source-email-caret { transform: rotate(90deg); }
.source-email-body {
  padding: 12px 14px 14px;
  border-top: 1px solid var(--border);
  background: var(--bg);
}
.source-email-subject {
  font-weight: 700;
  font-size: 14px;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.source-email-meta {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}
.source-email-excerpt {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
}
.source-email-more {
  margin-top: 8px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.source-email-more:hover { color: var(--text-primary); background: var(--bg-hover); }

/* ── Email Thread side-panel tab ─────────────────────────────────────────── */
.sp-email-thread {
  padding: 14px 20px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sp-email-subject {
  font-weight: 700;
  font-size: 14.5px;
  color: var(--text-primary);
  line-height: 1.4;
}
.sp-email-meta {
  font-size: 12.5px;
  color: var(--text-secondary);
}
.sp-email-body {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-primary);
  white-space: pre-wrap;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-height: 320px;
  overflow-y: auto;
}
.sp-email-open {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
}
.sp-email-open svg { width: 14px; height: 14px; }
.sp-email-note {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Search term highlight within completed rows — Golden Sand per Anka brand */
.completed-accordion mark {
  background: var(--amber);
  color: var(--text-primary);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: inherit;
}

/* Pending Review confirm form: task type pill toggle + edit grid */
.pref-type-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 3px;
  margin-bottom: 16px;
}
.pref-type-btn {
  padding: 6px 18px;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.pref-type-btn:hover { color: var(--text-primary); }
.pref-type-btn.active {
  background: var(--bg);
  color: var(--blue);
  box-shadow: var(--shadow-sm);
}

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

/* Description cells / titles preserve line breaks and bullets from stored plain text */
.td-description,
.sp-title,
.sp-closed-title,
.pr-field-value,
.sp-meta-row ~ .sp-tab-content .sp-note-input {
  white-space: pre-wrap;
}
#tasks-table .td-description {
  /* Don't let newlines push the row absurdly tall in the grid — cap visible
     lines; full text still shows in the side panel when the row is clicked. */
  max-width: 520px;
}

/* Quill container — wrap the rich editor so its borders match the Soft Product form palette */
.pref-quill,
.sp-quill {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  font-family: inherit;
}
.pref-quill .ql-toolbar,
.sp-quill .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: var(--bg-secondary);
  padding: 6px 8px;
}
.pref-quill .ql-container,
.sp-quill .ql-container {
  border: none;
  font-family: inherit;
  font-size: 14px;
  min-height: 120px;
}
.pref-quill .ql-editor,
.sp-quill .ql-editor {
  min-height: 120px;
  padding: 10px 12px;
  color: var(--text-primary);
  line-height: 1.55;
}
.pref-quill .ql-editor.ql-blank::before,
.sp-quill .ql-editor.ql-blank::before {
  color: var(--text-muted);
  font-style: normal;
}
