:root {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --ink: #1f2430;
  --muted: #6b7280;
  --brand: #4f46e5;
  --brand-2: #6366f1;
  --side: #1e2233;
  --side-ink: #c7ccdb;
  --side-active: #2b3047;
  --line: #e7e9f0;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 8px 24px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.app { display: flex; min-height: 100vh; }

/* ---------- Sidebar ---------- */
.sidebar {
  width: 264px;
  background: var(--side);
  color: var(--side-ink);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
@media (min-width: 992px) {
  .sidebar { position: sticky; top: 0; height: 100vh; }
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1.05rem 1.1rem;
  border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  color: #fff;
  font-weight: 700;
}
.brand-text { display: flex; flex-direction: column; line-height: 1.1; color: #fff; font-weight: 700; }
.brand-text small { color: #9aa1b8; font-weight: 500; font-size: .7rem; }
.sidebar-nav { padding: .25rem .6rem 1rem; overflow-y: auto; }
.nav-group-title {
  color: #7e859b;
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: .95rem .6rem .35rem;
}
.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: .65rem;
  color: var(--side-ink);
  border-radius: 10px;
  padding: .55rem .65rem;
  font-size: .92rem;
}
.sidebar .nav-link:hover { background: var(--side-active); color: #fff; }
.sidebar .nav-link.active { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; }
.sidebar .nav-link i { font-size: 1.05rem; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: .7rem 1.1rem;
  position: sticky;
  top: 0;
  z-index: 5;
}
.topbar-title { font-size: 1.1rem; margin: 0; font-weight: 650; }
.user-btn {
  display: flex;
  align-items: center;
  gap: .5rem;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 999px;
  padding: .25rem .7rem .25rem .3rem;
}
.avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
}
.content { padding: 1.25rem; width: 100%; max-width: 1200px; }

/* ---------- Cards / panels ---------- */
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); }
.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: #eef0fb; color: var(--brand);
  font-size: 1.15rem; margin-bottom: .5rem;
}
.stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-label { color: var(--muted); font-size: .85rem; margin-top: .25rem; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .75rem; }
.panel-head h3 { font-size: 1rem; margin: 0; font-weight: 650; }
.welcome h2 { font-weight: 700; margin-bottom: .15rem; }
.stat-row { margin-top: .25rem; }
.quick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .6rem; }
.quick-link {
  display: flex; flex-direction: column; align-items: flex-start; gap: .4rem;
  padding: .85rem; border: 1px solid var(--line); border-radius: 12px;
  text-decoration: none; color: var(--ink); background: #fff;
}
.quick-link:hover { border-color: var(--brand); color: var(--brand); }
.quick-link i { font-size: 1.3rem; color: var(--brand); }
.getting-started { margin: 0; padding-left: 1.1rem; color: var(--muted); line-height: 1.9; }

/* ---------- Placeholder & error ---------- */
.placeholder-hero { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 2rem; text-align: center; box-shadow: var(--shadow); }
.placeholder-icon { font-size: 2.4rem; color: var(--brand); margin-bottom: .4rem; }
.error-state { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 3rem 1.5rem; text-align: center; box-shadow: var(--shadow); }
.error-code { font-size: 3rem; font-weight: 800; color: var(--brand); line-height: 1; }

