:root {
  --ink: #18201d;
  --muted: #66736f;
  --line: #dfe5e2;
  --surface: #fff;
  --bg: #f4f5f1;
  --green: #195d46;
  --green-dark: #104733;
  --green-soft: #e8f1ed;
  --amber: #9b6315;
  --amber-soft: #fff3d8;
  --shadow: 0 16px 50px rgba(19, 36, 30, .07);
}

* { box-sizing: border-box; }
html { font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--bg); }
body { margin: 0; min-height: 100vh; }
a { color: inherit; }
button, input { font: inherit; }
button, .button { cursor: pointer; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

.topbar { height: 74px; padding: 0 max(24px, calc((100vw - 1180px) / 2)); display: flex; align-items: center; justify-content: space-between; background: rgba(255,255,255,.92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; backdrop-filter: blur(12px); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-size: 19px; font-weight: 750; text-decoration: none; letter-spacing: -.3px; }
.brand-mark { display: inline-grid; place-items: center; width: 35px; height: 35px; border-radius: 9px; color: #fff; background: var(--green); font-size: 12px; letter-spacing: .5px; }
.topbar nav { display: flex; align-items: center; gap: 24px; font-size: 14px; font-weight: 650; }
.topbar nav a { text-decoration: none; }
.topbar nav form { margin: 0; }
.link-button { border: 0; background: none; color: var(--muted); padding: 8px 0; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding: 58px 0 80px; }
.page-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 30px; margin-bottom: 32px; }
.page-heading.compact { align-items: flex-start; }
.page-heading h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 500; font-size: clamp(38px, 5vw, 56px); letter-spacing: -1.8px; line-height: 1; margin: 5px 0 10px; }
.eyebrow, .overline { color: var(--green); text-transform: uppercase; letter-spacing: 1.5px; font-size: 11px; font-weight: 800; margin: 0; }
.muted { color: var(--muted); }
.back { display: inline-block; color: var(--muted); margin-bottom: 30px; text-decoration: none; font-size: 14px; }

.button { display: inline-flex; align-items: center; justify-content: center; min-height: 44px; padding: 11px 19px; border: 1px solid var(--green); border-radius: 9px; background: var(--green); color: #fff; font-weight: 750; font-size: 14px; text-decoration: none; transition: .18s ease; }
.button:hover { background: var(--green-dark); border-color: var(--green-dark); transform: translateY(-1px); }
.button:disabled { opacity: .65; transform: none; cursor: wait; }
.button.small { min-height: 38px; padding: 8px 14px; color: #fff; }
.button.secondary { background: var(--green-soft); color: var(--green); border-color: transparent; }
.button.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.button.full { width: 100%; }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { padding: 20px; background: rgba(255,255,255,.62); border: 1px solid var(--line); border-radius: 12px; text-decoration: none; transition: .18s ease; }
.stat span { display: block; color: var(--muted); font-size: 13px; margin-bottom: 8px; }
.stat strong { font-family: Georgia, serif; font-size: 30px; font-weight: 500; }
.stat.active { background: var(--ink); color: #fff; border-color: var(--ink); }
.stat.active span { color: #b9c3bf; }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); }
.toolbar { padding: 17px; border-bottom: 1px solid var(--line); }
.search { max-width: 460px; display: flex; }
.search input { width: 100%; border: 1px solid var(--line); border-right: 0; border-radius: 8px 0 0 8px; padding: 11px 13px; outline: none; }
.search input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.search button { border: 0; border-radius: 0 8px 8px 0; background: var(--ink); color: #fff; padding: 0 15px; font-weight: 700; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 16px 18px; text-align: left; border-bottom: 1px solid #edf0ee; font-size: 13px; }
th { color: var(--muted); text-transform: uppercase; letter-spacing: .7px; font-size: 10px; }
td small { display: block; color: var(--muted); margin-top: 4px; }
tbody tr:hover { background: #fafbf9; }
tbody tr:last-child td { border-bottom: 0; }
.row-link { color: var(--green); font-weight: 750; text-decoration: none; white-space: nowrap; }
.badge { display: inline-flex; align-items: center; width: max-content; padding: 6px 9px; border-radius: 999px; font-size: 11px; font-weight: 800; white-space: nowrap; }
.badge.waiting { background: var(--amber-soft); color: var(--amber); }
.badge.signed { background: var(--green-soft); color: var(--green); }
.badge.draft { background: #edf0ef; color: #5e6865; }
.badge.large { padding: 8px 12px; font-size: 12px; }
.empty { text-align: center; padding: 72px 20px; }
.empty h2 { margin-bottom: 7px; }
.empty p { color: var(--muted); margin: 0 0 23px; }
.empty-icon { display: grid; place-items: center; width: 48px; height: 48px; margin: auto; border: 1px solid var(--line); border-radius: 50%; color: var(--green); font-size: 24px; }

.contract-form { display: grid; gap: 16px; }
.form-section { display: grid; grid-template-columns: 80px 1fr; padding: 34px; }
.section-number { color: var(--green); font-family: Georgia, serif; font-size: 18px; }
.section-content { max-width: 770px; }
.section-content h2, .actions-card h2 { font-family: Georgia, serif; font-size: 27px; font-weight: 500; margin: 0 0 5px; }
.section-content > .muted { margin: 0 0 26px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.form-grid label, .stack label { display: grid; gap: 8px; font-size: 13px; font-weight: 750; }
.form-grid input, .stack input { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 12px 13px; background: #fbfcfb; outline: none; }
.form-grid input:focus, .stack input:focus { border-color: var(--green); box-shadow: 0 0 0 3px var(--green-soft); background: #fff; }
.span-2 { grid-column: span 2; }
.duration { border: 0; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.duration legend { font-size: 13px; font-weight: 750; margin-bottom: 8px; }
.duration label { display: block; position: relative; }
.duration input { position: absolute; opacity: 0; }
.duration span { display: grid; gap: 3px; border: 1px solid var(--line); border-radius: 9px; padding: 13px 15px; cursor: pointer; }
.duration small { color: var(--muted); font-weight: 400; }
.duration input:checked + span { border-color: var(--green); background: var(--green-soft); box-shadow: inset 0 0 0 1px var(--green); }
.input-suffix { display: flex; }
.input-suffix input { border-radius: 8px 0 0 8px; }
.input-suffix span { display: grid; place-items: center; padding: 0 13px; border: 1px solid var(--line); border-left: 0; border-radius: 0 8px 8px 0; color: var(--muted); background: #f5f7f5; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 10px; }

.detail-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; }
.detail-main, .actions-card { padding: 30px; }
.detail-header { display: flex; align-items: flex-start; justify-content: space-between; border-bottom: 1px solid var(--line); padding-bottom: 24px; }
.detail-header h2 { font-family: Georgia, serif; font-size: 31px; font-weight: 500; margin: 6px 0 0; }
.price { font-family: Georgia, serif; font-size: 25px; font-weight: 500; }
.details-list { display: grid; grid-template-columns: 1fr 1fr; margin: 0; }
.details-list div { padding: 20px 0; border-bottom: 1px solid #edf0ee; }
.details-list div:nth-child(odd) { padding-right: 20px; }
.details-list dt { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .8px; margin-bottom: 6px; }
.details-list dd { margin: 0; font-size: 14px; line-height: 1.6; }
.actions-card { align-self: start; }
.actions-card h2 { font-size: 22px; margin-bottom: 20px; }
.actions-card form + form, .actions-card .button + form, .actions-card form + .button { margin-top: 9px; }
.document-link { display: grid; grid-template-columns: 42px 1fr auto; gap: 11px; align-items: center; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 10px; text-decoration: none; }
.document-link:hover { border-color: var(--green); }
.doc-icon { display: grid; place-items: center; width: 42px; height: 42px; background: #f4eee9; color: #9a4f2b; border-radius: 7px; font-size: 10px; font-weight: 850; }
.document-link small { display: block; color: var(--muted); margin-top: 3px; }
.signed-doc { background: var(--green-soft); border-color: transparent; }

.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 30px 20px; background: radial-gradient(circle at 20% 20%, #e1ece6 0, transparent 35%), var(--bg); }
.auth-card { width: min(430px, 100%); padding: 38px; border: 1px solid var(--line); border-radius: 16px; background: #fff; box-shadow: var(--shadow); }
.auth-brand { margin-bottom: 45px; }
.auth-card h1 { font-family: Georgia, serif; font-size: 38px; font-weight: 500; letter-spacing: -1px; margin: 5px 0 10px; }
.auth-card > .muted { line-height: 1.6; margin-bottom: 25px; }
.stack { display: grid; gap: 18px; }
.hint { color: var(--muted); font-weight: 400; float: right; }
.alert { margin-bottom: 18px; padding: 13px 15px; border-radius: 9px; font-size: 14px; }
.alert.error { background: #fce9e7; color: #8b2e25; border: 1px solid #f3cac5; }
.alert.success { background: var(--green-soft); color: var(--green-dark); border: 1px solid #cae2d7; }

dialog { width: min(540px, calc(100% - 30px)); border: 0; border-radius: 15px; padding: 0; box-shadow: 0 30px 90px rgba(0,0,0,.22); }
dialog::backdrop { background: rgba(13, 25, 21, .56); backdrop-filter: blur(3px); }
dialog form { padding: 30px; }
.dialog-head { display: flex; justify-content: space-between; gap: 20px; }
.dialog-head h2 { font-family: Georgia, serif; font-size: 29px; font-weight: 500; margin: 5px 0 10px; }
.dialog-close { border: 0; background: transparent; font-size: 28px; color: var(--muted); }
.dropzone { display: grid; place-items: center; gap: 7px; margin: 22px 0; padding: 30px; border: 1.5px dashed #b7c3be; border-radius: 12px; background: #f9faf8; cursor: pointer; text-align: center; }
.dropzone input { max-width: 100%; }
.dropzone small { color: var(--muted); }
.drop-icon { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; color: var(--green); background: var(--green-soft); font-size: 20px; }

@media (max-width: 800px) {
  .shell { width: min(100% - 24px, 1180px); padding-top: 35px; }
  .topbar { padding: 0 14px; }
  .topbar nav > a:first-child { display: none; }
  .stats { grid-template-columns: 1fr 1fr; }
  .page-heading { align-items: flex-start; flex-direction: column; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-section { grid-template-columns: 1fr; gap: 14px; padding: 24px 20px; }
  .form-grid, .details-list { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .duration { grid-template-columns: 1fr; }
  .details-list div:nth-child(odd) { padding-right: 0; }
  .form-actions { flex-wrap: wrap; }
  .form-actions .button { flex: 1; }
}
