/* InsightHub Analytics — design system */

:root {
  --navy-900: #0a1130;
  --navy-800: #0f1838;
  --navy-700: #16204a;
  --navy-600: #1e2a5e;
  --bg: #f3f5fb;
  --card: #ffffff;
  --border: #e7eaf3;
  --border-soft: #eef0f8;
  --text: #1b2035;
  --text-muted: #8a93a6;
  --text-soft: #aeb4c4;
  --text-inverse: #f4f6ff;
  --primary: #3b6ff2;
  --primary-soft: #eaf0ff;
  --teal: #14b8a6;
  --teal-soft: #e3f9f5;
  --purple: #8b5cf6;
  --purple-soft: #f1ecfe;
  --orange: #f59e0b;
  --orange-soft: #fef3e2;
  --red: #ef4444;
  --red-soft: #fdeaea;
  --green: #10b981;
  --green-soft: #e7f9f2;
  --pink: #ec4899;
  --pink-soft: #fdeaf3;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, .04), 0 10px 28px -12px rgba(16, 24, 40, .10);
  --shadow-pop: 0 12px 32px -8px rgba(16, 24, 40, .18);
  --sidebar-w: 264px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14.5px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
ul { list-style: none; margin: 0; padding: 0; }
button { font-family: inherit; cursor: pointer; }
img { max-width: 100%; }

/* ---------- Layout shell ---------- */

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

.sidebar {
  width: var(--sidebar-w);
  background: linear-gradient(180deg, var(--navy-900) 0%, var(--navy-700) 100%);
  color: var(--text-inverse);
  position: fixed;
  inset: 0 auto 0 0;
  display: flex;
  flex-direction: column;
  z-index: 40;
  transition: transform .25s ease;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 22px 20px;
}

.sidebar-brand .logo-badge {
  width: 40px; height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--primary), var(--purple));
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 17px; color: #fff;
  flex-shrink: 0;
}

