:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #64646b;
  --quiet: #8c8c94;
  --surface: rgba(255, 255, 255, 0.78);
  --surface-solid: #ffffff;
  --surface-soft: #f7f7f8;
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(29, 29, 31, 0.1);
  --line-strong: rgba(29, 29, 31, 0.18);
  --hot: #ff7a1a;
  --hot-2: #ff9f0a;
  --hot-soft: #fff2e6;
  --gold: #b56a00;
  --ok: #188038;
  --warn: #a45f00;
  --bad: #c9352b;
  --focus: rgba(255, 122, 26, 0.26);
  --shadow: 0 22px 60px rgba(29, 29, 31, 0.08);
  --shadow-soft: 0 12px 30px rgba(29, 29, 31, 0.06);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", Inter, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 246, 236, 0.92) 0%, rgba(250, 250, 251, 0.96) 34%, #f5f5f7 100%);
  background-attachment: fixed;
  letter-spacing: 0;
}

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

button {
  border: 0;
  cursor: pointer;
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  opacity: 0.42;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), transparent 42%),
    repeating-linear-gradient(90deg, rgba(29, 29, 31, 0.018) 0 1px, transparent 1px 4px);
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 78px;
  padding: 18px clamp(18px, 3vw, 48px);
  border-bottom: 1px solid rgba(29, 29, 31, 0.08);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: saturate(180%) blur(22px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 750;
  color: #111114;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(255, 122, 26, 0.24);
  border-radius: 8px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--hot), var(--hot-2));
  box-shadow: 0 8px 20px rgba(255, 122, 26, 0.22);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.session-chip,
.language-select {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--muted);
  box-shadow: 0 1px 2px rgba(29, 29, 31, 0.04);
}

.session-chip {
  max-width: 220px;
  padding: 0 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.language-select {
  gap: 8px;
  padding: 0 12px;
}

.language-select span {
  color: var(--quiet);
  font-size: 12px;
  white-space: nowrap;
}

.language-select select {
  width: auto;
  min-height: 30px;
  border: 0;
  border-radius: 999px;
  color: var(--ink);
  background: transparent;
  padding: 4px 6px;
  outline: none;
}

.shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 24px auto 64px;
}

.hero-row {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: saturate(150%) blur(18px);
}

.side-panel {
  position: sticky;
  top: 102px;
  padding: 18px;
}

.workspace {
  min-height: 680px;
  padding: clamp(18px, 2.4vw, 28px);
}

.eyebrow {
  color: var(--hot);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

h1,
h2,
h3 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  margin-top: 14px;
  font-size: clamp(36px, 5vw, 64px);
  font-weight: 720;
  line-height: 1.02;
}

.side-panel h1 {
  font-size: clamp(34px, 3.5vw, 48px);
  line-height: 1.04;
}

.sign-shell h1 {
  font-size: clamp(34px, 4.4vw, 56px);
  line-height: 1.06;
}

h2 {
  font-size: 22px;
  margin-bottom: 16px;
}

h3 {
  font-size: 15px;
}

.copy {
  color: var(--muted);
  line-height: 1.58;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 22px 0;
}

.metric {
  border: 1px solid rgba(255, 122, 26, 0.16);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, var(--hot-soft));
  padding: 14px;
  box-shadow: var(--shadow-soft);
}

.metric strong {
  display: block;
  font-size: 28px;
  line-height: 1.05;
}

.metric span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 18px;
}

.nav button,
.ghost,
.pill,
.primary {
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease;
}

.nav button,
.ghost,
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  text-decoration: none;
  box-shadow: 0 1px 2px rgba(29, 29, 31, 0.04);
}

.nav button {
  justify-content: flex-start;
  width: 100%;
  border-radius: 8px;
}

.nav button.active {
  color: #ffffff;
  background: linear-gradient(135deg, var(--hot), var(--hot-2));
  border-color: transparent;
  box-shadow: 0 10px 22px rgba(255, 122, 26, 0.22);
}

