@font-face {
  font-family: Manrope;
  src: url("../fonts/manrope-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("../fonts/manrope-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: Manrope;
  src: url("../fonts/manrope-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

:root {
  --orange: #f36815;
  --green: #005e2c;
  --ink: #142018;
  --text: #3e4a44;
  --line: #e4e0d8;
  --paper: #ffffff;
  --page: #f3f0ea;
  --green-dark: #004a23;
  --orange-hover: #d95a10;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(20, 32, 24, 0.06);
  --font: Manrope, "Segoe UI", system-ui, sans-serif;
  --tap: 44px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text);
  background: var(--page);
}

img,
svg {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--green);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--orange);
}

h1,
h2,
h3,
h4 {
  color: var(--ink);
  line-height: 1.25;
  margin: 0 0 0.5em;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
}

h2 {
  font-size: 1.2rem;
  font-weight: 600;
}

p {
  margin: 0 0 1em;
}

p:last-child {
  margin-bottom: 0;
}

ul,
ol {
  margin: 0 0 1em;
  padding-left: 1.25em;
}

.wordmark {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
}

.wordmark-place {
  color: var(--orange);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4em;
  min-height: var(--tap);
  padding: 0.6em 1.25em;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.btn-primary {
  background: var(--orange);
  color: var(--paper);
  border-color: var(--orange);
}

.btn-primary:hover {
  background: var(--orange-hover);
  border-color: var(--orange-hover);
  color: var(--paper);
}

.btn-secondary {
  background: var(--paper);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover {
  border-color: var(--green);
  color: var(--green);
}

.btn-ghost {
  background: transparent;
  color: var(--green);
  border-color: transparent;
}

.btn-ghost:hover {
  background: rgba(0, 94, 44, 0.08);
}

.btn-danger {
  background: var(--paper);
  color: #a32;
  border-color: #e8c4c4;
}

.btn-danger:hover {
  background: #fff5f5;
  border-color: #d99;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  min-height: 36px;
  padding: 0.35em 0.85em;
  font-size: 0.9rem;
}

/* Forms */
label {
  display: block;
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--ink);
  margin-bottom: 0.35em;
}

.field {
  margin-bottom: 1.1rem;
}

.field-hint {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.25em;
  font-weight: 400;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="tel"],
input[type="search"],
input[type="url"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: 0.55em 0.75em;
  font-family: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

textarea {
  min-height: 100px;
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid var(--green);
  outline-offset: 1px;
  border-color: var(--green);
}

.field-grid {
  display: grid;
  gap: 0 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .plain-list {
  list-style: none;
  margin: 0 0 1rem;
  padding: 0;
  display: grid;
  gap: 0.75rem;
}

.field-grid-2 {
    grid-template-columns: 1fr 1fr;
  }
}

.error-list {
  background: #fff5f5;
  border: 1px solid #e8c4c4;
  border-radius: var(--radius-sm);
  padding: 0.75em 1em;
  margin-bottom: 1.25rem;
  color: #822;
  list-style: disc;
}

.error-list li {
  margin: 0.25em 0;
}

/* Cards */
.card {
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1rem;
}

.card-header {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.card-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Flash & banners */
.flash,
.banner {
  padding: 0.85em 1em;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
}

.flash-ok,
.banner-ok {
  background: #e8f5ec;
  color: var(--green);
  border: 1px solid #b8dcc4;
}

.flash-bad,
.banner-bad {
  background: #fff5f5;
  color: #822;
  border: 1px solid #e8c4c4;
}

.banner-warn {
  background: #fff8f0;
  color: #6a4010;
  border: 1px solid #f0d8b8;
}

.banner-warn a {
  font-weight: 600;
}

/* Badges */
.badge {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.2em 0.55em;
  border-radius: 6px;
  background: var(--line);
  color: var(--text);
}

.badge-signed {
  background: #e8f5ec;
  color: var(--green);
}

.badge-open {
  background: #e8f0ff;
  color: #254;
}

.badge-expired,
.badge-revoked {
  background: var(--line);
  color: var(--text);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 0 -0.25rem;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.65em 0.5em;
  border-bottom: 1px solid var(--line);
}

table.data th {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.85rem;
}

table.data tr:hover td {
  background: rgba(243, 240, 234, 0.5);
}

table.data a.row-link {
  color: inherit;
  text-decoration: none;
  font-weight: 500;
}

table.data a.row-link:hover {
  color: var(--green);
}

/* Empty state */
.empty {
  text-align: center;
  padding: 2rem 1rem;
  color: var(--text);
}

.empty p {
  max-width: 28em;
  margin-left: auto;
  margin-right: auto;
}

/* Stats */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
  .stat-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-tile {
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1rem;
  box-shadow: var(--shadow);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.1;
}

.stat-label {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.15em;
}

/* Template tiles */
.tile-grid {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .tile-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .tile-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

.tile-link {
  display: block;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 1rem 1.15rem;
  box-shadow: var(--shadow);
  text-decoration: none;
  color: inherit;
  border: 2px solid transparent;
  transition: border-color 0.15s;
}

.tile-link:hover {
  border-color: var(--orange);
  color: inherit;
}

.tile-link h3 {
  margin: 0 0 0.35em;
  font-size: 1rem;
  color: var(--ink);
}

.tile-link p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text);
}

/* Segment control (job size) */
.segment {
  display: flex;
  flex-direction: row;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--paper);
}

.segment label {
  flex: 1;
  margin: 0;
  font-weight: 500;
  text-align: center;
  cursor: pointer;
}

.segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.segment span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0.5em;
  border-right: 1px solid var(--line);
  transition: background 0.15s;
}

