
:root {
  color-scheme: light;
  --bg: #f5f6f8;
  --surface: #ffffff;
  --surface-2: #eef5f3;
  --ink: #1e2428;
  --muted: #657079;
  --line: #dce2e5;
  --teal: #0f766e;
  --teal-2: #0d9488;
  --indigo: #4f46e5;
  --amber: #b7791f;
  --red: #b42318;
  --green: #16794c;
  --shadow: 0 16px 40px rgba(31, 41, 55, .08);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--bg);
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  font-size: 15px;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, .94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand strong {
  display: block;
  line-height: 1.15;
}

.brand small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal), var(--indigo));
  color: #fff;
  font-weight: 800;
}

.brand-mark.small {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

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

.topbar nav a {
  padding: 9px 12px;
  border-radius: var(--radius);
  color: #3e4a52;
  font-weight: 650;
}

.topbar nav a:hover {
  background: var(--surface-2);
  color: var(--teal);
}

.page {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 34px 0 56px;
}

.page-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.page-header h1 {
  margin: 0;
  font-size: 34px;
  line-height: 1.12;
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}

.primary-button {
  background: var(--teal);
  color: #fff;
  box-shadow: 0 10px 22px rgba(15, 118, 110, .18);
}

.primary-button:hover {
  background: #0b625b;
}

.secondary-button {
  background: #fff;
  border-color: var(--line);
  color: #2d3740;
}

.secondary-button:hover {
  border-color: #b9c5cc;
}

.danger-button {
  background: #fff;
  border-color: #f0c8c3;
  color: var(--red);
}

.danger-button:hover {
  background: #fff5f4;
}

.alert {
  margin: 0 0 18px;
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: #fff;
  font-weight: 650;
}

.alert.success {
  border-color: #b7e2ca;
  background: #eefaf3;
  color: var(--green);
}

.alert.danger {
  border-color: #f0c8c3;
  background: #fff5f4;
  color: var(--red);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}

.stats-grid article,
.panel,
.form-section,
.login-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.stats-grid article {
  padding: 18px;
}

.stats-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  text-transform: uppercase;
}

.stats-grid strong {
  display: block;
  margin-top: 8px;
  font-size: 30px;
  line-height: 1;
}

.panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
}

.panel-title h2,
.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 13px 15px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}

th {
  color: #3d474e;
  font-size: 12px;
  font-weight: 850;
  text-transform: uppercase;
  background: #f9fafb;
}

.actions {
  text-align: right;
  white-space: nowrap;
}

.actions a {
  color: var(--teal);
  font-weight: 750;
  margin-left: 12px;
}

.status {
  display: inline-flex;
  min-width: 76px;
  justify-content: center;
  padding: 5px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
}

.status.draft {
  background: #eef1f4;
  color: #52606a;
}

.status.ready {
  background: #fff4d8;
  color: var(--amber);
}

.status.submitted {
  background: #eef2ff;
  color: var(--indigo);
}

.status.approved {
  background: #e8f8ef;
  color: var(--green);
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 12px;
  min-height: 240px;
  text-align: center;
}

.empty-state h2 {
  margin: 0;
}

.editor {
  display: grid;
  gap: 18px;
}

.form-section {
  padding: 20px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

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

.form-grid.compact {
  margin-top: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label span {
  display: block;
  margin-bottom: 7px;
  color: #37424a;
  font-size: 13px;
  font-weight: 750;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cbd5dc;
  border-radius: var(--radius);
  background: #fff;
  color: var(--ink);
  outline: none;
}

textarea {
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal-2);
  box-shadow: 0 0 0 3px rgba(13, 148, 136, .16);
}

.wide {
  grid-column: 1 / -1;
}

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

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.check-row input {
  width: 16px;
  min-height: 16px;
  accent-color: var(--teal);
}

.check-row span {
  margin: 0;
}

.form-actions,
.document-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  padding: 24px;
  background:
    linear-gradient(140deg, rgba(15, 118, 110, .12), transparent 36%),
    linear-gradient(320deg, rgba(79, 70, 229, .10), transparent 42%),
    var(--bg);
}

.login-shell {
  width: min(100%, 420px);
}

.login-panel {
  padding: 28px;
}

.login-panel h1 {
  margin: 18px 0 6px;
  font-size: 28px;
  line-height: 1.15;
}

