/*
 * Minimal KC Phishing styles.
 *
 * PLACEHOLDER TOKENS — these --kcp-* custom properties stand in for the real KCDS
 * design-system tokens (--kcds-*). Reconcile against kc-safety-app's
 * frontend/k2/themes/kcds.css + the product theme once K2/KCDS is wired in.
 */
:root {
  /* KC UI-UX — KCDS "Comply" teal palette (teal ramp). Placeholder bridge to
     --kcds-* tokens; reconcile with the real KCDS/K2 theme when K2 is wired in. */
  --kcp-primary: #0EA5A5;        /* teal-500 */
  --kcp-primary-hover: #0C8989;  /* teal-600 */
  --kcp-primary-active: #0B7C7C; /* teal-700 */
  --kcp-primary-tint: #E0F7F7;   /* teal-50  */
  --kcp-primary-fill: #B5EBEB;   /* teal-100 */
  --kcp-primary-fg: #ffffff;
  --kcp-bg: #f6f7f9;
  --kcp-surface: #ffffff;
  --kcp-fg: #1a1d21;
  --kcp-muted: #6b7280;
  --kcp-border: #e3e6ea;
  --kcp-radius: 10px;
  --kcp-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 6px 24px rgba(0, 0, 0, 0.06);
  --kcp-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-mode="dark"] {
  --kcp-primary: #0EA5A5;
  --kcp-primary-hover: #2BC5C5;
  --kcp-primary-active: #0B8B8B;
  --kcp-primary-tint: rgba(14, 165, 165, 0.12);
  --kcp-primary-fill: rgba(14, 165, 165, 0.22);
  --kcp-bg: #0f1216;
  --kcp-surface: #171b21;
  --kcp-fg: #e8eaed;
  --kcp-muted: #9aa4b2;
  --kcp-border: #2a2f37;
  --kcp-shadow: 0 1px 3px rgba(0, 0, 0, 0.4), 0 6px 24px rgba(0, 0, 0, 0.3);
}

* {
  box-sizing: border-box;
}

/* The `hidden` attribute must always win. Without this, an author display rule
   (e.g. .boot-splash { display: flex }) overrides the UA `[hidden]` rule, so
   elements toggled via el.hidden = true never actually hide. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: var(--kcp-font);
  background: var(--kcp-bg);
  color: var(--kcp-fg);
  -webkit-font-smoothing: antialiased;
}

.boot-splash {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
}
/* KC brand icon as the pre-app loader (PHISH-71), gently pulsing. */
.boot-splash-logo {
  width: 68px;
  height: 68px;
  animation: kcp-splash-pulse 1.15s ease-in-out infinite;
}
@keyframes kcp-splash-pulse {
  0%, 100% { opacity: 0.5; transform: scale(0.92); }
  50% { opacity: 1; transform: scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .boot-splash-logo { animation: none; }
}

/* Centered auth card layout (mirrors KC Safety's <auth-shell>). */
.auth-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--kcp-surface);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
  box-shadow: var(--kcp-shadow);
  padding: 32px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
  font-weight: 700;
  font-size: 1.25rem;
}

.brand-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--kcp-primary);
}

.brand-logo {
  width: 28px;
  height: 28px;
  display: inline-block;
  vertical-align: middle;
  flex: none;
}

.subtitle {
  color: var(--kcp-muted);
  font-size: 0.9rem;
  margin: 0 0 24px;
}

label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin: 14px 0 6px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--kcp-border);
  border-radius: 8px;
  background: var(--kcp-bg);
  color: var(--kcp-fg);
}

input:focus {
  outline: 2px solid var(--kcp-primary);
  outline-offset: 1px;
}

button.btn {
  width: 100%;
  margin-top: 20px;
  padding: 11px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--kcp-primary-fg);
  background: var(--kcp-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

button.btn:hover {
  filter: brightness(0.95);
}

button.btn.secondary {
  color: var(--kcp-fg);
  background: transparent;
  border: 1px solid var(--kcp-border);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.link {
  display: inline-block;
  margin-top: 18px;
  color: var(--kcp-primary);
  text-decoration: none;
  font-size: 0.9rem;
}

.link:hover {
  text-decoration: underline;
}

.error {
  margin-top: 16px;
  padding: 10px 12px;
  border-radius: 8px;
  background: rgba(14, 165, 165,0.1);
  color: var(--kcp-primary);
  font-size: 0.88rem;
}

.hint {
  margin-top: 20px;
  padding: 12px;
  border: 1px dashed var(--kcp-border);
  border-radius: 8px;
  color: var(--kcp-muted);
  font-size: 0.8rem;
  line-height: 1.5;
}

/* Dashboard */
.dash-wrap {
  max-width: 900px;
  margin: 0 auto;
  padding: 24px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0;
  border-bottom: 1px solid var(--kcp-border);
  margin-bottom: 24px;
}

.panel {
  background: var(--kcp-surface);
  border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius);
  padding: 24px;
  box-shadow: var(--kcp-shadow);
}

.kv {
  display: grid;
  grid-template-columns: 160px 1fr;
  gap: 10px 16px;
  font-size: 0.92rem;
}

.kv dt {
  color: var(--kcp-muted);
  font-weight: 600;
}

.kv dd {
  margin: 0;
}

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(14, 165, 165,0.12);
  color: var(--kcp-primary);
  font-size: 0.8rem;
  font-weight: 600;
}

