/* ============================================================
   UniCompass — Design system v2: "Meridian"
   Ink black + warm paper + a single brass accent. Formal,
   editorial, restrained — built around the compass/wayfinding
   idea at the core of the product.
   ============================================================ */

:root {
  --ink: #1A1C26;
  --ink-soft: #5B5E6D;
  --ink-faint: #9C9686;
  --line: #E6E1D2;
  --surface: #FFFFFF;
  --bg: #F8F6F0;
  --primary: #1A1C26;
  --primary-dark: #000000;
  --primary-soft: #ECE8DC;
  --accent: #B8863F;
  --accent-soft: #F3E7CC;
  --coral: #A8462E;
  --coral-soft: #F3E1D8;
  --gold: #B8863F;
  --success: #3F6B4C;
  --danger: #A8342A;
  --radius-sm: 4px;
  --radius: 8px;
  --radius-lg: 14px;
  --shadow-sm: 0 1px 2px rgba(20,18,10,0.05);
  --shadow: 0 8px 24px rgba(20,18,10,0.08);
  --shadow-lg: 0 18px 44px rgba(20,18,10,0.14);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: 'IBM Plex Sans Arabic', 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { margin: 0 0 8px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; font-family: 'Markazi Text', 'Fraunces', serif; }
p { margin: 0 0 12px; color: var(--ink-soft); }
a { color: inherit; text-decoration: none; }
ul { padding: 0; margin: 0; list-style: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 15px; }

.container { max-width: 1180px; margin: 0 auto; padding: 0 24px; }
.container-narrow { max-width: 780px; margin: 0 auto; padding: 0 24px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 12px 24px; border-radius: var(--radius-sm); border: 1px solid transparent;
  font-weight: 600; font-size: 15px; cursor: pointer;
  transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease, border-color .15s ease;
  white-space: nowrap;
  font-family: 'IBM Plex Sans Arabic', sans-serif;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--accent); border-color: var(--accent); }
