@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  /* Self Defence Cyber Security Navy & Cyan Palette (from TPEP Portal) */
  --bg-app: #07090e;
  --bg-surface: #0d121d;
  --bg-surface-elevated: #151d2f;
  --bg-surface-hover: #1f2b45;
  --bg-card: rgba(13, 18, 29, 0.88);
  --bg-glass: rgba(13, 18, 29, 0.75);

  --border-subtle: rgba(255, 255, 255, 0.07);
  --border-default: rgba(255, 255, 255, 0.12);
  --border-focus: #00f0ff;
  --border-glow: rgba(0, 240, 255, 0.35);

  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #07090e;

  --primary: #0072ff;
  --primary-hover: #0056cc;
  --primary-glow: rgba(0, 114, 255, 0.35);
  --primary-subtle: rgba(0, 240, 255, 0.1);

  --accent-cyan: #00f0ff;
  --accent-cyan-glow: rgba(0, 240, 255, 0.35);
  --accent-emerald: #10b981;
  --accent-amber: #f59e0b;
  --accent-rose: #f43f5e;
  --accent-purple: #8b5cf6;

  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.3);

  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.12);
  --warning-border: rgba(245, 158, 11, 0.3);

  --danger: #f43f5e;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.3);

  --critical: #e11d48;
  --critical-bg: rgba(225, 29, 72, 0.2);
  --critical-border: rgba(225, 29, 72, 0.5);

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-heading: 'Outfit', 'Plus Jakarta Sans', sans-serif;
}

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

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background-color: var(--bg-app);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Background Cyber Grid (Self Defence Theme from TPEP) */
body::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* SecureLogic Watermark Background (Self Defence Theme from TPEP) */
.page-watermark {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(80vw, 750px);
  height: min(80vw, 750px);
  background-image: url("/images/securelogic-brand-logo.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  opacity: 0.07;
  pointer-events: none;
  z-index: 0;
  filter: drop-shadow(0 0 50px rgba(0, 240, 255, 0.3));
  mix-blend-mode: screen;
}

/* Ambient Radial Glows (Self Defence Theme from TPEP) */
.ambient-glow-1 {
  position: fixed;
  top: -120px;
  left: 20%;
  width: 650px;
  height: 650px;
  background: radial-gradient(circle, rgba(0, 240, 255, 0.09) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(65px);
}

.ambient-glow-2 {
  position: fixed;
  bottom: -100px;
  right: 15%;
  width: 750px;
  height: 750px;
  background: radial-gradient(circle, rgba(139, 92, 246, 0.08) 0%, transparent 70%);
  pointer-events: none;
  z-index: 0;
  filter: blur(75px);
}

h1, h2, h3 {
  font-family: var(--font-heading);
  letter-spacing: -0.02em;
  color: #ffffff;
}

h1 { font-size: 26px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }

a {
  color: var(--accent-cyan);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

code, .mono {
  font-family: var(--font-mono);
  font-size: 12px;
}

.hidden { display: none !important; }

/* Layout Shell */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

aside {
  background: linear-gradient(180deg, rgba(13, 18, 29, 0.95), rgba(7, 9, 14, 0.98));
  border-right: 1px solid var(--border-default);
  backdrop-filter: blur(20px);
  padding: 24px 14px;
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 10px 20px;
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: 8px;
}

.brand .logo-box {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(0, 240, 255, 0.28);
  box-shadow: 0 0 16px rgba(0, 240, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 5px;
  flex-shrink: 0;
}

.brand .logo-box img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  justify-content: center;
}

.brand b {
  font-family: var(--font-heading);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.15;
  color: #ffffff;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand small {
  color: var(--accent-cyan);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  margin-top: 2px;
  line-height: 1.2;
}

nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}

nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-weight: 500;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  border: 1px solid transparent;
}

nav a:hover {
  background: var(--bg-surface-elevated);
  color: #ffffff;
  border-color: var(--border-subtle);
  transform: translateX(2px);
}

nav a.on {
  background: linear-gradient(90deg, rgba(0, 240, 255, 0.15), rgba(0, 114, 255, 0.12));
  color: #ffffff;
  border: 1px solid rgba(0, 240, 255, 0.35);
  box-shadow: inset 3px 0 0 var(--accent-cyan), 0 0 16px rgba(0, 240, 255, 0.12);
  font-weight: 600;
}

nav .badge {
  margin-left: auto;
}

.user-panel {
  margin-top: auto;
  padding: 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.user-panel .user-name {
  font-weight: 700;
  color: #ffffff;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-panel small {
  color: var(--accent-cyan);
  font-size: 11px;
  display: block;
  margin-top: 2px;
  font-weight: 500;
}

.user-panel .user-actions {
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

main {
  padding: 32px 40px 80px;
  max-width: 1600px;
  width: 100%;
}

.head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}

.head p {
  margin: 4px 0 0;
  color: var(--text-secondary);
  font-size: 13.5px;
}

/* Grid & Cards */
.grid { display: grid; gap: 16px; }
.k4 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.k2 { grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); }

.card {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.45);
  position: relative;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: rgba(0, 240, 255, 0.25);
}

