:root {
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1a1f24;
  --muted: #5c6770;
  --border: #d8dee4;
  --accent: #2f6b4f;
  --accent-hover: #24543f;
  --error: #b42318;
  --pending: #b54708;
  --progress: #175cd3;
  --scheduled: #5925dc;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

.container {
  width: min(920px, calc(100% - 2rem));
  margin: 0 auto;
}

.container.narrow {
  width: min(420px, calc(100% - 2rem));
  padding: 3rem 0;
}

.site-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0 1rem;
  margin-bottom: 1.5rem;
}

.site-header h1 {
  margin: 0 0 0.25rem;
  font-size: 1.5rem;
}

.header-meta {
  margin: 0.75rem 0 0;
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.25rem 1.35rem;
  margin-bottom: 1rem;
}

.banner {
  border-left: 4px solid var(--accent);
}

h2 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

.muted {
  color: var(--muted);
}

.error {
  color: var(--error);
  font-weight: 600;
}

a {
  color: var(--accent);
}

a:hover {
  color: var(--accent-hover);
}

label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 600;
}

input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 0.85rem;
}

button[type="submit"],
.copy-btn {
  background: var(--accent);
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  font: inherit;
}

button[type="submit"]:hover,
.copy-btn:hover {
  background: var(--accent-hover);
}

.copy-btn.copied {
  background: #067647;
}

.decision-list {
  margin: 0;
  padding-left: 1.1rem;
}

.decision-list li {
  margin-bottom: 0.65rem;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 0.55rem 0.45rem;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
}

.badge {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 999px;
  font-size: 0.82rem;
  background: #eef2f6;
}

.badge-pending {
  background: #fef0c7;
  color: var(--pending);
}

.badge-progress {
  background: #d1e9ff;
  color: var(--progress);
}

.badge-scheduled {
  background: #ebe9fe;
  color: var(--scheduled);
}

.badge-done {
  background: #d3f9d8;
  color: #2b8a3e;
}

.row-done td {
  color: var(--muted);
}

.completed-task-link {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  color: var(--accent);
  text-align: left;
  cursor: pointer;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.row-done .completed-task-link {
  color: var(--accent);
}

.completed-task-link:hover {
  text-decoration-style: solid;
}

.email-lightbox-body {
  padding: 1rem 1.25rem;
}

.email-lightbox-note {
  margin: 0 0 1rem;
}

.email-lightbox-figure {
  margin: 0 0 1rem;
}

.email-lightbox-image {
  display: block;
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.email-lightbox-caption {
  margin-top: 0.35rem;
  font-size: 0.85rem;
}

.email-lightbox-body .email-meta {
  margin: 0 0 1rem;
}

.email-lightbox-body .email-body {
  margin: 0;
  max-height: none;
}

.draft-banner-sent {
  background: #d3f9d8;
  color: #2b8a3e;
}

.email-draft-sent {
  opacity: 0.92;
}

.email-draft {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  margin-top: 1rem;
  background: #fafbfc;
}

.email-draft-hold {
  border-color: #e8d48b;
  background: #fffdf5;
}

.draft-banner {
  margin: 0 0 0.75rem;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.9rem;
  background: #fef0c7;
  color: var(--pending);
}

.email-draft-header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 0.75rem;
}

.email-draft-header h3 {
  margin: 0;
  font-size: 1rem;
}

.email-meta {
  display: grid;
  grid-template-columns: 4rem 1fr;
  gap: 0.25rem 0.75rem;
  margin: 0 0 0.75rem;
  font-size: 0.92rem;
}

.email-meta dt {
  color: var(--muted);
  font-weight: 600;
}

.email-meta dd {
  margin: 0;
}

.email-body {
  margin: 0;
  padding: 0.85rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 6px;
  white-space: pre-wrap;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88rem;
  overflow-x: auto;
}

.copy-icon {
  margin-right: 0.25rem;
}

.toast {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  background: #067647;
  color: #fff;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
}

.doc-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.doc-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0;
  border-bottom: 1px solid var(--border);
}

.doc-item:last-child {
  border-bottom: none;
}

.doc-open {
  flex: 1;
  text-align: left;
  background: none;
  border: none;
  padding: 0.35rem 0.5rem;
  margin: -0.35rem -0.5rem;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
  border-radius: 4px;
}