.btn-coral { background: var(--coral); color: #fff; border-color: var(--coral); }
.btn-outline { background: transparent; color: var(--ink); border: 1.5px solid var(--line); }
.btn-outline:hover { border-color: var(--ink); }
.btn-ghost { background: var(--primary-soft); color: var(--ink); }
.btn-ghost:hover { background: var(--accent-soft); color: var(--accent); }
.btn-sm { padding: 8px 16px; font-size: 13.5px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------- Badges / pills ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 4px; font-size: 12.5px; font-weight: 600; }
.badge-primary { background: var(--primary-soft); color: var(--ink); }
.badge-accent { background: var(--accent-soft); color: var(--accent); }
.badge-coral { background: var(--coral-soft); color: var(--coral); }
.badge-success { background: #E1EBE3; color: var(--success); }
.badge-gray { background: #F0EEE6; color: var(--ink-soft); }

/* ---------- Cards ---------- */
.card {
  background: var(--surface); border-radius: var(--radius); border: 1px solid var(--line);
  padding: 22px; box-shadow: var(--shadow-sm);
}
.card-hover { transition: box-shadow .2s ease, transform .2s ease; }
.card-hover:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

/* ============================================================
   Public site chrome (landing / marketing pages)
   ============================================================ */
.pub-nav {
  position: sticky; top: 0; z-index: 40; background: rgba(248,246,240,.92); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.pub-nav-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px; max-width: 1180px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; font-size: 20px; color: var(--ink); font-family: 'Markazi Text', serif; }
.brand-mark { width: 34px; height: 34px; border-radius: var(--radius-sm); background: var(--ink); display: flex; align-items: center; justify-content: center; color: var(--accent); flex-shrink: 0; }
.pub-links { display: flex; gap: 26px; align-items: center; }
.pub-links a { font-weight: 500; font-size: 14.5px; color: var(--ink-soft); position: relative; padding-bottom: 2px; }
.pub-links a:hover { color: var(--ink); }
.pub-actions { display: flex; gap: 10px; align-items: center; }
.nav-toggle { display: none; background: none; border: none; padding: 6px; }

.hero { padding: 76px 0 60px; }
.hero-grid { display: grid; grid-template-columns: 1.05fr .95fr; gap: 56px; align-items: center; }
.eyebrow { display: inline-flex; align-items: center; gap: 9px; color: var(--accent); font-weight: 600; font-size: 12.5px; letter-spacing: 1.5px; text-transform: uppercase; padding: 0; margin-bottom: 20px; }
.eyebrow::before { content: ''; width: 24px; height: 1px; background: var(--accent); }
.hero h1 { font-size: 48px; margin-bottom: 18px; font-weight: 600; }
.hero p.lead { font-size: 17px; max-width: 480px; margin-bottom: 30px; font-weight: 300; }
.hero-actions { display: flex; gap: 14px; align-items: center; flex-wrap: wrap; }
.trust-row { display: flex; gap: 28px; margin-top: 38px; flex-wrap: wrap; }
.trust-item { display: flex; flex-direction: column; }
.trust-item b { font-size: 24px; font-family: 'Fraunces', serif; font-style: italic; font-weight: 500; color: var(--accent); }
.trust-item span { font-size: 12px; color: var(--ink-faint); font-weight: 600; letter-spacing: .3px; }

.hero-visual { position: relative; }
.mock-card { background: var(--ink); border-radius: var(--radius-lg); border: 1px solid var(--ink); box-shadow: var(--shadow-lg); padding: 22px; color: #fff; }
.mock-float { position: absolute; background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 14px 16px; border: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }

.section { padding: 64px 0; }
.section-head { text-align: center; max-width: 600px; margin: 0 auto 42px; }
.section-head h2 { font-size: 32px; font-weight: 600; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 22px; }

.feature-card .icon-tile { width: 44px; height: 44px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; margin-bottom: 14px; }
.icon-tile.blue { background: var(--primary-soft); color: var(--ink); }
.icon-tile.teal { background: var(--accent-soft); color: var(--accent); }
.icon-tile.coral { background: var(--coral-soft); color: var(--coral); }
.icon-tile.gold { background: var(--accent-soft); color: var(--accent); }

.step-num { width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--ink); color: var(--accent); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; margin-bottom: 14px; font-family: 'Fraunces', serif; font-style: italic; }

.cta-band { background: var(--ink); border-radius: var(--radius-lg); padding: 56px; text-align: center; color: #fff; }
.cta-band h2 { color: #fff; font-size: 30px; }
.cta-band p { color: rgba(255,255,255,.7); max-width: 480px; margin: 0 auto 24px; }

.pub-footer { border-top: 1px solid var(--line); padding: 44px 0 28px; margin-top: 40px; }
.footer-grid { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1fr; gap: 30px; margin-bottom: 30px; }
.footer-grid h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-faint); margin-bottom: 12px; font-family: 'IBM Plex Sans Arabic'; font-weight: 700; }
.footer-grid a, .footer-grid li { display: block; margin-bottom: 9px; font-size: 14px; color: var(--ink-soft); }
.footer-grid a:hover { color: var(--accent); }
.footer-bottom { display: flex; justify-content: space-between; padding-top: 22px; border-top: 1px solid var(--line); font-size: 13px; color: var(--ink-faint); flex-wrap: wrap; gap: 10px; }

/* ============================================================
   Auth pages
   ============================================================ */
.auth-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--ink); padding: 24px; }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: var(--radius-lg); border: 1px solid var(--line); box-shadow: var(--shadow-lg); padding: 36px 32px; }
.auth-card .brand { justify-content: center; margin-bottom: 22px; }
.auth-card h1 { font-size: 25px; text-align: center; }
.auth-card > p { text-align: center; margin-bottom: 26px; }
.field { margin-bottom: 16px; }
.field label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--line);
  background: var(--bg); outline: none; transition: border-color .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); background: #fff; }