.kpi {
  position: relative;
  overflow: hidden;
  transition: transform 0.25s, border-color 0.25s;
}

.kpi:hover {
  transform: translateY(-3px);
  border-color: var(--border-glow);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 24px rgba(0, 240, 255, 0.15);
}

.kpi .v {
  font-family: var(--font-heading);
  font-size: 34px;
  font-weight: 800;
  margin-top: 4px;
  color: #ffffff;
}

.kpi .l {
  color: var(--text-secondary);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}

.kpi::after {
  content: "";
  position: absolute;
  right: -30px;
  top: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--g, rgba(0, 240, 255, 0.25)), transparent 70%);
}

.kpi.bad { --g: rgba(244, 63, 94, 0.35); }
.kpi.warn { --g: rgba(245, 158, 11, 0.3); }
.kpi.good { --g: rgba(16, 185, 129, 0.3); }

/* Tables */
table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-default);
  font-weight: 600;
}

td {
  padding: 13px 14px;
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

tr.click {
  cursor: pointer;
  transition: background-color 0.15s;
}

tr.click:hover {
  background: rgba(0, 240, 255, 0.05);
}

.table-scroll-wrap {
  position: relative;
  width: 100%;
}

.tw-top-bar {
  overflow-x: auto;
  overflow-y: hidden;
  height: 12px;
  margin-bottom: 6px;
  border-radius: 6px;
  background: rgba(10, 14, 23, 0.65);
  border: 1px solid var(--border-subtle);
  display: none;
}

.tw-top-spacer {
  height: 1px;
}

.tw {
  overflow: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* Custom scrollbars for wide data tables & top scrollbars */
.tw,
.tw-top-bar {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 240, 255, 0.4) rgba(10, 14, 23, 0.7);
}

.tw::-webkit-scrollbar,
.tw-top-bar::-webkit-scrollbar {
  height: 9px;
  width: 9px;
}

.tw::-webkit-scrollbar-track,
.tw-top-bar::-webkit-scrollbar-track {
  background: rgba(10, 14, 23, 0.7);
  border-radius: 4px;
}

.tw::-webkit-scrollbar-thumb,
.tw-top-bar::-webkit-scrollbar-thumb {
  background: rgba(0, 240, 255, 0.32);
  border-radius: 4px;
  border: 1px solid rgba(0, 240, 255, 0.18);
  transition: background 0.15s, box-shadow 0.15s;
}

.tw::-webkit-scrollbar-thumb:hover,
.tw-top-bar::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 240, 255, 0.65);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  border: 1px solid transparent;
  white-space: nowrap;
}

