:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #64748b;
  --line: #d8dee8;
  --surface: #ffffff;
  --soft: #f4f7fb;
  --brand: #006f8f;
  --brand-strong: #004b62;
  --accent: #e2a13b;
  --ok: #18794e;
  --danger: #b42318;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background: var(--soft);
  color: var(--ink);
}

button,
input,
textarea,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  letter-spacing: 0;
}

h2 {
  font-size: 1rem;
  letter-spacing: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  min-height: 76px;
  align-items: center;
  padding: 14px 28px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  place-items: center;
  border-radius: 8px;
  background: var(--brand);
  color: #fff;
  font-weight: 800;
}

.brand span,
.page-heading p,
.summary span,
.timeline span,
.evidence dt,
.detail-fields span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

main {
  width: min(1440px, calc(100% - 32px));
  margin: 24px auto 56px;
}

.view {
  display: none;
}

.view.active,
.admin-page {
  display: block;
}

.is-hidden {
  display: none !important;
}

.panel,
.client-document {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 36px rgba(15, 23, 42, 0.06);
}

.admin-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.admin-sidebar {
  position: sticky;
  top: 100px;
  display: flex;
  min-height: calc(100vh - 126px);
  flex-direction: column;
  gap: 24px;
  border-radius: 8px;
  background: #102c37;
  color: #fff;
  padding: 22px;
}

.admin-sidebar h1 {
  margin: 6px 0 8px;
  font-size: 2.1rem;
}

.admin-sidebar p {
  color: #bfd0d7;
}

.admin-kicker,
.eyebrow {
  color: #d58b1f;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.admin-menu {
  display: grid;
  gap: 7px;
}

.admin-menu button,
.sidebar-button {
  min-height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: transparent;
  color: #fff;
  padding: 0 12px;
  text-align: left;
  font-weight: 750;
}

.admin-menu button:hover,
.admin-menu button.active,
.sidebar-button:hover {
  background: rgba(255, 255, 255, 0.1);
}

.sidebar-button {
  margin-top: auto;
  text-align: center;
}

.admin-content {
  min-width: 0;
}

.page-heading {
  display: flex;
  min-height: 92px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.page-heading .eyebrow {
  display: block;
  margin-bottom: 8px;
}

.page-heading p {
  margin-bottom: 0;
}

.primary,
.secondary,
.icon-button {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  font-weight: 750;
}

.primary {
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
}

.primary:hover {
  background: var(--brand-strong);
}

.primary:disabled,
.secondary:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.secondary,
.icon-button {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
}

.secondary.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  margin-bottom: 16px;
  font-weight: 750;
}

.dashboard {
  display: grid;
  gap: 12px;
  margin-bottom: 18px;
}

