:root {
  color-scheme: light;
  --ink: #22241f;
  --muted: #6b716a;
  --line: #dcddd7;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --mist: #f0f1ec;
  --sage: #667765;
  --clay: #a2614d;
  --steel: #384d58;
  --gold: #b69257;
  --danger: #9a4d46;
  --shadow: 0 18px 44px rgba(34, 36, 31, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.chip-button {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: white;
  cursor: pointer;
  display: inline-flex;
  font-weight: 720;
  justify-content: center;
  min-height: 42px;
  padding: 9px 13px;
}

button.secondary {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

button.subtle {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
}

button.danger {
  background: var(--danger);
  border-color: var(--danger);
}

button:disabled,
input:disabled,
select:disabled,
textarea:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-header {
  align-items: center;
  background: rgba(251, 250, 246, 0.95);
  border-bottom: 1px solid var(--line);
  display: grid;
  gap: 18px;
  grid-template-columns: auto 1fr auto;
  padding: 16px clamp(18px, 4vw, 44px);
  position: sticky;
  top: 0;
  z-index: 20;
}

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

.brand-mark {
  align-items: center;
  background: var(--ink);
  border-radius: 50%;
  color: var(--paper);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 780;
  height: 42px;
  justify-content: center;
  width: 42px;
}

.brand strong,
.brand small {
  display: block;
}

.brand small,
.user-switcher,
.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

nav a {
  border-radius: 999px;
  color: var(--muted);
  padding: 8px 12px;
}

nav a:hover,
nav a:focus-visible {
  background: var(--mist);
  color: var(--ink);
}

nav a.active {
  background: var(--ink);
  color: white;
}

.user-switcher {
  display: grid;
  gap: 5px;
  min-width: 230px;
}

.user-switcher strong {
  color: var(--ink);
  font-size: 0.95rem;
}

.user-switcher small {
  color: var(--muted);
}

.sign-out-button {
  justify-self: start;
  min-height: 34px;
  padding: 5px 10px;
}

.user-switcher select,
input,
select,
textarea {
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

textarea {
  resize: vertical;
}

main {
  overflow: hidden;
}

.signed-out .app-header nav,
.signed-out .user-switcher {
  display: none;
}

.auth-shell {
  display: grid;
  min-height: calc(100vh - 74px);
  padding: clamp(28px, 5vw, 72px);
  place-items: center;
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  max-width: 520px;
  padding: clamp(22px, 4vw, 34px);
  width: min(100%, 520px);
}

.auth-card form {
  display: grid;
  gap: 12px;
}

.app-toast {
  background: var(--ink);
  border-radius: 8px;
  bottom: 22px;
  box-shadow: var(--shadow);
  color: white;
  left: 50%;
  max-width: min(90vw, 520px);
  opacity: 0;
  padding: 12px 14px;
  pointer-events: none;
  position: fixed;
  transform: translate(-50%, 12px);
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 100;
}

.app-toast.visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.home-hero,
.page-head {
  display: grid;
  gap: 24px;
  padding: clamp(28px, 4vw, 46px) clamp(18px, 4vw, 44px) 28px;
}

.home-hero {
  align-items: end;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 0.8fr);
}

.page-head {
  align-items: end;
  border-bottom: 1px solid var(--line);
  grid-template-columns: minmax(0, 1fr) auto;
}

.home-copy {
  max-width: 840px;
}

address {
  color: var(--steel);
  font-size: 1.06rem;
  font-style: normal;
  font-weight: 760;
  margin-top: 22px;
}

.house-visual {
  aspect-ratio: 4 / 3;
  background: var(--mist);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.house-visual iframe {
  border: 0;
  height: 100%;
  width: 100%;
}

.button-link {
  align-items: center;
  background: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  color: white;
  display: inline-flex;
  font-weight: 720;
  justify-content: center;
  min-height: 42px;
  padding: 9px 13px;
}

.dashboard {
  align-items: end;
  display: grid;
  gap: 34px;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 520px);
  padding: clamp(28px, 4vw, 46px) clamp(18px, 4vw, 44px) 28px;
}

.dashboard-copy {
  max-width: 820px;
}

.eyebrow {
  color: var(--clay);
  font-size: 0.75rem;
  font-weight: 780;
  letter-spacing: 0.08em;
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.35rem, 3vw, 3rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.05;
  margin-bottom: 14px;
}

h2 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 2vw, 1.85rem);
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.08;
  margin-bottom: 0;
}

h3 {
  font-size: 1.02rem;
  margin-bottom: 8px;
}

.dashboard p:not(.eyebrow),
.form-head p,
.section-heading p {
  color: var(--muted);
  line-height: 1.62;
}

.status-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.status-grid article {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 132px;
  padding: 20px;
}

.status-grid span {
  color: var(--muted);
  display: block;
  font-size: 0.78rem;
  font-weight: 760;
  margin-bottom: 14px;
  text-transform: uppercase;
}

.status-grid strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 3rem;
  font-weight: 500;
}