.segment label:last-child span {
  border-right: none;
}

.segment input:checked + span {
  background: var(--green);
  color: var(--paper);
  font-weight: 600;
}

.segment input:focus-visible + span {
  outline: 2px solid var(--orange);
  outline-offset: -2px;
}

/* Section checkboxes */
.check-group {
  margin-bottom: 1.25rem;
}

.check-group h3 {
  font-size: 0.95rem;
  margin-bottom: 0.5em;
}

.check-list {
  display: grid;
  gap: 0.35rem;
}

.check-item {
  display: flex;
  align-items: flex-start;
  gap: 0.5em;
  font-weight: 400;
  cursor: pointer;
}

.check-item input {
  width: 1.15em;
  height: 1.15em;
  margin-top: 0.2em;
  flex-shrink: 0;
}

.radio-cards {
  display: grid;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.radio-card-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}

.radio-card-wrap .radio-card {
  flex: 1;
  min-width: 0;
}

.radio-card {
  display: flex;
  align-items: flex-start;
  gap: 0.65em;
  padding: 0.85em 1em;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  cursor: pointer;
  font-weight: 400;
}

.radio-card input {
  margin-top: 0.25em;
  flex-shrink: 0;
}

.radio-card:has(input:checked) {
  border-color: var(--green);
  background: #f8fcf9;
}

/* Definition list */
.dl-pairs {
  margin: 0 0 1.5rem;
}

.dl-pairs dt {
  font-weight: 600;
  color: var(--ink);
  font-size: 0.85rem;
  margin-top: 0.85em;
}

.dl-pairs dt:first-child {
  margin-top: 0;
}

.dl-pairs dd {
  margin: 0.15em 0 0;
  word-break: break-word;
}

.secret-value.hidden {
  display: none;
}

/* Mail panels */
.mail-panel {
  display: none;
  padding-top: 0.5rem;
}

.mail-panel.is-active {
  display: block;
}

/* Dashboard layout */
.dash {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.dash-nav {
  background: var(--green);
  color: var(--paper);
  flex-shrink: 0;
}

.dash-nav-inner {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem 1rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.dash-nav .wordmark {
  color: var(--paper);
  white-space: nowrap;
  flex-shrink: 0;
  margin-right: 0.5rem;
}

.dash-nav .wordmark-place {
  color: #ffb380;
}

.dash-nav-links {
  display: flex;
  gap: 0.15rem;
  flex: 1;
  min-width: 0;
}

.dash-nav-links a {
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
  padding: 0.5em 0.75em;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
}

.dash-nav-links a:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--paper);
}

.dash-nav-links a.is-active {
  background: rgba(255, 255, 255, 0.2);
  color: var(--paper);
  font-weight: 600;
}

.dash-nav-user {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  font-size: 0.85rem;
}

.dash-nav-user .username {
  opacity: 0.9;
  white-space: nowrap;
}

.dash-nav-user form {
  margin: 0;
}

.dash-nav-user .btn-ghost {
  color: var(--paper);
  min-height: 36px;
  padding: 0.35em 0.65em;
  font-size: 0.85rem;
}