.doc-open:hover {
  color: var(--accent-hover);
  background: rgba(47, 107, 79, 0.08);
  text-decoration: underline;
}

.doc-newtab {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 6px;
  color: var(--muted);
  text-decoration: none;
  font-size: 1.1rem;
}

.doc-newtab:hover {
  background: var(--bg);
  color: var(--accent);
}

/* Document viewer toolbar (full page) */
.doc-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
}

.doc-toolbar-back,
.doc-toolbar-download {
  color: var(--accent);
  text-decoration: none;
  font-size: 0.95rem;
}

.doc-toolbar-back:hover,
.doc-toolbar-download {
  text-decoration: underline;
}

.doc-toolbar-title {
  flex: 1;
  font-weight: 600;
  min-width: 12rem;
}

.doc-toolbar-download {
  margin-left: auto;
}

/* Lightbox */
body.doc-lightbox-open {
  overflow: hidden;
}

.doc-lightbox {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.doc-lightbox.is-open {
  display: flex;
}

.doc-lightbox[hidden] {
  display: none !important;
}

.doc-lightbox-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(26, 31, 36, 0.55);
}

.doc-lightbox-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(920px, 100%);
  max-height: min(90vh, 900px);
  background: var(--card);
  border-radius: 10px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

.doc-lightbox-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem 1rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  background: #fafbfc;
}

.doc-lightbox-title {
  margin: 0;
  font-size: 1rem;
  flex: 1;
  min-width: 10rem;
}

.doc-lightbox-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.doc-lightbox-actions a {
  color: var(--accent);
  font-size: 0.9rem;
  text-decoration: none;
}

.doc-lightbox-actions a:hover {
  text-decoration: underline;
}

.doc-lightbox-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--muted);
  padding: 0 0.25rem;
}

.doc-lightbox-close:hover {
  background: none;
  color: var(--text);
}

.doc-lightbox-body {
  overflow: auto;
  padding: 1rem 1.25rem 1.5rem;
  flex: 1;
}

.doc-lightbox-content[hidden],
.doc-lightbox-loading[hidden] {
  display: none;
}

.doc-error {
  color: var(--error);
  margin: 0;
}

/* Markdown prose */
.prose {
  max-width: 70ch;
  line-height: 1.6;
}

.prose > :first-child {
  margin-top: 0;
}

.prose > :last-child {
  margin-bottom: 0;
}

.prose h1,
.prose h2,
.prose h3,
.prose h4 {
  line-height: 1.25;
  margin: 1.5rem 0 0.75rem;
}

.prose h1 { font-size: 1.5rem; }
.prose h2 { font-size: 1.25rem; }
.prose h3 { font-size: 1.1rem; }

.prose p,
.prose ul,
.prose ol,
.prose blockquote,
.prose pre,
.prose table {
  margin: 0 0 1rem;
}

.prose ul,
.prose ol {
  padding-left: 1.4rem;
}

.prose li + li {
  margin-top: 0.25rem;
}

.prose a {
  color: var(--accent);
}

.prose .doc-ref-unpublished {
  color: var(--muted);
  cursor: help;
  text-decoration: underline dotted;
}

.prose img {
  max-width: 100%;
  height: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
}

.prose blockquote {
  border-left: 3px solid var(--border);
  margin-left: 0;
  padding-left: 1rem;
  color: var(--muted);
}

.prose code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9em;
  background: #eef2f6;
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.prose pre {
  overflow-x: auto;
  background: #1a1f24;
  color: #f4f6f8;
  padding: 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
}

.prose pre code {
  background: none;
  padding: 0;
  color: inherit;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  display: block;
  overflow-x: auto;
}

.prose th,
.prose td {
  border: 1px solid var(--border);
  padding: 0.45rem 0.6rem;
  text-align: left;
  vertical-align: top;
}

.prose th {
  background: #fafbfc;
  font-weight: 600;
}

.prose hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.5rem 0;
}

@media (max-width: 640px) {
  .email-draft-header {
    flex-direction: column;
  }

  .doc-lightbox {
    padding: 0;
    align-items: stretch;
  }

  .doc-lightbox-panel {
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
  }

  .doc-toolbar-title {
    order: -1;
    width: 100%;
  }
}
