/* ---------- Font (self-hosted, no third-party requests) ---------- */
@font-face {
  font-family: "Montserrat";
  src: url("../fonts/Montserrat-VariableFont_wght.4d444017fdf9.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Montserrat";
  src: url("../fonts/Montserrat-Italic-VariableFont_wght.1cd1b7e6ec79.ttf") format("truetype");
  font-weight: 100 900;
  font-style: italic;
  font-display: swap;
}


/* ---------- Brand tokens: change a value here, it changes everywhere ---------- */
:root {
  /* Core brand */
  --cream: #f7f1eb;
  --teal: #00687a;
  --rust-brand: #c95517;  /* logo and large decorative uses only */
  --rust: #b94e15;        /* interface rust: meets contrast standards on white and cream */
  --ink: #1d1e1f;

  /* Supporting shades */
  --white: #ffffff;
  --teal-deep: #00505e;   /* hover states, text on teal tint */
  --rust-deep: #a8440f;   /* text on rust tint (meets contrast) */
  --teal-tint: #d9ebee;
  --teal-wash: #eef6f7;   /* very light teal for large calm areas, like the drop zone */
  --teal-soft: #7fb3bd;   /* lighter teal for dashed borders */
  /* Status: warnings use union gold, so rust can be the brand color */
  --gold: #7a5810;        /* warning text, icons, borders (5.6:1 on the gold tint) */
  --gold-tint: #f8ecd2;   /* warning background */
  --gold-line: #ead39f;   /* thin dividers inside warning boxes */
  --rust-tint: #fbe6da;
  --surface: #f4f0ec;     /* soft tiles inside cards */
  --border: #e3ddd6;
  --muted: #67615b;       /* secondary text: meets contrast standards, including on tints */

  /* Type scale: change a size here and it changes everywhere it's used */
  --text-2xs: 10px;   /* tiny labels, like ORGANIZATION */
  --text-xs: 11px;    /* pills, roles, initials */
  --text-sm: 12px;    /* supporting text: meta lines, labels, buttons, links */
  --text-base: 13px;  /* body text, inputs, outline */
  --text-read: 14px;  /* contract language: kept larger for long reading */
  --text-lg: 16px;    /* pop-up titles */
  --text-xl: 20px;    /* page titles */

  /* Type and shape */
  --font: "Montserrat", system-ui, sans-serif;
  --radius: 14px;
  --radius-sm: 8px;
}

/* ---------- Layout ---------- */
* { box-sizing: border-box; }

body {
  margin: 0;
  display: flex;
  min-height: 100vh; 
  font-family: var(--font);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--cream);
  -webkit-font-smoothing: antialiased;
}

.sidebar {
  width: 220px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 32px 20px;
  background: var(--white);
  border-right: 1px solid var(--border);
}

.logo img {
  display: block;
  width: 140px;
  margin: 0 0 36px 8px;
}

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

.nav-item {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--surface); color: var(--ink); }
.nav-item.is-active { color: var(--white); background: var(--rust); }

.main {
  flex: 1;
  max-width: 1040px;
  padding: 40px 48px;
}