/* ============================================================
 * Marketing page (/:portalCode/marketing) — PHISH-8
 * Placeholder styling on --kcp-* tokens; reskin with KCDS later.
 * ============================================================ */
.mk { max-width: 1080px; margin: 0 auto; padding: 0 24px 64px; }

.mk-nav {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 0; position: sticky; top: 0; background: var(--kcp-bg);
  z-index: 5; border-bottom: 1px solid var(--kcp-border);
}
.mk-nav-links { display: flex; align-items: center; gap: 22px; }
.mk-navlink { color: var(--kcp-muted); text-decoration: none; font-size: 0.92rem; font-weight: 600; }
.mk-navlink:hover { color: var(--kcp-fg); }

/* Anchor buttons: existing .btn rules target <button>, so style anchors here. */
.mk .btn {
  display: inline-block; width: auto; margin: 0; padding: 11px 20px;
  font-size: 0.95rem; font-weight: 700; text-decoration: none; text-align: center;
  color: var(--kcp-primary-fg); background: var(--kcp-primary);
  border: 1px solid var(--kcp-primary); border-radius: 8px; cursor: pointer;
}
.mk .btn:hover { filter: brightness(0.95); }
.mk .btn.secondary { color: var(--kcp-fg); background: transparent; border-color: var(--kcp-border); }
.mk-navbtn { padding: 8px 16px !important; }
.mk-btn-lg { padding: 14px 26px !important; font-size: 1rem !important; }

.mk-hero { text-align: center; padding: 72px 0 56px; }
.mk-eyebrow {
  display: inline-block; text-transform: uppercase; letter-spacing: 0.08em;
  font-size: 0.75rem; font-weight: 700; color: var(--kcp-primary);
  background: rgba(14, 165, 165,0.10); padding: 6px 12px; border-radius: 999px; margin-bottom: 20px;
}
.mk-title { font-size: clamp(2rem, 5vw, 3.25rem); line-height: 1.08; margin: 0 auto 20px; max-width: 16ch; font-weight: 800; letter-spacing: -0.02em; }
.mk-lede { font-size: clamp(1.05rem, 2vw, 1.25rem); line-height: 1.6; color: var(--kcp-muted); max-width: 62ch; margin: 0 auto 32px; }
.mk-cta { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }
.mk-trust { margin-top: 26px; font-size: 0.85rem; color: var(--kcp-muted); }

.mk-h2 { font-size: clamp(1.5rem, 3vw, 2rem); text-align: center; margin: 0 0 36px; font-weight: 800; letter-spacing: -0.01em; }
.mk-accent { color: var(--kcp-primary); }

.mk-loopwrap { padding: 44px 0; border-top: 1px solid var(--kcp-border); }
.mk-loop { list-style: none; padding: 0; margin: 0; display: flex; align-items: stretch; justify-content: center; gap: 8px; flex-wrap: wrap; }
.mk-step { flex: 1 1 168px; max-width: 200px; background: var(--kcp-surface); border: 1px solid var(--kcp-border); border-radius: var(--kcp-radius); padding: 18px 16px; box-shadow: var(--kcp-shadow); display: flex; flex-direction: column; gap: 8px; }
.mk-step-num { width: 26px; height: 26px; border-radius: 50%; background: var(--kcp-primary); color: var(--kcp-primary-fg); font-size: 0.8rem; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.mk-step-name { font-weight: 700; font-size: 1.02rem; }
.mk-step-desc { font-size: 0.85rem; color: var(--kcp-muted); line-height: 1.45; }
.mk-step-arrow { display: flex; align-items: center; color: var(--kcp-muted); font-size: 1.3rem; }

.mk-section { padding: 56px 0; border-top: 1px solid var(--kcp-border); }
.mk-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }
.mk-card { background: var(--kcp-surface); border: 1px solid var(--kcp-border); border-radius: var(--kcp-radius); padding: 26px; box-shadow: var(--kcp-shadow); }
.mk-card-title { margin: 0 0 10px; font-size: 1.15rem; font-weight: 700; }
.mk-card-body { margin: 0; color: var(--kcp-muted); line-height: 1.6; font-size: 0.95rem; }

