:root{
  --green-950:#052e16;
  --green-900:#14532d;
  --green-800:#166534;
  --green-700:#15803d;
  --green-100:#dcfce7;
  --green-50:#f0fdf4;
  --bg:#f3f7f4;
  --surface:#ffffff;
  --surface-2:#f8faf9;
  --line:#d8e2dc;
  --text:#142019;
  --muted:#607068;
  --danger:#b42318;
  --danger-bg:#fff1f0;
  --warning:#9a6700;
  --warning-bg:#fff7db;
  --info:#1d4ed8;
  --info-bg:#eff6ff;
  --shadow:0 10px 30px rgba(20,53,45,.10);
  --radius:18px;
  --safe-top:env(safe-area-inset-top,0px);
  --safe-bottom:env(safe-area-inset-bottom,0px);
}

*{box-sizing:border-box}

html,body{
  margin:0;
  padding:0;
  min-height:100%;
  background:var(--bg);
  color:var(--text);
  font-family:-apple-system,BlinkMacSystemFont,"SF Pro Text","Segoe UI",sans-serif;
  -webkit-text-size-adjust:100%;
}

body{min-height:100dvh}

button,input,select,textarea{font:inherit}
button{cursor:pointer}
button:disabled{cursor:not-allowed;opacity:.52}
a{color:var(--green-800)}
.hidden{display:none!important}

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

.app-shell{
  min-height:100dvh;
  padding-top:var(--safe-top);
  padding-bottom:calc(80px + var(--safe-bottom));
}

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:16px;
  padding:12px 18px;
  background:rgba(255,255,255,.94);
  backdrop-filter:blur(18px);
  border-bottom:1px solid var(--line);
}

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

.brand-logo{
  width:54px;
  height:54px;
  border-radius:14px;
  border:1px solid #e2e8e4;
  background:white;
  object-fit:contain;
}

.brand-text{min-width:0}

.brand-title{
  font-size:18px;
  font-weight:850;
  letter-spacing:-.02em;
}

.brand-sub{
  font-size:12px;
  color:var(--muted);
  margin-top:2px;
  font-weight:650;
}

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

.status-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  border-radius:999px;
  padding:7px 10px;
  font-size:12px;
  font-weight:800;
  border:1px solid transparent;
  white-space:nowrap;
}

.status-pill.good{
  background:var(--green-100);
  color:var(--green-900);
  border-color:#bbf7d0;
}

.status-pill.bad{
  background:var(--danger-bg);
  color:var(--danger);
  border-color:#fecaca;
}

.status-pill.warn{
  background:var(--warning-bg);
  color:var(--warning);
  border-color:#fde68a;
}

.status-pill.neutral{
  background:#eef2f0;
  color:#44544b;
  border-color:#dfe7e2;
}

.main-content{
  max-width:1050px;
  margin:0 auto;
  padding:22px 18px 34px;
  outline:none;
}

.page-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
  margin-bottom:18px;
}

.page-title{
  margin:0;
  font-size:29px;
  line-height:1.1;
  letter-spacing:-.03em;
}

.page-sub{
  color:var(--muted);
  margin-top:7px;
  line-height:1.45;
}

.page-actions{
  display:flex;
  gap:9px;
  flex-wrap:wrap;
}

.card{
  background:var(--surface);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow:var(--shadow);
  overflow:hidden;
  margin-bottom:16px;
}