.sidebar-brand .brand-text .name { font-weight: 700; font-size: 16px; color: #fff; letter-spacing: .2px; }
.sidebar-brand .brand-text .tag { font-size: 11.5px; color: #9aa4c7; margin-top: 2px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 14px; }
.sidebar-section-title {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .08em;
  color: #6d78a3; margin: 18px 10px 8px; font-weight: 600;
}
.sidebar-nav a.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: 10px; margin-bottom: 2px;
  color: #c3cae6; font-size: 13.6px; font-weight: 500;
  transition: background .15s ease, color .15s ease;
}
.sidebar-nav a.nav-item svg { width: 18px; height: 18px; flex-shrink: 0; opacity: .85; }
.sidebar-nav a.nav-item:hover { background: rgba(255,255,255,.06); color: #fff; }
.sidebar-nav a.nav-item.active { background: rgba(59,111,242,.18); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.sidebar-nav a.nav-item .dot { width: 8px; height: 8px; border-radius: 50%; margin-left: auto; flex-shrink: 0; }
.sidebar-nav a.nav-item .badge-count {
  margin-left: auto; background: var(--red); color: #fff; font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: 999px;
}

.sidebar-user {
  padding: 16px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-user .avatar {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(135deg, var(--teal), var(--primary));
  display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 14px;
}
.sidebar-user .who { flex: 1; min-width: 0; }
.sidebar-user .who .n { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .who .r { color: #8a93c2; font-size: 11.5px; }
.sidebar-user button.logout-btn {
  background: rgba(255,255,255,.06); border: none; color: #c3cae6; width: 32px; height: 32px;
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
}
.sidebar-user button.logout-btn:hover { background: rgba(239,68,68,.25); color: #fff; }

.main { flex: 1; margin-left: var(--sidebar-w); display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky; top: 0; z-index: 30;
  background: rgba(243,245,251,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-soft);
  padding: 16px 28px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.topbar-title h1 { font-size: 21px; font-weight: 700; margin: 0; letter-spacing: -.2px; }
.topbar-title p { margin: 2px 0 0; color: var(--text-muted); font-size: 12.8px; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.hamburger {
  display: none; width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; align-items: center; justify-content: center; flex-shrink: 0;
}

.search-box {
  display: flex; align-items: center; gap: 8px;
  background: #fff; border: 1px solid var(--border); border-radius: 999px;
  padding: 9px 16px; min-width: 240px; color: var(--text-muted);
}
.search-box svg { width: 16px; height: 16px; flex-shrink: 0; }
.search-box input { border: none; outline: none; background: transparent; font-size: 13px; width: 100%; color: var(--text); }

.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--border);
  background: #fff; display: flex; align-items: center; justify-content: center; position: relative; flex-shrink: 0;
}
.icon-btn svg { width: 17px; height: 17px; color: var(--text-muted); }
.icon-btn .ping { position: absolute; top: -3px; right: -3px; background: var(--red); color: #fff; font-size: 9.5px; font-weight: 700; padding: 1px 5px; border-radius: 999px; }

.lang-switch { display: flex; background: #fff; border: 1px solid var(--border); border-radius: 999px; padding: 3px; }
.lang-switch a { padding: 5px 12px; border-radius: 999px; font-size: 12px; font-weight: 700; color: var(--text-muted); }
.lang-switch a.active { background: var(--navy-800); color: #fff; }

.topbar-avatar { display: flex; align-items: center; gap: 8px; }
.topbar-avatar .av { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(135deg,var(--purple),var(--pink)); display:flex;align-items:center;justify-content:center;color:#fff;font-weight:700;font-size:13px; }

.content { padding: 24px 28px 90px; flex: 1; }

.status-footer {
  position: sticky; bottom: 0; z-index: 20;
  background: #fff; border-top: 1px solid var(--border-soft);
  padding: 10px 28px; display: flex; align-items: center; gap: 22px; flex-wrap: wrap;
  font-size: 12px; color: var(--text-muted);
}
.status-footer .item { display: flex; align-items: center; gap: 6px; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 3px var(--green-soft); }
.status-footer .spacer { flex: 1; }

/* ---------- Grid & cards ---------- */

.grid { display: grid; gap: 18px; }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }
.grid-2 { grid-template-columns: 2fr 1fr; }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-domains { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }

@media (max-width: 1100px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

.card {
  background: var(--card); border: 1px solid var(--border-soft); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card); padding: 20px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 10px; }
.card-head h3 { font-size: 15px; font-weight: 700; margin: 0; }
.card-head .sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.card-link { font-size: 12.5px; font-weight: 700; color: var(--primary); }

.stat-card { display: flex; flex-direction: column; gap: 12px; }
.stat-card .top-row { display: flex; align-items: flex-start; justify-content: space-between; }
.stat-icon { width: 42px; height: 42px; border-radius: 12px; display: flex; align-items: center; justify-content: center; }
.stat-icon svg { width: 20px; height: 20px; }
.stat-card .label { color: var(--text-muted); font-size: 12.5px; font-weight: 600; }
.stat-card .value { font-size: 25px; font-weight: 800; letter-spacing: -.4px; margin-top: 2px; }
.stat-change { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 999px; width: fit-content; }
.stat-change.up { color: var(--green); background: var(--green-soft); }
.stat-change.down { color: var(--red); background: var(--red-soft); }
.stat-change.flat { color: var(--text-muted); background: var(--border-soft); }
.stat-change svg { width: 12px; height: 12px; }
.stat-sub { font-size: 11.5px; color: var(--text-soft); }

/* badges / pills */
.badge { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; }
.badge-green { background: var(--green-soft); color: var(--green); }
.badge-red { background: var(--red-soft); color: var(--red); }
.badge-orange { background: var(--orange-soft); color: #b06a00; }
.badge-blue { background: var(--primary-soft); color: var(--primary); }
.badge-purple { background: var(--purple-soft); color: var(--purple); }
.badge-gray { background: var(--border-soft); color: var(--text-muted); }

.severity-critical { background: var(--red-soft); color: var(--red); }
.severity-high { background: var(--orange-soft); color: #b06a00; }
.severity-medium { background: var(--primary-soft); color: var(--primary); }
.severity-low { background: var(--border-soft); color: var(--text-muted); }

/* tables */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data-table th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em;
  color: var(--text-muted); font-weight: 700; padding: 8px 12px; border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.data-table td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; white-space: nowrap; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafbfe; }
.rank-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; border-radius: 7px; background: var(--border-soft); font-weight: 700; font-size: 11.5px; color: var(--text-muted); }
.progress-track { width: 100%; height: 7px; background: var(--border-soft); border-radius: 999px; overflow: hidden; min-width: 80px; }
.progress-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--primary), var(--teal)); }

/* domain overview cards */
.domain-card { display: flex; flex-direction: column; gap: 14px; }
.domain-card .dh { display: flex; align-items: center; gap: 12px; }
.domain-card .dh .icon { width: 44px; height: 44px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.domain-card .dh .icon svg { width: 21px; height: 21px; color: #fff; }
.domain-card .dh .titles .t { font-weight: 700; font-size: 15.5px; }
.domain-card .dh .titles .s { font-size: 11.5px; color: var(--text-muted); }
.domain-mini-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.domain-mini-stats .mini { background: var(--bg); border-radius: 12px; padding: 10px 12px; }
.domain-mini-stats .mini .l { font-size: 11px; color: var(--text-muted); font-weight: 600; }
.domain-mini-stats .mini .v { font-size: 16px; font-weight: 700; margin-top: 2px; }
.domain-card .cta { display: flex; align-items: center; justify-content: space-between; margin-top: 4px; }
.btn-goto { font-size: 12.5px; font-weight: 700; color: var(--primary); display: flex; align-items: center; gap: 4px; }

/* action / insight cards */
.action-item { display: flex; align-items: flex-start; gap: 12px; padding: 13px 0; border-bottom: 1px solid var(--border-soft); }
.action-item:last-child { border-bottom: none; }
.action-item .ai-icon { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.action-item .ai-body { flex: 1; min-width: 0; }
.action-item .ai-body .m { font-weight: 600; font-size: 13.2px; }
.action-item .ai-body .a { font-size: 12px; color: var(--text-muted); margin-top: 3px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 10px 18px; border-radius: 10px; font-size: 13.4px; font-weight: 700; border: 1px solid transparent; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: #2f5fe0; }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-danger-outline { background: #fff; border-color: var(--red-soft); color: var(--red); }
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }
.btn svg { width: 15px; height: 15px; }
.btn-block { width: 100%; }

/* forms */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--text-muted); margin-top: 5px; }
.field input[type=text], .field input[type=email], .field input[type=password],
.field input[type=number], .field input[type=date], .field input[type=file],
.field select, .field textarea {
  width: 100%; padding: 10px 13px; border: 1px solid var(--border); border-radius: 10px;
  font-size: 13.5px; background: #fff; color: var(--text); outline: none; font-family: inherit;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 700px) { .field-row { grid-template-columns: 1fr; } }
.checkbox-row { display: flex; align-items: center; gap: 8px; }
.checkbox-row input { width: 16px; height: 16px; }
.error-text { color: var(--red); font-size: 12px; margin-top: 5px; }

.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--border); margin-bottom: 20px; flex-wrap: wrap; }
.tabs a { padding: 10px 4px; margin-right: 20px; font-size: 13px; font-weight: 700; color: var(--text-muted); border-bottom: 2px solid transparent; }
.tabs a.active { color: var(--primary); border-color: var(--primary); }

.alert { padding: 12px 16px; border-radius: 10px; font-size: 13px; font-weight: 600; margin-bottom: 18px; }
.alert-success { background: var(--green-soft); color: #0a7a5a; }
.alert-error { background: var(--red-soft); color: #b02323; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state svg { width: 48px; height: 48px; margin-bottom: 14px; opacity: .4; }

.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }

/* Login page */
.login-shell { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: radial-gradient(circle at 20% 20%, #16204a, #0a1130 60%); padding: 20px; }
.login-card { width: 100%; max-width: 400px; background: #fff; border-radius: 20px; padding: 36px 32px; box-shadow: var(--shadow-pop); }
.login-card .brand { display: flex; align-items: center; gap: 12px; margin-bottom: 26px; }
.login-card h2 { font-size: 21px; margin: 0 0 4px; }
.login-card p.sub { color: var(--text-muted); font-size: 13px; margin: 0 0 24px; }
.demo-hint { background: var(--primary-soft); border-radius: 10px; padding: 12px 14px; font-size: 12px; color: var(--primary); margin-top: 18px; line-height: 1.6; }

.level-pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; padding: 5px 10px; border-radius: 999px; background: var(--navy-800); color: #fff; }
.level-pill.dim { background: var(--border-soft); color: var(--text-soft); }
.level-track { display: flex; gap: 6px; }

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

@media (max-width: 1024px) {
  .sidebar { transform: translateX(-100%); }
  body.sidebar-open .sidebar { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: flex; }
  .search-box { display: none; }
  .content { padding: 18px 16px 90px; }
  .topbar { padding: 14px 16px; }
  .status-footer { padding: 10px 16px; overflow-x: auto; }
  .grid-domains { grid-template-columns: 1fr; }
}

body.sidebar-open::before {
  content: ''; position: fixed; inset: 0; background: rgba(10,17,48,.5); z-index: 35;
}