.login-copy {
  margin: 0 0 22px;
  color: var(--muted);
}

.login-form {
  display: grid;
  gap: 14px;
}

.login-form .primary-button {
  width: 100%;
  margin-top: 2px;
}

.document-body {
  background: #e9edf1;
}

.document-page {
  width: min(1040px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 56px;
}

.document-actions {
  justify-content: flex-end;
  margin-bottom: 16px;
}

.document-actions form {
  margin: 0;
}

.dossier-sheet {
  background: #fff;
  border-radius: var(--radius);
  box-shadow: 0 22px 60px rgba(31, 41, 55, .15);
  padding: clamp(28px, 5vw, 60px);
}

.cover {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 34px;
  padding-bottom: 26px;
  border-bottom: 3px solid var(--ink);
}

.cover h1 {
  max-width: 720px;
  margin: 0 0 22px;
  font-size: 38px;
  line-height: 1.08;
  letter-spacing: 0;
}

.cover-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px 18px;
  margin: 0;
}

.cover-meta div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.cover-meta dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
  text-transform: uppercase;
}

.cover-meta dd {
  margin: 4px 0 0;
  font-weight: 750;
}

.code-panel {
  align-self: start;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.code-panel img {
  max-width: 100%;
  height: auto;
}

.code-panel .barcode {
  width: 100%;
}

.code-panel span {
  font-size: 12px;
  font-weight: 850;
  text-align: center;
  word-break: break-word;
}

.document-note {
  margin-top: 22px;
  padding: 14px 16px;
  border-left: 4px solid var(--teal);
  background: var(--surface-2);
  color: #2f4542;
  font-weight: 650;
}

.doc-section {
  padding-top: 28px;
  break-inside: avoid;
}

.doc-section h2 {
  margin: 0 0 12px;
  font-size: 22px;
  line-height: 1.2;
}

.doc-section h3 {
  margin: 20px 0 8px;
  font-size: 16px;
}

.doc-section p {
  margin: 0 0 12px;
}

.doc-section ul,
.doc-section ol {
  margin: 0 0 14px 20px;
  padding: 0;
}

.doc-section li {
  margin: 5px 0;
}

.doc-table {
  margin: 12px 0 16px;
  border: 1px solid var(--line);
}

.doc-table th,
.doc-table td {
  border: 1px solid var(--line);
  padding: 10px 11px;
}

.doc-table th {
  width: 28%;
}

.toc {
  columns: 2;
  column-gap: 38px;
}

.letter {
  background: #fbfcfd;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  margin-top: 24px;
}

.signature-block {
  margin-top: 20px;
  line-height: 1.9;
}

.checklist td:last-child {
  width: 130px;
}

.end-note {
  margin-top: 22px;
  color: var(--muted);
  font-weight: 750;
}

@media (max-width: 900px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .stats-grid,
  .form-grid,
  .form-grid.compact,
  .check-grid,
  .cover,
  .cover-meta {
    grid-template-columns: 1fr;
  }

  .code-panel {
    justify-self: start;
    width: min(100%, 260px);
  }

  .toc {
    columns: 1;
  }
}

@media (max-width: 560px) {
  .page,
  .document-page {
    width: min(100vw - 20px, 100%);
  }

  .page-header h1,
  .cover h1 {
    font-size: 28px;
  }

  .dossier-sheet {
    padding: 20px;
  }

  th,
  td {
    padding: 10px;
  }
}

@media print {
  :root {
    --bg: #fff;
    --line: #cfd6dc;
    --shadow: none;
  }

  body {
    background: #fff;
    color: #111;
    font-size: 11pt;
  }

  .no-print,
  .topbar {
    display: none !important;
  }

  .document-page {
    width: 100%;
    padding: 0;
  }

  .dossier-sheet {
    box-shadow: none;
    border-radius: 0;
    padding: 0;
  }

  .doc-section {
    break-inside: avoid;
    page-break-inside: avoid;
  }

  .cover {
    grid-template-columns: 1fr 180px;
  }

  .cover h1 {
    font-size: 28pt;
  }

  .doc-section h2 {
    font-size: 16pt;
  }

  .primary-button,
  .secondary-button,
  .danger-button {
    display: none;
  }
}