.b-Critical { background: rgba(225, 29, 72, 0.18); color: #fda4af; border-color: rgba(225, 29, 72, 0.45); }
.b-High { background: rgba(245, 158, 11, 0.18); color: #fcd34d; border-color: rgba(245, 158, 11, 0.45); }
.b-Medium { background: rgba(234, 179, 8, 0.14); color: #fef08a; border-color: rgba(234, 179, 8, 0.35); }
.b-Low { background: rgba(14, 165, 233, 0.15); color: #7dd3fc; border-color: rgba(14, 165, 233, 0.4); }

.b-ok { background: var(--success-bg); color: #6ee7b7; border-color: var(--success-border); }
.b-bad { background: var(--danger-bg); color: #fda4af; border-color: var(--danger-border); }
.b-neutral { background: rgba(255, 255, 255, 0.08); color: #cbd5e1; border-color: var(--border-default); }
.b-warn { background: var(--warning-bg); color: #fde68a; border-color: var(--warning-border); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  box-shadow: 0 0 8px currentColor;
}

/* Buttons */
button, .btn {
  font: inherit;
  font-weight: 600;
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  background: var(--bg-surface-elevated);
  padding: 9px 16px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

button:hover {
  background: var(--bg-surface-hover);
  border-color: rgba(0, 240, 255, 0.45);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
}

button.pri {
  background: linear-gradient(135deg, var(--accent-cyan), var(--primary));
  color: #07090e;
  border: 0;
  font-weight: 700;
  box-shadow: 0 4px 18px rgba(0, 240, 255, 0.3);
}

button.pri:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(0, 240, 255, 0.45);
}

button.danger {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: #fda4af;
}

button.danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

button.sm {
  padding: 6px 12px;
  font-size: 12px;
}

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

.icon-btn {
  padding: 6px 10px;
}

/* Inputs & Form Controls */
input, select, textarea {
  font: inherit;
  color: #ffffff;
  background: rgba(7, 9, 14, 0.85);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  width: 100%;
  outline: none;
  transition: all 0.2s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0, 240, 255, 0.2);
}

label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin: 14px 0 6px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.sp { flex: 1; }
.f2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.mut { color: var(--text-muted); }
.small { font-size: 12px; }

/* Login View with Self Defence Theme */
.login {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login .card {
  width: min(450px, 100%);
  padding: 38px;
  background: var(--bg-card);
  border: 1px solid var(--border-default);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(0, 240, 255, 0.1);
}

.login-brand-logo {
  height: 48px;
  width: auto;
  object-fit: contain;
  margin-bottom: 20px;
  filter: drop-shadow(0 2px 14px rgba(0, 240, 255, 0.3));
}

.login h1 {
  font-size: 24px;
  font-weight: 700;
  color: #ffffff;
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(0, 240, 255, 0.1);
  border: 1px solid rgba(0, 240, 255, 0.3);
  border-radius: var(--radius-full);
  color: var(--accent-cyan);
  font-size: 11px;
  font-weight: 600;
  margin: 6px 0 16px;
}

.bar {
  height: 8px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
  margin: 8px 0 14px;
}

.bar > i {
  display: block;
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent-cyan), var(--primary));
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 14, 0.85);
  backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 20px;
  animation: fade 0.2s;
}

.modal-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: 20px;
  width: min(880px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  padding: 28px;
  position: relative;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.8), 0 0 40px rgba(0, 240, 255, 0.15);
  animation: pop 0.25s;
}

.close {
  position: absolute;
  right: 18px;
  top: 18px;
  background: transparent;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
}
.close:hover {
  color: #ffffff;
}

@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(14px) scale(0.98); opacity: 0; } }

.kv {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 8px 16px;
  margin: 16px 0;
}

.kv dt { color: var(--text-secondary); font-weight: 500; }
.kv dd { margin: 0; word-break: break-all; color: #ffffff; }

pre {
  background: rgba(7, 9, 14, 0.95);
  border: 1px solid var(--border-default);
  padding: 14px;
  border-radius: var(--radius-md);
  overflow: auto;
  max-height: 240px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent-cyan);
}

.tl {
  border-left: 2px solid rgba(0, 240, 255, 0.3);
  margin: 14px 0 14px 8px;
  padding-left: 18px;
}

.tl > div {
  position: relative;
  margin-bottom: 16px;
}

.tl > div::before {
  content: "";
  position: absolute;
  left: -25px;
  top: 5px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-cyan);
  box-shadow: 0 0 12px var(--accent-cyan);
}

#toasts {
  position: fixed;
  right: 24px;
  bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 1000;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-default);
  border-left: 4px solid var(--accent-cyan);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.6);
  animation: pop 0.25s;
  max-width: 400px;
  font-weight: 500;
}

.toast.err {
  border-left-color: var(--critical);
}

.flow {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin: 14px 0;
}

.flow span {
  padding: 5px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-secondary);
}

.flow span.cur {
  color: #07090e;
  background: var(--accent-cyan);
  border-color: var(--accent-cyan);
  font-weight: 700;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.35);
}

.flow i {
  color: var(--text-muted);
  font-style: normal;
}

.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button.on {
  background: rgba(0, 240, 255, 0.15);
  border-color: var(--accent-cyan);
  color: #ffffff;
}

/* MFA Card & QR Styling (Self Defence Portal Component) */
.mfa-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 24px;
  text-align: center;
  margin-top: 14px;
}

.mfa-qr-img {
  width: 220px;
  height: 220px;
  border-radius: var(--radius-md);
  border: 4px solid #ffffff;
  margin: 14px auto;
  display: block;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

.mfa-secret-code {
  background: rgba(0, 240, 255, 0.08);
  border: 1px dashed rgba(0, 240, 255, 0.4);
  color: var(--accent-cyan);
  padding: 8px 14px;
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.15em;
  display: inline-block;
  margin: 8px 0 16px;
  user-select: all;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-app);
}
::-webkit-scrollbar-thumb {
  background: var(--bg-surface-elevated);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--bg-surface-hover);
}

@media (max-width: 900px) {
  .shell { grid-template-columns: 1fr; }
  aside { position: static; height: auto; flex-direction: row; flex-wrap: wrap; }
  main { padding: 20px; }
  .f2, .kv { grid-template-columns: 1fr; }
}