/* ---------- Cards and headings ---------- */
.card {
  margin-bottom: 20px;
  padding: 24px 28px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

h1 { margin: 0; font-size: var(--text-xl); font-weight: 700; } /* change font size here */

.subtitle { margin: 8px 0 0; font-size: var(--text-sm); color: var(--muted); }

.section-label {
  margin: 0 0 14px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
}

/* ---------- Forms ---------- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 420px;
}

.form label { font-size: var(--text-sm); font-weight: 600; }

.form input[type="text"],
.form input[type="email"],
.form input[type="password"],
.form input[type="date"] {
  max-width: 420px;
  padding: 10px 12px;
  font: inherit;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.form input:focus {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
  border-color: var(--teal);
}

.form input[type="file"] { font: inherit; font-size: var(--text-base); }

.errorlist {
  list-style: none;
  margin: 0 0 12px;
  padding: 10px 14px;
  font-size: var(--text-base);
  color: var(--rust-deep);
  background: var(--rust-tint);
  border-radius: var(--radius-sm);
}

/* ---------- Buttons ---------- */
.button {
  padding: 12px 22px;
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--white);
  background: var(--teal);
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.button:hover { background: var(--teal-deep); }

/* ---------- Lists, pills ---------- */
.row-list { list-style: none; margin: 0; padding: 0; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 10px;
  padding: 16px 18px;
  background: var(--surface);
  border-radius: var(--radius-sm);
}

.row-title { font-weight: 600; color: var(--ink); text-decoration: none; }
.row-title:hover { color: var(--teal); }

.meta { margin-top: 4px; font-size: var(--text-sm); color: var(--muted); }

.pill {
  padding: 6px 12px;
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.06em;
  white-space: nowrap;
  color: var(--teal-deep);
  background: var(--teal-tint);
  border-radius: 999px;
}

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

/* ---------- Page headers ---------- */
.page-header {
  display: flex;
  align-items: center;
  gap: 24px;
}

.page-icon {
  flex-shrink: 0;
  width: 42px;
  height: 52px;
  color: var(--teal);
}

.page-title { letter-spacing: 0; }

/* ---------- Drop zone ---------- */
.field-label { font-size: var(--text-base); font-weight: 600; }

.dropzone {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: 420px;
  padding: 14px 18px;
  background: var(--teal-wash);
  border: 2px dashed var(--teal-soft);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.dropzone:hover,
.dropzone.is-dragging { background: var(--teal-tint); border-color: var(--teal); }
.dropzone.has-file { border-style: solid; border-color: var(--teal); background: var(--teal-wash); }
.dropzone:focus-within { outline: 2px solid var(--teal); outline-offset: 2px; }

/* Keeps the highlight from flickering while dragging over the text */
.dropzone > * { pointer-events: none; }

/* Hidden but still usable by keyboard and screen readers */
.dropzone input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.dropzone-icon { flex-shrink: 0; width: 26px; height: 26px; color: var(--teal); }

.dropzone-text { font-size: var(--text-base); font-weight: 400; color: var(--muted); }
.dropzone-text strong { font-weight: 600; color: var(--ink); }
.dropzone-browse { font-weight: 600; color: var(--teal); text-decoration: underline; }

.dropzone-file {
  display: block;
  margin-top: 2px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--teal-deep);
}
/* ---------- Contract detail ---------- */
.back-link {
  display: inline-block;
  margin-bottom: 12px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
}
.back-link:hover { text-decoration: underline; }

/* Icon-only links, like "open the original contract" */
.icon-link {
  display: inline-flex;
  padding: 6px;
  color: var(--teal);
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.icon-link:hover { background: var(--teal-tint); }
.icon-link svg { width: 20px; height: 20px; }

.header-link { margin-left: auto; align-self: flex-start; }

.notice {
  padding: 12px 16px;
  font-size: var(--text-base);
  color: var(--gold);
  background: var(--gold-tint);
  border-radius: var(--radius-sm);
}

/* "Show extracted text" toggle */
.raw-text summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--teal);
}

.pdf-page {
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}