.mk-why-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px 40px; }
.mk-why-item { border-left: 3px solid var(--kcp-primary); padding-left: 16px; }
.mk-why-title { margin: 0 0 6px; font-size: 1.05rem; font-weight: 700; }
.mk-why-body { margin: 0; color: var(--kcp-muted); line-height: 1.55; font-size: 0.92rem; }
.mk-why-note { text-align: center; max-width: 62ch; margin: 40px auto 0; font-size: 1.05rem; font-weight: 600; line-height: 1.5; }

.mk-footer { border-top: 1px solid var(--kcp-border); padding: 32px 0 0; margin-top: 24px; text-align: center; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.mk-foot-note { font-size: 0.9rem; }
.mk-muted { color: var(--kcp-muted); font-size: 0.82rem; }

@media (max-width: 720px) {
  .mk-nav-links { gap: 12px; }
  .mk-navlink { display: none; }
  .mk-grid, .mk-why-grid { grid-template-columns: 1fr; }
  .mk-step-arrow { display: none; }
}

/* ============================================================
 * App shell + framework UI (PHISH-47)
 * Authenticated chrome (sidebar + topbar + content) and UI
 * primitives (toast, modal, spinner, empty-state). Everything
 * reads the --kcp-* bridge (-> --kcds-*), so it tracks the theme.
 * ============================================================ */
/* minmax(0,1fr) (not bare 1fr) + min-width:0 on children so wide content
   (tables, code) scrolls inside its own container and the page never scrolls
   horizontally — KCDS "the 1fr gotcha" (PHISH-74). */
.kcp-shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.kcp-side {
  background: var(--kcp-surface);
  border-right: 1px solid var(--kcp-border);
  padding: 20px 14px;
  display: flex; flex-direction: column; gap: 20px;
}
.kcp-side-brand { margin: 4px 6px 8px; }
/* Post-login brand: KnowledgeCity logo, theme-aware (PHISH-65). Both PNGs render;
   CSS shows the one matching the active [data-mode] on <html>. Per-asset heights
   (light 36 / dark 22) so the two wordmarks render at matching visual width —
   mirrors kc-safety-app comp/portal-shell.js (the assets carry different padding). */
.kcp-brand-logo { display: block; width: auto; max-width: 100%; }
.kcp-brand-logo--light { height: 43px; }
.kcp-brand-logo--dark { height: 26px; display: none; }
[data-mode="dark"] .kcp-brand-logo--light { display: none; }
[data-mode="dark"] .kcp-brand-logo--dark { display: block; }
.kcp-nav { display: flex; flex-direction: column; gap: 2px; }
.kcp-nav-link {
  display: block; padding: 9px 12px; border-radius: 8px;
  color: var(--kcp-fg); text-decoration: none; font-size: 0.92rem; font-weight: 600;
}
.kcp-nav-link:hover { background: var(--kcp-primary-tint); }
.kcp-nav-link.is-active { background: var(--kcp-primary); color: var(--kcp-primary-fg); }

.kcp-main { display: flex; flex-direction: column; min-width: 0; }
.kcp-topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 24px; border-bottom: 1px solid var(--kcp-border); background: var(--kcp-bg);
}
.kcp-topbar-title { font-size: 1.05rem; font-weight: 700; }
.kcp-user { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; }
.kcp-user-name { font-weight: 600; }
.kcp-content { padding: 24px; max-width: 1800px; width: 100%; margin-inline: auto; }

/* Toasts */
.kcp-toast-host { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 1000; }
.kcp-toast {
  min-width: 220px; max-width: 360px; padding: 12px 14px; border-radius: 10px;
  background: var(--kcp-surface); color: var(--kcp-fg);
  border: 1px solid var(--kcp-border); border-left: 4px solid var(--kcp-primary);
  box-shadow: var(--kcp-shadow); font-size: 0.9rem; cursor: pointer;
  opacity: 0; transform: translateY(8px); transition: opacity 0.2s ease, transform 0.2s ease;
}
.kcp-toast.is-in { opacity: 1; transform: none; }
.kcp-toast-success { border-left-color: #16a34a; }
.kcp-toast-error { border-left-color: #dc2626; }
.kcp-toast-info { border-left-color: var(--kcp-primary); }

/* Modal */
.kcp-modal-overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 24px; z-index: 1100;
}
.kcp-modal {
  width: 100%; max-width: 440px; background: var(--kcp-surface);
  border: 1px solid var(--kcp-border); border-radius: var(--kcp-radius);
  box-shadow: var(--kcp-shadow); padding: 24px;
}
.kcp-modal-title { margin: 0 0 12px; font-size: 1.15rem; font-weight: 700; }
.kcp-modal-body { color: var(--kcp-fg); font-size: 0.95rem; }
.kcp-modal-msg { margin: 0; color: var(--kcp-muted); line-height: 1.5; }
.kcp-modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }

