:root {
  --rose: #d6336c;
  --rose-dark: #9f1239;
  --rose-light: #fff1f5;
  --teal: #0f766e;
  --mint: #ecfdf5;
  --ink: #1f2937;
  --muted: #6b7280;
  --line: #e5e7eb;
  --bg: #fff7f9;
  --card: #ffffff;
  --yellow: #facc15;
  --red: #dc2626;
  --green: #16a34a;
  --blue: #2563eb;
  --purple: #7c3aed;
  --orange: #ea580c;
}
* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif; background: var(--bg); color: var(--ink); }
a { color: var(--rose-dark); text-decoration: none; }
a:hover { text-decoration: underline; }
.topbar { background: linear-gradient(135deg, var(--rose), var(--teal)); color: white; padding: 14px 18px; display: flex; align-items: center; justify-content: space-between; gap: 16px; position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 800; font-size: 1.25rem; letter-spacing: .2px; }
.subtitle { font-size: .85rem; opacity: .92; }
.userbox { display: flex; align-items: center; gap: 10px; font-size: .9rem; flex-wrap: wrap; justify-content: flex-end; }
.userbox a { color: white; font-weight: 700; }
.role-pill, .notif-pill { border-radius: 999px; padding: 3px 8px; background: rgba(255,255,255,.22); font-size: .75rem; }
.notif-pill { background: #fef08a; color: #854d0e; font-weight: 800; }
.menu-toggle { display:none; border: 1px solid rgba(255,255,255,.45); background: rgba(255,255,255,.12); color: white; padding: 8px 10px; border-radius: 10px; }
.app-shell { display: grid; grid-template-columns: 250px 1fr; min-height: calc(100vh - 116px); }
.sidebar { background: white; border-right: 1px solid var(--line); padding: 16px; }
.sidebar a { display: block; padding: 11px 12px; border-radius: 14px; color: var(--ink); margin-bottom: 6px; font-weight: 700; }
.sidebar a small { color: var(--muted); font-weight: 500; }
.sidebar a:hover { background: var(--rose-light); text-decoration: none; }
.nav-section { margin: 18px 12px 8px; color: var(--muted); font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; }
.content { padding: 22px; }
.footer { padding: 14px 18px; color: var(--muted); text-align: center; font-size: .86rem; border-top: 1px solid var(--line); background: white; }
h1 { margin: 0 0 6px; font-size: 1.65rem; }
h2 { margin-top: 0; }
.page-subtitle { color: var(--muted); margin: 0 0 18px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 22px; padding: 18px; box-shadow: 0 12px 24px rgba(31,41,55,.06); margin-bottom: 18px; }
.card-title { font-weight: 800; font-size: 1.05rem; margin-bottom: 12px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stat { background: white; border: 1px solid var(--line); border-radius: 20px; padding: 16px; }
.stat .num { font-size: 2rem; font-weight: 900; color: var(--rose-dark); }
.stat .label { color: var(--muted); font-weight: 700; }
.btn { border: 0; border-radius: 12px; padding: 10px 13px; font-weight: 800; cursor: pointer; display: inline-block; background: var(--rose); color: white; text-decoration: none; }
.btn:hover { text-decoration: none; filter: brightness(.97); }
.btn-secondary { background: var(--teal); }
.btn-muted { background: #6b7280; }
.btn-danger { background: var(--red); }
.btn-light { background: var(--rose-light); color: var(--rose-dark); border: 1px solid #fecdd3; }
.actions { display:flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 12px 0; }
.form-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-row-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
label { display: block; font-weight: 800; margin-bottom: 6px; }
label small { display:block; color: var(--muted); font-weight: 600; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; background: white; color: var(--ink); font: inherit; }
textarea { min-height: 90px; }
.help { color: var(--muted); font-size: .86rem; margin-top: 4px; }
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); background: white; }
table { width: 100%; border-collapse: collapse; min-width: 850px; }
th, td { padding: 12px 11px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: #fff1f5; font-size: .86rem; text-transform: uppercase; letter-spacing: .04em; color: #831843; }
tr:last-child td { border-bottom: 0; }
.badge { display: inline-block; padding: 4px 9px; border-radius: 999px; font-weight: 800; font-size: .78rem; background: #e5e7eb; color: #374151; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-darkred { background: #7f1d1d; color: white; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-green { background: #dcfce7; color: #166534; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-orange { background: #ffedd5; color: #9a3412; }
.alert { border-radius: 16px; padding: 12px 14px; margin-bottom: 14px; font-weight: 700; }
.alert-success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.alert-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }
.login-wrap { max-width: 440px; margin: 40px auto; padding: 18px; }
.login-card { background: white; border: 1px solid var(--line); border-radius: 26px; padding: 26px; box-shadow: 0 16px 32px rgba(31,41,55,.08); }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px 14px; }
.check-item { display:flex; align-items:flex-start; gap: 8px; font-weight: 600; }
.check-item input { width: auto; margin-top: 4px; }
.kpi-note { font-size: .9rem; color: var(--muted); }
.print-only { display: none; }
@media (max-width: 850px) {
  .menu-toggle { display:block; }
  .app-shell { display:block; }
  .sidebar { display:none; border-right: 0; border-bottom: 1px solid var(--line); }
  body.nav-open .sidebar { display:block; }
  .content { padding: 14px; }
  .grid-2, .grid-3, .grid-4, .form-row, .form-row-3 { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .userbox { font-size: .82rem; }
  .check-grid { grid-template-columns: 1fr; }
}
@media print {
  .topbar, .sidebar, .footer, .actions, .btn, .menu-toggle { display:none !important; }
  body { background:white; }
  .app-shell { display:block; }
  .content { padding:0; }
  .card { box-shadow:none; border: 1px solid #ddd; }
  .print-only { display:block; }
}

/* Version 2 refinements */
.brand-wrap { display:flex; align-items:center; gap:12px; }
.logo-mark { width:42px; height:42px; border-radius:16px; background:rgba(255,255,255,.22); display:grid; place-items:center; font-weight:900; letter-spacing:.04em; box-shadow: inset 0 0 0 1px rgba(255,255,255,.25); }
.narrow-card { max-width: 560px; }
.no-print { }
.card-title::first-letter { color: var(--rose-dark); }
.stat { position: relative; overflow: hidden; }
.stat::after { content:""; position:absolute; right:-22px; top:-22px; width:76px; height:76px; border-radius:999px; background: var(--rose-light); opacity:.9; }
.stat .num, .stat .label { position: relative; z-index: 1; }
.table-wrap table tbody tr:hover { background:#fff7f9; }
hr { border: 0; border-top: 1px solid var(--line); margin: 18px 0; }
@media print {
  .no-print { display:none !important; }
  table { min-width: 0; font-size: 11px; }
  th, td { padding: 6px; }
}

/* Version 3: inactivity timeout warning */
.session-warning {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  max-width: 340px;
  background: #fff7ed;
  color: #7c2d12;
  border: 1px solid #fed7aa;
  border-left: 6px solid #ea580c;
  border-radius: 18px;
  box-shadow: 0 18px 42px rgba(31,41,55,.18);
  padding: 14px 16px;
  font-size: .92rem;
}
.session-warning strong { display:block; margin-bottom: 4px; }
.session-warning small { color: #9a3412; }
@media (max-width: 640px) {
  .session-warning { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* Version 3 full workflow hardening */
.sidebar-note { margin: 8px 12px 14px; color: var(--muted); font-size: .82rem; line-height: 1.35; }
.timeline { display: grid; gap: 12px; }
.timeline-item { display:flex; gap: 12px; align-items:flex-start; padding: 12px; border: 1px solid var(--line); border-radius: 16px; background: white; }
.timeline-dot { width: 14px; height: 14px; border-radius: 999px; margin-top: 4px; background: var(--rose); flex: 0 0 auto; }
.timeline-item.done .timeline-dot { background: var(--teal); }
.timeline-item.overdue .timeline-dot { background: var(--red); }
.timeline-title { font-weight: 900; }
.timeline-meta { color: var(--muted); font-size: .9rem; }
.profile-section { display:grid; grid-template-columns: 1fr 1fr; gap:16px; }
.referral-slip { max-width: 820px; margin: 0 auto; background:white; padding: 22px; border: 1px solid #ddd; }
.referral-slip h1 { text-align:center; }
.referral-slip .slip-grid { display:grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.callout { border-left: 6px solid var(--rose); background:#fff1f5; padding: 12px 14px; border-radius: 14px; }
.callout-red { border-left-color: var(--red); background:#fff1f2; }
@media (max-width: 850px) { .profile-section, .referral-slip .slip-grid { grid-template-columns:1fr; } }
@media print {
  .referral-slip { border:0; padding:0; max-width:100%; }
  .referral-slip .slip-grid { grid-template-columns:1fr 1fr; }
}
