:root {
  --dg-bg: #f5f7fb;
  --dg-surface: #ffffff;
  --dg-surface-soft: #f0f3f8;
  --dg-text: #172033;
  --dg-muted: #667085;
  --dg-border: #d9e0ea;
  --dg-orange: #ff7a00;
  --dg-orange-dark: #d96500;
  --dg-ink: #111827;
  --dg-ok: #00855a;
  --dg-warn: #a15c00;
}

* { box-sizing: border-box; }

html {
  min-height: 100%;
  background: var(--dg-bg);
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--dg-bg);
  color: var(--dg-text);
  font-family: Inter, Arial, Helvetica, sans-serif;
  letter-spacing: 0;
}

a { color: inherit; }

.auth-page {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  min-height: 100vh;
}

.auth-panel {
  background: var(--dg-surface);
  border-right: 1px solid var(--dg-border);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-visual {
  padding: 56px;
  background: #172033;
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  min-height: 320px;
}

.sign-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  background: var(--dg-bg);
}

.sign-panel {
  background: var(--dg-surface);
  border-right: 1px solid var(--dg-border);
  padding: 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.sign-document {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #172033;
}

.document-toolbar {
  min-height: 70px;
  padding: 14px 18px;
  background: #fff;
  border-bottom: 1px solid var(--dg-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.document-toolbar span {
  display: block;
  margin-top: 3px;
  color: var(--dg-muted);
  font-size: 13px;
}

.pdf-frame {
  width: 100%;
  flex: 1;
  border: 0;
  background: #fff;
}

.sign-proof {
  padding: 56px;
  color: #fff;
  margin-top: auto;
}

.document-preview-mobile { display: none; }

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 900;
  font-size: 22px;
}

.brand-logo {
  display: block;
  width: 210px;
  height: 112px;
  max-width: 100%;
  max-height: 112px;
  object-fit: contain;
  object-position: left center;
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  background: var(--dg-orange);
  color: #fff;
  font-weight: 900;
}

.auth-title {
  margin: 36px 0 10px;
  font-size: 32px;
  line-height: 1.1;
}

.muted { color: var(--dg-muted); }

.field { margin-top: 18px; }
.field label {
  display: block;
  font-weight: 800;
  font-size: 13px;
  margin-bottom: 8px;
}

.input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--dg-border);
  border-radius: 8px;
  padding: 11px 13px;
  font-size: 15px;
  background: #fff;
}

.input:focus {
  outline: 2px solid rgba(255, 122, 0, .22);
  border-color: var(--dg-orange);
}

.btn {
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-weight: 900;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--dg-orange);
  color: #fff;
}

.btn-primary:hover { background: var(--dg-orange-dark); }

.btn-ghost {
  background: var(--dg-surface-soft);
  color: var(--dg-text);
  border: 1px solid var(--dg-border);
}

.alert {
  border-radius: 8px;
  padding: 12px 14px;
  margin: 18px 0;
  font-weight: 700;
}
.alert-error { background: #fff1f0; color: #9f1f17; border: 1px solid #ffd2cf; }
.alert-ok { background: #ecfdf5; color: #067647; border: 1px solid #a6f4c5; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px 1fr;
  align-items: start;
}

.sidebar {
  background: #172033;
  color: #fff;
  padding: 24px 18px;
  position: sticky;
  top: 0;
  min-height: 100vh;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .brand {
  height: 116px;
  margin-bottom: 18px;
  overflow: hidden;
}

.auth-panel .brand,
.sign-panel .brand {
  min-height: 116px;
}

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

.nav a {
  text-decoration: none;
  color: #d9e2f0;
  padding: 12px 14px;
  border-radius: 8px;
  font-weight: 800;
}

.nav a.active,
.nav a:hover {
  color: #fff;
  background: rgba(255, 122, 0, .18);
}

.main {
  padding: 28px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}

.topbar h1 {
  margin: 0;
  font-size: 28px;
}

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

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

.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }

.filter-bar {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(160px, .8fr) minmax(160px, .8fr) minmax(160px, .8fr) auto auto;
  gap: 10px;
  align-items: center;
}

.card {
  background: var(--dg-surface);
  border: 1px solid var(--dg-border);
  border-radius: 8px;
  padding: 18px;
  overflow: visible;
}

.card-inner {
  margin-top: 18px;
  background: #fbfcff;
}

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

.option-card {
  border: 1px solid var(--dg-border);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  cursor: pointer;
}

.option-card strong,
.option-card small {
  display: block;
}

.option-card small {
  margin-top: 5px;
  color: var(--dg-muted);
  line-height: 1.35;
}

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

.check-grid label {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 800;
  font-size: 13px;
}

.metric-label {
  color: var(--dg-muted);
  font-weight: 800;
  font-size: 13px;
}

.metric-value {
  font-size: 30px;
  font-weight: 900;
  margin-top: 8px;
}

.section-title {
  font-size: 18px;
  margin: 0 0 14px;
}

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

.table th,
.table td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--dg-border);
  font-size: 14px;
  vertical-align: top;
}

.table th {
  color: var(--dg-muted);
  font-size: 12px;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--dg-surface-soft);
  font-size: 12px;
  font-weight: 900;
}

.actions-menu {
  position: relative;
  display: inline-flex;
  justify-content: flex-end;
  z-index: 20;
}

.gear-btn {
  width: 38px;
  height: 38px;
  border: 1px solid var(--dg-border);
  border-radius: 999px;
  background: #fff;
  color: var(--dg-muted);
  display: inline-grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: background .15s ease, border-color .15s ease, box-shadow .15s ease;
}

.gear-btn svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.gear-btn:hover,
.actions-menu:focus-within .gear-btn {
  background: var(--dg-surface-soft);
  border-color: #c7d0dd;
  box-shadow: 0 4px 12px rgba(23, 32, 51, .08);
}

.actions-dropdown {
  position: absolute;
  top: 42px;
  right: 0;
  min-width: 190px;
  z-index: 999;
  background: #fff;
  border: 1px solid var(--dg-border);
  border-radius: 8px;
  box-shadow: 0 16px 34px rgba(23, 32, 51, .2);
  padding: 6px;
}

.actions-dropdown[hidden] {
  display: none;
}

.actions-dropdown a,
.actions-dropdown button {
  width: 100%;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--dg-text);
  display: flex;
  align-items: center;
  padding: 8px 10px;
  text-align: left;
  text-decoration: none;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.actions-dropdown a:hover,
.actions-dropdown button:hover {
  background: var(--dg-surface-soft);
}

.sign-link-row td {
  background: #fafbfe;
  padding-top: 10px;
  padding-bottom: 14px;
}

.sign-link-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
}

.input-copy {
  min-height: 38px;
  font-size: 13px;
  font-family: Consolas, Monaco, monospace;
}

.btn-copy {
  min-height: 38px;
  white-space: nowrap;
}

@media (max-width: 900px) {
  .auth-page,
  .sign-page,
  .app-shell,
  .grid-4,
  .grid-2 {
    grid-template-columns: 1fr;
  }
  .auth-visual { display: none; }
  .auth-panel,
  .sign-panel { padding: 28px; }
  .sign-document { display: none; }
  .document-preview-mobile { display: block; margin-top: 18px; }
  .sidebar {
    position: static;
    min-height: auto;
    height: auto;
  }
  .topbar { align-items: flex-start; flex-direction: column; }
  .filter-bar { grid-template-columns: 1fr; }
  .signature-options,
  .check-grid { grid-template-columns: 1fr; }
}