/* Spinner + empty state */
.kcp-spinner { display: inline-flex; align-items: center; gap: 10px; color: var(--kcp-muted); font-size: 0.9rem; }
.kcp-spinner-dot {
  width: 14px; height: 14px; border-radius: 50%;
  border: 2px solid var(--kcp-border); border-top-color: var(--kcp-primary);
  animation: kcp-spin 0.7s linear infinite;
}
@keyframes kcp-spin { to { transform: rotate(360deg); } }
.kcp-empty { text-align: center; padding: 40px 20px; color: var(--kcp-muted); }
.kcp-empty-icon { font-size: 2rem; margin-bottom: 8px; }
.kcp-empty-title { font-weight: 700; color: var(--kcp-fg); font-size: 1.05rem; }
.kcp-empty-msg { margin-top: 6px; font-size: 0.9rem; max-width: 42ch; margin-left: auto; margin-right: auto; line-height: 1.5; }

/* Mobile shell behaviour lives with the topbar-chrome block below (PHISH-74):
   the sidebar is hidden < 900px and its nav is revealed in a hamburger drawer
   (Reveal, not Reflow) rather than reflowed into a horizontal strip. */

/* ============================================================
 * i18n (PHISH-48) — language selector + RTL (Arabic) adjustments.
 * dir="rtl" is set on <html> by serv/i18n.js; rules below mirror
 * the LTR chrome for RTL without a full physical-property rewrite.
 * ============================================================ */
.kcp-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kcp-lang-wrap { display: inline-flex; align-items: center; }
.kcp-lang {
  font: inherit; font-size: 0.85rem; padding: 5px 8px; border-radius: 8px;
  border: 1px solid var(--kcp-border); background: var(--kcp-surface); color: var(--kcp-fg); cursor: pointer;
}

[dir="rtl"] .kcp-side { border-right: none; border-left: 1px solid var(--kcp-border); }
[dir="rtl"] .kcp-toast-host { right: auto; left: 16px; }
[dir="rtl"] .kcp-nav, [dir="rtl"] .kcp-topbar-title { text-align: right; }
[dir="rtl"] .kv { direction: rtl; }
@media (max-width: 720px) {
  [dir="rtl"] .kcp-nav { margin-left: 0; margin-right: auto; }
}

/* ============================================================
 * Admin & Analyst areas (PHISH-64) — shared area components.
 * pageHeader, stat cards, data table, toolbar, section card,
 * bar chart, detail drawer. All on the --kcp-* token bridge.
 * ============================================================ */

/* Content well is centered + capped at 1800px (PHISH-69) — set on base .kcp-content
 * above; area screens (tables + stat grids) use the same wide well. */

/* Grouped sidebar nav (section labels). */
.kcp-nav-group { margin-top: 14px; }
.kcp-nav-group:first-child { margin-top: 0; }
.kcp-nav-group-label {
  padding: 6px 12px 4px; font-size: 0.68rem; font-weight: 700;
  letter-spacing: 0.07em; text-transform: uppercase; color: var(--kcp-muted); user-select: none;
}