/* ---------- Login ---------- */
.login-body { background: linear-gradient(135deg, #eef0fb, #f5f6fa); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 1.25rem; }
.login-card { background: #fff; border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 1.75rem; width: 100%; max-width: 400px; }
.login-brand { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.1rem; }
.login-brand strong { display: block; line-height: 1.1; }
.login-brand span { color: var(--muted); font-size: .8rem; }
.login-title { font-size: 1.4rem; font-weight: 700; margin: 0; }
.login-sub { color: var(--muted); font-size: .9rem; margin-bottom: 1rem; }
.login-foot { color: var(--muted); font-size: .78rem; margin-top: 1rem; }

/* ---------- Process configuration ---------- */
.module-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: .9rem;
}
.module-toolbar h2 { margin: 0; font-size: 1.2rem; font-weight: 700; }
.module-subtitle { color: var(--muted); font-size: .82rem; margin-top: .1rem; }
.process-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: .9rem;
  align-items: start;
}
.process-index { position: sticky; top: 76px; }
.process-list { display: grid; gap: .45rem; }
.process-item {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 8px;
  padding: .65rem .7rem;
  text-align: left;
}
.process-item:hover,
.process-item.active { border-color: var(--brand); background: #f7f8ff; }
.process-item-title {
  display: block;
  font-weight: 650;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.process-item-meta,
.process-item-foot,
.table-subtext {
  color: var(--muted);
  font-size: .76rem;
}
.process-item-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: .35rem;
}
.process-workspace { display: grid; gap: .9rem; min-width: 0; }
.dense-form .form-label {
  color: #4b5563;
  font-size: .78rem;
  font-weight: 650;
  margin-bottom: .2rem;
}
.form-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  margin-top: .75rem;
}
.stage-pill,
.mini-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid #d6e4dd;
  background: #f1faf5;
  color: #1f6f43;
  border-radius: 999px;
  padding: .1rem .45rem;
  font-size: .72rem;
  font-weight: 650;
  margin-right: .25rem;
}
.version-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: .5rem;
}
.version-chip {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 8px;
  padding: .55rem .6rem;
  text-align: left;
}
.version-chip:hover,
.version-chip.active { border-color: #0f766e; background: #f0fdfa; }
.version-chip span,
.version-chip strong,
.version-chip small { display: block; line-height: 1.25; }
.version-chip span { font-weight: 700; }
.version-chip strong { color: #0f766e; font-size: .78rem; text-transform: capitalize; }
.version-chip small { color: var(--muted); font-size: .72rem; }
.step-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  gap: .9rem;
  align-items: start;
}
.config-subgrid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .9rem;
}
.config-table { margin-bottom: 0; }
.config-table th {
  color: var(--muted);
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
  white-space: nowrap;
}
.config-table td { font-size: .85rem; vertical-align: middle; }
.selected-row td { background: #f7f8ff; }
.link-button {
  border: 0;
  background: transparent;
  color: var(--brand);
  padding: 0;
  font: inherit;
  text-align: left;
}
.link-button.strong { font-weight: 650; color: var(--ink); }
.table-actions {
  white-space: nowrap;
  text-align: right;
}
.icon-btn {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #475569;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn.danger:hover { border-color: #dc2626; color: #dc2626; }
.empty-state,
.empty-cell {
  color: var(--muted);
  font-size: .85rem;
  padding: .7rem;
  text-align: center;
}
.flag-row {
  display: flex;
  gap: .8rem;
  align-items: end;
  padding-bottom: .2rem;
}

/* ---------- Content configuration ---------- */
.content-shell {
  display: grid;
  grid-template-columns: minmax(220px, 280px) minmax(0, 1fr);
  gap: .9rem;
  align-items: start;
}
.content-index { position: sticky; top: 76px; }
.content-workspace {
  display: grid;
  gap: .9rem;
  min-width: 0;
}
.content-workspace .card,
.content-index.card { border-radius: 8px; }
.content-page .list-group-item {
  border-color: var(--line);
  cursor: pointer;
}
.content-page .list-group-item:hover,
.content-page .list-group-item.active {
  border-color: var(--brand);
  background: #f7f8ff;
  color: var(--ink);
}
.code-area {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .8rem;
  line-height: 1.5;
}
.report-filter-grid,
.audit-filter-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .6rem;
  align-items: end;
}
.audit-snapshot {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: .75rem;
}

/* ---------- Runtime operations ---------- */
.detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .9rem;
}
.detail-head h3 {
  font-size: 1.08rem;
  font-weight: 700;
  margin: 0 0 .15rem;
  overflow-wrap: anywhere;
}
.detail-actions {
  display: flex;
  align-items: center;
  gap: .45rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .6rem;
}
.summary-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem .7rem;
  background: #fafbff;
  min-width: 0;
}
.summary-grid span {
  display: block;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 650;
  text-transform: uppercase;
}
.summary-grid strong {
  display: block;
  margin-top: .2rem;
  font-size: .9rem;
  overflow-wrap: anywhere;
}
.action-row {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
  align-items: center;
  min-height: 34px;
}
.timeline {
  display: grid;
  gap: .7rem;
}
.timeline-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: .6rem;
}
.timeline-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand);
  margin-top: .35rem;
}
.timeline-body {
  display: grid;
  gap: .08rem;
  padding-bottom: .55rem;
  border-bottom: 1px solid var(--line);
}
.timeline-body strong { font-size: .86rem; }
.timeline-body span { color: #374151; font-size: .84rem; overflow-wrap: anywhere; }
.timeline-body small { color: var(--muted); font-size: .74rem; }
.email-body {
  min-height: 150px;
  max-height: 420px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: .8rem;
  color: #374151;
  font-size: .88rem;
  line-height: 1.55;
}
@media (max-width: 1100px) {
  .process-shell,
  .content-shell,
  .step-layout,
  .config-subgrid,
  .report-filter-grid,
  .audit-filter-grid,
  .summary-grid { grid-template-columns: 1fr; }
  .process-index,
  .content-index { position: static; }
  .detail-head { flex-direction: column; }
  .detail-actions { justify-content: flex-start; }
}