.role-select { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.role-opt { border: 1.5px solid var(--line); border-radius: var(--radius-sm); padding: 12px 6px; text-align: center; cursor: pointer; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.role-opt input { display: none; }
.role-opt.active, .role-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.alert { padding: 12px 15px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600; margin-bottom: 16px; }
.alert-error { background: #F3E1DB; color: var(--danger); }
.alert-success { background: #E1EBE3; color: var(--success); }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; }
.auth-foot a { color: var(--accent); font-weight: 600; }

/* ============================================================
   App shell (logged-in area: sidebar + topbar)
   ============================================================ */
.app-shell { display: flex; min-height: 100vh; }
.sidebar {
  width: 240px; flex-shrink: 0; background: var(--ink); border-right: 1px solid var(--ink);
  padding: 22px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 30;
  color: #E4E1D6;
}
.sidebar .brand { padding: 0 8px; margin-bottom: 26px; color: #fff; }
.sidebar .brand-mark { background: var(--accent); color: var(--ink); }
.side-section { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: #7D7A6C; font-weight: 700; margin: 18px 10px 8px; }
.side-link {
  display: flex; align-items: center; gap: 11px; padding: 10px 12px; border-radius: var(--radius-sm);
  font-weight: 500; font-size: 14.5px; color: #C7C3B4; margin-bottom: 3px;
}
.side-link svg { flex-shrink: 0; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.side-link.active { background: rgba(184,134,63,.16); color: var(--accent); }
.side-link.active svg { opacity: 1; }
.sidebar-foot { border-top: 1px solid rgba(255,255,255,.1); margin-top: 16px; padding-top: 14px; }

.main-col { flex: 1; min-width: 0; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 28px; background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
.topbar-search { display: flex; align-items: center; gap: 9px; background: var(--bg); border-radius: var(--radius-sm); padding: 9px 16px; flex: 1; max-width: 380px; color: var(--ink-faint); }
.topbar-search input { background: none; border: none; outline: none; width: 100%; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.icon-btn { width: 38px; height: 38px; border-radius: 999px; background: var(--bg); border: none; display: flex; align-items: center; justify-content: center; color: var(--ink-soft); position: relative; }
.icon-btn:hover { background: var(--accent-soft); color: var(--accent); }
.dot { position: absolute; top: 8px; right: 9px; width: 7px; height: 7px; border-radius: 999px; background: var(--coral); border: 1.5px solid #fff; }
.avatar { width: 38px; height: 38px; border-radius: 999px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 13.5px; flex-shrink: 0; }
.avatar-sm { width: 30px; height: 30px; font-size: 11.5px; }
.avatar-lg { width: 56px; height: 56px; font-size: 18px; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.user-chip .who b { display: block; font-size: 13.5px; font-weight: 600; }
.user-chip .who span { font-size: 12px; color: var(--ink-faint); }

.page { padding: 26px 28px 60px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head h1 { font-size: 27px; margin-bottom: 4px; }
.page-head p { margin: 0; }

.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-card .stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.stat-card .stat-icon { width: 36px; height: 36px; border-radius: var(--radius-sm); display: flex; align-items: center; justify-content: center; }
.stat-card b { font-size: 25px; display: block; font-family: 'Fraunces', serif; font-style: italic; font-weight: 500; }
.stat-card span.label { font-size: 12px; color: var(--ink-faint); font-weight: 700; letter-spacing: .3px; }

.two-col { display: grid; grid-template-columns: 1fr 340px; gap: 20px; align-items: start; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; font-size: 14px; }
table.dt th { text-align: left; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-faint); padding: 10px 14px; border-bottom: 1.5px solid var(--line); white-space: nowrap; font-weight: 700; }
table.dt td { padding: 13px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.dt tr:last-child td { border-bottom: none; }
table.dt tr:hover td { background: var(--bg); }

/* ---------- Progress ---------- */
.progress-track { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .3s ease; }

/* ---------- Filters ---------- */
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.filter-bar select, .filter-bar input { padding: 9px 12px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); background: var(--bg); font-size: 13.5px; outline: none; }
.filter-bar select:focus, .filter-bar input:focus { border-color: var(--accent); }
.search-wide { display: flex; align-items: center; gap: 9px; background: var(--bg); border-radius: var(--radius-sm); padding: 10px 16px; flex: 1; min-width: 200px; color: var(--ink-faint); }
.search-wide input { background: none; border: none; outline: none; width: 100%; }

/* ---------- Explorer cards ---------- */
.explore-card { display: flex; flex-direction: column; height: 100%; }
.explore-card .thumb { height: 120px; border-radius: var(--radius-sm); margin-bottom: 14px; display: flex; align-items: center; justify-content: center; color: #fff; font-weight: 700; font-size: 15px; }
.explore-card h3 { font-size: 17px; margin-bottom: 4px; }
.explore-card .meta-row { display: flex; gap: 14px; margin: 10px 0; flex-wrap: wrap; }
.meta-item { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--ink-soft); font-weight: 500; }
.explore-card .tags { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 14px; }
.explore-card .card-foot { margin-top: auto; display: flex; justify-content: space-between; align-items: center; padding-top: 12px; border-top: 1px solid var(--line); }

/* ---------- Assessment ---------- */
.assess-wrap { max-width: 680px; margin: 0 auto; padding: 40px 24px 80px; }
.assess-progress { display: flex; align-items: center; gap: 8px; margin-bottom: 34px; }
.assess-progress .seg { flex: 1; height: 4px; border-radius: 999px; background: var(--line); }
.assess-progress .seg.done { background: var(--accent); }
.assess-step-label { text-align: center; font-size: 12.5px; font-weight: 700; color: var(--ink-faint); margin-bottom: 30px; letter-spacing: .3px; }
.assess-q h2 { font-size: 25px; margin-bottom: 26px; text-align: center; }
.opt-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.opt-card {
  border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px; cursor: pointer;
  display: flex; align-items: center; gap: 12px; font-weight: 600; font-size: 14.5px; background: #fff;
  transition: all .15s;
}
.opt-card:hover { border-color: var(--accent); }
.opt-card.selected { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.opt-card .opt-icon { width: 38px; height: 38px; border-radius: var(--radius-sm); background: var(--bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.opt-card.selected .opt-icon { background: #fff; }
.assess-nav { display: flex; justify-content: space-between; margin-top: 34px; }
.range-row input[type=range] { width: 100%; accent-color: var(--accent); }
.range-labels { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--ink-faint); font-weight: 700; margin-top: 6px; }

/* ---------- Results ---------- */
.result-hero { background: var(--ink); border-radius: var(--radius-lg); padding: 34px 32px; color: #fff; margin-bottom: 26px; }
.result-hero h1 { color: #fff; }
.result-hero p { color: rgba(255,255,255,.7); }
.match-card { display: flex; align-items: center; gap: 16px; }
.match-rank { width: 44px; height: 44px; border-radius: var(--radius-sm); background: var(--primary-soft); color: var(--ink); display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 17px; flex-shrink: 0; font-family: 'Fraunces', serif; font-style: italic; }
.match-pct { font-weight: 600; color: var(--accent); font-size: 18px; font-family: 'Fraunces', serif; font-style: italic; }

/* ---------- Chat / AI Advisor ---------- */
.chat-shell { display: flex; flex-direction: column; height: calc(100vh - 130px); background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.chat-head { padding: 16px 22px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 12px; }
.chat-body { flex: 1; overflow-y: auto; padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.msg { max-width: 72%; padding: 12px 16px; border-radius: var(--radius); font-size: 14.5px; line-height: 1.55; }
.msg.ai { background: var(--bg); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.user { background: var(--ink); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.chat-input-row { display: flex; gap: 10px; padding: 16px 20px; border-top: 1px solid var(--line); }
.chat-input-row input { flex: 1; padding: 12px 16px; border-radius: var(--radius-sm); border: 1.5px solid var(--line); outline: none; background: var(--bg); }
.chat-input-row input:focus { border-color: var(--accent); }
.chat-send { width: 46px; height: 46px; border-radius: 999px; background: var(--ink); color: var(--accent); border: none; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.suggest-row { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 20px 14px; }
.suggest-chip { background: var(--primary-soft); color: var(--ink); border: none; padding: 8px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 600; }

/* ---------- Modal ---------- */
.modal-bg { position: fixed; inset: 0; background: rgba(20,18,10,.55); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.open { display: flex; }
.modal { background: #fff; border-radius: var(--radius-lg); padding: 28px; width: 100%; max-width: 460px; box-shadow: var(--shadow-lg); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }

/* ---------- Empty states ---------- */
.empty-state { text-align: center; padding: 60px 24px; color: var(--ink-faint); }
.empty-state .icon-tile { margin: 0 auto 16px; width: 56px; height: 56px; }

/* ---------- Utility ---------- */
.flex { display: flex; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.mt-0 { margin-top: 0; } .mb-0 { margin-bottom: 0; }
.text-faint { color: var(--ink-faint); }
.text-sm { font-size: 13px; }
.w-full { width: 100%; }

/* ---------- Language switcher ---------- */
.lang-switch { display: flex; gap: 4px; background: var(--bg); border-radius: var(--radius-sm); padding: 3px; }
.lang-opt { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 12.5px; font-weight: 600; color: var(--ink-faint); }
.lang-opt.active { background: #fff; color: var(--accent); box-shadow: var(--shadow-sm); }
.lang-opt:hover { color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 980px) {
  .hero-grid, .two-col { grid-template-columns: 1fr; }
  .grid-3, .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .sidebar { position: fixed; left: -260px; top: 0; transition: left .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { left: 0; }
  .nav-toggle { display: block; }
  .pub-links { display: none; }
}
@media (max-width: 640px) {
  .grid-3, .grid-4, .grid-2 { grid-template-columns: 1fr; }
  .opt-grid { grid-template-columns: 1fr; }
  .hero h1 { font-size: 32px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .page { padding: 18px 16px 50px; }
  .topbar { padding: 14px 16px; }
  .topbar-search { display: none; }
}