/* Unified action button (styles both <a> and <button> the same). */
.kcp-btn {
  display: inline-flex; align-items: center; gap: 6px; width: auto; margin: 0;
  padding: 9px 16px; font-size: 0.9rem; font-weight: 600; font-family: inherit;
  color: var(--kcp-primary-fg); background: var(--kcp-primary);
  border: 1px solid var(--kcp-primary); border-radius: 8px; cursor: pointer;
  text-decoration: none; line-height: 1.2; white-space: nowrap;
}
.kcp-btn:hover { filter: brightness(0.95); }
.kcp-btn.secondary { color: var(--kcp-fg); background: var(--kcp-surface); border-color: var(--kcp-border); }
.kcp-btn.secondary:hover { background: var(--kcp-primary-tint); filter: none; }
.kcp-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.kcp-btn.danger { background: #dc2626; border-color: #dc2626; color: #fff; }

/* Page header */
.kcp-pagehead {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 16px;
  margin: 0 0 22px; flex-wrap: wrap;
}
.kcp-pagehead-title { margin: 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.01em; }
.kcp-pagehead-sub { margin: 6px 0 0; color: var(--kcp-muted); font-size: 0.92rem; max-width: 68ch; line-height: 1.5; }
.kcp-pagehead-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Stat cards */
.kcp-stat-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.kcp-stat {
  background: var(--kcp-surface); border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius); padding: 16px 18px; box-shadow: var(--kcp-shadow);
  display: flex; flex-direction: column; gap: 8px; min-width: 0;
}
.kcp-stat-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.kcp-stat-label { font-size: 0.72rem; color: var(--kcp-muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.kcp-stat-icon { font-size: 1.15rem; opacity: 0.85; }
.kcp-stat-value { font-size: 2rem; font-weight: 800; line-height: 1.1; letter-spacing: -0.02em; }
.kcp-stat-delta { font-size: 0.78rem; font-weight: 700; display: inline-flex; align-items: center; gap: 5px; }
.kcp-stat-hint { font-size: 0.76rem; color: var(--kcp-muted); font-weight: 500; }
.kcp-trend-up { color: #16a34a; }
.kcp-trend-down { color: #dc2626; }
.kcp-trend-flat { color: var(--kcp-muted); }

/* Status pill */
.kcp-pill {
  display: inline-block; padding: 2px 10px; border-radius: 999px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.01em; white-space: nowrap;
}
.kcp-pill-neutral { background: rgba(107,114,128,0.14); color: var(--kcp-muted); }
.kcp-pill-info { background: rgba(14,165,165,0.14); color: var(--kcp-primary); }
.kcp-pill-primary { background: rgba(14,165,165,0.14); color: var(--kcp-primary); }
.kcp-pill-success { background: rgba(22,163,74,0.14); color: #16a34a; }
.kcp-pill-warn { background: rgba(217,119,6,0.16); color: #b45309; }
.kcp-pill-danger { background: rgba(220,38,38,0.14); color: #dc2626; }

/* Data table */
.kcp-table-wrap {
  background: var(--kcp-surface); border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius); box-shadow: var(--kcp-shadow); overflow-x: auto;
}
.kcp-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.kcp-th {
  text-align: left; padding: 12px 16px; font-size: 0.72rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--kcp-muted);
  border-bottom: 1px solid var(--kcp-border); white-space: nowrap; background: var(--kcp-bg);
}
.kcp-td { padding: 12px 16px; border-bottom: 1px solid var(--kcp-border); vertical-align: middle; }
.kcp-tr:last-child .kcp-td { border-bottom: none; }
.kcp-tr:hover { background: var(--kcp-primary-tint); }
.kcp-tr[data-row-id] { cursor: pointer; }
.kcp-al-right { text-align: right; }
.kcp-al-center { text-align: center; }
.kcp-table-empty { padding: 40px 20px; text-align: center; color: var(--kcp-muted); font-size: 0.9rem; }
.kcp-cell-strong { font-weight: 600; color: var(--kcp-fg); }
.kcp-cell-mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.82rem; color: var(--kcp-muted); }

/* Sortable headers (PHISH-75) — sortable-by-default; button gives keyboard focus. */
.kcp-th-sortable { padding: 0; }
.kcp-sort-btn {
  display: inline-flex; align-items: center; width: 100%;
  padding: 12px 16px; background: transparent; border: none; cursor: pointer;
  font: inherit; color: inherit; letter-spacing: inherit; text-transform: inherit; text-align: inherit;
}
.kcp-sort-btn:hover { color: var(--kcp-fg); }
.kcp-sort-btn:focus-visible { outline: 2px solid var(--kcp-primary); outline-offset: -2px; }
.kcp-al-right .kcp-sort-btn { justify-content: flex-end; }
.kcp-al-center .kcp-sort-btn { justify-content: center; }
.kcp-sort-caret::before { content: "↕"; opacity: 0.4; margin-inline-start: 6px; font-size: 0.9em; }
.kcp-th-sortable[aria-sort="ascending"] .kcp-sort-caret::before { content: "↑"; opacity: 1; }
.kcp-th-sortable[aria-sort="descending"] .kcp-sort-caret::before { content: "↓"; opacity: 1; }
.kcp-th-sortable[aria-sort="ascending"], .kcp-th-sortable[aria-sort="descending"] { color: var(--kcp-fg); }

/* Mobile-table rules (PHISH-75): drop secondary columns + tighten density so admin
   tables stay legible on narrow viewports instead of forcing a wide h-scroll. */
@media (max-width: 720px) {
  .kcp-col-secondary { display: none; }
  .kcp-table { font-size: 0.85rem; }
  .kcp-th, .kcp-td { padding: 10px 12px; }
  .kcp-sort-btn { padding: 10px 12px; }
  .kcp-td .kcp-pill { margin: 1px 0; } /* chips wrap/stack rather than overflow */
}

/* Row action buttons (icon-ish text buttons inside a table cell) */
.kcp-rowact { display: inline-flex; gap: 6px; }
.kcp-rowbtn {
  border: 1px solid var(--kcp-border); background: var(--kcp-surface); color: var(--kcp-fg);
  border-radius: 7px; padding: 4px 10px; font-size: 0.8rem; font-weight: 600; cursor: pointer; font-family: inherit;
}
.kcp-rowbtn:hover { background: var(--kcp-primary-tint); }
.kcp-rowbtn.danger:hover { background: rgba(220,38,38,0.12); color: #dc2626; border-color: rgba(220,38,38,0.3); }

/* Toolbar (search + selects) */
.kcp-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.kcp-toolbar-l, .kcp-toolbar-r { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kcp-search { position: relative; display: inline-flex; align-items: center; }
.kcp-search-icon { position: absolute; left: 10px; color: var(--kcp-muted); font-size: 1rem; pointer-events: none; }
.kcp-search-input {
  width: 260px; max-width: 100%; padding: 9px 12px 9px 30px; font-size: 0.9rem;
  border: 1px solid var(--kcp-border); border-radius: 8px; background: var(--kcp-surface); color: var(--kcp-fg);
}
.kcp-search-input:focus { outline: 2px solid var(--kcp-primary); outline-offset: 1px; }
.kcp-filter { display: inline-flex; align-items: center; margin: 0; }
.kcp-select {
  font: inherit; font-size: 0.88rem; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--kcp-border); background: var(--kcp-surface); color: var(--kcp-fg); cursor: pointer;
}

/* Section card */
.kcp-card {
  background: var(--kcp-surface); border: 1px solid var(--kcp-border);
  border-radius: var(--kcp-radius); box-shadow: var(--kcp-shadow); padding: 20px 22px; margin-bottom: 20px;
}
.kcp-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.kcp-card-title { margin: 0; font-size: 1.05rem; font-weight: 700; }
.kcp-card-sub { margin: 4px 0 0; color: var(--kcp-muted); font-size: 0.85rem; }
.kcp-card-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kcp-card-body { min-width: 0; }
.kcp-grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px; }
.kcp-grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
@media (max-width: 860px) { .kcp-grid-2, .kcp-grid-3 { grid-template-columns: 1fr; } }

/* Bar chart */
.kcp-bars { display: flex; flex-direction: column; gap: 12px; }
.kcp-bar-row { display: grid; grid-template-columns: 130px 1fr 56px; align-items: center; gap: 12px; font-size: 0.85rem; }
.kcp-bar-label { color: var(--kcp-muted); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcp-bar-track { background: var(--kcp-bg); border-radius: 999px; height: 12px; overflow: hidden; border: 1px solid var(--kcp-border); }
.kcp-bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--kcp-primary); transition: width 0.4s ease; }
.kcp-bar-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.kcp-tone-primary { background: var(--kcp-primary); }
.kcp-tone-success { background: #16a34a; }
.kcp-tone-warn { background: #d97706; }
.kcp-tone-danger { background: #dc2626; }
.kcp-tone-muted { background: var(--kcp-muted); }

/* Detail drawer */
.kcp-drawer-overlay {
  position: fixed; inset: 0; background: rgba(2,6,23,0.5); z-index: 1100;
  display: flex; justify-content: flex-end; opacity: 0; transition: opacity 0.2s ease;
}
.kcp-drawer-overlay.is-in { opacity: 1; }
.kcp-drawer {
  width: 100%; height: 100%; background: var(--kcp-surface); border-left: 1px solid var(--kcp-border);
  box-shadow: var(--kcp-shadow); display: flex; flex-direction: column;
  transform: translateX(24px); transition: transform 0.2s ease; overflow: hidden;
}
.kcp-drawer.is-in { transform: none; }
[dir="rtl"] .kcp-drawer-overlay { justify-content: flex-start; }
[dir="rtl"] .kcp-drawer { border-left: none; border-right: 1px solid var(--kcp-border); transform: translateX(-24px); }
[dir="rtl"] .kcp-drawer.is-in { transform: none; }
.kcp-drawer-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 20px; border-bottom: 1px solid var(--kcp-border);
}
.kcp-drawer-title { margin: 0; font-size: 1.1rem; font-weight: 700; }
.kcp-drawer-x { border: none; background: transparent; color: var(--kcp-muted); font-size: 1.1rem; cursor: pointer; padding: 4px 8px; border-radius: 6px; }
.kcp-drawer-x:hover { background: var(--kcp-primary-tint); color: var(--kcp-fg); }
.kcp-drawer-body { padding: 20px; overflow-y: auto; flex: 1; }

/* Prototype notice (screens whose backend epic hasn't landed) */
.kcp-proto {
  border: 1px dashed var(--kcp-border); border-radius: var(--kcp-radius);
  background: var(--kcp-primary-tint); padding: 14px 16px; margin-bottom: 20px;
  color: var(--kcp-fg); font-size: 0.85rem; line-height: 1.5;
}
.kcp-proto strong { color: var(--kcp-primary); }

/* Form fields inside modals/drawers */
.kcp-field { margin-bottom: 14px; }
.kcp-field label { margin: 0 0 6px; }
.kcp-field input[type="text"], .kcp-field input[type="email"], .kcp-field textarea, .kcp-field select {
  width: 100%; padding: 9px 12px; font-size: 0.92rem; font-family: inherit;
  border: 1px solid var(--kcp-border); border-radius: 8px; background: var(--kcp-bg); color: var(--kcp-fg);
}
.kcp-field textarea { min-height: 120px; resize: vertical; }
.kcp-field-hint { font-size: 0.76rem; color: var(--kcp-muted); margin-top: 4px; }

/* Timeline (incident/investigation activity) */
.kcp-timeline { list-style: none; margin: 0; padding: 0; }
.kcp-tl-item { position: relative; padding: 0 0 18px 22px; border-left: 2px solid var(--kcp-border); }
.kcp-tl-item:last-child { border-left-color: transparent; padding-bottom: 0; }
.kcp-tl-dot { position: absolute; left: -7px; top: 2px; width: 12px; height: 12px; border-radius: 50%; background: var(--kcp-primary); border: 2px solid var(--kcp-surface); }
.kcp-tl-when { font-size: 0.76rem; color: var(--kcp-muted); }
.kcp-tl-what { font-size: 0.9rem; margin-top: 2px; }
[dir="rtl"] .kcp-tl-item { padding: 0 22px 18px 0; border-left: none; border-right: 2px solid var(--kcp-border); }
[dir="rtl"] .kcp-tl-item:last-child { border-right-color: transparent; }
[dir="rtl"] .kcp-tl-dot { left: auto; right: -7px; }

/* Prototype planned-capabilities list */
.kcp-plan-list { margin: 0; padding-left: 20px; color: var(--kcp-fg); line-height: 1.7; font-size: 0.92rem; }
.kcp-plan-list li { margin-bottom: 6px; }
[dir="rtl"] .kcp-plan-list { padding-left: 0; padding-right: 20px; }

/* Email preview (template drawer) */
.kcp-mail { border: 1px solid var(--kcp-border); border-radius: 8px; overflow: hidden; }
.kcp-mail-row { display: flex; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--kcp-border); font-size: 0.88rem; }
.kcp-mail-k { color: var(--kcp-muted); font-weight: 700; min-width: 64px; }
.kcp-mail-body { padding: 16px; font-size: 0.92rem; line-height: 1.6; background: var(--kcp-surface); }
.kcp-mail-body a { color: var(--kcp-primary); }

/* Drawer section headings */
.kcp-drawer-h3 { margin: 22px 0 10px; font-size: 0.95rem; font-weight: 700; }

/* Incident pills row + response action grid */
.kcp-inc-pills { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.kcp-action-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 12px 0; }
.kcp-action-grid .kcp-btn { justify-content: center; width: 100%; }
@media (max-width: 520px) { .kcp-action-grid { grid-template-columns: 1fr; } }

/* Dashboard quick links */
.kcp-quicklinks { display: flex; flex-direction: column; gap: 8px; }
.kcp-quicklink {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 14px; border: 1px solid var(--kcp-border); border-radius: 8px;
  color: var(--kcp-fg); text-decoration: none; font-weight: 600; font-size: 0.92rem;
}
.kcp-quicklink:hover { background: var(--kcp-primary-tint); border-color: var(--kcp-primary); }

/* Reports library rows */
.kcp-report-list { display: flex; flex-direction: column; }
.kcp-report-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 0; border-bottom: 1px solid var(--kcp-border);
}
.kcp-report-row:last-child { border-bottom: none; }

/* ============================================================
 * Topbar chrome (PHISH-76) + app footer (PHISH-77) + mobile nav
 * drawer (PHISH-74). All on the --kcp-* token bridge → theme + RTL aware.
 * ============================================================ */
.kcp-topbar-l { display: flex; align-items: center; gap: 12px; min-width: 0; }
.kcp-topbar-r { display: flex; align-items: center; gap: 8px; }
.kcp-topbar-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Icon buttons (hamburger, theme, bell) */
.kcp-iconbtn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 38px; height: 38px; padding: 0; font-size: 1rem; line-height: 1;
  border: 1px solid transparent; border-radius: 9px; background: transparent;
  color: var(--kcp-fg); cursor: pointer; font-family: inherit;
}
.kcp-iconbtn:hover { background: var(--kcp-primary-tint); }
.kcp-iconbtn:focus-visible { outline: 2px solid var(--kcp-primary); outline-offset: 1px; }
.kcp-hamburger { display: none; } /* revealed < breakpoint (mobile only) */

/* Global search affordance (topbar) */
.kcp-gsearch { position: relative; display: inline-flex; align-items: center; }
.kcp-gsearch-icon { position: absolute; inset-inline-start: 10px; color: var(--kcp-muted); font-size: 1rem; pointer-events: none; }
.kcp-gsearch-input {
  width: 210px; max-width: 100%; padding: 8px 12px 8px 30px; font-size: 0.9rem;
  border: 1px solid var(--kcp-border); border-radius: 999px;
  background: var(--kcp-surface); color: var(--kcp-fg);
}
[dir="rtl"] .kcp-gsearch-input { padding: 8px 30px 8px 12px; }
.kcp-gsearch-input:focus { outline: 2px solid var(--kcp-primary); outline-offset: 1px; }

/* Popover shell (bell + user menu) */
.kcp-pop-wrap { position: relative; }
.kcp-pop {
  position: absolute; top: calc(100% + 8px); inset-inline-end: 0; z-index: 1200;
  min-width: 240px; background: var(--kcp-surface); border: 1px solid var(--kcp-border);
  border-radius: 12px; box-shadow: var(--kcp-shadow); padding: 8px;
}
.kcp-pop-head { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--kcp-muted); padding: 6px 10px; }
.kcp-pop-empty { padding: 18px 10px; color: var(--kcp-muted); font-size: 0.88rem; text-align: center; line-height: 1.5; }
.kcp-pop-sep { height: 1px; background: var(--kcp-border); margin: 6px 4px; }
.kcp-pop-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 9px 10px; border-radius: 8px; font-size: 0.9rem; color: var(--kcp-fg);
  text-decoration: none; background: transparent; border: none; cursor: pointer;
  font-family: inherit; text-align: start;
}
.kcp-pop-link { justify-content: space-between; }
.kcp-pop-link:hover { background: var(--kcp-primary-tint); }
.kcp-pop-danger { color: #dc2626; }
.kcp-pop-danger:hover { background: rgba(220, 38, 38, 0.1); }
.kcp-pop-lang { justify-content: space-between; }
.kcp-pop-lang .kcp-lang { min-width: 120px; }

/* User avatar button + menu header */
.kcp-avatar-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding-block: 4px; padding-inline: 4px 10px;
  border: 1px solid transparent; border-radius: 999px; background: transparent;
  color: var(--kcp-fg); cursor: pointer; font-family: inherit; font-size: 0.9rem; max-width: 220px;
}
.kcp-avatar-btn:hover { background: var(--kcp-primary-tint); }
.kcp-avatar-btn:focus-visible { outline: 2px solid var(--kcp-primary); outline-offset: 1px; }
.kcp-avatar {
  display: inline-flex; align-items: center; justify-content: center; flex: none;
  width: 30px; height: 30px; border-radius: 50%; background: var(--kcp-primary);
  color: var(--kcp-primary-fg); font-size: 0.76rem; font-weight: 700;
}
.kcp-avatar-lg { width: 40px; height: 40px; font-size: 0.95rem; }
.kcp-avatar-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcp-caret { color: var(--kcp-muted); font-size: 0.7rem; }
.kcp-pop-user { min-width: 264px; }
.kcp-pop-user-head { display: flex; align-items: center; gap: 12px; padding: 10px; }
.kcp-pop-user-id { min-width: 0; }
.kcp-pop-user-name { font-weight: 700; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; }
.kcp-pop-user-email { color: var(--kcp-muted); font-size: 0.82rem; margin-bottom: 6px; overflow: hidden; text-overflow: ellipsis; }

