:root {
  --bg: #f7f8fa;
  --bg-elev: #ffffff;
  --bg-soft: #f1f3f6;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --text: #111827;
  --text-dim: #4b5563;
  --text-mute: #9ca3af;
  --accent: #111827;
  --accent-hover: #000000;
  --accent-soft: #eef0f4;
  --link: #2563eb;
  --link-hover: #1d4ed8;
  --success: #047857;
  --success-bg: #ecfdf5;
  --danger: #b91c1c;
  --danger-bg: #fef2f2;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(15,23,42,0.04), 0 1px 3px rgba(15,23,42,0.06);
  --shadow-lg: 0 10px 30px rgba(15,23,42,0.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "Inter", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--link-hover); text-decoration: underline; }
hr { border: 0; border-top: 1px solid var(--border); margin: 24px 0; }

.app-header {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.app-header-inner {
  max-width: 1200px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px;
}
.brand {
  font-weight: 600; font-size: 16px; letter-spacing: -0.01em;
  display: flex; align-items: center; gap: 10px;
  color: var(--text);
}
.brand-mark {
  width: 26px; height: 26px; border-radius: 6px;
  background: var(--text); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700; letter-spacing: -0.02em;
}
.nav { display: flex; gap: 2px; align-items: center; }
.nav a {
  color: var(--text-dim); padding: 7px 12px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 14px; transition: 0.15s;
  text-decoration: none;
}
.nav a:hover { color: var(--text); background: var(--bg-soft); text-decoration: none; }
.nav a.active { color: var(--text); background: var(--bg-soft); }
.nav .btn-logout {
  background: transparent; border: 0; cursor: pointer;
  color: var(--text-dim); padding: 7px 12px;
  border-radius: var(--radius-sm); font-size: 14px;
  font-family: inherit;
}
.nav .btn-logout:hover { color: var(--danger); background: var(--danger-bg); }

.container { max-width: 1200px; margin: 0 auto; padding: 32px 24px 80px; }
.container-sm { max-width: 760px; }
.container-xs { max-width: 460px; }

h1 { font-size: 26px; margin: 0 0 6px; font-weight: 600; letter-spacing: -0.02em; }
h2 { font-size: 17px; margin: 28px 0 10px; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 14px; margin: 14px 0 6px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; }
.subtitle { color: var(--text-dim); margin: 0 0 24px; font-size: 15px; }

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
  margin-bottom: 18px;
  box-shadow: var(--shadow);
}
.card-tight { padding: 14px; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 18px;
}
.card-header h2, .card-header h1 { margin: 0; }
.card h2:first-child { margin-top: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 720px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

label {
  display: block; font-size: 13px; color: var(--text);
  margin-bottom: 5px; font-weight: 500;
}
input[type=text], input[type=email], input[type=tel], input[type=number], input[type=password], select, textarea {
  width: 100%;
  background: white;
  border: 1px solid var(--border-strong);
  color: var(--text);
  padding: 9px 11px;
  border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--text);
  box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}
textarea { min-height: 90px; resize: vertical; line-height: 1.55; }
input::placeholder, textarea::placeholder { color: var(--text-mute); }

.field { margin-bottom: 14px; }
.field-row { display: flex; gap: 12px; }
.field-row > * { flex: 1; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--accent); color: white; border: 1px solid var(--accent);
  padding: 9px 16px; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: 0.15s;
  text-decoration: none; line-height: 1.4;
}
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: white; text-decoration: none; }
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-secondary {
  background: white; color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--bg-soft); color: var(--text); border-color: var(--border-strong); }