.dash-nav-user .btn-ghost:hover {
  background: rgba(255, 255, 255, 0.15);
}

@media (min-width: 800px) {
  .dash {
    flex-direction: row;
  }

  .dash-nav {
    width: 220px;
    flex-direction: column;
  }

  .dash-nav-inner {
    flex-direction: column;
    align-items: stretch;
    padding: 1.25rem 1rem;
    overflow: visible;
    height: 100%;
    min-height: 100vh;
  }

  .dash-nav-links {
    flex-direction: column;
    flex: 1;
    margin-top: 1rem;
  }

  .dash-nav-links a {
    padding: 0.55em 0.75em;
  }

  .dash-nav-user {
    flex-direction: column;
    align-items: stretch;
    margin-top: auto;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
  }
}

.dash-main {
  flex: 1;
  min-width: 0;
  padding: 1.25rem;
  max-width: 1200px;
}

@media (min-width: 800px) {
  .dash-main {
    padding: 1.75rem 2rem;
  }
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.page-header h1 {
  margin: 0;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.search-form .field-grow {
  flex: 1;
  min-width: 12rem;
  margin-bottom: 0;
}

.actions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.25rem;
}

/* Login */
.auth-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: var(--page);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.75rem 1.5rem;
}

.auth-card .wordmark {
  text-align: center;
  margin-bottom: 1.25rem;
  font-size: 1.1rem;
}

.auth-lead {
  text-align: center;
  margin-bottom: 1.25rem;
  color: var(--text);
}

/* Customer public form */
.customer-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
}

.customer-header {
  padding: 1.25rem 1rem 0;
  text-align: center;
}

.customer-sheet {
  flex: 1;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.customer-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: 0.9rem;
  color: var(--text);
  border-top: 1px solid var(--line);
  background: var(--paper);
}

.customer-footer a {
  font-weight: 600;
}

/* Steps */
.step-progress {
  display: flex;
  gap: 0.35rem;
  margin-bottom: 1.25rem;
  overflow-x: auto;
  padding-bottom: 0.25rem;
}

.step-progress-dot {
  flex: 1;
  min-width: 2rem;
  height: 4px;
  border-radius: 2px;
  background: var(--line);
}

.step-progress-dot.is-done,
.step-progress-dot.is-current {
  background: var(--green);
}

.step {
  display: none;
}

.step.is-active {
  display: block;
}

.step-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1.5rem;
  justify-content: space-between;
}

.step-actions .btn-group {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.signature-wrap {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--paper);
  overflow: hidden;
}

#signature {
  display: block;
  width: 100%;
  height: 160px;
  touch-action: none;
}

.sig-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5em 0.75em;
  border-top: 1px solid var(--line);
  background: #faf9f7;
}

.sig-error {
  color: #822;
  font-size: 0.9rem;
  margin-top: 0.5em;
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5em;
}

.chip {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.35em 0.75em;
  font-family: inherit;
  font-size: 0.85rem;
  background: var(--page);
  border: 1px solid var(--line);
  border-radius: 999px;
  cursor: pointer;
  color: var(--ink);
}

.chip:hover {
  border-color: var(--green);
  background: #f8fcf9;
}

/* Awesomplete */
.awesomplete {
  width: 100%;
}

.awesomplete > ul {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  background: var(--paper);
  margin-top: 2px;
}

.awesomplete > ul > li {
  padding: 0.45em 0.75em;
  cursor: pointer;
}

.awesomplete > ul > li[aria-selected="true"] {
  background: var(--green);
  color: var(--paper);
}

/* Thanks / closed */
.message-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  text-align: center;
}

.message-card {
  max-width: 480px;
  background: var(--paper);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem 1.5rem;
}

.ref-box {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--green);
  margin: 1rem 0;
  padding: 0.75em;
  background: #f8fcf9;
  border-radius: var(--radius-sm);
}

.guide-content h2 {
  margin-top: 1.5rem;
}

.guide-content h2:first-child {
  margin-top: 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

#suggest {
  display: none;
}

.parts-table input {
  min-height: 40px;
}

.meta-list {
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 1rem;
}

.meta-list li {
  margin: 0.25em 0;
}

.request-url {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin: 1rem 0;
}

.request-url code {
  flex: 1;
  min-width: 0;
  word-break: break-all;
  font-size: 0.85rem;
  background: var(--page);
  padding: 0.5em 0.75em;
  border-radius: var(--radius-sm);
}