.card-head{
  padding:17px 18px;
  border-bottom:1px solid var(--line);
  background:linear-gradient(180deg,#fff,#fbfdfc);
}

.card-title{
  margin:0;
  font-size:18px;
  font-weight:850;
}

.card-sub{
  color:var(--muted);
  font-size:13px;
  margin-top:5px;
  line-height:1.45;
}

.card-body{padding:18px}
.card.compact .card-body{padding:14px 16px}

.notice{
  padding:13px 14px;
  border-radius:14px;
  border:1px solid var(--line);
  background:var(--surface-2);
  line-height:1.48;
}

.notice.good{
  background:var(--green-50);
  border-color:#bbf7d0;
}

.notice.warn{
  background:var(--warning-bg);
  border-color:#fde68a;
}

.notice.error{
  background:var(--danger-bg);
  border-color:#fecaca;
  color:#7f1d1d;
}

.notice.info{
  background:var(--info-bg);
  border-color:#bfdbfe;
  color:#1e3a8a;
}

.notice strong{font-weight:850}
.notice+.notice{margin-top:10px}

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

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

.field-full{grid-column:1/-1}

.section-group{
  grid-column:1/-1;
  border-top:1px solid var(--line);
  padding-top:15px;
  margin-top:4px;
}

.section-group:first-child{
  border-top:0;
  padding-top:0;
}

.section-title{
  font-weight:850;
  font-size:15px;
  margin:0 0 12px;
  color:var(--green-900);
}

.field{min-width:0}

.field label,.label{
  display:block;
  font-weight:780;
  font-size:14px;
  margin:0 0 7px;
}

.required{
  display:inline-block;
  margin-left:7px;
  padding:2px 7px;
  border-radius:999px;
  background:#fef2f2;
  color:#b91c1c;
  font-size:10px;
  font-weight:850;
  vertical-align:1px;
}

.field input,
.field select,
.field textarea,
.text-input{
  width:100%;
  border:1px solid #bdc9c1;
  border-radius:12px;
  padding:12px 13px;
  background:white;
  color:var(--text);
  min-height:46px;
  outline:none;
  transition:border .15s,box-shadow .15s;
}

.field textarea{
  min-height:104px;
  resize:vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus,
.text-input:focus{
  border-color:var(--green-700);
  box-shadow:0 0 0 3px rgba(21,128,61,.12);
}

.field.invalid input,
.field.invalid select,
.field.invalid textarea,
.choice-group.invalid,
.checkbox-row.invalid{
  border-color:#dc2626!important;
  box-shadow:0 0 0 3px rgba(220,38,38,.09);
}

.field-error{
  color:#b42318;
  font-size:12px;
  font-weight:700;
  margin-top:6px;
}

.small{font-size:12px}
.muted{color:var(--muted)}

.checkbox-row,
.choice-option{
  display:flex;
  align-items:flex-start;
  gap:11px;
  border:1px solid var(--line);
  border-radius:12px;
  padding:12px 13px;
  background:#fff;
  line-height:1.4;
}

.checkbox-row input,
.choice-option input{
  margin-top:2px;
  width:20px;
  height:20px;
  flex:0 0 20px;
  accent-color:var(--green-800);
}

.checkbox-row+.checkbox-row,
.choice-option+.choice-option{
  margin-top:8px;
}

.choice-group{
  border:1px solid var(--line);
  border-radius:14px;
  padding:13px;
}

.choice-title{
  font-weight:800;
  margin-bottom:9px;
}

.choice-options{
  display:grid;
  gap:8px;
}

.declarations{
  display:grid;
  gap:10px;
}

.btn{
  appearance:none;
  border:0;
  border-radius:12px;
  min-height:46px;
  padding:11px 16px;
  font-weight:820;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:8px;
  text-align:center;
}

.btn.primary{
  background:var(--green-800);
  color:white;
}

.btn.primary:active{
  background:var(--green-950);
}

.btn.secondary{
  background:#edf3ef;
  color:var(--green-950);
  border:1px solid #cfdad3;
}

.btn.danger{
  background:#fff0f0;
  color:#a71919;
  border:1px solid #fecaca;
}

.btn.ghost{
  background:transparent;
  color:var(--green-900);
  border:1px solid var(--line);
}

.btn.wide{width:100%}

.actions{
  display:flex;
  gap:10px;
  align-items:center;
  flex-wrap:wrap;
  margin-top:18px;
}

.actions.end{justify-content:flex-end}
.actions.split{justify-content:space-between}

.template-list,
.hire-list,
.queue-list{
  display:grid;
  gap:11px;
}

.template-card,
.hire-card,
.queue-card{
  border:1px solid var(--line);
  border-radius:15px;
  background:white;
  padding:15px;
  display:grid;
  gap:11px;
}

.template-row,
.hire-row,
.queue-row{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:14px;
}

.template-title,
.hire-title,
.queue-title{
  font-weight:850;
  font-size:16px;
}

.meta{
  display:flex;
  gap:7px;
  flex-wrap:wrap;
  margin-top:5px;
}

.tag{
  display:inline-flex;
  align-items:center;
  border-radius:999px;
  padding:4px 8px;
  background:#eef3ef;
  color:#4a5c51;
  font-size:11px;
  font-weight:760;
}

.tag.green{
  background:var(--green-100);
  color:var(--green-900);
}

.tag.warn{
  background:var(--warning-bg);
  color:#7a5100;
}

.tag.red{
  background:var(--danger-bg);
  color:#9f1d1d;
}

.photo-grid{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:10px;
  margin-top:12px;
}

.photo-card{
  position:relative;
  border:1px solid var(--line);
  border-radius:12px;
  overflow:hidden;
  background:#eef2ef;
  aspect-ratio:4/3;
}

.photo-card img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.photo-remove{
  position:absolute;
  right:7px;
  top:7px;
  border:0;
  border-radius:999px;
  background:rgba(15,23,18,.82);
  color:white;
  padding:7px 9px;
  font-weight:800;
}

.photo-add{
  border:1px dashed #91aa9a;
  border-radius:12px;
  background:#f8fbf9;
  min-height:115px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  padding:16px;
  color:var(--green-900);
  font-weight:800;
}

.document-preview{
  border:1px solid var(--line);
  border-radius:14px;
  padding:17px;
  background:#fff;
  max-height:420px;
  overflow:auto;
  line-height:1.5;
}

.document-preview h1,
.document-preview h2,
.document-preview h3{
  line-height:1.2;
}

.prepared-list{
  display:grid;
  gap:8px;
}

.prepared-row{
  display:grid;
  grid-template-columns:minmax(130px,.7fr) 1.3fr;
  gap:14px;
  border-bottom:1px solid #edf1ee;
  padding:8px 0;
}

.prepared-row:last-child{
  border-bottom:0;
}

.prepared-row span:first-child{
  color:var(--muted);
  font-size:13px;
}

.prepared-row strong{
  overflow-wrap:anywhere;
}

.signature-wrap{
  border:2px solid #c6d3ca;
  border-radius:15px;
  background:white;
  overflow:hidden;
  touch-action:none;
}

.signature-wrap canvas{
  width:100%;
  height:220px;
  display:block;
  touch-action:none;
}

.signature-tools{
  display:flex;
  justify-content:flex-end;
  margin-top:8px;
}

.consent-stack{
  display:grid;
  gap:10px;
  margin-top:14px;
}

.signing-lock-note{
  font-size:12px;
  color:var(--muted);
  margin-top:10px;
}

.stepper{
  display:flex;
  align-items:center;
  gap:5px;
  margin-bottom:16px;
  overflow:auto;
  padding:2px;
}

.step{
  display:flex;
  align-items:center;
  gap:7px;
  color:#819087;
  font-size:12px;
  font-weight:760;
  white-space:nowrap;
}

.step::after{
  content:"";
  width:24px;
  height:1px;
  background:#cbd5ce;
  margin-left:2px;
}

.step:last-child::after{
  display:none;
}

.step-num{
  display:grid;
  place-items:center;
  width:26px;
  height:26px;
  border-radius:999px;
  background:#e8eeea;
  color:#64746a;
  font-weight:850;
}

.step.active{
  color:var(--green-900);
}

.step.active .step-num,
.step.done .step-num{
  background:var(--green-800);
  color:white;
}

.step.done{
  color:#476052;
}

.bottom-nav{
  position:fixed;
  left:0;
  right:0;
  bottom:0;
  z-index:70;
  display:grid;
  grid-template-columns:repeat(4,1fr);
  padding:7px 8px calc(7px + var(--safe-bottom));
  background:rgba(255,255,255,.97);
  backdrop-filter:blur(18px);
  border-top:1px solid var(--line);
}

.nav-button{
  border:0;
  background:transparent;
  color:#64746a;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:3px;
  min-height:55px;
  border-radius:12px;
  font-size:11px;
  font-weight:760;
}

.nav-button.active{
  color:var(--green-900);
  background:#eff7f1;
}

.nav-icon{
  font-size:20px;
  line-height:1;
}

.blocking-layer{
  position:fixed;
  inset:0;
  z-index:100;
  display:grid;
  place-items:center;
  padding:22px;
  background:linear-gradient(180deg,rgba(5,46,22,.92),rgba(20,83,45,.95));
  padding-top:calc(22px + var(--safe-top));
  padding-bottom:calc(22px + var(--safe-bottom));
}

.blocking-card{
  width:min(520px,100%);
  max-height:90dvh;
  overflow:auto;
  background:#fff;
  border-radius:24px;
  padding:23px;
  box-shadow:0 30px 80px rgba(0,0,0,.28);
}

.blocking-logo{
  display:block;
  width:82px;
  height:82px;
  margin:0 auto 14px;
  border-radius:20px;
  border:1px solid var(--line);
}

.blocking-title{
  text-align:center;
  margin:0;
  font-size:25px;
  letter-spacing:-.03em;
}

.blocking-sub{
  text-align:center;
  color:var(--muted);
  line-height:1.45;
  margin:8px 0 20px;
}

.pin-input{
  font-size:24px;
  letter-spacing:.22em;
  text-align:center;
  font-weight:850;
}

.blocking-card .field{
  margin-bottom:13px;
}

.toast{
  position:fixed;
  left:50%;
  transform:translateX(-50%);
  bottom:calc(92px + var(--safe-bottom));
  z-index:120;
  background:#142019;
  color:white;
  border-radius:12px;
  padding:11px 15px;
  box-shadow:0 10px 32px rgba(0,0,0,.22);
  font-size:13px;
  font-weight:700;
  max-width:min(90vw,620px);
  text-align:center;
}

.empty{
  text-align:center;
  padding:34px 18px;
  color:var(--muted);
}

.empty strong{
  display:block;
  color:var(--text);
  font-size:17px;
  margin-bottom:6px;
}

.loader{
  width:22px;
  height:22px;
  border:3px solid #d8e4dc;
  border-top-color:var(--green-800);
  border-radius:50%;
  animation:spin .8s linear infinite;
}

@keyframes spin{
  to{transform:rotate(360deg)}
}

.sync-stat-grid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
}

.sync-stat{
  border:1px solid var(--line);
  border-radius:14px;
  padding:13px;
  background:var(--surface-2);
}

.sync-stat .n{
  font-weight:900;
  font-size:24px;
}

.sync-stat .l{
  color:var(--muted);
  font-size:12px;
  margin-top:2px;
}

.danger-zone{
  border:1px solid #fecaca;
  background:#fff7f7;
  border-radius:14px;
  padding:14px;
}

.code{
  font-family:ui-monospace,SFMono-Regular,Menlo,monospace;
  font-size:12px;
  overflow-wrap:anywhere;
}

@media(max-width:720px){
  .topbar{padding:10px 12px}
  .brand-logo{width:48px;height:48px}
  .brand-title{font-size:16px}
  .brand-sub{font-size:11px}
  .status-row{gap:5px}
  .status-pill{padding:6px 8px;font-size:10px}
  .main-content{padding:17px 12px 28px}
  .page-title{font-size:25px}
  .page-head{display:block}
  .page-actions{margin-top:12px}
  .grid,.grid.three{grid-template-columns:1fr}
  .field-full{grid-column:auto}
  .photo-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
  .prepared-row{grid-template-columns:1fr;gap:3px}
  .sync-stat-grid{grid-template-columns:1fr}
  .template-row,.hire-row,.queue-row{display:block}
  .template-row>.btn,.hire-row>.btn{width:100%;margin-top:11px}
  .actions{display:grid;grid-template-columns:1fr}
  .actions .btn{width:100%}
  .actions.split{display:grid}
  .signature-wrap canvas{height:190px}
}

@media(min-width:1000px){
  .main-content{padding-top:28px}
  .bottom-nav{
    left:50%;
    right:auto;
    transform:translateX(-50%);
    width:620px;
    border:1px solid var(--line);
    border-bottom:0;
    border-radius:18px 18px 0 0;
    box-shadow:var(--shadow);
  }
}

@media(prefers-reduced-motion:reduce){
  *{
    scroll-behavior:auto!important;
    animation:none!important;
    transition:none!important;
  }
}
