:root {
  --bg: #080808;
  --panel: #11100e;
  --ink: #f0ece3;
  --muted: rgba(240,236,227,0.55);
  --line: rgba(240,236,227,0.12);
  --gold: #b8956a;
  --danger: #df6f7a;
  --serif: "Cormorant Garamond", Georgia, serif;
  --sans: "Inter", system-ui, sans-serif;
}

:root[data-theme="light"] {
  --bg: #cec9c1;
  --panel: #e2ddd5;
  --ink: #26231f;
  --muted: rgba(38,35,31,0.68);
  --line: rgba(38,35,31,0.17);
  --gold: #704c2c;
  --danger: #a74450;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 75% 10%, rgba(184,149,106,0.08), transparent 32%),
    var(--bg);
  color: var(--ink);
  font-family: var(--sans);
}

:root[data-theme="light"] body {
  background:
    radial-gradient(circle at 75% 10%, rgba(143,104,65,0.11), transparent 32%),
    #cec9c1;
}

a { color: inherit; text-decoration: none; }
button, input { font: inherit; }
[hidden],
.setup-only[hidden] {
  display: none !important;
}

.client-shell {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
  padding: clamp(28px, 5vw, 70px) 0;
}

.client-top {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: clamp(28px, 5vw, 62px);
}

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

.brand span {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(184,149,106,0.45);
  color: var(--gold);
  font-family: var(--serif);
}

.brand strong {
  font-family: var(--serif);
  font-size: 1.35rem;
}

.auth-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(320px, 520px);
  gap: clamp(28px, 6vw, 92px);
  align-items: center;
}

.eyebrow {
  color: var(--gold);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1 {
  margin: 0.5rem 0 1.1rem;
  font-family: var(--serif);
  font-size: clamp(4.5rem, 11vw, 8.5rem);
  line-height: 0.82;
}

p {
  color: var(--muted);
  line-height: 1.8;
  max-width: 560px;
}

.panel {
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(184,149,106,0.06), transparent 36%),
    rgba(255,255,255,0.025);
  padding: clamp(20px, 4vw, 38px);
}

.form {
  display: grid;
  gap: 16px;
}

.form label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.form input {
  width: 100%;
  min-height: 54px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 14px;
  outline: none;
}

.form input:focus {
  border-color: rgba(184,149,106,0.62);
}

.btn {
  min-height: 54px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 18px;
  cursor: pointer;
}

.btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #080808;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.btn:disabled {
  opacity: 0.55;
  cursor: wait;
}

