:root {
  --bg: #f2f5f8;
  --panel: #ffffff;
  --sidebar: #0f1720;
  --sidebar-accent: #1f2937;
  --text: #111827;
  --muted: #6b7280;
  --primary: #006d77;
  --primary-strong: #03545b;
  --border: #d1d5db;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, sans-serif;
  background: linear-gradient(180deg, #f7fbfd 0%, var(--bg) 100%);
  color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: linear-gradient(180deg, var(--sidebar) 0%, #16202d 100%);
  color: #fff;
  padding: 18px;
}

.brand {
  margin-bottom: 20px;
}

.brand-logo {
  display: block;
  width: 100%;
  max-width: 180px;
  height: auto;
}

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

.nav-item {
  width: 100%;
  border: 0;
  text-align: left;
  color: #fff;
  background: transparent;
  padding: 12px 14px;
  border-radius: 8px;
  cursor: pointer;
}

.nav-item.active {
  background: var(--sidebar-accent);
}

.content {
  padding: 24px;
}

.shell-content {
  padding: 0;
}

.page-frame {
  width: 100%;
  height: 100vh;
  border: 0;
  background: transparent;
}

.content-panel[hidden] {
  display: none;
}

.page-wrapper {
  padding: 24px;
}

h1 {
  margin: 0;
  font-size: 30px;
}

.subtitle {
  color: var(--muted);
  margin-top: 8px;
}

form,
.document-panel {
  margin-top: 20px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
}

form > section + section {
  margin-top: 20px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

input,
textarea,
button,
.doc-link {
  font: inherit;
}

input,
textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
}

textarea {
  resize: vertical;
}

.stack {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 12px;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

legend {
  font-weight: 700;
  padding: 0 6px;
}

fieldset label {
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-weight: 500;
}

fieldset input[type="radio"] {
  margin: 0;
}

.textareas {
  display: grid;
  gap: 12px;
}

.signature-section {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
}

.signature-section h2 {
  margin: 0 0 12px;
  font-size: 18px;
}

#signature-pad {
  width: 100%;
  max-width: 700px;
  height: 180px;
  border: 1px dashed #9ca3af;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

#project-signature-pad {
  width: 100%;
  max-width: 700px;
  height: 180px;
  border: 1px dashed #9ca3af;
  border-radius: 8px;
  background: #fff;
  touch-action: none;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.doc-link {
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  padding: 10px 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.doc-link:hover {
  background: var(--primary-strong);
}

#saved-signature-preview {
  margin-top: 12px;
  max-width: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
}

#project-signature-preview,
#project-stamp-preview {
  margin-top: 12px;
  max-width: 300px;
  border: 1px solid var(--border);
  border-radius: 8px;
  display: none;
}

.field-note {
  margin: 0;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}

.field-note.warning {
  color: #b45309;
}

.file-upload-label {
  margin-top: 14px;
}

.pdf-preview-section h2 {
  margin: 0;
  font-size: 18px;
}

.pdf-preview {
  margin-top: 14px;
  width: 100%;
  min-height: 70vh;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #fff;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    padding-bottom: 8px;
  }

  .page-wrapper {
    padding: 16px;
  }

  form,
  .document-panel {
    padding: 14px;
  }

  .pdf-preview {
    min-height: 55vh;
  }
}