.workspace-section {
  padding: clamp(44px, 6vw, 78px) clamp(18px, 4vw, 44px);
}

.section-card-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

.section-card,
.user-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 9px;
  min-height: 150px;
  padding: 18px;
}

.section-card span,
.user-card span,
.user-card small,
.empty-state p {
  color: var(--muted);
  line-height: 1.48;
}

.paper-band {
  background: #f0eee7;
  border-block: 1px solid var(--line);
}

.section-heading {
  align-items: end;
  display: flex;
  gap: 22px;
  justify-content: space-between;
  margin-bottom: 22px;
}

.toolbar,
.entry-form {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 14px;
  margin-bottom: 16px;
  padding: 16px;
}

.toolbar {
  grid-template-columns: 220px 220px minmax(220px, 1fr);
}

label {
  color: var(--muted);
  display: grid;
  font-size: 0.84rem;
  gap: 7px;
}

.entry-form {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.entry-form.compact {
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
}

.form-head {
  grid-column: 1 / -1;
}

.form-head h3 {
  margin-bottom: 2px;
}

.form-head p {
  margin-bottom: 0;
}

.wide {
  grid-column: span 2;
}

.inline-fields {
  display: grid;
  gap: 14px;
  grid-column: span 2;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.entry-form button {
  align-self: end;
}

.decision-list,
.invite-list {
  display: grid;
  gap: 12px;
}

.document-card,
.invite-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(34, 36, 31, 0.05);
  padding: 18px;
}

.decision-table-wrap,
.access-table-wrap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 26px rgba(34, 36, 31, 0.05);
  overflow-x: auto;
}

.decision-table,
.access-table {
  border-collapse: collapse;
  min-width: 1040px;
  width: 100%;
}

.access-table {
  min-width: 1180px;
}

.decision-table th,
.decision-table td,
.access-table th,
.access-table td {
  border-bottom: 1px solid var(--line);
  padding: 14px 12px;
  text-align: left;
  vertical-align: top;
}

.decision-table th,
.access-table th {
  background: var(--mist);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 780;
  text-transform: uppercase;
}

.decision-table th input,
.decision-table th select {
  font-size: 0.84rem;
  min-height: 36px;
  text-transform: none;
}

.filter-row th {
  background: #f7f6f1;
  padding: 8px;
}

.sort-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  justify-content: flex-start;
  min-height: 0;
  padding: 0;
  text-transform: uppercase;
}

.table-hint {
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 500;
  padding: 8px 0;
  text-transform: none;
}

.decision-row {
  cursor: pointer;
}

.decision-row:hover td,
.decision-row:focus td {
  background: #faf8f1;
}

.decision-table td strong,
.decision-table td small,
.access-table td strong,
.access-table td small {
  display: block;
}

.decision-table td small,
.access-table td small {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 5px;
}

.decision-detail-row td {
  background: #fbfaf6;
  padding: 0;
}

.decision-detail {
  display: grid;
  gap: 12px;
  padding: 14px 16px 18px;
}

.decision-detail > div > span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.decision-detail p {
  color: var(--muted);
  line-height: 1.5;
  margin-bottom: 0;
}

.detail-note {
  background: var(--mist);
  border-radius: 6px;
  padding: 12px;
}

