/* ===== Shared page elements ===== */

.compact-empty {
  min-height: 220px;
}
/* ===== Responsive ===== */

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .mobile-only {
    display: inline-grid !important;
  }
}

@media (max-width: 760px) {
  .topbar {
    padding: 16px;
    align-items: flex-start;
  }

  .topbar h1 {
    font-size: 22px;
  }

  .top-actions {
    display: none;
  }

  .page-surface {
    padding: 18px 14px 110px;
  }


  .form-grid {
    grid-template-columns: 1fr;
  }

  .item-head {
    display: none;
  }

  .item-row {
    grid-template-columns: 1fr 1fr;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: var(--surface-2);
  }

  .item-row input:first-child,
  .item-row input:nth-child(6) {
    grid-column: 1 / -1;
  }

  .sticky-submit {
    left: 12px;
    right: 12px;
    display: grid;
  }
}
/* ===== Public signing clean final ===== */

.sign-clean-shell {
  min-height: 100vh;
  padding: 22px 18px 36px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background:
    radial-gradient(circle at 18% 0%, rgba(255, 255, 255, .95), transparent 32%),
    linear-gradient(135deg, #faf8f4, #f1ede6);
}

.sign-clean-card {
  width: min(100%, 820px);
  padding: 28px;
  border: 1px solid rgba(229, 223, 215, .95);
  border-radius: 32px;
  background: rgba(255, 255, 255, .94);
  box-shadow:
    0 30px 80px rgba(17, 17, 17, .085),
    inset 0 1px 0 rgba(255, 255, 255, .86);
}

.sign-clean-header {
  margin-bottom: 16px;
}

.sign-clean-header h1 {
  margin: 0;
  color: #050505;
  font-size: clamp(30px, 4.5vw, 44px);
  line-height: .96;
  letter-spacing: -.08em;
}

.sign-clean-header p:not(.eyebrow) {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.45;
}

.sign-clean-summary,
.sign-clean-form {
  border: 1px solid rgba(229, 223, 215, .95);
  border-radius: 26px;
  background: rgba(255, 255, 255, .78);
  box-shadow: 0 16px 44px rgba(17, 17, 17, .04);
}

.sign-clean-summary {
  padding: 20px;
  margin-bottom: 14px;
}

.sign-clean-form {
  display: grid;
  gap: 12px;
  padding: 20px;
}

.sign-clean-title {
  margin-bottom: 14px;
}

.sign-clean-title h2 {
  margin: 0;
  color: #111;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -.06em;
}

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

.sign-clean-meta > div {
  min-width: 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #faf9f7;
}

.sign-clean-meta span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  line-height: 1.1;
}

.sign-clean-meta strong {
  display: block;
  min-width: 0;
  color: #111;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -.035em;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.sign-clean-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.sign-clean-readonly input[readonly] {
  background: #faf9f7;
  color: #111;
  cursor: default;
}

.sign-clean-pad {
  overflow: hidden;
  border-radius: 24px;
  background: #fff;
}

.sign-clean-pad canvas {
  width: 100%;
  height: 210px;
  display: block;
  background: #fff;
  touch-action: none;
}

.sign-clean-submit {
  height: 50px;
  border-radius: 999px;
  font-size: 15px;
  box-shadow: 0 16px 36px rgba(17, 17, 17, .13);
}

.sign-clean-empty {
  padding: 40px 20px;
  text-align: center;
}

.sign-clean-empty h1 {
  margin: 0;
  color: #050505;
  font-size: clamp(28px, 5vw, 44px);
  line-height: 1;
  letter-spacing: -.07em;
}
.sign-token-empty {
  max-width: 620px;
  margin: 0 auto;
}

.sign-token-icon {
  width: 58px;
  height: 58px;
  margin: 0 auto 18px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: #111;
  color: #fff;
  font-size: 28px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 18px 42px rgba(17, 17, 17, .16);
}

.sign-token-empty .auth-copy {
  max-width: 520px;
  margin: 16px auto 0;
}

.sign-token-note {
  max-width: 520px;
  margin: 22px auto 0;
  padding: 14px 16px;
  border-radius: 18px;
  background: #faf7f1;
  border: 1px solid rgba(220, 210, 190, .8);
  color: #5f5345;
  font-size: 13px;
  line-height: 1.6;
}

.sign-token-note strong {
  color: #151515;
}


@media (max-width: 760px) {
  .sign-clean-shell {
    padding: 16px 12px 32px;
  }

  .sign-clean-card {
    padding: 20px;
    border-radius: 28px;
  }

  .sign-clean-header h1 {
    font-size: 34px;
    line-height: .98;
  }

  .sign-clean-header p:not(.eyebrow) {
    font-size: 14px;
  }

  .sign-clean-summary,
  .sign-clean-form {
    padding: 18px;
    border-radius: 24px;
  }

  .sign-clean-meta {
    grid-template-columns: 1fr;
  }

  .sign-clean-actions {
    display: grid;
  }

  .sign-clean-actions .button {
    width: 100%;
  }

  .sign-clean-pad canvas {
    height: 220px;
  }
}