/* App footer (PHISH-77) — low-emphasis; pinned to the bottom of the main column */
.kcp-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 16px 24px; margin-top: auto; border-top: 1px solid var(--kcp-border);
  color: var(--kcp-muted); font-size: 0.8rem; background: var(--kcp-bg);
}
.kcp-footer-r { display: flex; gap: 14px; }
.kcp-footer-r a { color: var(--kcp-muted); text-decoration: none; }
.kcp-footer-r a:hover { color: var(--kcp-primary); text-decoration: underline; }

/* Mobile nav drawer (PHISH-74) — Reveal, not Reflow. Hidden via [hidden] until opened. */
.kcp-navdrawer-overlay {
  position: fixed; inset: 0; background: rgba(2, 6, 23, 0.5); z-index: 1300;
  display: flex; opacity: 0; transition: opacity 0.2s ease;
}
.kcp-navdrawer-overlay.is-in { opacity: 1; }
.kcp-navdrawer {
  width: 82%; max-width: 300px; height: 100%; background: var(--kcp-surface);
  border-inline-end: 1px solid var(--kcp-border); box-shadow: var(--kcp-shadow);
  display: flex; flex-direction: column; padding: 16px 14px; gap: 16px;
  transform: translateX(-100%); transition: transform 0.2s ease; overflow-y: auto;
}
[dir="rtl"] .kcp-navdrawer { transform: translateX(100%); }
.kcp-navdrawer-overlay.is-in .kcp-navdrawer { transform: none; }
.kcp-navdrawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kcp-navdrawer-brand { flex-direction: column; align-items: flex-start; gap: 4px; margin: 0; font-size: 1rem; }
.kcp-navdrawer-sub { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--kcp-muted); }

/* Responsive: collapse the sidebar into the drawer; tighten topbar; >=16px inputs. */
@media (max-width: 900px) {
  .kcp-shell { grid-template-columns: minmax(0, 1fr); }
  .kcp-side { display: none; }
  .kcp-hamburger { display: inline-flex; }
  .kcp-gsearch { display: none; }
  .kcp-avatar-name { display: none; }
  .kcp-content { padding: 16px; }
  /* iOS zooms any focused input < 16px, breaking layout — bump interactive fonts. */
  input, select, textarea,
  .kcp-search-input, .kcp-gsearch-input, .kcp-lang, .kcp-select,
  .kcp-field input, .kcp-field textarea, .kcp-field select { font-size: 16px; }
}