.nav button:hover,
.ghost:hover,
.pill:hover {
  border-color: rgba(255, 122, 26, 0.32);
  background: #ffffff;
  box-shadow: 0 8px 20px rgba(29, 29, 31, 0.07);
  transform: translateY(-1px);
}

.primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  border-radius: 999px;
  color: white;
  background: linear-gradient(135deg, var(--hot), var(--hot-2));
  box-shadow: 0 14px 28px rgba(255, 122, 26, 0.26);
  text-decoration: none;
}

.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(255, 122, 26, 0.32);
}

.primary:disabled,
.ghost:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
  box-shadow: none;
}

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

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

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.9);
  outline: none;
  box-shadow: inset 0 1px 2px rgba(29, 29, 31, 0.04);
}

.field textarea {
  min-height: 132px;
  resize: vertical;
}

.field input::placeholder,
.field textarea::placeholder {
  color: #aaaab2;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.language-select select:focus {
  border-color: rgba(255, 122, 26, 0.58);
  box-shadow:
    0 0 0 4px var(--focus),
    inset 0 1px 2px rgba(29, 29, 31, 0.04);
}

.section {
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

.subpanel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.76);
  padding: 16px;
  box-shadow: var(--shadow-soft);
}

.table {
  display: grid;
  gap: 8px;
}

.row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 0.9fr 0.9fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 10px;
  box-shadow: 0 6px 18px rgba(29, 29, 31, 0.04);
}

.row.signer-row {
  grid-template-columns: 1fr 1fr 0.8fr auto;
}

.row strong {
  color: #151518;
}

.row small,
.muted {
  color: var(--muted);
}

.status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface-soft);
  font-size: 12px;
  font-weight: 650;
}

.status.signed {
  color: var(--ok);
  border-color: rgba(24, 128, 56, 0.2);
  background: #ecf8ef;
}

.status.sent {
  color: var(--warn);
  border-color: rgba(255, 122, 26, 0.22);
  background: var(--hot-soft);
}

.status.failed {
  color: var(--bad);
  border-color: rgba(201, 53, 43, 0.18);
  background: #fff0ee;
}

.notice {
  border: 1px solid rgba(255, 122, 26, 0.2);
  border-radius: 8px;
  background: var(--hot-soft);
  padding: 12px;
  color: #6a3a00;
  line-height: 1.45;
}

.code {
  overflow: auto;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #1d1d1f;
  padding: 12px;
  color: #fff6ed;
  white-space: pre-wrap;
  word-break: break-word;
}

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

.sign-shell {
  width: min(960px, calc(100vw - 28px));
  margin: 28px auto 72px;
}

.auth-panel {
  min-height: 420px;
  display: grid;
  align-content: center;
  gap: 18px;
}

.sign-doc {
  max-height: 440px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  color: #1d1d1f;
  padding: 22px;
  white-space: pre-wrap;
  line-height: 1.58;
  box-shadow: inset 0 1px 3px rgba(29, 29, 31, 0.04);
}

.check-row {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 10px;
  align-items: start;
  color: var(--muted);
  line-height: 1.45;
}

.check-row input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--hot);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 5;
  max-width: 420px;
  border: 1px solid rgba(255, 122, 26, 0.24);
  border-radius: 8px;
  background: var(--panel-strong);
  padding: 14px 16px;
  color: var(--ink);
  box-shadow: var(--shadow);
}

a {
  color: #c85000;
}

@media (max-width: 900px) {
  .hero-row,
  .grid-2,
  .grid-3,
  .metric-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    position: static;
  }

  .row,
  .row.signer-row {
    grid-template-columns: 1fr;
  }

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

  .top-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 540px) {
  .shell,
  .sign-shell {
    width: min(100% - 24px, 960px);
    margin-top: 18px;
  }

  .workspace {
    min-height: auto;
  }

  .auth-panel {
    min-height: 360px;
  }

  .sign-shell h1 {
    font-size: 28px;
    line-height: 1.12;
  }

  .primary,
  .ghost,
  .pill {
    width: 100%;
  }
}
