:root {
  --ink: #16201b;
  --muted: #66736d;
  --line: #dce4df;
  --paper: #fbfcf8;
  --panel: #ffffff;
  --field: #f5f7f3;
  --brand: #0f6b55;
  --brand-2: #b72b39;
  --amber: #b87909;
  --ok: #18734d;
  --shadow: 0 16px 40px rgba(18, 32, 25, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.5 "Aptos", "Segoe UI", sans-serif;
}
a { color: inherit; text-decoration: none; }
.shell { min-height: 100vh; display: grid; grid-template-columns: 236px 1fr; }
.side {
  background: #101713;
  color: #edf4ef;
  padding: 22px 18px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}
.brand { font-size: 22px; font-weight: 800; letter-spacing: 0; }
.brand span { display: block; color: #9fb8ae; font-size: 12px; font-weight: 600; text-transform: uppercase; }
.nav { display: grid; gap: 6px; }
.nav a, .logout {
  border: 1px solid transparent;
  border-radius: 8px;
  color: #dfe9e3;
  padding: 10px 12px;
  text-align: left;
  background: transparent;
  font: inherit;
  cursor: pointer;
}
.nav a:hover, .logout:hover { background: #1b2822; border-color: #2c3f36; }
.main { padding: 28px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 24px; }
h1 { font-size: 30px; line-height: 1.1; margin: 0; }
h2 { font-size: 20px; margin: 0 0 14px; }
h3 { font-size: 15px; margin: 0 0 10px; text-transform: uppercase; color: var(--muted); }
.muted { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid.stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.panel, .card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 18px;
}
.stat .num { display: block; font-size: 31px; font-weight: 850; }
.stat .label { color: var(--muted); font-size: 13px; }
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  border: 1px solid var(--brand);
  border-radius: 8px;
  background: var(--brand);
  color: white;
  padding: 8px 13px;
  font-weight: 750;
  cursor: pointer;
}
.btn.secondary { background: white; color: var(--ink); border-color: var(--line); }
.btn.warn { background: var(--brand-2); border-color: var(--brand-2); }
.actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 9px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--muted); font-size: 12px; text-transform: uppercase; }
label { display: grid; gap: 6px; font-weight: 700; }
input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
  color: var(--ink);
  padding: 10px 11px;
  font: inherit;
}
textarea { min-height: 130px; font-family: "Cascadia Mono", Consolas, monospace; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.full { grid-column: 1 / -1; }
.flash { margin-bottom: 16px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.flash.success { border-color: #b8decf; color: var(--ok); }
.flash.error { border-color: #f0bbc1; color: var(--brand-2); }
.badge { display: inline-flex; border-radius: 999px; padding: 3px 8px; font-size: 12px; font-weight: 800; background: #e8eee9; }
.badge.danger { background: #f8d9dd; color: var(--brand-2); }
.badge.warn { background: #f4e5c7; color: var(--amber); }
.badge.ok { background: #dcefe7; color: var(--ok); }
.risk {
  border-left: 4px solid var(--brand-2);
  background: #fff7f8;
  padding: 14px;
  border-radius: 8px;
}
.preview {
  border: 1px solid var(--line);
  background: white;
  border-radius: 8px;
  padding: 16px;
  min-height: 160px;
}
.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at top left, rgba(15,107,85,.14), transparent 34%), var(--paper);
}
.login-card { width: min(430px, 100%); }
.signature-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, .65fr);
  gap: 16px;
  align-items: start;
}
.signature-editor { padding: 0; overflow: hidden; }
.editor-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, #ffffff, #f7faf6);
}
.toggle-line {
  display: inline-flex;
  grid-auto-flow: column;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--muted);
}
.toggle-line input { width: auto; }
.signature-editor .form-grid { padding: 18px; }
.logo-panel {
  margin: 0 18px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7faf6;
  padding: 14px;
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}
.logo-controls {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) 140px auto;
  gap: 10px;
  align-items: end;
}
.signature-editor > .actions { padding: 0 18px 18px; }
.signature-workbench.simple { grid-template-columns: minmax(0, 1fr) minmax(360px, .75fr); }
.signature-fields textarea { min-height: 88px; font-family: inherit; }
.signature-fields label:has(textarea[name="disclaimer"]) textarea { min-height: 180px; font-size: 13px; line-height: 1.45; }
.logo-panel.simple {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 140px auto;
  align-items: end;
}
.current-logo.compact {
  margin: 0;
  border-top: 0;
  padding-top: 0;
}
.current-logo.compact img { max-width: 150px; }
.signature-preview-panel {
  position: sticky;
  top: 18px;
}
.signature-preview {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 300px;
  background: white;
  padding: 16px;
  overflow: auto;
}
.current-logo {
  margin-top: 14px;
  border-top: 1px solid var(--line);
  padding-top: 14px;
  display: grid;
  gap: 8px;
}
.current-logo img {
  max-width: 220px;
  height: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 8px;
}
@media (max-width: 920px) {
  .shell { grid-template-columns: 1fr; }
  .side { position: static; }
  .grid.stats, .grid.two, .form-grid, .signature-workbench, .signature-workbench.simple, .logo-controls, .logo-panel.simple { grid-template-columns: 1fr; }
  .main { padding: 18px; }
  .signature-preview-panel { position: static; }
}
