:root {
  --bg: #f5f8f4;
  --panel: #ffffff;
  --panel-2: #eef6ef;
  --text: #172018;
  --muted: #667366;
  --line: #dce8dd;
  --accent: #2f8f5b;
  --accent-dark: #1f6f43;
  --danger: #b3261e;
  --shadow: 0 14px 32px rgba(30, 75, 45, .08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: var(--accent-dark);
  text-decoration: none;
}

button,
input,
select,
textarea {
  font: inherit;
  border-radius: 0;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(135deg, rgba(47, 143, 91, .12), rgba(255, 255, 255, .3)),
    var(--bg);
}

.auth-main {
  width: min(100%, 760px);
}

.auth-card {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 44px);
}

.auth-title {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 28px;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  letter-spacing: .04em;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-dark);
  text-transform: uppercase;
  letter-spacing: .08em;
  font-size: 12px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  font-size: clamp(24px, 3vw, 38px);
  line-height: 1.08;
  margin-bottom: 10px;
}

h2 {
  font-size: 22px;
  margin-bottom: 16px;
}

h3 {
  font-size: 18px;
  margin-bottom: 8px;
}

.form {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  padding: 13px 14px;
  outline: none;
}

input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(47, 143, 91, .12);
}

button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 11px 18px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

button:disabled,
.button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.button.secondary {
  background: #fff;
  color: var(--accent-dark);
}

.button.full {
  width: 100%;
}

.muted-link {
  color: var(--muted);
}

.alert {
  border: 1px solid rgba(179, 38, 30, .25);
  background: #fff3f1;
  color: var(--danger);
  padding: 12px 14px;
  margin-bottom: 18px;
}

.alert.soft {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  width: 100%;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 22px;
  min-height: 100vh;
  position: sticky;
  top: 0;
}

.brand {
  display: flex;
  gap: 13px;
  align-items: center;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.brand strong,
.brand span {
  display: block;
}

.brand span {
  color: var(--muted);
  font-size: 13px;
  margin-top: 3px;
}

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

.sidebar nav a {
  display: block;
  color: var(--text);
  padding: 12px 13px;
  border: 1px solid transparent;
}

.sidebar nav a:hover,
.sidebar nav a.active {
  border-color: var(--line);
  background: var(--panel-2);
  color: var(--accent-dark);
}

.main {
  min-width: 0;
  width: 100%;
  padding: 28px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, #fff, var(--panel-2));
  padding: clamp(20px, 3vw, 34px);
  margin-bottom: 22px;
  box-shadow: var(--shadow);
}

.page-header p:last-child {
  color: var(--muted);
  margin-bottom: 0;
}

.toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.search-box {
  flex: 1;
  min-width: 220px;
  display: flex;
  align-items: center;
  gap: 10px;
  background: #fff;
  border: 1px solid var(--line);
  padding: 0 14px;
}

.search-box input {
  border: 0;
  padding-left: 0;
}

.panel,
.stat-card,
.doc-preview {
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.panel {
  padding: 20px;
  margin-bottom: 22px;
}

.panel.narrow {
  max-width: 760px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin-bottom: 0;
}

.panel-head span {
  color: var(--muted);
}

.table-wrap {
  overflow-x: auto;
  width: 100%;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

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

th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .04em;
  background: #fbfdfb;
}

.empty-cell {
  color: var(--muted);
  text-align: center;
  padding: 28px 12px;
}

.icon-btn {
  min-height: 34px;
  width: 38px;
  padding: 0;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

.preview-grid,
.stats-grid,
.choice-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  width: 100%;
}

.stats-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 22px;
}

.stat-card,
.doc-preview {
  padding: 18px;
}

.stat-card span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-card strong {
  display: block;
  font-size: 26px;
  margin-bottom: 6px;
}

.stat-card p,
.doc-preview p {
  color: var(--muted);
  margin-bottom: 0;
}

.doc-paper {
  height: 170px;
  background: #fbfdfb;
  border: 1px solid var(--line);
  padding: 18px;
  margin-bottom: 14px;
  position: relative;
}

.doc-paper:after {
  content: "";
  position: absolute;
  right: 18px;
  bottom: 16px;
  width: 54px;
  height: 54px;
  border: 2px solid rgba(47, 143, 91, .24);
}

.doc-paper.accent {
  background: linear-gradient(180deg, #fff, #eef6ef);
}

.doc-paper.darkline {
  border-top: 6px solid var(--accent-dark);
}

.doc-top {
  height: 15px;
  width: 64%;
  background: var(--accent);
  margin-bottom: 18px;
}

.doc-line {
  height: 8px;
  background: #d8e7dc;
  margin-bottom: 10px;
  width: 88%;
}

.doc-line.short {
  width: 48%;
}

.doc-line.wide {
  width: 100%;
}

.doc-table {
  display: grid;
  grid-template-columns: 1fr .6fr .6fr;
  gap: 4px;
  margin-top: 14px;
}

.doc-table span {
  height: 15px;
  background: #d8e7dc;
  border: 1px solid #c6d7ca;
}

.choice-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-card {
  min-height: 130px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 10px;
  background: #fff;
  color: var(--text);
  border: 1px solid var(--line);
  text-align: left;
}

.choice-card strong {
  font-size: 20px;
}

.choice-card span {
  color: var(--muted);
}

.profile-list {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}

.profile-list div {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}

.profile-list span {
  color: var(--muted);
}

@media (max-width: 1180px) {
  .preview-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    min-height: auto;
    position: static;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .sidebar nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .main {
    padding: 18px;
  }

  .toolbar,
  .panel-head {
    align-items: stretch;
    flex-direction: column;
  }

  .stats-grid,
  .choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .auth-shell {
    padding: 12px;
  }

  .auth-card,
  .panel,
  .page-header {
    padding: 18px;
  }

  .auth-title {
    flex-direction: column;
  }

  .sidebar nav {
    grid-template-columns: 1fr;
  }

  .preview-grid {
    grid-template-columns: 1fr;
  }

  .doc-paper {
    height: 145px;
  }
}

/* STEP 004 — documents core */

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

.document-form {
  max-width: none;
}

.document-form textarea {
  min-height: 160px;
}

.small-button {
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.choice-card {
  text-decoration: none;
}

.choice-card.active-choice {
  border-color: var(--accent);
  background: var(--panel-2);
  box-shadow: inset 0 0 0 2px rgba(47, 143, 91, .12);
}

.items-block {
  border: 1px solid var(--line);
  background: #fbfdfb;
  padding: 16px;
}

.items-table input {
  min-width: 120px;
  padding: 9px 10px;
}

.editor-wrap {
  border: 1px solid var(--line);
  background: #fff;
}

.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--line);
  background: #fbfdfb;
}

.editor-toolbar button,
.editor-toolbar select {
  min-height: 34px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  cursor: pointer;
}

.editor {
  min-height: 170px;
  padding: 14px;
  outline: none;
  line-height: 1.55;
}

.editor:focus {
  box-shadow: inset 0 0 0 3px rgba(47, 143, 91, .1);
}

.inline-table,
.doc-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 12px 0;
}

