/* ============================================================
   Kinetic Compliance — App Shell CSS
   ============================================================ */

:root {
  --k-bg: #f8fafc;
  --k-surface: #ffffff;
  --k-surface-2: #f1f5f9;
  --k-border: #e2e8f0;
  --k-text: #0f172a;
  --k-muted: #64748b;
  --k-blue: #2563eb;
  --k-blue-dark: #1d4ed8;
  --k-blue-light: #eff6ff;
  --k-green: #059669;
  --k-green-light: #ecfdf5;
  --k-red: #dc2626;
  --k-red-light: #fef2f2;
  --k-amber: #d97706;
  --k-amber-light: #fffbeb;
  --k-sidebar-w: 240px;
  --k-topbar-h: 60px;
  --k-radius: 8px;
  --k-shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--k-bg);
  color: var(--k-text);
  line-height: 1.5;
  font-size: 14px;
}

/* ── APP LAYOUT ── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── SIDEBAR ── */
.sidebar {
  width: var(--k-sidebar-w);
  background: var(--k-surface);
  border-right: 1px solid var(--k-border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--k-border);
  text-decoration: none;
}

.sidebar-brand-icon {
  width: 28px;
  height: 28px;
  background: var(--k-blue);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--k-text);
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--k-muted);
  padding: 10px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--k-radius);
  text-decoration: none;
  color: var(--k-muted);
  font-size: 13.5px;
  font-weight: 500;
  transition: background .12s, color .12s;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--k-surface-2);
  color: var(--k-text);
}

.nav-item.active {
  background: var(--k-blue-light);
  color: var(--k-blue);
  font-weight: 600;
}

.nav-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  opacity: .8;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  border-top: 1px solid var(--k-border);
  padding: 12px 10px;
}

.org-badge {
  padding: 8px 10px;
  border-radius: var(--k-radius);
  background: var(--k-surface-2);
}

.org-badge-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--k-muted);
  font-weight: 600;
}

.org-badge-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--k-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ── MAIN CONTENT ── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── TOPBAR ── */
.topbar {
  height: var(--k-topbar-h);
  background: var(--k-surface);
  border-bottom: 1px solid var(--k-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

.topbar-left {
  display: flex;
  flex-direction: column;
}

.topbar-page-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--k-text);
  line-height: 1.2;
}

.topbar-org-name {
  font-size: 12px;
  color: var(--k-muted);
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--k-blue);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}

.avatar-btn:hover { opacity: .85; }

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--k-radius);
  border: 1px solid var(--k-border);
  background: var(--k-surface);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--k-muted);
  transition: background .12s;
  position: relative;
}

.icon-btn:hover { background: var(--k-surface-2); }

.notif-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  background: var(--k-red);
  border-radius: 50%;
  border: 2px solid var(--k-surface);
}

/* ── PAGE CONTENT ── */
.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

/* ── PAGE HEADER ── */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--k-text);
  letter-spacing: -.02em;
}

.page-subtitle {
  font-size: 13px;
  color: var(--k-muted);
  margin-top: 2px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--k-radius);
  font-size: 13px;
  font-weight: 600;
  border: none;
  cursor: pointer;
  text-decoration: none;
  transition: background .12s, opacity .12s;
  white-space: nowrap;
}

.btn:hover { opacity: .88; }
.btn:active { opacity: .75; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

.btn-primary { background: var(--k-blue); color: #fff; }
.btn-secondary { background: var(--k-surface-2); color: var(--k-text); border: 1px solid var(--k-border); }
.btn-danger { background: var(--k-red); color: #fff; }
.btn-ghost { background: transparent; color: var(--k-muted); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn svg { width: 14px; height: 14px; }

/* ── CARDS ── */
.card {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  box-shadow: var(--k-shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--k-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--k-text);
}

.card-body { padding: 20px; }
.card-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--k-border);
  background: var(--k-surface-2);
  border-radius: 0 0 var(--k-radius) var(--k-radius);
}

/* ── STAT CARDS ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 20px;
  box-shadow: var(--k-shadow);
}

.stat-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--k-muted);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--k-text);
  letter-spacing: -.03em;
  line-height: 1;
}

.stat-subtext {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 4px;
}

/* ── ALERTS ── */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--k-radius);
  margin-bottom: 16px;
  font-size: 13.5px;
}

.alert-warning {
  background: var(--k-amber-light);
  border: 1px solid #fde68a;
  color: #92400e;
}

.alert-danger {
  background: var(--k-red-light);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: var(--k-blue-light);
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

.alert-success {
  background: var(--k-green-light);
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

/* ── TABLES ── */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--k-muted);
  border-bottom: 1px solid var(--k-border);
  background: var(--k-surface-2);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--k-border);
  font-size: 13.5px;
  color: var(--k-text);
  vertical-align: middle;
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--k-surface-2); }

