:root {
  --red: #B21F29;
  --red-dark: #8a1820;
  --gray: #595959;
  --light-gray: #f5f5f5;
  --med-gray: #e0e0e0;
  --white: #fff;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 0.82rem;
  color: var(--gray);
  background: var(--light-gray);
}

a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: #aaa; }

/* ---------- Top bar ---------- */
.topbar {
  background: var(--red);
  color: var(--white);
  padding: 0.55rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}
.topbar-left { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; }
.topbar h1 { margin: 0; font-size: 1.35rem; font-weight: 700; }
.synced { font-size: 0.8rem; opacity: 0.85; }
.topbar-right { display: flex; align-items: center; gap: 0.6rem; }
.topbar-right form { margin: 0; }

.btn-refresh {
  background: var(--white); color: var(--red);
  border: none; border-radius: 6px; padding: 0.5rem 1rem;
  font-weight: 600; font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
.btn-refresh:hover { background: #ffe9ea; }
.btn-refresh:disabled { opacity: 0.6; cursor: wait; }
.btn-logout { color: var(--white); font-size: 0.8rem; opacity: 0.9; }
.btn-logout:hover { opacity: 1; }

.btn-share {
  background: transparent; color: var(--white);
  border: 1px solid rgba(255,255,255,0.6); border-radius: 6px;
  padding: 0.5rem 0.9rem; font-weight: 600; font-family: inherit; font-size: 0.85rem; cursor: pointer;
}
.btn-share:hover { background: rgba(255,255,255,0.15); }
.share-view .btn-share { background: var(--white); color: var(--red); border-color: var(--white); }

/* ---------- Share view (privacy) redaction ---------- */
.share-view .item-name,
.share-view td.pii,
.share-view .slack-text {
  filter: blur(6px);
  user-select: none;
  pointer-events: none;
}
.share-view .estate-search-bar { display: none; }

/* ---------- Slack card ---------- */
.slack-list { list-style: none; margin: 0; padding: 0.2rem 0; }
.slack-list li {
  padding: 0.4rem 0.9rem; border-bottom: 1px solid #f0f0f0;
}
.slack-list li:last-child { border-bottom: none; }
.slack-line { display: flex; align-items: center; gap: 0.4rem; }
.slack-tag {
  background: var(--light-gray); border: 1px solid var(--med-gray); color: var(--gray);
  border-radius: 10px; padding: 0.02rem 0.4rem; font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
}
.slack-text {
  font-size: 0.78rem; color: #777; margin-top: 0.15rem; line-height: 1.35;
  overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Quick links ---------- */
.quick-links {
  background: var(--white);
  border-bottom: 1px solid var(--med-gray);
  padding: 0.4rem 1.1rem;
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.4rem;
}
.ql-label { font-weight: 600; color: var(--gray); margin-right: 0.25rem; }
.quick-links a {
  background: var(--light-gray); border: 1px solid var(--med-gray);
  border-radius: 20px; padding: 0.3rem 0.8rem; font-size: 0.8rem; color: var(--gray);
}
.quick-links a:hover { border-color: var(--red); color: var(--red); text-decoration: none; }

/* ---------- Estate search ---------- */
.estate-search-bar {
  background: var(--white);
  border-bottom: 1px solid var(--med-gray);
  padding: 0.55rem 1.1rem;
}
.estate-search-wrap { position: relative; max-width: 520px; }
#estate-search {
  width: 100%; font-family: inherit; font-size: 0.9rem;
  padding: 0.55rem 0.9rem;
  border: 1px solid var(--med-gray); border-radius: 8px;
  color: var(--gray); background: var(--light-gray);
}
#estate-search:focus {
  outline: none; border-color: var(--red); background: var(--white);
  box-shadow: 0 0 0 2px rgba(178, 31, 41, 0.12);
}
.estate-results {
  position: absolute; top: calc(100% + 4px); left: 0; right: 0; z-index: 40;
  background: var(--white); border: 1px solid var(--med-gray); border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 60vh; overflow-y: auto;
}
.es-item {
  display: flex; flex-direction: column; gap: 0.1rem;
  padding: 0.5rem 0.9rem; border-bottom: 1px solid #f0f0f0; color: var(--gray);
}
.es-item:last-child { border-bottom: none; }
.es-item:hover { background: #fdecee; text-decoration: none; }
.es-name { font-weight: 600; color: var(--gray); }
.es-item:hover .es-name { color: var(--red); }
.es-group { font-size: 0.72rem; color: #aaa; }
.es-msg { padding: 0.6rem 0.9rem; color: #999; font-style: italic; font-size: 0.82rem; }

/* ---------- Layout ---------- */
/* Three fixed columns with explicit section placement. */
.container {
  max-width: none; margin: 0.9rem auto; padding: 0 1.1rem;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; align-items: start;
}
.dash-col { min-width: 0; }
@media (max-width: 1400px) { .container { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 950px)  { .container { grid-template-columns: 1fr; } }

.card {
  background: var(--white); border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.07);
  margin-bottom: 0.9rem; overflow: hidden;
}
.card-header {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.9rem; border-bottom: 2px solid var(--med-gray);
}
.card-title { font-size: 0.98rem; font-weight: 700; color: var(--red); }
.count-badge {
  background: var(--red); color: var(--white);
  border-radius: 12px; padding: 0.05rem 0.55rem; font-size: 0.75rem; font-weight: 600;
}

.sub-head {
  padding: 0.5rem 0.9rem 0.2rem; font-weight: 600; color: var(--gray);
  font-size: 0.85rem;
}
.sub-count { color: #aaa; font-weight: 400; }
.sub-collapsible > summary.sub-head {
  cursor: pointer; list-style: none; user-select: none;
  display: flex; align-items: center; gap: 0.4rem;
}
.sub-collapsible > summary.sub-head::-webkit-details-marker { display: none; }
.sub-collapsible > summary.sub-head::before {
  content: "▶"; color: var(--gray); font-size: 0.95rem; line-height: 1;
  display: inline-block; transition: transform 0.15s ease;
}
.sub-collapsible[open] > summary.sub-head::before { transform: rotate(90deg); }
.sub-collapsible > summary.sub-head:hover { color: var(--red, #c0392b); }
.sub-collapsible > summary.sub-head:hover::before { color: var(--red, #c0392b); }
.board-link { display: inline-block; margin: 0.4rem 0.9rem 0.7rem; font-size: 0.8rem; }
.empty { padding: 0.6rem 0.9rem; color: #999; font-style: italic; }

/* ---------- Tables ---------- */
.section-table { width: 100%; border-collapse: collapse; }
.section-table th {
  text-align: left; font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.03em;
  color: #999; font-weight: 600; padding: 0.3rem 0.9rem; border-bottom: 1px solid var(--med-gray);
}
.section-table td {
  padding: 0.32rem 0.9rem; border-bottom: 1px solid #f0f0f0; vertical-align: top;
}
.section-table tr:last-child td { border-bottom: none; }
.col-name { max-width: 340px; }
.item-name { font-weight: 600; color: var(--gray); }
.item-name:hover { color: var(--red); }
.doc-link { font-weight: 600; }
.col-action { width: 40px; text-align: center; }

.status-select, .funds-select {
  font-family: inherit; font-size: 0.76rem; padding: 0.15rem 0.3rem;
  border: 1px solid var(--med-gray); border-radius: 5px; background: var(--white);
  color: var(--gray); max-width: 190px;
}
.status-select:hover, .funds-select:hover { border-color: var(--red); }
.status-select.saving, .funds-select.saving { opacity: 0.5; }

.btn-comment {
  background: none; border: 1px solid var(--med-gray); border-radius: 6px;
  cursor: pointer; padding: 0.25rem 0.4rem; font-size: 0.9rem;
}
.btn-comment:hover { border-color: var(--red); }

.hidden { display: none !important; }

/* ---------- Checklist (To Do) ---------- */
.checklist { list-style: none; margin: 0; padding: 0.3rem 0; }
.check-item {
  display: flex; align-items: flex-start; gap: 0.55rem;
  padding: 0.45rem 0.9rem; border-bottom: 1px solid #f0f0f0;
  transition: opacity 0.3s, transform 0.3s;
}
.check-item:last-child { border-bottom: none; }
.check-item.checking { opacity: 0; transform: translateX(12px); }
.todo-check {
  width: 18px; height: 18px; margin-top: 0.1rem; cursor: pointer;
  accent-color: var(--red); flex-shrink: 0;
}
.check-main { min-width: 0; flex: 1; }
.check-item .item-name { display: block; line-height: 1.3; }
.check-title-row {
  display: flex; align-items: center; gap: 0.5rem; justify-content: space-between;
}
.check-title-row .item-name { flex: 1; min-width: 0; }
.check-title-row .status-select,
.check-title-row .btn-comment { flex-shrink: 0; }
.check-meta {
  display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem;
  margin-top: 0.2rem; font-size: 0.75rem; color: #999;
}
.meta-dod { color: #999; }
.comment-box-wrap { margin-top: 0.4rem; }

.comment-row td { background: var(--light-gray); }
.comment-box { display: flex; gap: 0.5rem; align-items: flex-start; }
.comment-box textarea {
  flex: 1; font-family: inherit; font-size: 0.85rem; padding: 0.5rem;
  border: 1px solid var(--med-gray); border-radius: 6px; min-height: 52px; resize: vertical;
}

.btn-primary {
  background: var(--red); color: var(--white); border: none; border-radius: 6px;
  padding: 0.5rem 1rem; font-weight: 600; font-family: inherit; cursor: pointer; font-size: 0.85rem;
}
.btn-primary:hover { background: var(--red-dark); }
.btn-send { white-space: nowrap; }

/* ---------- Toast ---------- */
.toast {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  background: #333; color: #fff; padding: 0.7rem 1.1rem; border-radius: 8px;
  font-size: 0.85rem; opacity: 0; transform: translateY(10px);
  transition: opacity 0.2s, transform 0.2s; z-index: 50;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { background: var(--red); }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.login-card {
  background: var(--white); padding: 2.5rem; border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,0.1); width: 320px; text-align: center;
}
.login-card h1 { color: var(--red); margin: 0 0 0.2rem; font-size: 1.4rem; }
.login-card .muted { margin: 0 0 1.5rem; }
.login-card input {
  width: 100%; padding: 0.6rem; margin-bottom: 1rem; font-family: inherit;
  border: 1px solid var(--med-gray); border-radius: 6px; font-size: 0.9rem;
}
.login-card .btn-primary { width: 100%; }
.login-error { background: #fdecee; color: var(--red); padding: 0.5rem; border-radius: 6px; margin-bottom: 1rem; font-size: 0.85rem; }

@media (max-width: 768px) {
  .container { padding: 0 0.75rem; }
  .section-table th, .section-table td { padding: 0.5rem 0.7rem; }
}
