* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f6f8fa;
  color: #1f2328;
  line-height: 1.5;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  background: #1a1f2b;
  color: #e6edf3;
  border-bottom: 1px solid #21262d;
}
.brand a {
  color: #fff;
  text-decoration: none;
  font-weight: 600;
  font-size: 1.1rem;
  margin-right: 12px;
}
.badge {
  display: inline-block;
  background: #2d333b;
  color: #adbac7;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 10px;
}
.nav a {
  color: #adbac7;
  text-decoration: none;
  margin-left: 18px;
  font-size: 0.95rem;
}
.nav a.active, .nav a:hover { color: #fff; }

.container { max-width: 1100px; margin: 24px auto; padding: 0 24px; }

h1 { margin-top: 0; }

.hero {
  background: #fff;
  padding: 48px 32px;
  border-radius: 8px;
  border: 1px solid #d0d7de;
  text-align: center;
}
.cta { margin-top: 20px; display: flex; justify-content: center; gap: 12px; }

.btn {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  border: 1px solid #b6e3ff;
  background: #ddf4ff;
  color: #0969da;
  text-decoration: none;
  cursor: pointer;
  font-size: 0.9rem;
}
.btn:hover { background: #b6e3ff; border-color: #0969da; }
.btn.primary { background: #1f6feb; color: #fff; border-color: #1f6feb; }
.btn.primary:hover { background: #1858c4; }
.btn.danger { background: #cf222e; color: #fff; border-color: #cf222e; }
.btn.small { padding: 4px 10px; font-size: 0.8rem; }

.card {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
}

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 32px; }
.stat {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}
.stat .num { display: block; font-size: 2rem; font-weight: 600; color: #1f6feb; }
.stat .lbl { display: block; font-size: 0.85rem; color: #57606a; margin-top: 4px; }

.table { width: 100%; border-collapse: collapse; background: #fff; border-radius: 8px; overflow: hidden; border: 1px solid #d0d7de; }
.table th, .table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid #eaeef2; font-size: 0.9rem; }
.table th { background: #f6f8fa; font-weight: 600; }
.table tr:last-child td { border-bottom: none; }

.status { display: inline-block; padding: 2px 10px; border-radius: 10px; font-size: 0.75rem; text-transform: uppercase; font-weight: 600; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-signed { background: #d1fae5; color: #065f46; }
.status-failed { background: #fee2e2; color: #991b1b; }
.err-msg { font-size: 0.75rem; color: #991b1b; margin-top: 4px; }

.form .field { margin-bottom: 14px; }
.form label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 4px; }
.form input[type="text"], .form input[type="email"], .form input[type="file"], .form select {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
}
.form.inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form.inline input, .form.inline select { width: auto; flex: 1; min-width: 150px; }

.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; font-size: 0.9rem; }
.flash.success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }

.muted { color: #57606a; }

.footer { text-align: center; padding: 24px; color: #57606a; font-size: 0.85rem; }

.error-card { text-align: center; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 600px) { .grid-2 { grid-template-columns: 1fr; } }

.form textarea {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.85rem;
  resize: vertical;
}

.form input[type="password"] {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  font-size: 0.9rem;
}

code.json {
  display: inline-block;
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.75rem;
  color: #57606a;
}

.comp-list { margin: 0; padding-left: 18px; font-size: 0.85rem; }

.status-invalid { background: #f3f4f6; color: #57606a; }
.status-requested { background: #dbeafe; color: #1e40af; }
.status-processing { background: #fef3c7; color: #92400e; }
.status-done { background: #d1fae5; color: #065f46; }
.status-expired { background: #f3e8ff; color: #6b21a8; }
.status-failed { background: #fee2e2; color: #991b1b; }

.user-info { display: flex; align-items: center; gap: 12px; color: #adbac7; font-size: 0.85rem; }
.user-info .user-name { color: #fff; }
.user-info .badge.admin { background: #1f6feb; color: #fff; margin-left: 4px; }
.inline-form { display: inline; margin: 0; }
.user-info .btn { background: #2d333b; border-color: #444c56; color: #adbac7; }
.user-info .btn:hover { background: #444c56; color: #fff; }

.auth-body {
  background: #f6f8fa;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  margin: 0;
}
.auth-card {
  background: #fff;
  padding: 40px;
  border-radius: 12px;
  border: 1px solid #d0d7de;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  width: 100%;
  max-width: 400px;
}
.auth-card h1 { margin-top: 0; text-align: center; }
.auth-card p { text-align: center; }
.btn.block { display: block; width: 100%; padding: 10px; }

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  margin: 0;
  font: inherit;
  color: #0969da;
  cursor: pointer;
  text-decoration: underline;
}
.btn-link:hover { color: #1f6feb; }

.btn.btn-download {
  background: #008080;
  border-color: #008080;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}
.btn.btn-download:hover {
  background: #006666;
  border-color: #006666;
  color: #fff;
}

.flash.error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.checkbox-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin-bottom: 16px; }
.checkbox { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; padding: 6px 10px; border: 1px solid #d0d7de; border-radius: 6px; background: #fff; cursor: pointer; }
.checkbox input { margin: 0; }
.form-actions { display: flex; gap: 8px; margin-top: 16px; }

.email-list { margin: 0; padding-left: 18px; font-size: 0.85rem; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-overlay[hidden] { display: none; }
.row-actions { display: flex; gap: 6px; }

/* === Project edit modal — modern redesign === */
.modal.modal-edit {
  width: 880px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  padding: 0;
  display: flex;
  flex-direction: column;
  background: #f6f8fa;
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(15, 20, 30, 0.28);
  overflow: hidden;
}
.modal-edit .modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 24px 16px;
  background: #fff;
  border-bottom: 1px solid #d0d7de;
}
.modal-edit .modal-header h3 { margin: 0; font-size: 1.1rem; font-weight: 600; }
.modal-edit .modal-subtitle {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: #57606a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.modal-edit form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}
.modal-edit .modal-body { flex: 1; overflow-y: auto; padding: 18px 24px; min-height: 0; }
.modal-edit .modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 24px;
  background: #fff;
  border-top: 1px solid #d0d7de;
}

.btn.ghost {
  background: #eaeef2;
  border-color: #d0d7de;
  color: #1f2328;
}
.btn.ghost:hover { background: #d0d7de; border-color: #adbac7; }
.btn.ghost-small {
  padding: 4px 10px;
  font-size: 0.78rem;
  background: #eaeef2;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  cursor: pointer;
  color: #1f2328;
}
.btn.ghost-small:hover { background: #d0d7de; border-color: #adbac7; }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: transparent;
  color: #57606a;
  font-size: 1.15rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.btn-icon:hover { background: #eaeef2; color: #1f2328; }
.btn-icon.danger:hover { background: #fee2e2; color: #cf222e; }

.panel {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  margin-bottom: 14px;
  overflow: hidden;
}
.panel:last-child { margin-bottom: 0; }
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid #eaeef2;
  background: #fafbfc;
}
.panel-header > div:first-child { min-width: 0; }
.panel-header h4 { margin: 0; font-size: 0.92rem; font-weight: 600; color: #1f2328; }
.panel-help { margin: 2px 0 0; font-size: 0.78rem; color: #57606a; }
.panel-body { padding: 14px 16px; }

.field-modern { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.field-modern[hidden] { display: none; }
.field-modern:last-child { margin-bottom: 0; }
.field-modern > label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #57606a;
}
.field-modern input[type="text"],
.field-modern input[type="email"],
.field-modern input[type="number"],
.field-modern input[type="password"],
.field-modern textarea,
.field-modern select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  font-size: 0.9rem;
  color: #1f2328;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s, background-color 0.12s;
}
.field-modern select {
  padding-right: 36px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 16 16' fill='%2357606a'%3E%3Cpath d='M4 6l4 4 4-4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  line-height: 1.4;
}
.field-modern select:hover { border-color: #adbac7; }
.field-modern input:focus,
.field-modern textarea:focus,
.field-modern select:focus {
  outline: none;
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.field-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
@media (max-width: 720px) {
  .field-grid-2, .field-grid-3 { grid-template-columns: 1fr; }
}

.checkbox-grid-modern {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 6px;
}
.checkbox-modern {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  background: #fff;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}
.checkbox-modern:hover { border-color: #adbac7; background: #fafbfc; }
.checkbox-modern input { margin: 0; accent-color: #1f6feb; }
.checkbox-modern .muted { font-size: 0.78rem; }

.entry-list { counter-reset: entry; display: flex; flex-direction: column; gap: 12px; }
.entry-list:empty {
  display: block;
  padding: 24px;
  border: 1px dashed #d0d7de;
  border-radius: 8px;
  text-align: center;
  background: #fafbfc;
}
.entry-list:empty::before {
  content: attr(data-empty);
  color: #57606a;
  font-size: 0.85rem;
}

.entry-card {
  counter-increment: entry;
  background: #fff;
  border: 1px solid #d0d7de;
  border-left: 4px solid var(--entry-accent, #1f6feb);
  border-radius: 8px;
  overflow: hidden;
}
.entry-card.entry-signing { --entry-accent: #1f6feb; }
.entry-card.entry-extra { --entry-accent: #8957e5; }

.entry-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: #fafbfc;
  border-bottom: 1px solid #eaeef2;
}
.entry-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: 12px;
  background: var(--entry-accent, #1f6feb);
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
}
.entry-badge::before { content: counter(entry); }
.entry-title {
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.entry-type-label { font-size: 0.85rem; font-weight: 600; color: #1f2328; }
.entry-type-name {
  font-size: 0.82rem;
  color: #57606a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.entry-body { padding: 14px; }

.subentry-section { margin-top: 12px; padding-top: 12px; border-top: 1px dashed #d0d7de; }
.subentry-section.flush { margin-top: 0; padding-top: 0; border-top: none; }
.subentry-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.subentry-header h5 {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #57606a;
}
.partitions-list { counter-reset: partition; display: flex; flex-direction: column; gap: 8px; }
.partitions-list:empty { display: block; padding: 8px 0; }
.partitions-list:empty::before {
  content: "No partitions yet.";
  font-size: 0.8rem;
  color: #57606a;
}
.subentry-card {
  counter-increment: partition;
  background: #f6f8fa;
  border: 1px solid #eaeef2;
  border-radius: 6px;
  padding: 10px 12px;
}
.subentry-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.subentry-badge {
  font-size: 0.78rem;
  font-weight: 600;
  color: #1f2328;
}
.subentry-badge::before { content: "Partition " counter(partition); }

.required-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  user-select: none;
  padding: 7px 0;
  text-transform: none;
  letter-spacing: 0;
  font-weight: 400;
  color: #1f2328;
}
.required-toggle input { accent-color: #1f6feb; }
.modal {
  background: #fff;
  border-radius: 8px;
  padding: 22px 24px;
  width: 380px;
  max-width: calc(100% - 32px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}
.modal h3 { margin: 0 0 12px; font-size: 1.05rem; }
.modal .request-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 1.4rem;
  font-weight: 600;
  letter-spacing: 1px;
  color: #1f2328;
  background: #f6f8fa;
  border: 1px solid #d0d7de;
  border-radius: 6px;
  padding: 8px 12px;
  text-align: center;
  margin: 8px 0 4px;
}
.modal .modal-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 0.9rem;
  margin: 8px 0 0;
}
.modal-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.modal-actions[hidden] { display: none; }

.progress {
  width: 100%;
  height: 14px;
  background: #eaeef2;
  border-radius: 7px;
  overflow: hidden;
  margin: 12px 0 4px;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: #1f6feb;
  transition: width 0.15s ease;
}
.progress-bar.indeterminate {
  width: 40%;
  background: linear-gradient(90deg, #1f6feb 0%, #58a6ff 50%, #1f6feb 100%);
  animation: progress-slide 1.1s linear infinite;
}
@keyframes progress-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(250%); }
}

/* === Signing request page — modern redesign === */
.section-title {
  margin: 24px 0 12px;
  font-size: 1.05rem;
  font-weight: 600;
  color: #1f2328;
}
.request-form .panel { margin-bottom: 14px; }
.request-form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  margin-top: 14px;
}
.request-form-footer p { margin: 0; font-size: 0.85rem; color: #57606a; }

.partition-card {
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.partition-card:last-child { margin-bottom: 0; }
.partition-card.partition-extra { border-left: 3px solid #8957e5; }
.partition-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}
.partition-name { font-size: 0.92rem; font-weight: 600; color: #1f2328; }
.partition-required { color: #cf222e; margin-left: 2px; }
.partition-desc { font-size: 0.85rem; color: #57606a; }
.partition-hint { margin: 6px 0 0; font-size: 0.78rem; color: #57606a; }

.file-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.file-pick-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: 1px solid #b6e3ff;
  border-radius: 6px;
  background: #ddf4ff;
  cursor: pointer;
  font-size: 0.85rem;
  color: #0969da;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s, box-shadow 0.12s;
  user-select: none;
}
.file-pick-btn:hover { background: #b6e3ff; border-color: #0969da; }
.file-pick-btn:focus-within {
  outline: none;
  border-color: #1f6feb;
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.file-pick-btn input[type="file"] {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  pointer-events: none;
}
.file-pick-name {
  font-size: 0.85rem;
  color: #57606a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 360px;
  flex: 1;
  min-width: 0;
}
.file-pick-name.has-file { color: #1f2328; font-weight: 500; }
.file-pick-clear {
  background: transparent;
  border: 0;
  color: #57606a;
  cursor: pointer;
  padding: 0 8px;
  font-size: 1.15rem;
  line-height: 1;
  border-radius: 4px;
  height: 24px;
}
.file-pick-clear:hover { background: #fee2e2; color: #cf222e; }

.field-error {
  color: #cf222e;
  font-size: 0.85rem;
  margin: 4px 0 0;
}
.empty-card {
  background: #fff;
  border: 1px dashed #d0d7de;
  border-radius: 10px;
  padding: 24px;
  text-align: center;
}
.empty-card p { margin: 0; font-size: 0.9rem; }

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-top: 14px;
  font-size: 0.85rem;
}
.pagination .pagination-info {
  color: #57606a;
  min-width: 110px;
  text-align: center;
}
.pagination-pages {
  display: flex;
  align-items: center;
  gap: 4px;
}
.pagination-page {
  color: #1f6feb;
  text-decoration: none;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.85rem;
}
.pagination-page:hover { background: #ddf4ff; }
.pagination-page.current {
  font-weight: 600;
  color: #1f2328;
  background: #eaeef2;
  cursor: default;
}
.pagination-sep {
  color: #d0d7de;
  user-select: none;
}
.pagination .btn { padding: 4px 12px; font-size: 0.85rem; }
.pagination .btn[aria-disabled="true"] {
  opacity: 0.4;
  pointer-events: none;
}

/* Project cards (general user dashboard) */
.project-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.project-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #d0d7de;
  border-radius: 10px;
  padding: 16px;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.12s, transform 0.12s, box-shadow 0.12s;
}
.project-card:hover {
  border-color: #1f6feb;
  box-shadow: 0 4px 14px rgba(31, 111, 235, 0.12);
  transform: translateY(-1px);
}
.project-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.project-card-title {
  font-size: 1rem;
  font-weight: 600;
  color: #1f2328;
  line-height: 1.3;
  flex: 1;
  min-width: 0;
}
.project-card-codename {
  display: inline-block;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.72rem;
  color: #0969da;
  background: #ddf4ff;
  border: 1px solid #b6e3ff;
  padding: 2px 8px;
  border-radius: 11px;
  white-space: nowrap;
}
.project-card-desc {
  font-size: 0.85rem;
  color: #57606a;
  margin: 0 0 12px;
  line-height: 1.45;
  flex: 1;
}
.project-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.78rem;
  border-top: 1px solid #eaeef2;
  padding-top: 10px;
  margin-top: auto;
}
.project-card-link {
  color: #1f6feb;
  font-weight: 500;
}