.dashboard-five {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.metric {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 17px;
}

.metric span {
  color: var(--muted);
  font-size: 0.9rem;
}

.metric strong {
  display: block;
  margin-top: 7px;
  font-size: 2rem;
  line-height: 1;
}

.activity-panel,
.quote-list-panel,
.form-panel,
.detail-panel,
.side-panel,
.template-nav,
.template-editor {
  padding: 22px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.section-head h2 {
  margin: 0;
}

.recent-list,
.quote-list {
  display: grid;
  gap: 8px;
}

.archive-toolbar {
  display: grid;
  grid-template-columns: 220px minmax(260px, 1fr);
  gap: 12px;
  margin-bottom: 12px;
}

.template-workspace {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.template-nav {
  position: sticky;
  top: 100px;
}

.template-list {
  display: grid;
  gap: 8px;
}

.template-list-button {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  text-align: left;
}

.template-list-button:hover,
.template-list-button.active {
  border-color: var(--brand);
  background: #f0fafc;
}

.template-list-button span {
  color: var(--muted);
  font-size: 0.8rem;
}

.template-editor .section-head h2 {
  margin: 6px 0 0;
  font-size: 1.35rem;
}

.template-note,
.template-picker {
  border-left: 4px solid var(--accent);
  border-radius: 4px;
  background: #fff8e9;
  padding: 14px 16px;
  color: #624718;
  line-height: 1.5;
}

.template-picker {
  display: grid;
  grid-template-columns: minmax(240px, 420px) minmax(0, 1fr);
  align-items: end;
  gap: 18px;
  margin-bottom: 20px;
}

.template-picker p {
  margin: 0 0 11px;
  color: #72582a;
  font-size: 0.9rem;
}

.save-message {
  align-self: center;
  color: var(--ok);
  font-weight: 750;
}

.settings-form {
  display: grid;
  gap: 18px;
}

.settings-section {
  padding: 22px;
}

.settings-section .section-head h2 {
  margin: 6px 0 0;
  font-size: 1.35rem;
}

.settings-help {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.input-with-suffix {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.input-with-suffix input {
  border: 0;
  border-radius: 0;
}

.input-with-suffix > span {
  padding-right: 13px;
  color: var(--muted);
  font-weight: 500;
}

label {
  display: grid;
  gap: 7px;
  color: var(--brand-strong);
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 12px 13px;
  font-weight: 500;
}

textarea {
  resize: vertical;
  line-height: 1.5;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

form > label {
  margin-top: 16px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.quote-table-head,
.quote-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 125px 105px 110px 150px;
  gap: 12px;
  align-items: center;
}

.quote-table-head {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.quote-row {
  width: 100%;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px 12px;
  color: var(--ink);
}

.quote-row:hover {
  border-color: var(--brand);
  background: #f7fcfd;
}

.quote-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.compact-row {
  grid-template-columns: minmax(240px, 1fr) 125px 105px 110px 150px;
}

.quote-name-button {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  padding: 0;
  text-align: left;
}

.quote-name-button:hover strong {
  color: var(--brand);
}

.row-actions {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.row-action {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 0 9px;
  color: var(--brand);
  font-weight: 750;
}

.trash-action {
  color: var(--danger);
}

.trash-table-head,
.trash-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 140px 180px 100px;
  gap: 12px;
  align-items: center;
}

.trash-table-head {
  padding: 0 12px 10px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 750;
  text-transform: uppercase;
}

.trash-row {
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}

.trash-row small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
}

.status-badge {
  display: inline-flex;
  width: max-content;
  min-height: 32px;
  align-items: center;
  border-radius: 999px;
  padding: 0 11px;
  font-size: 0.86rem;
  font-weight: 800;
  white-space: nowrap;
}

.status-badge.draft {
  background: #edf1f5;
  color: #475569;
}

.status-badge.sent {
  background: #fff0cf;
  color: #805000;
}

.status-badge.signed {
  background: #dcf5e8;
  color: var(--ok);
}

.status-badge.rejected {
  background: #fee7e5;
  color: var(--danger);
}

.status-badge.invoiced {
  background: #e5eafa;
  color: #3646a3;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 18px;
  align-items: start;
}

.detail-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.detail-fields div {
  min-width: 0;
  background: #fff;
  padding: 14px;
}

.detail-fields strong {
  display: block;
  margin-top: 4px;
  overflow-wrap: anywhere;
}

.legal-preview h2 {
  margin: 24px 0 8px;
}

pre {
  margin: 0;
  color: #263445;
  font: inherit;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.link-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  margin-top: 14px;
}

.full-width {
  width: 100%;
  margin-top: 10px;
}

.timeline,
.evidence {
  display: grid;
  gap: 14px;
  margin: 20px 0 0;
}

.timeline div,
.evidence div {
  border-top: 1px solid var(--line);
  padding-top: 13px;
}

.evidence dd {
  margin: 4px 0 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.side-panel > h2:not(:first-child) {
  margin-top: 26px;
}

.login-shell {
  display: grid;
  min-height: calc(100vh - 160px);
  place-items: center;
}

.login-panel {
  display: grid;
  gap: 16px;
  width: min(450px, 100%);
  padding: 28px;
}

.login-panel h1 {
  font-size: 2rem;
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-weight: 750;
}

.muted {
  color: var(--muted);
}

.empty-copy {
  padding: 18px 6px;
  margin: 0;
}

.client-mode {
  background: #eef3f6;
}

.client-mode main {
  width: min(1040px, calc(100% - 32px));
  margin-top: 36px;
}

.client-document {
  padding: 28px;
}

.document-head,
.document-grid {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.document-grid {
  margin-top: 34px;
}

.document-grid > section {
  flex: 1;
  min-width: 0;
}

.document-main-title {
  width: 100%;
  margin: 34px 0 18px;
  font-size: clamp(2.6rem, 5vw, 3.7rem);
  line-height: 1.05;
  white-space: nowrap;
}

.document-section-title {
  margin: 30px 0 14px;
  font-size: clamp(1.65rem, 3vw, 2.15rem);
  line-height: 1.15;
}

.document-grid .document-section-title {
  margin-top: 0;
}

.document-grid p {
  line-height: 1.6;
}

.summary {
  display: grid;
  width: min(320px, 100%);
  gap: 12px;
  border-left: 4px solid var(--accent);
  border-radius: 8px;
  background: #fffaf1;
  padding: 16px;
}

.legal-block,
.acceptance {
  margin-top: 24px;
  border-top: 1px solid var(--line);
  padding-top: 22px;
}

.client-document .legal-block pre {
  column-count: 2;
  column-gap: 34px;
  column-rule: 1px solid var(--line);
  font-size: 0.78rem;
  line-height: 1.35;
  text-align: justify;
}

.client-document .legal-block h2 {
  font-size: 1.15rem;
  margin-bottom: 10px;
}

.check-row {
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: start;
  margin-bottom: 12px;
  color: var(--ink);
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--brand);
}

.client-actions {
  justify-content: flex-end;
}

.locked-notice {
  margin-top: 22px;
  border-left: 4px solid var(--ok);
  border-radius: 4px;
  background: #edf9f3;
  padding: 14px 16px;
  color: #155f3e;
  font-weight: 750;
}

.evidence.compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.empty-state {
  display: grid;
  justify-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 48px 24px;
  text-align: center;
}

@media (max-width: 1050px) {
  .dashboard-five {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .quote-table-head {
    display: none;
  }

  .quote-row,
  .compact-row {
    grid-template-columns: minmax(0, 1fr) auto auto auto;
  }

  .quote-date,
  .trash-table-head {
    display: none;
  }

  .trash-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .trash-row > :nth-child(3) {
    display: none;
  }
}

@media (max-width: 780px) {
  main,
  .client-mode main {
    width: min(100% - 20px, 1180px);
    margin-top: 14px;
  }

  .topbar {
    padding: 12px 16px;
  }

  .admin-shell,
  .workspace,
  .template-workspace,
  .template-picker,
  .field-grid,
  .archive-toolbar,
  .detail-fields,
  .evidence.compact {
    grid-template-columns: 1fr;
  }

  .admin-sidebar {
    position: static;
    min-height: 0;
  }

  .admin-menu {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .template-nav {
    position: static;
  }

  .admin-menu button {
    padding: 8px;
    text-align: center;
  }

  .sidebar-button {
    margin-top: 0;
  }

  .page-heading,
  .document-head,
  .document-grid {
    flex-direction: column;
  }

  .dashboard-five {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .quote-row,
  .compact-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
  }

  .quote-amount {
    display: none;
  }

  .row-actions {
    gap: 4px;
  }

  .row-action {
    padding: 0 7px;
    font-size: 0.82rem;
  }

  .client-document {
    padding: 20px;
  }
}

.service-items-editor {
  margin-top: 20px;
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.optional-label {
  color: var(--muted);
  font-size: 0.85em;
  font-weight: 500;
}

.compact-heading {
  align-items: center;
  margin-bottom: 12px;
}

.compact-heading h2,
.compact-heading p {
  margin: 0;
}

.compact-heading p {
  margin-top: 4px;
  color: var(--muted);
}

.service-items {
  display: grid;
  gap: 12px;
}

.service-item-row {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) 100px 140px 110px;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #f8fafc;
  padding: 14px;
}

.service-item-main {
  display: grid;
  gap: 8px;
}

.service-item-controls {
  display: grid;
  gap: 10px;
  justify-items: end;
  padding-top: 4px;
}

.inline-check {
  display: flex;
  gap: 7px;
  align-items: center;
}

.inline-check input {
  width: auto;
}

.service-total {
  display: flex;
  justify-content: flex-end;
  gap: 16px;
  align-items: baseline;
  margin-top: 14px;
  font-size: 1.1rem;
}

.service-total strong {
  color: var(--brand-strong);
  font-size: 1.45rem;
}

.service-items-preview {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
}

.service-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 120px;
  gap: 16px;
  align-items: start;
  background: #fff;
  padding: 14px;
}

.service-preview-row p {
  margin: 5px 0 0;
  color: var(--muted);
}

.service-preview-row > :last-child {
  text-align: right;
}

.service-preview-row.alternative {
  background: #fffaf1;
}

.client-items {
  margin-top: 20px;
}

.client-items-total {
  display: flex;
  justify-content: flex-end;
  gap: 24px;
  align-items: baseline;
  border-top: 2px solid var(--ink);
  padding: 14px 16px;
  font-size: 1.1rem;
}

.client-items-total strong {
  min-width: 140px;
  text-align: right;
  font-size: 1.35rem;
}

.document-full-width {
  width: 100%;
  margin-top: 24px;
}

.document-full-width > h2 {
  margin: 24px 0 10px;
}

.summary strong {
  overflow-wrap: anywhere;
}

.inline-add-control {
  display: flex;
  gap: 8px;
  align-items: end;
}

.included-services,
.included-services-preview {
  display: grid;
  gap: 10px;
}

.included-service-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.included-services-preview article {
  display: grid;
  grid-template-columns: 180px minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 10px 0;
}

.included-services-preview p,
.document-sections p {
  margin: 0;
  line-height: 1.55;
}

.preset-services-editor {
  margin-top: 18px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.preset-services-editor h3,
.preset-services-editor p {
  margin: 0;
}

.preset-service-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.preset-service-row {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.post-items-fields,
.quote-text-section,
.billing-note,
.legal-template-picker {
  margin-top: 22px;
}

.quote-text-section {
  border-top: 1px solid var(--line);
  padding-top: 18px;
}

.quote-text-section > label {
  margin-top: 12px;
}

.section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-toggle input {
  width: auto;
}

.billing-note,
.billing-document-note {
  border: 1px solid #f0d19a;
  border-radius: 8px;
  background: #fffaf1;
  padding: 14px;
}

.billing-note h2,
.billing-document-note h2 {
  margin: 0 0 6px;
}

.document-sections {
  display: grid;
  gap: 20px;
  margin-top: 24px;
}

.optional-files-grid {
  margin-top: 16px;
}

.file-references {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 20px;
}

.file-references section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 14px;
}

.file-references h3 {
  margin: 0 0 8px;
  font-size: 0.95rem;
}

.file-references a,
.file-references span {
  display: block;
  margin-top: 5px;
  overflow-wrap: anywhere;
  font-size: 0.88rem;
}

@media (max-width: 900px) {
  .document-main-title {
    white-space: normal;
  }
  .file-references {
    grid-template-columns: 1fr;
  }

  .included-service-row,
  .included-services-preview article,
  .preset-service-row {
    grid-template-columns: 1fr;
  }

  .client-document .legal-block pre {
    column-count: 1;
    text-align: left;
  }

  .service-item-row {
    grid-template-columns: 1fr 1fr;
  }

  .service-item-main {
    grid-column: 1 / -1;
  }

  .service-preview-row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .service-preview-row > :last-child {
    text-align: left;
  }
}

@media print {
  body {
    background: #fff;
  }

  .topbar,
  .client-actions,
  .acceptance {
    display: none !important;
  }

  main,
  .client-mode main {
    width: 100%;
    margin: 0;
  }

  .client-document {
    border: 0;
    box-shadow: none;
  }
}
