:root {
  --primary: #0066ff;
  --primary-2: #00a8ff;
  --default: #071a3a;
  --success: #2dce89;
  --info: #00a8ff;
  --warning: #fb6340;
  --danger: #f5365c;
  --gray-100: #f4f8fc;
  --gray-200: #e9ecef;
  --gray-300: #dee2e6;
  --gray-600: #6b7c93;
  --gray-700: #3d4f6f;
  --gray-800: #0b1f4d;
  --bg: #f3f7fb;
  --panel: #fff;
  --surface: #f4f8fc;
  --ink: #0b1f4d;
  --muted: #6b7c93;
  --line: #e4edf5;
  --line-2: #e4edf5;
  --ok: #2dce89;
  --bad: #f5365c;
  --warn: #fb6340;
  --accent: #0066ff;
  --accent-2: #00a8ff;
  --side: 250px;
  --dark: #071a3a;
  --flow: linear-gradient(135deg, #0066ff 0%, #00a8ff 100%);
  --glow: 0 0 2rem 0 rgba(0, 102, 255, 0.12);
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #060e1a;
  --panel: #0d1b30;
  --surface: #10233d;
  --ink: #e8eef8;
  --muted: #8aa0c2;
  --line: #1c3250;
  --gray-100: #12233c;
  --gray-600: #8aa0c2;
  --gray-700: #c5d0e0;
  --gray-800: #f0f4fa;
  --glow: 0 0 2rem 0 rgba(0, 102, 255, 0.2);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow-x: hidden; }
[hidden], .is-off, #login-view[hidden], #app-view[hidden] { display: none !important; }
body {
  font-family: Open Sans, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
button { cursor: pointer; }

.auth-page {
  min-height: 100%;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: var(--bg);
}
.brand-mark {
  display: block;
  background: transparent;
  filter: drop-shadow(0 16px 24px rgba(0, 80, 200, 0.28));
}
.auth-stage {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(700px 420px at 80% 0%, rgba(0, 168, 255, 0.4), transparent 60%),
    var(--default);
  color: #fff;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 48px 32px;
}
.stage-back {
  position: absolute;
  top: 22px;
  left: 22px;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
}
.stage-mark {
  position: relative;
  width: min(240px, 56vw);
  margin-bottom: 18px;
}
.stage-mark .glow {
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(0,168,255,.4), transparent 70%);
  animation: pulse 5s ease-in-out infinite;
}
.stage-mark .brand-mark {
  position: relative;
  width: 100%;
  height: auto;
}
.stage-k { margin: 0 0 6px; font-size: 13px; letter-spacing: 0.12em; text-transform: uppercase; color: #9ed8ff; }
.stage-k b { font-size: 20px; letter-spacing: -0.03em; text-transform: none; color: #fff; }
.stage-k i { font-style: normal; color: var(--primary-2); }
.auth-stage h2 { margin: 0; font-size: clamp(28px, 4vw, 40px); letter-spacing: -0.04em; font-weight: 800; }
.auth-stage p { margin: 8px 0 0; color: rgba(255,255,255,.8); }
.auth-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.panel-bar {
  display: flex;
  justify-content: flex-end;
  padding: 16px 20px 0;
}
.auth-card {
  width: min(420px, calc(100% - 48px));
  margin: auto;
  padding: 12px 0 48px;
  animation: rise 0.7s ease both;
}
.auth-card .mark-sm {
  width: 56px;
  height: auto;
  margin-bottom: 14px;
}
.auth-card h1 {
  margin: 0 0 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
#auth-sub { margin: 0 0 20px; color: var(--muted); }
.btn.trial { width: 100%; margin-bottom: 8px; }
.or {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 16px 0;
}
.roles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.role-chip {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 14px;
  padding: 10px 8px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: var(--primary);
}
.role-chip span {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.role-chip:hover { border-color: var(--primary); }
#login-form .btn { width: 100%; }
.is-out .auth-card h1 { color: var(--primary); }
@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: none; }
}
.float { animation: float 5.5s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) {
  .float, .auth-card, .stage-mark .glow { animation: none; }
}

label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--gray-700);
  margin: 0 0 6px;
}
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=submit]):not([type=button]),
select {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 0 14px;
  margin-bottom: 16px;
  outline: none;
  color: var(--gray-700);
  -webkit-appearance: none;
  appearance: none;
}
select {
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'><path fill='%238898aa' d='M1 1l5 5 5-5'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 132px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 16px;
  padding: 14px 16px;
  margin-bottom: 16px;
  outline: none;
  color: var(--gray-800);
  line-height: 1.6;
  resize: vertical;
  -webkit-appearance: none;
  appearance: none;
}
::placeholder { color: #adb5bd; }
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  background-color: var(--panel);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.18);
}
.btn {
  border: 0;
  background: var(--flow);
  color: #fff;
  border-radius: 12px;
  padding: 11px 18px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 18px rgba(0, 102, 255, 0.28);
}
.btn:hover { filter: brightness(1.05); color: #fff; }
.btn.ghost {
  background: var(--panel);
  color: var(--primary);
  border: 1px solid var(--primary);
  box-shadow: none;
}
.btn.danger { background: linear-gradient(87deg, #f5365c 0, #f56036 100%); }
.btn.ok { background: linear-gradient(87deg, #2dce89 0, #2dcecc 100%); }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }
.err { color: var(--danger); min-height: 1.2em; font-size: 13px; margin: 0 0 8px; }

.shell {
  min-height: 100%;
  display: grid;
  grid-template-columns: var(--side) 1fr;
  background: var(--bg);
}
.side {
  background: var(--default);
  color: #fff;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.side .logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 22px;
}
.side .logo img {
  width: 42px;
  height: 42px;
  object-fit: contain;
  background: transparent;
  border-radius: 0;
  flex: none;
  filter: drop-shadow(0 8px 14px rgba(0, 168, 255, 0.35));
}
.side .logo strong { display: block; font-size: 18px; font-weight: 800; letter-spacing: -0.03em; }
.side .logo strong .c { color: var(--primary-2); }
.side .logo span { color: #8aa0c2; font-size: 10px; font-weight: 600; letter-spacing: 0.02em; }
.nav-label {
  padding: 12px 14px 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #8b95a9;
}
.nav-btn {
  text-align: left;
  background: transparent;
  color: rgba(255,255,255,.75);
  border: 0;
  border-radius: 12px;
  padding: 10px 14px;
  width: 100%;
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-btn svg { width: 16px; height: 16px; flex: none; opacity: .85; }
.nav-btn:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-btn.on {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 6px rgba(50, 50, 93, 0.11);
}
.nav-btn .count {
  margin-left: auto;
  background: #fff;
  color: var(--primary);
  border-radius: 999px;
  padding: 0 7px;
  font-size: 11px;
  font-weight: 700;
}
.workspace { min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.page-header {
  background: var(--flow);
  color: #fff;
  padding: 22px 28px 56px;
}
.page-header-top {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
}
.page-header h1 {
  margin: 10px 0 0;
  font-size: 22px;
  font-weight: 600;
}
.page-header p { margin: 4px 0 0; opacity: 0.85; font-size: 13px; }
.who { display: flex; align-items: center; gap: 10px; color: #fff; font-size: 12px; flex-shrink: 0; }
.who b { display: block; font-weight: 700; }
#who-role { opacity: 0.85; }
.av {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--primary);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
}
.page-header .btn.ghost {
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  background: transparent;
  border-radius: 12px;
}
.canvas {
  padding: 0 28px 48px;
  margin-top: -36px;
  position: relative;
  z-index: 2;
}

.window, .card {
  background: var(--panel);
  border: 0;
  border-radius: 16px;
  overflow: visible;
  box-shadow: var(--glow);
}
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 20px;
  align-items: start;
}
.form-grid > * { min-width: 0; }
.sec {
  margin: 0 0 8px;
  padding: 0 0 8px;
  border-bottom: 1px solid var(--line);
}
.sec:last-of-type { border-bottom: 0; margin-bottom: 4px; }
.sec-h {
  margin: 4px 0 12px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gray-600);
}
.hint {
  margin: -6px 0 14px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.45;
}
input[readonly] {
  background: var(--surface);
  color: var(--gray-700);
}
td.code, .code {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: 0.04em;
}
.window + .window { margin-top: 16px; }
.window-h {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  letter-spacing: 0;
  text-transform: none;
  border-radius: 16px 16px 0 0;
}
.window-b { padding: 16px 20px 20px; }

.kpi {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.kpi-card {
  background: var(--panel);
  border-radius: 16px;
  box-shadow: var(--glow);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.kpi-card span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.kpi-card b {
  display: block;
  font-size: 20px;
  font-weight: 700;
  color: var(--gray-800);
  letter-spacing: 0;
  margin-top: 4px;
}
.icon-shape {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex: none;
  box-shadow: 0 0 2rem 0 rgba(136, 152, 170, 0.15);
}
.icon-shape.danger { background: linear-gradient(87deg, #f5365c 0, #f56036 100%); }
.icon-shape.success { background: linear-gradient(87deg, #2dce89 0, #2dcecc 100%); }
.icon-shape.info { background: var(--flow); }
.icon-shape.warning { background: linear-gradient(87deg, #fb6340 0, #fbb140 100%); }
.icon-shape.primary { background: var(--flow); }

.grid2 {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
}
.grid2.even { grid-template-columns: 1fr 1fr; }
.full { grid-column: 1 / -1; }

.table { width: 100%; border-collapse: collapse; }
.table th, .table td {
  text-align: left;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--gray-700);
}
.table th {
  color: var(--muted);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: var(--panel);
}
.table tr:last-child td { border-bottom: 0; }
.table tr:hover td { background: var(--gray-100); }
.table .id {
  font-weight: 700;
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  color: var(--primary);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 700;
  background: var(--gray-100);
  color: var(--gray-700);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.legal_review { background: #e0f3ff; color: #1171ef; }
.pill.changes_requested { background: #fff4e6; color: #fb6340; }
.pill.pending_head, .pill.pending_gm, .pill.pending_ceo { background: #e7f1ff; color: #0066ff; }
.pill.pending_supplier { background: #e6fcf5; color: #2dce89; }
.pill.archived { background: var(--gray-100); color: var(--gray-600); }
.pill.rejected { background: #fdd9e2; color: #f5365c; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li {
  position: relative;
  padding: 0 0 16px 16px;
  border-left: 2px solid var(--line);
  margin-left: 5px;
}
.timeline li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline li::before {
  content: "";
  width: 9px;
  height: 9px;
  background: var(--primary);
  border-radius: 50%;
  position: absolute;
  left: -6px;
  top: 5px;
}
.muted { color: var(--muted); font-size: 13px; }
.notes .note { padding: 12px 0; border-top: 1px solid var(--line); }
.notes .note:first-of-type { border-top: 0; padding-top: 0; }
.empty { text-align: center; color: var(--muted); padding: 42px 12px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 14px; }
.check input { width: auto; height: auto; margin: 0; }
.drop {
  position: relative;
  display: block;
  border: 1px dashed #c5cde0;
  border-radius: 16px;
  padding: 22px 18px;
  text-align: center;
  background: var(--surface);
  margin-bottom: 16px;
  color: var(--muted);
  cursor: pointer;
}
.drop:hover { border-color: var(--primary); color: var(--primary); }
.drop input[type=file] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  margin: 0;
}
.drop b { display: block; color: var(--gray-800); font-size: 13px; margin-bottom: 4px; }
.filechip {
  display: inline-block;
  margin: 4px 8px 0 0;
  background: var(--gray-100);
  color: var(--primary);
  border-radius: 12px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  text-decoration: none;
}
.meta-row {
  display: grid;
  grid-template-columns: 118px 1fr;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.meta-row:last-child { border-bottom: 0; }
.meta-row span { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.lede-in { margin: 0 0 12px; color: var(--gray-700); }
.must {
  margin: 0;
  padding: 0 0 0 18px;
  color: var(--gray-700);
}
.must li { margin: 0 0 6px; }
.flow {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 8px;
}
.flow li {
  background: var(--gray-100);
  border-radius: 12px;
  padding: 12px 12px 10px;
  border: 1px solid transparent;
}
.flow li .n {
  display: block;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 4px;
}
.flow li b { display: block; font-size: 13px; font-weight: 700; }
.flow li small { display: block; margin-top: 4px; color: var(--muted); font-size: 11px; }
.flow li.you, .flow li.current {
  background: #e7f1ff;
  border-color: #9dc4ff;
}
.flow li.done { background: #e6fcf5; }
.flow li.skip { opacity: 0.55; }
.flow li.rejected { background: #fdd9e2; }
.flow-card.on { box-shadow: 0 0 0 1px var(--primary), var(--glow); }
html[data-theme="dark"] .drop { border-color: #2a4668; }
html[data-theme="dark"] .side { background: #050d18; }
html[data-theme="dark"] .pill.legal_review { background: #12355a; color: #7ec4ff; }
html[data-theme="dark"] .pill.changes_requested { background: #3a2414; color: #ff9b6b; }
html[data-theme="dark"] .pill.pending_head,
html[data-theme="dark"] .pill.pending_gm,
html[data-theme="dark"] .pill.pending_ceo { background: #102a52; color: #7eb6ff; }
html[data-theme="dark"] .pill.pending_supplier { background: #0f3328; color: #5ee0b0; }
html[data-theme="dark"] .pill.rejected { background: #3a1420; color: #ff6b8a; }
html[data-theme="dark"] .flow li.you,
html[data-theme="dark"] .flow li.current { background: #122a4d; border-color: #2b5ea8; }
html[data-theme="dark"] .flow li.done { background: #0f3328; }
html[data-theme="dark"] .flow li.rejected { background: #3a1420; }
.page-header [data-theme-btn] {
  border: 1px solid rgba(255,255,255,.45);
  color: #fff;
  background: transparent;
}
@media (max-width: 960px) {
  .shell, .kpi, .grid2, .auth-page { grid-template-columns: 1fr; }
  .auth-stage { min-height: 280px; padding: 56px 24px 32px; }
  .side { flex-direction: row; flex-wrap: wrap; }
  .page-header { padding-top: 20px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-header-top { flex-wrap: wrap; }
}