.page-text {
  margin: 8px 0 0;
  font-family: var(--font);
  font-size: var(--text-read);
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ---------- Sign in ---------- */
.auth-page { align-items: center; justify-content: center; }

.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 32px 32px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-logo { display: block; width: 240px; margin: 0 auto 20px; }

.auth-card .form input { width: 100%; max-width: none; }

.auth-notice {
  margin-bottom: 18px;
  padding: 10px 14px;
  font-size: var(--text-base);
  text-align: center;
  color: var(--teal-deep);
  background: var(--teal-tint);
  border-radius: var(--radius-sm);
}

.button-full { width: 100%; margin-top: 4px; }

/* ---------- Sidebar: organization switcher and account ---------- */
[hidden] { display: none !important; }

.sidebar { display: flex; flex-direction: column; }

.org-switcher { margin-bottom: 18px; }

.org-current {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: border-color 0.15s;
}
.org-current:hover,
.org-current[aria-expanded="true"] { border-color: var(--teal); }
.org-current.is-static { cursor: default; }
.org-current.is-static:hover { border-color: var(--border); }
.org-current svg { flex-shrink: 0; width: 16px; height: 16px; color: var(--muted); }

.org-label {
  display: block;
  font-size: var(--text-2xs);
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.org-name { display: block; font-weight: 600; }

.org-menu {
  margin-top: 6px;
  padding: 6px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.org-search {
  width: 100%;
  margin-bottom: 4px;
  padding: 7px 9px;
  font: inherit;
  font-size: var(--text-sm);
  border: 1px solid var(--border);
  border-radius: 6px;
}
.org-search:focus { outline: 2px solid var(--teal); outline-offset: 0; }

.org-option {
  display: block;
  width: 100%;
  padding: 7px 9px;
  font: inherit;
  text-align: left;
  color: var(--ink);
  background: none;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}
.org-option:hover { background: var(--surface); }
.org-option.is-current { color: var(--teal-deep); background: var(--teal-tint); }
.org-empty { margin: 6px 9px; font-size: var(--text-sm); color: var(--muted); }

.account {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--teal-deep);
  background: var(--teal-tint);
  border-radius: 50%;
}

.account-name { font-size: var(--text-base); font-weight: 600; }
.account-meta { font-size: var(--text-xs); color: var(--muted); }

.inline-form { display: inline; }
.link-button {
  padding: 0;
  font: inherit;
  font-weight: 600;
  color: var(--teal);
  background: none;
  border: none;
  cursor: pointer;
}
.link-button:hover { text-decoration: underline; }

/* ---------- Walls: owner badge, smaller header line, switch page ---------- */
.subtitle-small { font-size: var(--text-sm); }
.header-pill { align-self: flex-start; margin-left: auto; }
.header-pill + .header-link { margin-left: 0; }
.switch-form { margin-top: 18px; }

/* ---------- Contract outline ---------- */
.warning-list { margin: 8px 0 0; padding-left: 20px; }
.warning-list li { margin: 4px 0; }

.outline,
.outline-sections { list-style: none; margin: 0; padding: 0; }

.outline-article + .outline-article {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.outline-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.outline-row:hover { background: var(--surface); }
.outline-row .icon-link { padding: 4px; }
.outline-row .icon-link svg { width: 16px; height: 16px; }

.outline-article-title { font-weight: 700; }

.outline-sections { margin-top: 2px; padding-left: 20px; }

/* ---------- Pop-ups ---------- */
.modal {
  max-width: 420px;
  padding: 32px 28px;
  font-family: var(--font);
  text-align: center;
  color: var(--ink);
  border: none;
  border-radius: var(--radius);
}
.modal::backdrop { background: rgba(29, 30, 31, 0.55); }
.modal-title { margin: 0; font-size: var(--text-lg); font-weight: 700; line-height: 1.35; }
.modal-text { margin: 8px 0 22px; color: var(--muted); }
.modal-cancel {
  display: inline-block;
  margin-top: 14px;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--teal);
  text-decoration: none;
}
.modal-cancel:hover { text-decoration: underline; }

/* ---------- Reading your contract ---------- */
.reading { display: flex; align-items: center; gap: 18px; }
.reading-title { font-size: var(--text-lg); }
.reading.has-error .subtitle { color: var(--rust-deep); }
.reading.has-error .spinner { display: none; }

.spinner {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border: 3px solid var(--teal-tint);
  border-top-color: var(--teal);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 3s; }
}

/* ---------- Fewer boxes: plain page headers, standalone notices ---------- */
.page-header-plain {
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.page-header-plain .page-icon { width: 34px; height: 42px; }
.notice-standalone { margin-bottom: 20px; }

/* ---------- Checks ---------- */
.checks { padding: 14px 16px; }
.checks-title {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  font-size: var(--text-base);
  font-weight: 700;
}
.checks-icon { flex-shrink: 0; width: 16px; height: 16px; }

.check { padding-left: 0; }
.check-links { margin-left: 22px; }
.check + .check { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--gold-line); }
.check-row { display: flex; align-items: center; gap: 16px; margin-top: 2px; }
.check-main { flex: 1; min-width: 0; }
.check-message { margin: 2px 0 0 22px; }

.check-resolve {
  flex-shrink: 0;
  padding: 6px 10px;
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--gold);
  background: var(--white);
  border: 1px solid var(--gold);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.check-resolve:hover { color: var(--white); background: var(--gold); }

/* Notes: text on the left, name and date on the right */
.notes { list-style: none; margin: 8px 0 0; padding: 0; border-top: 1px solid var(--gold-line); }
.note {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 12px;
  padding: 8px 0;
  color: var(--ink);
  border-bottom: 1px solid var(--gold-line);
}
.note-text { margin: 0; }
.note-meta { font-size: var(--text-xs); text-align: right; }
.note-meta strong { display: block; }
.note-meta span { color: var(--muted); }
@media (max-width: 600px) {
  .note { grid-template-columns: 1fr; gap: 2px; }
  .note-meta { order: -1; text-align: left; }
}

.check-links summary {
  width: fit-content;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--teal);
  list-style: none;
  cursor: pointer;
}
.check-links summary::-webkit-details-marker { display: none; }
.note-form[open] summary { display: none; }
.note-actions { display: flex; align-items: center; gap: 12px; margin-top: 6px; }
.button-small { padding: 7px 14px; }