.inline-table td,
.doc-body td,
.doc-body th {
  border: 1px solid #bfcfc3;
  padding: 8px;
}

.document-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 18px;
}

.pdf-preview-shell {
  width: 100%;
  overflow-x: auto;
  padding-bottom: 20px;
}

.pdf-preview {
  width: min(100%, 980px);
  min-height: 1180px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 54px);
  margin: 0 auto;
}

.pdf-preview.rel {
  font-family: Arial, Helvetica, sans-serif;
}

.pdf-preview.globex {
  font-family: Arial, Helvetica, sans-serif;
}

.letterhead {
  display: flex;
  justify-content: space-between;
  gap: 22px;
  padding-bottom: 22px;
  border-bottom: 4px solid var(--accent);
  margin-bottom: 26px;
}

.letterhead strong {
  display: block;
  font-size: 24px;
}

.letterhead span {
  display: block;
  color: var(--muted);
  margin-top: 5px;
}

.stamp {
  width: 150px;
  height: 82px;
  border: 2px solid rgba(47, 143, 91, .28);
  display: grid;
  place-items: center;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.doc-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  color: var(--muted);
  margin-bottom: 22px;
}

.to-org {
  margin: 18px 0;
}

.doc-body {
  line-height: 1.65;
  margin: 18px 0;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  margin: 22px 0;
}

.preview-table th,
.preview-table td {
  border: 1px solid #bfcfc3;
  padding: 10px;
}

.preview-table th {
  background: #f1f8f2;
}

.danger {
  color: var(--danger);
  border-color: rgba(179, 38, 30, .25);
}

.muted {
  color: var(--muted);
}

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

  .document-actions {
    flex-direction: column;
  }

  .pdf-preview {
    min-width: 680px;
  }
}

/* STEP 005 — PDF generation/download */
.document-actions .button:first-child {
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.pdf-preview .fixed-note {
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
}


/* STEP 006 — employees/profile/security */

.employee-form {
  margin-top: 8px;
}

.success {
  border-color: rgba(47, 143, 91, .25);
  background: #eff8f1;
  color: var(--accent-dark);
}

.danger-btn {
  background: #fff;
  color: var(--danger);
  border-color: rgba(179, 38, 30, .3);
}

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

.danger-panel {
  border-color: rgba(179, 38, 30, .18);
}


/* STEP 007 — hardening/audit */
.table-wrap table th:nth-child(7),
.table-wrap table td:nth-child(7),
.table-wrap table th:nth-child(8),
.table-wrap table td:nth-child(8) {
  white-space: nowrap;
}


/* STEP 008 — document link behavior */
.panel input[readonly] {
  background: #f8fbf8;
  color: var(--muted);
}

