:root {
  --bg: #f5efe7;
  --bg-strong: #efe2d4;
  --ink: #221b16;
  --muted: #746457;
  --line: rgba(76, 50, 30, 0.14);
  --surface: rgba(255, 250, 245, 0.9);
  --surface-strong: #fffdf9;
  --brand: #8c6239;
  --brand-deep: #5b3c22;
  --forest: #33594a;
  --gold: #b38a3c;
  --slate: #4b5963;
  --danger: #9e3b31;
  --success: #295b43;
  --shadow: 0 18px 44px rgba(66, 39, 16, 0.10);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-body: "Avenir Next", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  font-family: var(--font-body);
  background:
    radial-gradient(circle at top left, rgba(179, 138, 60, 0.20), transparent 24%),
    radial-gradient(circle at top right, rgba(51, 89, 74, 0.12), transparent 28%),
    linear-gradient(180deg, #f8f2eb 0%, #f1e8de 100%);
}

a {
  color: inherit;
}

.login-body {
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-stage {
  width: min(1100px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) 320px;
  gap: 18px;
}

.login-panel,
.panel-card,
.hero-card,
.metric-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.login-panel {
  padding: 42px;
}

.login-side {
  display: grid;
  gap: 16px;
}

.metric-card {
  padding: 22px;
  background: linear-gradient(160deg, rgba(255,255,255,0.72), rgba(239,226,212,0.88));
}

.metric-card span,
.eyebrow {
  display: inline-block;
  margin-bottom: 12px;
  color: var(--brand-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  font-family: var(--font-display);
  letter-spacing: -0.03em;
}

h1 {
  font-size: clamp(36px, 6vw, 64px);
  line-height: 0.98;
}

h2 {
  font-size: clamp(26px, 3vw, 34px);
}

p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.lead {
  max-width: 56ch;
  margin: 18px 0 24px;
}

.app-shell,
.preview-shell {
  width: min(1380px, calc(100% - 28px));
  margin: 18px auto 32px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  margin-bottom: 20px;
  padding: 8px 4px;
}

.topbar.compact h1 {
  font-size: clamp(28px, 4vw, 48px);
}

.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.hero-card {
  padding: 20px 22px;
}

.hero-card span {
  display: block;
  margin-bottom: 8px;
  color: rgba(255,255,255,0.82);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.hero-card strong {
  display: block;
  color: #fff;
  font-size: clamp(24px, 3vw, 34px);
  line-height: 1.1;
}

.accent-warm { background: linear-gradient(135deg, #9d7146, #6d4929); }
.accent-green { background: linear-gradient(135deg, #436a5b, #28463b); }
.accent-gold { background: linear-gradient(135deg, #b89249, #876322); }
.accent-slate { background: linear-gradient(135deg, #61707b, #3f4e58); }

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

.panel-card {
  padding: 24px;
}

.full-width {
  grid-column: 1 / -1;
}

.section-head {
  margin-bottom: 18px;
}

.section-head p {
  margin-top: 8px;
}

.stack-form {
  display: grid;
  gap: 14px;
}

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

.full-span {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}

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

input,
select,
textarea {
  width: 100%;
  min-height: 48px;
  padding: 13px 14px;
  border: 1px solid rgba(91, 60, 34, 0.16);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.88);
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

textarea {
  min-height: 112px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(140, 98, 57, 0.52);
  box-shadow: 0 0 0 4px rgba(140, 98, 57, 0.10);
}

button,
.link-btn,
.ghost-link {
  min-height: 48px;
  border-radius: 999px;
  text-decoration: none;
}

button {
  border: 0;
  cursor: pointer;
  transition: transform 180ms ease, box-shadow 180ms ease, filter 180ms ease;
}

button:hover,
.link-btn:hover,
.ghost-link:hover {
  transform: translateY(-1px);
}

.primary-btn,
.link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-deep));
  box-shadow: 0 14px 24px rgba(91, 60, 34, 0.22);
}

.secondary-btn {
  padding: 0 18px;
  color: #fff;
  background: linear-gradient(135deg, var(--forest), #223e33);
  box-shadow: 0 14px 24px rgba(51, 89, 74, 0.18);
}

.ghost-btn,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 16px;
  border: 1px solid rgba(91, 60, 34, 0.18);
  background: rgba(255, 255, 255, 0.58);
  color: var(--ink);
}

.feedback {
  margin-bottom: 18px;
  padding: 14px 16px;
  border-radius: 16px;
  font-weight: 700;
}

.feedback.success {
  color: var(--success);
  background: rgba(41, 91, 67, 0.10);
  border: 1px solid rgba(41, 91, 67, 0.18);
}

.feedback.error {
  color: var(--danger);
  background: rgba(158, 59, 49, 0.10);
  border: 1px solid rgba(158, 59, 49, 0.16);
}

.checkbox-line {
  display: flex;
  align-items: center;
  gap: 10px;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
}

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

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

.data-table th,
.data-table td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(91, 60, 34, 0.10);
  text-align: left;
  vertical-align: top;
}

.data-table th {
  color: var(--brand-deep);
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.small-text {
  color: var(--muted);
  font-size: 13px;
}

.preview-toolbar,
.inline-actions {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 18px;
}

.contract-preview {
  padding: 28px;
  border: 1px solid rgba(184, 147, 115, 0.28);
  border-radius: 24px;
  background: linear-gradient(180deg, #fffdfa 0%, #fff9f3 100%);
}

.contract-preview .doc-shell {
  display: grid;
  gap: 18px;
}

.contract-preview .doc-badge {
  display: inline-flex;
  width: fit-content;
  padding: 6px 10px;
  border: 1px solid rgba(140, 98, 57, 0.32);
  border-radius: 999px;
  color: var(--brand-deep);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.contract-preview .doc-lead {
  max-width: 65ch;
}

.contract-preview .clause-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.contract-preview .clause-card {
  padding: 18px;
  border: 1px solid rgba(184, 147, 115, 0.22);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.contract-preview .clause-card.full {
  grid-column: 1 / -1;
}

.contract-preview .signature-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-top: 22px;
}

.contract-preview .signature-box {
  padding: 20px 16px 10px;
  border-top: 1px solid rgba(91, 60, 34, 0.32);
  text-align: center;
}

.contract-preview .signature-box span {
  display: block;
  margin-bottom: 8px;
  color: transparent;
}

.contract-preview .doc-meta {
  margin-top: 14px;
  text-align: right;
}

.detail-list {
  display: grid;
  gap: 12px;
  margin: 0;
}

.detail-list div {
  display: grid;
  gap: 4px;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(91, 60, 34, 0.08);
}

.detail-list dt {
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}

.detail-list dd {
  margin: 0;
  font-weight: 700;
}

@media (max-width: 1024px) {
  .login-stage,
  .panel-grid,
  .detail-grid,
  .hero-grid {
    grid-template-columns: 1fr;
  }

  .dense-grid,
  .contract-preview .clause-grid,
  .contract-preview .signature-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .login-panel,
  .panel-card,
  .hero-card,
  .metric-card,
  .contract-preview {
    padding: 20px;
    border-radius: 22px;
  }

  .app-shell,
  .preview-shell {
    width: min(100%, calc(100% - 18px));
    margin-top: 10px;
  }

  .topbar,
  .preview-toolbar,
  .inline-actions {
    flex-direction: column;
    align-items: stretch;
  }

  h1 {
    font-size: clamp(30px, 9vw, 44px);
  }
}