.detail-note span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 250px;
}

.table-actions select {
  flex: 1 1 130px;
}

.table-actions button {
  min-height: 38px;
  padding: 7px 10px;
}

.card-title-row {
  align-items: start;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.meta {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  font-size: 0.84rem;
  gap: 9px;
  margin-bottom: 10px;
}

.status {
  border-radius: 999px;
  color: white;
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 780;
  padding: 7px 10px;
  white-space: nowrap;
}

.status.open {
  background: var(--clay);
}

.status.needs-pricing,
.status.needs-owner-approval {
  background: var(--gold);
  color: #211d12;
}

.status.approved,
.status.closed {
  background: var(--sage);
}

.status.changed {
  background: var(--steel);
}

.role-pill {
  background: var(--mist);
  border-radius: 999px;
  color: var(--ink);
  display: inline-flex;
  font-size: 0.76rem;
  font-weight: 780;
  padding: 7px 10px;
  text-transform: capitalize;
}

.role-pill.admin {
  background: var(--steel);
  color: white;
}

.role-pill.contributor {
  background: var(--gold);
  color: #211d12;
}

.role-pill.viewer {
  background: var(--sage);
  color: white;
}

.detail-grid {
  display: grid;
  gap: 9px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.detail-grid div,
.comment {
  background: var(--mist);
  border-radius: 6px;
  padding: 10px;
}

.detail-grid span,
.comment small {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
  margin-bottom: 3px;
}

.side-actions {
  align-content: start;
  display: grid;
  gap: 8px;
}

.side-actions select {
  margin-bottom: 4px;
}

.permission-note {
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.comments {
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  padding-top: 14px;
}

.comments h4 {
  margin: 0 0 8px;
}

.comment-list {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.comment-form {
  display: grid;
  gap: 8px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.document-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.drop-zone {
  align-items: center;
  background: var(--panel);
  border: 1px dashed var(--sage);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 6px;
  justify-items: center;
  margin-bottom: 18px;
  min-height: 160px;
  padding: 24px;
  text-align: center;
}

.drop-zone strong {
  color: var(--ink);
}

.drop-zone.dragging {
  background: #f6f4ec;
  border-color: var(--clay);
}

.drop-zone.disabled {
  opacity: 0.55;
}

#fileInput {
  display: none;
}

.media-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.media-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.media-card h3,
.media-card p {
  padding-left: 18px;
  padding-right: 18px;
}

.media-card p {
  color: var(--muted);
  line-height: 1.5;
  padding-bottom: 20px;
}

.placeholder {
  align-items: center;
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(135deg, rgba(56, 77, 88, 0.9), rgba(102, 119, 101, 0.76)),
    repeating-linear-gradient(90deg, transparent 0 22px, rgba(255, 255, 255, 0.1) 22px 23px);
  color: white;
  display: flex;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.6rem, 4vw, 3.2rem);
  justify-content: center;
  margin-bottom: 18px;
}

.document-card {
  display: grid;
  gap: 14px;
}

.file-preview {
  background: var(--mist);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  min-height: 170px;
  overflow: hidden;
  padding: 0;
}

.file-preview img,
.file-preview iframe,
.large-preview img,
.large-preview iframe,
.pending-preview-frame img,
.pending-preview-frame iframe {
  border: 0;
  display: block;
  height: 100%;
  object-fit: cover;
  width: 100%;
}

.file-icon {
  align-items: center;
  background: linear-gradient(135deg, rgba(56, 77, 88, 0.12), rgba(166, 97, 77, 0.14));
  display: flex;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.8rem;
  height: 100%;
  justify-content: center;
  min-height: 170px;
  width: 100%;
}

.upload-preview {
  align-items: center;
  background: var(--mist);
  border-radius: 8px;
  display: grid;
  gap: 12px;
  grid-template-columns: 150px minmax(0, 1fr);
  min-height: 120px;
  padding: 12px;
}

.pending-preview-frame {
  aspect-ratio: 4 / 3;
  background: white;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.upload-preview small {
  color: var(--muted);
  display: block;
  margin-top: 4px;
}

.large-preview {
  background: var(--mist);
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 65vh;
  min-height: 280px;
  overflow: auto;
}

.large-preview img {
  height: auto;
  max-height: 65vh;
  object-fit: contain;
}

.large-preview iframe {
  min-height: 65vh;
}

.version-list {
  border-top: 1px solid var(--line);
  display: grid;
  gap: 8px;
  padding-top: 12px;
}

.version-row {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.official {
  color: var(--sage);
  font-size: 0.78rem;
  font-weight: 780;
  text-transform: uppercase;
}

.invite-card {
  align-items: center;
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(0, 1fr) auto;
}

.invite-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.modal {
  background: transparent;
  border: 0;
  max-width: min(760px, calc(100vw - 28px));
  padding: 0;
  width: 100%;
}

.modal::backdrop {
  background: rgba(34, 36, 31, 0.46);
}

.modal-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  padding: 18px;
}

.modal-head {
  align-items: start;
  display: flex;
  gap: 20px;
  justify-content: space-between;
}

.modal-head h2 {
  font-size: clamp(1rem, 2vw, 1.3rem);
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.icon-button {
  min-height: 38px;
}

details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

summary {
  cursor: pointer;
  font-weight: 720;
}

footer {
  color: var(--muted);
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  padding: 26px clamp(18px, 4vw, 44px);
}

@media (max-width: 980px) {
  .app-header,
  .home-hero,
  .page-head,
  .dashboard,
  .toolbar,
  .entry-form,
  .entry-form.compact,
  .document-grid,
  .media-grid,
  .section-card-grid,
  .user-grid {
    grid-template-columns: 1fr;
  }

  .decision-table-wrap,
  .access-table-wrap {
    overflow: visible;
  }

  .decision-table,
  .access-table {
    border-collapse: separate;
    border-spacing: 0 12px;
    min-width: 0;
  }

  .decision-table thead {
    display: block;
  }

  .decision-table,
  .decision-table tbody,
  .decision-table thead,
  .decision-table tr,
  .decision-table th,
  .decision-table td,
  .access-table,
  .access-table tbody,
  .access-table thead,
  .access-table tr,
  .access-table th,
  .access-table td {
    display: block;
    width: 100%;
  }

  .access-table thead {
    display: none;
  }

  .decision-table thead tr:first-child {
    display: none;
  }

  .filter-row {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    margin-bottom: 12px;
    padding: 8px;
  }

  .filter-row th {
    border-bottom: 0;
  }

  .decision-row,
  .access-table tbody tr {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
  }

  .decision-table td,
  .access-table td {
    align-items: start;
    border-bottom: 1px solid var(--line);
    display: grid;
    gap: 10px;
    grid-template-columns: 110px minmax(0, 1fr);
    padding: 12px;
  }

  .decision-table td::before,
  .access-table td::before {
    color: var(--muted);
    content: attr(data-label);
    font-size: 0.75rem;
    font-weight: 780;
    text-transform: uppercase;
  }

  .table-actions {
    min-width: 0;
  }

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

  .access-table {
    border-collapse: collapse;
    display: table;
    min-width: 920px;
  }

  .access-table thead {
    display: table-header-group;
  }

  .access-table tbody {
    display: table-row-group;
  }

  .access-table tr,
  .access-table tbody tr {
    border: 0;
    display: table-row;
  }

  .access-table th,
  .access-table td {
    display: table-cell;
    width: auto;
  }

  .access-table td {
    padding: 12px;
  }

  .access-table td::before {
    content: none;
  }

  nav {
    justify-content: flex-start;
  }

  .section-heading,
  .card-title-row,
  .invite-card {
    align-items: flex-start;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .wide,
  .inline-fields {
    grid-column: auto;
  }
}

@media (max-width: 560px) {
  .app-header {
    position: static;
  }

  h1 {
    font-size: 1.35rem;
  }

  .status-grid,
  .inline-fields,
  .comment-form,
  .detail-grid,
  .upload-preview {
    grid-template-columns: 1fr;
  }

  .invite-actions {
    width: 100%;
  }

  .invite-actions button {
    width: 100%;
  }
}