.btn-ghost { background: transparent; color: var(--text-dim); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-soft); color: var(--text); border-color: transparent; }
.btn-danger {
  background: white; color: var(--danger);
  border: 1px solid #fecaca;
}
.btn-danger:hover { background: var(--danger-bg); color: var(--danger); border-color: #fca5a5; }
.btn-block { width: 100%; }
.btn-lg { padding: 12px 22px; font-size: 15px; }
.btn-sm { padding: 6px 11px; font-size: 13px; }

.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th {
  color: var(--text-dim); font-weight: 500; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.05em;
  background: var(--bg-soft);
}
tbody tr { transition: background 0.1s; }
tbody tr:hover { background: var(--bg-soft); }
tbody tr:last-child td { border-bottom: 0; }
.table-wrap {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow);
}

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 99px;
  font-size: 12px; font-weight: 500;
  border: 1px solid transparent;
}
.badge-pending { background: var(--warn-bg); color: var(--warn); border-color: #fde68a; }
.badge-signed { background: var(--success-bg); color: var(--success); border-color: #a7f3d0; }
.badge-mute { background: var(--bg-soft); color: var(--text-dim); border-color: var(--border); }

.alert {
  padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--bg-soft); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; margin-bottom: 16px;
}
.alert-error { background: var(--danger-bg); border-color: #fecaca; color: var(--danger); }
.alert-success { background: var(--success-bg); border-color: #a7f3d0; color: var(--success); }

.muted { color: var(--text-dim); }
.small { font-size: 13px; }
.tiny { font-size: 12px; color: var(--text-dim); }
.mono { font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace; font-size: 13px; }

.empty-state {
  text-align: center; padding: 60px 24px;
  color: var(--text-dim);
}
.empty-state h2 { margin: 0 0 6px; color: var(--text); }
.empty-state p { margin: 0 0 16px; }

.package-card {
  position: relative; cursor: pointer;
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
  transition: 0.15s;
}
.package-card:hover { border-color: var(--border-strong); }
.package-card.selected {
  border-color: var(--text); border-width: 1.5px;
  padding: 19.5px;
  background: white;
}
.package-card input[type=radio] { position: absolute; opacity: 0; }
.package-title { font-size: 17px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.package-price { color: var(--text); font-size: 22px; font-weight: 600; margin: 0 0 14px; letter-spacing: -0.01em; }
.package-list { list-style: none; padding: 0; margin: 0; }
.package-list li {
  padding: 4px 0 4px 22px; position: relative;
  font-size: 13.5px; color: var(--text-dim);
}
.package-list li::before {
  content: '✓'; position: absolute; left: 0;
  color: var(--success); font-weight: 600;
}

.addon-card {
  background: white; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
  display: flex; align-items: center; gap: 12px; cursor: pointer;
  transition: 0.12s;
}
.addon-card:hover { border-color: var(--border-strong); background: var(--bg-soft); }
.addon-card.selected { border-color: var(--text); background: white; box-shadow: 0 0 0 1px var(--text); }
.addon-card input { margin: 0; accent-color: var(--text); }
.addon-card .addon-info { flex: 1; }
.addon-card .addon-name { font-weight: 500; font-size: 14px; }
.addon-card .addon-price { color: var(--text); font-weight: 600; font-size: 14px; }

.summary-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.summary-row {
  display: flex; justify-content: space-between;
  padding: 5px 0; font-size: 14px;
  color: var(--text-dim);
}
.summary-row span:last-child { color: var(--text); font-weight: 500; }
.summary-row.total {
  border-top: 1px solid var(--border);
  margin-top: 10px; padding-top: 12px;
  font-size: 15px; font-weight: 600; color: var(--text);
}
.summary-row.total span:last-child { font-weight: 600; }

.copy-row {
  display: flex; gap: 6px;
  background: white; border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 4px;
  align-items: center;
}
.copy-row input {
  border: 0; background: transparent;
  flex: 1; padding: 7px 9px; font-size: 13px;
  font-family: ui-monospace, monospace;
}
.copy-row input:focus { background: transparent; box-shadow: none; }

/* Customer card */
.customer-pick {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
}
.customer-pick .info { flex: 1; }
.customer-pick .name { font-weight: 600; font-size: 15px; }
.customer-pick .sub { color: var(--text-dim); font-size: 13px; }
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--text); color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 14px; letter-spacing: -0.01em;
  flex-shrink: 0;
}

/* sign page */
.sign-shell { max-width: 760px; margin: 0 auto; padding: 16px; }
.sign-doc {
  background: var(--bg-elev); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 22px; margin-bottom: 16px;
  box-shadow: var(--shadow);
}
.pdf-preview-frame {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #f3f4f6;
}
.pdf-preview-frame object { display: block; width: 100%; }
@media (max-width: 640px) {
  .pdf-preview-frame object { height: 480px !important; }
}
.sig-canvas-wrap {
  background: white; border-radius: var(--radius-sm);
  border: 2px dashed var(--border-strong);
  position: relative; touch-action: none;
}
.sig-canvas-wrap canvas { display: block; width: 100%; height: 200px; border-radius: var(--radius-sm); }
.sig-hint {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--text-mute); pointer-events: none; font-size: 14px;
}
.sig-hint.hidden { display: none; }
.checkbox-row {
  display: flex; gap: 10px; align-items: flex-start;
  cursor: pointer; padding: 12px 0;
}
.checkbox-row input { margin: 3px 0 0; flex-shrink: 0; accent-color: var(--text); }
.checkbox-row span { font-size: 14px; color: var(--text-dim); }

.success-screen {
  text-align: center; padding: 40px 20px;
}
.success-icon {
  width: 64px; height: 64px; border-radius: 50%;
  background: var(--success-bg); color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: 30px; margin: 0 auto 18px;
  border: 1px solid #a7f3d0;
}

@media (max-width: 600px) {
  .container { padding: 20px 14px 60px; }
  .card { padding: 16px; }
  h1 { font-size: 22px; }
  .nav a { padding: 6px 10px; font-size: 13px; }
  .app-header-inner { padding: 10px 14px; }
}
