:root {
  --ink: #001c22;
  --muted: #66777a;
  --line: #dce4e5;
  --paper: #f5f8f8;
  --white: #fff;
  --red: #dc0041;
  --red-dark: #b60036;
  --red-soft: #fde8ef;
  --yellow: #f0b700;
  --yellow-soft: #fff6d9;
  --green: #287052;
  --green-soft: #e8f3ed;
  --amber: #9a6318;
  --amber-soft: #fbf0dc;
  --blue: #42677f;
  --blue-soft: #e8f0f4;
  --shadow: 0 18px 54px rgba(0, 28, 34, .14);
}

* { box-sizing: border-box; }
html { background: var(--paper); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.loading-view {
  min-height: 100vh;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--muted);
}
.loading-mark {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font: 700 24px Georgia, serif;
  animation: pulse 1.3s infinite;
}
@keyframes pulse { 50% { box-shadow: 0 0 0 12px rgba(220, 0, 65, .08); } }
.loading-view p { font-size: 13px; }

.login-view {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, .9fr) minmax(460px, 1.1fr);
}
.login-brand {
  min-height: 100vh;
  padding: clamp(38px, 7vw, 92px);
  background: var(--ink);
  color: white;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-brand::after {
  content: "";
  position: absolute;
  width: 420px;
  height: 420px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 50%;
  right: -210px;
  bottom: -120px;
  box-shadow: 0 0 0 70px rgba(255,255,255,.025), 0 0 0 140px rgba(255,255,255,.018);
}
.login-logo-frame {
  position: absolute;
  top: 38px;
  left: clamp(38px, 7vw, 92px);
  width: 145px;
  height: 66px;
  padding: 6px 10px;
  background: white;
  border-radius: 4px;
}
.login-logo-frame img { width: 100%; height: 100%; object-fit: contain; }
.eyebrow { margin: 0 0 10px; color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .16em; }
.eyebrow.light { color: var(--yellow); }
.login-brand h1 { margin: 0; font: 500 clamp(42px, 5vw, 68px)/1.02 Georgia, serif; letter-spacing: -.04em; }
.login-brand > p:not(.eyebrow) { max-width: 470px; color: #9fb0b3; font-size: 15px; line-height: 1.65; }
.login-stripes { display: flex; width: 260px; height: 7px; margin-top: 34px; }
.login-stripes span:first-child { width: 42%; background: var(--red); }
.login-stripes span:last-child { flex: 1; background: var(--yellow); }
.login-panel { display: grid; place-items: center; padding: 32px; background: white; }
.login-form { width: min(410px, 100%); }
.login-form h2 { margin: 0; font: 500 38px/1.15 Georgia, serif; }
.form-lead { color: var(--muted); font-size: 13px; line-height: 1.55; margin: 12px 0 26px; }
.login-form label, .create-modal label, .drawer-form label, .upload-panel label {
  display: grid;
  gap: 7px;
}
.login-form label + label { margin-top: 16px; }
label > span { color: #526064; font-size: 10px; font-weight: 800; letter-spacing: .03em; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: white;
  color: var(--ink);
  outline: none;
}
input, select { height: 44px; padding: 0 11px; }
textarea { min-height: 80px; padding: 10px 11px; resize: vertical; }
input:focus, select:focus, textarea:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px var(--red-soft);
}
.login-form .primary-button { margin-top: 22px; }
.login-form small { display: block; margin-top: 16px; color: #9aa6a8; font-size: 10px; line-height: 1.5; }
.form-error {
  margin-top: 14px;
  padding: 10px 12px;
  color: #9b153d;
  background: var(--red-soft);
  border-left: 3px solid var(--red);
  font-size: 11px;
  line-height: 1.45;
}

.app-shell { min-height: 100vh; }
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  display: flex;
  flex-direction: column;
  background: var(--ink);
  color: #f8f4f0;
  z-index: 30;
}
.brand {
  min-height: 96px;
  padding: 16px;
  display: flex;
  gap: 10px;
  align-items: center;
  border-bottom: 1px solid rgba(255,255,255,.09);
}
.brand-logo {
  width: 137px;
  height: 62px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  background: white;
  border-radius: 5px;
}
.brand-logo img { width: 100%; height: 100%; object-fit: contain; }
.brand strong { display: block; color: white; font-size: 11px; letter-spacing: .08em; }
.brand > div:last-child span { display: block; color: #8da0a3; font-size: 9px; margin-top: 5px; line-height: 1.35; }
.main-nav { padding: 18px 12px 12px; }
.nav-item, .division-link {
  width: 100%;
  border: 0;
  background: transparent;
  color: #d7d0cb;
  display: flex;
  align-items: center;
  text-align: left;
  cursor: pointer;
}
.nav-item {
  min-height: 44px;
  padding: 0 12px;
  gap: 12px;
  border-radius: 7px;
  font-size: 14px;
  margin-bottom: 3px;
}
.nav-item:hover, .nav-item.active { background: rgba(255,255,255,.075); color: white; }
.nav-item.active { box-shadow: inset 3px 0 0 var(--red); }
.nav-item > span { width: 18px; font-size: 18px; text-align: center; }
.nav-item small { margin-left: auto; color: #8f9c9e; font-size: 9px; }
.nav-item.disabled { cursor: default; opacity: .55; }
.sidebar-label { color: #7f7772; font-size: 9px; letter-spacing: .14em; padding: 21px 24px 10px; }
.division-nav { padding: 0 12px; }
.division-link { min-height: 38px; padding: 0 13px; gap: 10px; font-size: 11px; letter-spacing: .035em; }
.division-link:hover, .division-link.selected { color: white; }
.division-link small { margin-left: auto; color: #817974; }
.division-dot { width: 6px; height: 6px; border-radius: 50%; background: #807873; }
.division-link.selected .division-dot { background: var(--yellow); box-shadow: 0 0 0 4px rgba(240,183,0,.13); }
.sidebar-footer { margin: auto 18px 20px; padding-top: 17px; border-top: 1px solid rgba(255,255,255,.08); }
.pilot-label { color: var(--yellow); font-size: 9px; letter-spacing: .15em; }
.sidebar-footer p { color: #8f9c9e; font-size: 10px; line-height: 1.5; margin: 7px 0 0; }

.main-content { min-height: 100vh; margin-left: 246px; }
.topbar {
  height: 76px;
  padding: 0 34px;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  background: rgba(255,255,255,.95);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(12px);
}
.breadcrumbs { font-size: 12px; color: var(--muted); }
.breadcrumbs button { padding: 0; border: 0; background: none; color: var(--red); cursor: pointer; }
.breadcrumbs span { margin: 0 8px; color: #b6c0c2; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 12px; }
.user-meta { text-align: right; }
.user-meta strong { display: block; font-size: 11px; }
.user-meta span { display: block; margin-top: 3px; color: var(--muted); font-size: 9px; }
.user-avatar {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 800;
}
.logout-button, .back-link {
  border: 0;
  background: transparent;
  color: var(--red);
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}
.mobile-menu { display: none; }
.pilot-banner {
  padding: 10px 34px;
  background: var(--yellow-soft);
  border-bottom: 1px solid #ecd975;
  color: #64572f;
  font-size: 11px;
}
.content-wrap { max-width: 1460px; margin: 0 auto; padding: 34px 38px 60px; }
.page-intro {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 27px;
}
.page-intro h1 { margin: 0; font: 500 clamp(30px, 3vw, 42px)/1.1 Georgia, serif; letter-spacing: -.025em; }
.page-intro p:not(.eyebrow) { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
.back-link { margin: 0 0 18px; padding: 0; }

.primary-button, .secondary-button {
  min-height: 42px;
  padding: 0 17px;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}
.primary-button { background: var(--red); color: white; box-shadow: 0 5px 14px rgba(220,0,65,.16); }
.primary-button:hover { background: var(--red-dark); }
.secondary-button { background: white; border-color: var(--line); }
.secondary-button:hover { border-color: #b9c5c7; }
.full { width: 100%; }
button:disabled { cursor: wait; opacity: .62; }

.division-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.division-card {
  min-height: 210px;
  padding: 23px;
  border: 1px solid var(--line);
  background: white;
  text-align: left;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.division-card::after {
  content: "";
  position: absolute;
  right: -42px;
  bottom: -52px;
  width: 130px;
  height: 130px;
  border: 1px solid #edf1f2;
  border-radius: 50%;
  box-shadow: 0 0 0 30px #f9fbfb;
}
.division-card:hover { border-color: #b7c4c6; box-shadow: 0 12px 32px rgba(0,28,34,.07); transform: translateY(-1px); }
.division-card-top { display: flex; align-items: center; justify-content: space-between; }
.division-card-top span { color: var(--red); font-size: 10px; font-weight: 800; letter-spacing: .12em; }
.division-card-top b { width: 30px; height: 30px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; }
.division-card h2 { margin: 23px 0 5px; font: 500 27px Georgia, serif; }
.division-card > p { margin: 0; color: var(--muted); font-size: 11px; }
.division-card-metrics { display: flex; gap: 18px; margin-top: 25px; position: relative; z-index: 1; }
.division-card-metrics div { min-width: 64px; }
.division-card-metrics strong { display: block; font: 500 22px Georgia, serif; }
.division-card-metrics span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.division-card-metrics .warning strong { color: var(--red); }

.activity-card { margin-top: 26px; padding: 20px; background: white; border: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-end; justify-content: space-between; margin-bottom: 15px; }
.section-heading h2 { margin: 0; font: 500 22px Georgia, serif; }
.section-heading p { margin: 4px 0 0; color: var(--muted); font-size: 10px; }
.activity-row { display: grid; grid-template-columns: 30px 1fr auto; gap: 11px; align-items: center; padding: 10px 0; border-top: 1px solid #edf1f2; }
.activity-icon { width: 28px; height: 28px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-soft); color: var(--blue); font-size: 10px; }
.activity-row strong { display: block; font-size: 11px; }
.activity-row p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.activity-row time { color: #98a5a7; font-size: 9px; }
.activity-empty { padding: 20px 0; color: var(--muted); font-size: 11px; }

.metric-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 13px; margin-bottom: 26px; }
.metric-card { min-height: 125px; padding: 18px; background: white; border: 1px solid var(--line); }
.metric-card span { color: var(--muted); font-size: 10px; }
.metric-card strong { display: block; margin-top: 16px; font: 500 31px Georgia, serif; }
.metric-card small { display: block; margin-top: 7px; color: var(--muted); font-size: 9px; }
.metric-card.attention strong { color: var(--red); }

.list-tools { display: flex; align-items: center; gap: 18px; margin-bottom: 13px; }
.search-field {
  flex: 0 0 320px;
  height: 40px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: white;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: #99a4a6;
}
.search-field input { height: auto; padding: 0; border: 0; box-shadow: none; background: transparent; font-size: 11px; }
.status-filters { display: flex; gap: 4px; overflow-x: auto; }
.status-filters button {
  min-height: 34px;
  padding: 0 11px;
  white-space: nowrap;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--muted);
  font-size: 9px;
  cursor: pointer;
}
.status-filters button.active { background: white; border-color: var(--line); color: var(--red); font-weight: 800; }
.employee-table-wrap { overflow-x: auto; background: white; border: 1px solid var(--line); }
.employee-table { width: 100%; min-width: 760px; border-collapse: collapse; }
.employee-table th { padding: 12px 17px; background: #f7f9f9; color: #8e9a9c; text-align: left; font-size: 9px; letter-spacing: .1em; }
.employee-table td { padding: 13px 17px; border-top: 1px solid #edf1f2; color: #4c585a; font-size: 11px; }
.employee-table tbody tr { cursor: pointer; }
.employee-table tbody tr:hover { background: #fffafb; }
.employee-cell { display: flex; align-items: center; gap: 11px; }
.avatar { width: 37px; height: 37px; flex: 0 0 auto; display: grid; place-items: center; border-radius: 50%; background: var(--red-soft); color: var(--red); font-size: 10px; font-weight: 800; }
.employee-cell strong { display: block; color: var(--ink); font-size: 12px; }
.employee-cell span { display: block; margin-top: 4px; color: var(--muted); font-size: 9px; }
.document-progress { min-width: 140px; }
.document-progress > span { font-size: 9px; }
.progress-track { width: 100%; height: 4px; margin-top: 6px; overflow: hidden; border: 0; background: #e9eeee; appearance: none; display: block; }
.progress-track::-webkit-progress-bar { background: #e9eeee; }
.progress-track::-webkit-progress-value { background: var(--red); }
.progress-track::-moz-progress-bar { background: var(--red); }
.status { display: inline-block; padding: 5px 8px; border-radius: 3px; font-size: 9px; font-weight: 800; white-space: nowrap; }
.status-draft, .status-correction_required { color: var(--red); background: var(--red-soft); }
.status-in_accounting { color: var(--blue); background: var(--blue-soft); }
.status-collecting_signatures { color: var(--amber); background: var(--amber-soft); }
.status-complete, .status-signed, .status-uploaded { color: var(--green); background: var(--green-soft); }
.row-open { width: 28px; height: 28px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: 50%; background: white; }
.empty-state { padding: 50px 20px; text-align: center; color: var(--muted); }
.empty-state strong { color: var(--ink); }
.empty-state p { font-size: 11px; }

.drawer-backdrop { position: fixed; inset: 0; z-index: 50; border: 0; background: rgba(0,20,24,.42); }
.employee-drawer {
  position: fixed;
  inset: 0 0 0 auto;
  z-index: 51;
  width: min(620px, 97vw);
  padding: 22px 28px 32px;
  overflow-y: auto;
  background: white;
  box-shadow: -20px 0 50px rgba(0,28,34,.16);
  animation: drawer-in .18s ease-out;
}
@keyframes drawer-in { from { transform: translateX(30px); opacity: .5; } }
.drawer-header { display: flex; align-items: center; justify-content: space-between; }
.drawer-header > div { display: flex; align-items: center; gap: 9px; }
.drawer-close { border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.drawer-person { display: flex; align-items: center; gap: 14px; padding: 22px 0 17px; }
.drawer-person .avatar { width: 52px; height: 52px; font-size: 14px; }
.drawer-person h2 { margin: 0; font: 500 27px Georgia, serif; }
.drawer-person p { margin: 5px 0 0; color: var(--muted); font-size: 10px; }
.completion-block { padding: 14px 16px; background: #f6f9f9; }
.completion-line { display: flex; justify-content: space-between; font-size: 10px; }
.completion-line b { color: var(--red); }
.completion-block p { margin: 8px 0 0; color: var(--muted); font-size: 9px; }
.drawer-tabs { display: flex; gap: 22px; margin: 21px 0 16px; border-bottom: 1px solid var(--line); }
.drawer-tabs button { padding: 0 0 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 10px; cursor: pointer; }
.drawer-tabs button.active { border-color: var(--red); color: var(--red); font-weight: 800; }
.facts-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); }
.fact { min-height: 62px; padding: 11px; background: white; }
.fact span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 9px; }
.fact strong { font-size: 11px; }
.drawer-section-title { display: flex; align-items: center; justify-content: space-between; margin: 23px 0 8px; }
.drawer-section-title h3 { margin: 0; font: 500 18px Georgia, serif; }
.drawer-section-title span { color: var(--muted); font-size: 9px; }
.document-item { padding: 11px 0; display: grid; grid-template-columns: 24px 1fr auto; gap: 10px; align-items: center; border-bottom: 1px solid #edf1f2; }
.document-state { width: 23px; height: 23px; display: grid; place-items: center; border: 1px solid #d6dfe0; border-radius: 50%; color: #94a1a3; font-size: 9px; }
.document-state.done { border-color: transparent; background: var(--green-soft); color: var(--green); }
.document-item strong { display: block; font-size: 10px; }
.document-item p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.document-controls { display: flex; align-items: center; gap: 6px; }
.mini-button, .file-link {
  min-height: 29px;
  padding: 0 9px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: white;
  color: var(--red);
  text-decoration: none;
  font-size: 8px;
  font-weight: 800;
  cursor: pointer;
}
.file-form input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.mini-button:focus-within { outline: 2px solid var(--red); outline-offset: 2px; }
.correction-alert {
  display: grid;
  gap: 4px;
  margin-bottom: 14px;
  padding: 11px 12px;
  border-left: 3px solid var(--red);
  background: var(--red-soft);
  color: #5e2527;
  font-size: 9px;
  line-height: 1.5;
}
.drawer-actions { display: grid; gap: 8px; margin-top: 22px; }
.action-note { padding: 10px 12px; background: var(--yellow-soft); color: #685d3d; font-size: 9px; line-height: 1.5; }
.drawer-form { margin-top: 20px; padding: 15px; border: 1px solid var(--line); background: #fafcfc; }
.drawer-form h3 { margin: 0 0 13px; font: 500 17px Georgia, serif; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 13px; margin-top: 14px; }
.form-grid.three { grid-template-columns: repeat(3, 1fr); margin-top: 0; }
.drawer-form .form-grid:first-of-type { margin-top: 0; }
.drawer-form .primary-button { margin-top: 14px; }
.return-block { display: grid; gap: 8px; margin-top: 8px; }
.return-block input { height: 38px; }
.history-row { padding: 10px 0; border-bottom: 1px solid #edf1f2; }
.history-row strong { display: block; font-size: 10px; }
.history-row p { margin: 4px 0 0; color: var(--muted); font-size: 9px; }
.history-empty { color: var(--muted); font-size: 10px; }

.modal-layer { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 20px; }
.modal-backdrop { position: absolute; inset: 0; border: 0; background: rgba(0,20,24,.55); }
.create-modal { z-index: 1; width: min(720px, 100%); padding: 27px; background: white; box-shadow: var(--shadow); }
.modal-heading { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.modal-heading h2 { margin: 0; font: 500 28px Georgia, serif; }
.modal-heading p:not(.eyebrow) { margin: 7px 0 0; color: var(--muted); font-size: 10px; }
.modal-heading button { align-self: flex-start; border: 0; background: transparent; color: var(--muted); font-size: 26px; cursor: pointer; }
.process-preview { margin-top: 18px; padding: 14px; background: #f6f9f9; }
.process-preview strong { font-size: 10px; }
.process-preview p { margin: 5px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 21px; }
.password-modal { width: min(560px, 100%); }
.password-modal > label { margin-bottom: 14px; }
.password-modal .primary-button { margin-top: 19px; }
.toast { position: fixed; z-index: 80; right: 23px; bottom: 23px; padding: 12px 16px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 10px; }

@media (max-width: 1080px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .list-tools { align-items: flex-start; flex-direction: column; }
  .search-field { width: 100%; flex-basis: 40px; }
  .status-filters { width: 100%; }
}
@media (max-width: 780px) {
  .login-view { grid-template-columns: 1fr; }
  .login-brand { display: none; }
  .login-panel { min-height: 100vh; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar { height: 68px; padding: 0 15px; gap: 10px; }
  .mobile-menu { display: block; border: 0; background: transparent; font-size: 20px; }
  .user-meta { display: none; }
  .content-wrap { padding: 26px 16px 50px; }
  .pilot-banner { padding: 10px 16px; }
  .division-grid { grid-template-columns: 1fr; }
  .page-intro { align-items: flex-start; flex-direction: column; }
  .page-intro .primary-button { width: 100%; }
  .form-grid, .form-grid.three, .facts-grid { grid-template-columns: 1fr; }
  .create-modal { max-height: 94vh; overflow-y: auto; }
  .document-item { grid-template-columns: 24px 1fr; }
  .document-controls { grid-column: 2; justify-content: flex-start; }
}