/* ── BADGES ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}

.badge-blue { background: var(--k-blue-light); color: var(--k-blue); }
.badge-green { background: var(--k-green-light); color: var(--k-green); }
.badge-amber { background: var(--k-amber-light); color: var(--k-amber); }
.badge-red { background: var(--k-red-light); color: var(--k-red); }
.badge-gray { background: var(--k-surface-2); color: var(--k-muted); }
.badge-purple { background: #f3e8ff; color: #7c3aed; }

/* ── PROGRESS BAR ── */
.progress-bar {
  height: 8px;
  background: var(--k-border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 4px;
  transition: width .3s;
}

.progress-fill-blue { background: var(--k-blue); }
.progress-fill-green { background: var(--k-green); }
.progress-fill-amber { background: var(--k-amber); }
.progress-fill-red { background: var(--k-red); }

/* ── MODAL ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal {
  background: var(--k-surface);
  border-radius: var(--k-radius);
  box-shadow: 0 20px 60px rgba(0,0,0,.15);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--k-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--k-text);
}

.modal-close {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: var(--k-surface-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--k-muted);
  transition: background .12s;
}

.modal-close:hover { background: var(--k-border); }

.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--k-border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ── FORMS ── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--k-text);
  margin-bottom: 5px;
}

.form-hint {
  font-size: 12px;
  color: var(--k-muted);
  margin-top: 3px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  font-size: 13.5px;
  color: var(--k-text);
  background: var(--k-surface);
  transition: border-color .12s;
  font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--k-blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

.form-textarea { resize: vertical; min-height: 80px; }

.form-error {
  font-size: 12px;
  color: var(--k-red);
  margin-top: 4px;
}

/* ── WIZARD / STEPPED FORM ── */
.wizard-steps {
  display: flex;
  align-items: center;
  gap: 0;
  margin-bottom: 28px;
  padding: 0 4px;
}

.wizard-step {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--k-muted);
}

.wizard-step-dot {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid var(--k-border);
  background: var(--k-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  flex-shrink: 0;
}

.wizard-step.active { color: var(--k-blue); }
.wizard-step.active .wizard-step-dot {
  border-color: var(--k-blue);
  background: var(--k-blue);
  color: #fff;
}

.wizard-step.done { color: var(--k-green); }
.wizard-step.done .wizard-step-dot {
  border-color: var(--k-green);
  background: var(--k-green);
  color: #fff;
}

.wizard-step-line {
  flex: 1;
  height: 2px;
  background: var(--k-border);
  margin: 0 8px;
}

.wizard-step.done + .wizard-step .wizard-step-line,
.wizard-step.done .wizard-step-line { background: var(--k-green); }

.wizard-content {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 28px;
}

.wizard-footer {
  display: flex;
  justify-content: space-between;
  margin-top: 20px;
}

/* ── RISK SCORE ── */
.risk-score-ring {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 8px solid var(--k-border);
  position: relative;
}

.risk-score-ring .score-val {
  font-size: 24px;
  font-weight: 700;
}

.risk-score-ring .score-label {
  font-size: 10px;
  color: var(--k-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* ── EMPTY STATE ── */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--k-muted);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  opacity: .4;
  margin-bottom: 12px;
}

.empty-state h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--k-text);
  margin-bottom: 4px;
}

.empty-state p {
  font-size: 13px;
  margin-bottom: 16px;
}

/* ── TOAST ── */
.toast-wrap {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 16px;
  border-radius: var(--k-radius);
  background: var(--k-text);
  color: #fff;
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,.2);
  display: flex;
  align-items: center;
  gap: 8px;
  animation: toast-in .2s ease;
}

.toast-success { background: var(--k-green); }
.toast-error { background: var(--k-red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── STAR RATING ── */
.star-rating {
  display: flex;
  gap: 2px;
}

.star-rating button {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--k-border);
  transition: color .1s;
  font-size: 16px;
}

.star-rating button.filled { color: var(--k-amber); }

/* ── FRAMEWORK GRID ── */
.framework-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.framework-card {
  background: var(--k-surface);
  border: 1px solid var(--k-border);
  border-radius: var(--k-radius);
  padding: 20px;
  box-shadow: var(--k-shadow);
}

.framework-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--k-text);
  margin-bottom: 2px;
}

.framework-card-body {
  font-size: 12px;
  color: var(--k-muted);
}

.framework-score-bar {
  margin-top: 12px;
}

/* ── UTILITY ── */
.text-muted { color: var(--k-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: 'SF Mono', Menlo, monospace; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.w-full { width: 100%; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .sidebar { display: none; }
  .page-content { padding: 16px; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header { flex-direction: column; }
}