.note-form textarea,
.modal textarea {
  width: 100%;
  padding: 8px 10px;
  font: inherit;
  color: var(--ink);
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 6px;
  resize: vertical;
}
.note-form textarea:focus,
.modal textarea:focus { outline: 2px solid var(--teal); outline-offset: 0; border-color: var(--teal); }

/* Cream pop-ups (applies to every pop-up) */
.modal { background: var(--cream); }
.modal-form { text-align: left; }
.modal-form label { display: block; margin-bottom: 4px; font-size: var(--text-sm); font-weight: 600; }
.modal-form .button { display: block; margin: 14px auto 0; }
.optional { font-weight: 400; color: var(--muted); }

/* Links under each check: "2 notes" and "Add a note"; an opened one drops to its own line */
.check-links { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 16px; margin-top: 8px; }
.check-links details[open] { flex-basis: 100%; order: 2; }
.notes-toggle[open] > summary { margin-bottom: 0; }

/* Resolved checks: a quiet line at the bottom of the page */
.resolved-checks {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.resolved-checks > summary {
  display: flex;
  align-items: center;
  gap: 4px;
  width: fit-content;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--muted);
  list-style: none;
  cursor: pointer;
}
.resolved-checks > summary::-webkit-details-marker { display: none; }
.resolved-checks > summary svg { width: 14px; height: 14px; transition: transform 0.15s; }
.resolved-checks[open] > summary svg { transform: rotate(180deg); }
.resolved-check { padding: 10px 0 10px 18px; font-size: var(--text-sm); }
.resolved-check + .resolved-check { border-top: 1px solid var(--border); }
.resolved-check .check-message { display: flex; gap: 6px; margin-left: 0; }
.resolved-check .check-message svg { flex-shrink: 0; width: 16px; height: 16px; margin-top: 1px; color: var(--teal); }
.resolved-meta { margin: 3px 0 0 22px; font-size: var(--text-xs); color: var(--muted); }
.resolved-check .check-links { margin-left: 22px; }
.resolved-check .notes { border-color: var(--border); }
.resolved-check .note { border-color: var(--border); }

/* ---------- Narrow windows ---------- */
.main { min-width: 0; overflow-wrap: break-word; }  /* lets the page shrink and long text wrap */
.outline-row > span { min-width: 0; }
.icon-link, .pill { flex-shrink: 0; }               /* icons and pills never get squeezed out */

/* "Can't read yet" on the contracts list */
.row-end { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.row-unreadable { background: var(--gold-tint); box-shadow: inset 0 0 0 1px var(--gold-line); }
.unreadable-flag {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: var(--text-sm); font-weight: 600; color: var(--gold); white-space: nowrap;
}
.unreadable-flag svg { width: 18px; height: 18px; }