@media (max-width: 460px) {
  .sign-clean-card {
    padding: 18px;
  }

  .sign-clean-header h1 {
    font-size: 28px;
  }

  .sign-clean-title h2 {
    font-size: 21px;
  }

  .sign-clean-meta strong {
    font-size: 16px;
  }

  .sign-clean-pad canvas {
    height: 210px;
  }
}

/* ===== Mobile final system ===== */

@media (max-width: 760px) {
  html,
  body {
    overflow-x: hidden;
  }

  body {
    background: #f6f4f0;
  }

  .app-shell {
    display: block;
    min-width: 0;
  }

  .app-main {
    min-width: 0;
  }

  .topbar {
    min-height: auto;
    padding: 13px 14px;
    gap: 12px;
    align-items: center;
    justify-content: flex-start;
    background: rgba(246, 244, 240, .93);
  }

  .topbar .icon-button {
    width: 40px;
    height: 40px;
    flex: 0 0 auto;
    border-radius: 15px;
    font-size: 22px;
  }

  .topbar-title {
    min-width: 0;
    padding-top: 0;
  }

  .topbar .eyebrow {
    margin-bottom: 5px;
    font-size: 9.5px;
    letter-spacing: .12em;
  }

  .topbar h1 {
    font-size: 23px;
    line-height: 1.02;
    letter-spacing: -.06em;
  }

  .top-subtitle {
    display: none;
  }

  .top-actions {
    display: none;
  }

  .page-surface {
    width: 100%;
    max-width: none;
    padding: 14px 12px 40px;
  }

  .panel {
    padding: 16px;
    border-radius: 24px;
    box-shadow: 0 12px 34px rgba(17, 17, 17, .045);
  }

  .panel-head {
    display: grid;
    gap: 12px;
    margin-bottom: 14px;
  }

  .panel-head h3 {
    font-size: 19px;
    line-height: 1.08;
  }

  .button {
    min-height: 46px;
    padding: 11px 15px;
    font-size: 13px;
  }

  .field {
    gap: 7px;
  }

  .field span {
    font-size: 11.5px;
  }

  .field input,
  .field textarea,
  .field select {
    min-height: 48px;
    padding: 12px 13px;
    border-radius: 15px;
    font-size: 14px;
  }

  .field textarea {
    min-height: 92px;
  }


  .history-card-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .history-card-actions a,
  .history-card-actions button {
    width: 100%;
    min-height: 42px;
    justify-content: center;
    text-align: center;
  }

  .create-form {
    gap: 12px;
    padding-bottom: 124px;
  }

  .form-section {
    scroll-margin-top: 82px;
  }

  .create-section {
    padding: 15px;
    border-radius: 22px;
  }

  .section-title,
  .section-title-inline {
    gap: 12px;
  }

  .section-title {
    margin-bottom: 14px;
  }

  .section-title > span,
  .section-title-inline > span {
    width: 34px;
    height: 34px;
    border-radius: 13px;
    font-size: 11px;
  }

  .section-title h3 {
    font-size: 19px;
    line-height: 1.08;
  }

  .section-title p {
    font-size: 12.5px;
    line-height: 1.45;
  }

  .section-title.with-action {
    display: grid;
    gap: 14px;
  }

  .add-row-button {
    width: 100%;
    min-height: 44px;
    padding: 0 14px;
    display: grid;
    place-items: center;
    border-radius: 999px;
  }

  .form-grid {
    grid-template-columns: 1fr;
    gap: 11px;
  }

  .field-half,
  .field-wide {
    grid-column: 1 / -1;
  }

  .create-form .field input,
  .create-form .field select {
    min-height: 46px;
    padding: 11px 13px;
  }

  .create-form .field textarea {
    min-height: 82px;
    padding: 11px 13px;
  }

  .item-table-shell {
    overflow: visible;
    padding-bottom: 0;
  }

  .item-table {
    min-width: 0;
    gap: 10px;
  }

  .item-head {
    display: none;
  }

  .item-row {
    position: relative;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    padding: 12px;
    border: 1px solid rgba(229, 223, 215, .95);
    border-radius: 20px;
    background: rgba(255, 255, 255, .84);
    box-shadow: 0 10px 28px rgba(17, 17, 17, .035);
  }

  .item-cell {
    min-width: 0;
  }

  .item-cell > span {
    display: block;
    font-size: 11px;
    letter-spacing: .02em;
  }

  .item-cell-name,
  .item-row .item-cell:nth-child(6) {
    grid-column: 1 / -1;
  }

  .item-row input {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 14px;
    font-size: 13.5px;
  }

  .remove-row {
    grid-column: 1 / -1;
    width: 100%;
    height: 40px;
    border-radius: 14px;
    font-size: 14px;
  }

  .create-signature-card canvas {
    height: 190px;
  }

  .create-signature-card .signature-actions {
    min-height: 56px;
    align-items: center;
    flex-direction: row;
    gap: 10px;
    padding: 10px 12px;
  }

  .create-signature-card .signature-actions .button {
    width: auto;
    min-height: 38px;
    padding: 0 14px;
    margin-left: auto;
    border-radius: 999px;
    font-size: 12px;
  }

  .create-submit-dock {
    position: sticky;
    bottom: 12px;
    z-index: 12;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    padding: 16px;
    border-radius: 22px;
    backdrop-filter: blur(18px);
  }

  .create-submit-dock strong {
    font-size: 15px;
    line-height: 1.15;
  }

  .create-submit-dock span {
    width: min(100%, 320px);
    font-size: 11.5px;
    line-height: 1.35;
  }

  .create-submit-button {
    width: 290px;
    max-width: calc(100% - 32px);
    min-height: 50px;
    padding-inline: 22px;
    margin-inline: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    text-align: center;
    line-height: 1;
  }

  .history-filter {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .history-panel {
    padding: 15px;
    border-radius: 23px;
  }

  .history-list {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    gap: 9px;
    max-height: 760px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    padding-right: 2px;
    scrollbar-width: thin;
  }

  .history-list::-webkit-scrollbar {
    width: 6px;
  }

  .history-list::-webkit-scrollbar-track {
    background: transparent;
  }

  .history-list::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(17, 17, 17, .16);
  }

  .history-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 14px;
    border-radius: 20px;
    overflow: hidden;
  }

  .history-card-main,
  .history-card-status,
  .history-card-date,
  .history-card-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
  }

  .history-card-main strong {
    font-size: 15.5px;
    line-height: 1.15;
    max-width: 100%;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .history-card-main span,
  .history-card-status small,
  .history-card-date small {
    max-width: 100%;
    font-size: 12px;
    line-height: 1.35;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .history-card-status {
    gap: 6px;
  }

  .history-card-status .status-badge {
    width: max-content;
    max-width: 100%;
    padding-inline: 12px;
  }

  .history-card-date {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    overflow: hidden;
  }

  .history-card-date span {
    display: none;
  }

  .history-card-date strong {
    font-size: 12.5px;
    line-height: 1.25;
  }

  .history-card-actions {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    overflow: hidden;
  }

  .history-card-actions a,
  .history-card-actions button {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    min-height: 42px;
    display: grid;
    place-items: center;
    padding: 0 12px;
    text-align: center;
    line-height: 1;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .history-card-actions > :last-child:nth-child(odd) {
    grid-column: 1 / -1;
  }

  .detail-process {
    margin-bottom: 14px;
  }

  .detail-timeline {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
  }

  .detail-timeline::before,
  .detail-timeline::after {
    display: none;
  }

  .detail-timeline-step {
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 12px;
    padding: 12px;
    justify-items: start;
    text-align: left;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #faf9f7;
  }

  .detail-timeline-step > span {
    width: 42px;
    height: 42px;
  }

  .detail-timeline-step div {
    align-self: center;
    min-width: 0;
  }

  .detail-sign-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .detail-sign-card {
    width: 100%;
    min-width: 0;
    min-height: 152px;
    padding: 13px;
    border-radius: 20px;
    grid-template-rows: auto 68px auto auto;
    overflow: hidden;
  }

  .signature-preview-box {
    height: 68px;
  }

  .signature-preview-box img {
    max-height: 62px;
  }

  .detail-item-card {
    width: 100%;
    min-width: 0;
    max-width: 100%;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 14px;
    border-radius: 20px;
    overflow: hidden;
  }

  .sign-clean-shell {
    padding: 14px 12px 32px;
  }

  .sign-clean-card {
    padding: 18px;
    border-radius: 26px;
  }

  .sign-clean-header h1 {
    font-size: 28px;
    line-height: 1.02;
  }

  .sign-clean-header p:not(.eyebrow) {
    font-size: 14px;
  }

  .sign-clean-summary,
  .sign-clean-form {
    padding: 16px;
    border-radius: 22px;
  }

  .sign-clean-title h2 {
    font-size: 20px;
  }

  .sign-clean-meta {
    grid-template-columns: 1fr;
  }

  .sign-clean-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sign-clean-pad canvas {
    height: 218px;
  }

  .toast-stack {
    left: 12px;
    right: 12px;
    top: 12px;
  }

  .toast {
    min-width: 0;
    max-width: none;
    width: 100%;
  }
}

@media (max-width: 420px) {
  .item-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .item-cell-name,
  .item-row .item-cell:nth-child(6),
  .remove-row {
    grid-column: 1 / -1;
  }

  .sign-clean-header h1 {
    font-size: 26px;
  }
}