.client-top .btn-back {
  min-height: 38px;
  width: auto;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted-link {
  justify-self: start;
  color: var(--muted);
  font-size: 0.9rem;
}

.link-button {
  border: 0;
  background: transparent;
  padding: 0;
  font: inherit;
  cursor: pointer;
  text-align: left;
}

.link-button:hover,
.muted-link:hover {
  color: var(--ink);
}

.status {
  min-height: 24px;
  color: var(--muted);
  line-height: 1.5;
}

.status.error { color: #ffb8bd; }
.status.ok { color: #9ee2af; }

.dashboard-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 34px;
}

.gallery-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery-card {
  min-height: 360px;
  position: relative;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
  display: flex;
  align-items: flex-end;
}

.gallery-card-bg {
  position: absolute;
  inset: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.58;
  filter: saturate(0.88);
}

.gallery-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(to top, rgba(8,8,8,0.94), rgba(8,8,8,0.12));
}

.gallery-card-body {
  position: relative;
  z-index: 2;
  padding: 20px;
}

.gallery-card h2 {
  font-family: var(--serif);
  font-size: 2.8rem;
  line-height: 0.92;
  margin: 0 0 0.7rem;
}

.gallery-card small {
  display: block;
  color: var(--muted);
  margin-bottom: 1rem;
}

@media (max-width: 820px) {
  .auth-grid,
  .dashboard-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .client-top {
    align-items: flex-start;
    flex-direction: column;
    gap: 12px;
  }

  .client-top .btn-back {
    min-height: 34px;
    padding: 0 12px;
    font-size: 0.76rem;
  }
}

.theme-toggle {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 120;
  min-height: 36px;
  border: 1px solid var(--line);
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  color: var(--ink);
  padding: 0 12px;
  font: 800 0.74rem var(--sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 14px 34px rgba(0,0,0,0.18);
  backdrop-filter: blur(14px);
}

:root[data-theme="light"] .panel,
:root[data-theme="light"] .gallery-card {
  background: rgba(226,221,213,0.96);
  box-shadow: 0 18px 48px rgba(32,32,30,0.08);
}

:root[data-theme="light"] .btn:not(.btn-primary),
:root[data-theme="light"] .form input {
  background: #d6d0c7;
}

:root[data-theme="light"] .btn-primary {
  background: var(--gold);
  border-color: var(--gold);
  color: #f7f4ee;
}

/* Client dashboard */
.dashboard-section {
  margin-top: 42px;
}

.dashboard-section[hidden] {
  display: none !important;
}

.dashboard-section-head {
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}

.dashboard-section-head h2 {
  margin: 4px 0 0;
  font-family: var(--serif);
  font-size: 2.1rem;
  line-height: 1;
}

.quote-list {
  display: grid;
  gap: 8px;
}

.client-quote-card {
  min-height: 96px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.025);
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.client-quote-card:hover {
  border-color: rgba(184,149,106,0.55);
  background: rgba(184,149,106,0.07);
}

.client-quote-card > span,
.client-quote-card strong,
.client-quote-card small {
  display: block;
}

.client-quote-card > span:first-child strong {
  margin-top: 5px;
  font-family: var(--serif);
  font-size: 1.6rem;
  line-height: 1;
}

.client-quote-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.client-quote-value {
  text-align: right;
  white-space: nowrap;
}

.client-quote-value strong {
  color: var(--gold);
  font-size: 1.05rem;
}

.client-quote-value small {
  margin-top: 5px;
}

:root[data-theme="light"] .client-quote-card {
  background: rgba(226,221,213,0.96);
}

/* Quote and contract */
.quote-client-shell {
  width: min(1080px, calc(100% - 36px));
  padding-top: 24px;
}

.quote-client-top {
  margin-bottom: 24px;
}

.quote-client-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.quote-client-actions .btn {
  min-height: 38px;
  padding: 0 14px;
  font-size: 0.78rem;
}

.quote-loading {
  min-height: 180px;
  display: grid;
  place-items: center;
}

.quote-document {
  border: 1px solid var(--line);
  background: var(--panel);
}

:root[data-theme="light"] .quote-document {
  background: #e2ddd5;
}

.quote-document-head {
  min-height: 260px;
  padding: clamp(28px, 5vw, 54px);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  background:
    linear-gradient(135deg, rgba(184,149,106,0.12), transparent 46%),
    rgba(255,255,255,0.02);
}

.quote-document-head > div {
  max-width: 760px;
}

.quote-document-head h1 {
  margin: 12px 0 18px;
  font-size: clamp(2.8rem, 6vw, 4.8rem);
  line-height: 0.92;
}

.quote-document-head p {
  margin: 0;
  max-width: 720px;
  font-size: 0.95rem;
  line-height: 1.75;
}

.client-status {
  min-height: 28px;
  border: 1px solid var(--line);
  color: var(--gold);
  padding: 6px 10px;
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  white-space: nowrap;
}

.client-status.accepted {
  color: #75c68b;
  border-color: rgba(117,198,139,0.4);
}

.client-status.expired {
  color: var(--danger);
  border-color: rgba(223,111,122,0.4);
}

.quote-party-band {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.quote-party-band > div {
  min-height: 120px;
  padding: 20px clamp(22px, 5vw, 54px);
  display: grid;
  align-content: center;
  gap: 6px;
}

.quote-party-band > div + div {
  border-left: 1px solid var(--line);
}

.quote-party-band small,
.quote-meta-grid small,
.quote-client-totals small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quote-party-band strong {
  font-family: var(--serif);
  font-size: 1.55rem;
}

.quote-party-band span {
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.quote-document-section,
.quote-accept-panel,
.quote-accepted-panel {
  padding: clamp(28px, 6vw, 64px);
  border-bottom: 1px solid var(--line);
}

.quote-section-title {
  margin-bottom: 22px;
}

.quote-section-title h2,
.quote-accept-panel h2,
.quote-accepted-panel h2 {
  margin: 5px 0 0;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3.2rem);
  line-height: 0.95;
}

.quote-meta-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
}

.quote-meta-grid > div {
  min-height: 88px;
  background: var(--panel);
  padding: 14px;
  display: grid;
  align-content: center;
  gap: 7px;
}

:root[data-theme="light"] .quote-meta-grid > div {
  background: #e2ddd5;
}

.quote-meta-grid strong {
  font-size: 0.86rem;
  line-height: 1.4;
}

.quote-client-items {
  border-top: 1px solid var(--line);
}

.quote-client-item {
  min-height: 68px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
}

.quote-client-item span strong,
.quote-client-item span small {
  display: block;
}

.quote-client-item span small {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.72rem;
}

.quote-client-totals {
  margin-top: 18px;
  margin-left: auto;
  width: min(420px, 100%);
  display: grid;
  gap: 8px;
}

.quote-client-totals > span {
  display: flex;
  justify-content: space-between;
  gap: 20px;
}

.quote-client-totals > span:last-child {
  border-top: 1px solid var(--line);
  margin-top: 4px;
  padding-top: 12px;
}

.quote-client-totals > span:last-child strong {
  color: var(--gold);
  font-size: 1.35rem;
}

.quote-client-payments {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
}

.quote-client-payments > div {
  min-height: 86px;
  border: 1px solid var(--line);
  padding: 14px;
}

.quote-client-payments strong,
.quote-client-payments span {
  display: block;
}

.quote-client-payments span {
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.quote-client-clauses {
  border-top: 1px solid var(--line);
}

.quote-client-clauses article {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 16px;
  border-bottom: 1px solid var(--line);
  padding: 22px 0;
}

.quote-client-clauses article > span {
  color: var(--gold);
  font-family: var(--serif);
  font-size: 1.4rem;
}

.quote-client-clauses h3 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 1.45rem;
}

.quote-client-clauses p {
  margin: 0;
  max-width: none;
  line-height: 1.65;
}

.quote-client-note {
  margin-top: 24px;
  border-left: 2px solid var(--gold);
  padding: 4px 0 4px 16px;
  color: var(--muted);
  line-height: 1.7;
}

.quote-accept-panel {
  background: rgba(184,149,106,0.07);
}

.quote-accept-form {
  margin-top: 24px;
  display: grid;
  gap: 16px;
}

.quote-accept-fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.quote-accept-fields label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.quote-accept-fields input {
  min-height: 44px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.04);
  color: var(--ink);
  padding: 0 12px;
}

.quote-confirmation {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.quote-confirmation input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--gold);
}

.quote-accept-submit {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}

.quote-accept-submit .btn {
  min-height: 44px;
}

.quote-accept-submit small {
  color: var(--danger);
}

.quote-accepted-panel {
  border: 1px solid rgba(117,198,139,0.38);
  background: rgba(117,198,139,0.07);
}

.quote-accepted-panel p,
.quote-accepted-panel small {
  display: block;
  color: var(--muted);
  overflow-wrap: anywhere;
}

@media (max-width: 760px) {
  .client-quote-card,
  .quote-document-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .client-quote-value {
    text-align: left;
  }

  .quote-client-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .quote-party-band,
  .quote-meta-grid,
  .quote-accept-fields {
    grid-template-columns: 1fr;
  }

  .quote-party-band > div + div {
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  .quote-client-clauses article {
    grid-template-columns: 34px minmax(0, 1fr);
    gap: 10px;
  }
}
