/* ==========================================================================
   Vietnam Banking Product Intelligence
   app.css — design tokens, reset, typography, layout, navigation, utilities
   ========================================================================== */

:root {
  /* Brand palette */
  --brand-violet: #4300FF;
  --brand-blue: #0065F8;
  --brand-cyan: #00CAFF;
  --brand-aqua: #00FFDE;

  /* Brand derivatives */
  --violet-hover: #3500D9;
  --violet-press: #2B00B3;
  --violet-soft: rgba(67, 0, 255, 0.08);
  --violet-soft-2: rgba(67, 0, 255, 0.06);
  --blue-soft: rgba(0, 101, 248, 0.10);
  --blue-soft-2: rgba(0, 101, 248, 0.07);
  --blue-soft-3: rgba(0, 101, 248, 0.04);
  --cyan-soft: rgba(0, 202, 255, 0.10);
  --cyan-soft-2: rgba(0, 202, 255, 0.08);
  --cyan-ink: #007FA6;
  --aqua-soft: rgba(0, 255, 222, 0.12);
  --aqua-soft-2: rgba(0, 255, 222, 0.08);
  --aqua-line: rgba(0, 255, 222, 0.38);
  --aqua-ink: #0B7A6B;

  /* Neutral surfaces & text */
  --bg-page: #F7F9FC;
  --bg-surface: #FFFFFF;
  --bg-soft: #F2F6FB;
  --text-primary: #111827;
  --text-secondary: #475569;
  --text-muted: #64748B;
  --border: #DCE4EE;
  --border-soft: #E8EEF5;

  /* Semantic */
  --danger: #DC2626;
  --warning: #D97706;
  --success: #16A34A;
  --danger-soft: rgba(220, 38, 38, 0.10);
  --warning-soft: rgba(217, 119, 6, 0.12);
  --success-soft: rgba(22, 163, 74, 0.10);

  /* Spacing scale */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  /* Radii */
  --radius: 12px;
  --radius-sm: 10px;
  --radius-xs: 8px;
  --radius-pill: 999px;

  /* Shadow */
  --shadow-xs: 0 1px 2px rgba(17, 24, 39, 0.04);
  --shadow-sm: 0 4px 16px rgba(17, 24, 39, 0.05);

  /* Layout */
  --sidebar-w: 264px;
  --topbar-h: 64px;
  --content-max: 1520px;
}

/* --------------------------------------------------------------------------
   Reset & base
   -------------------------------------------------------------------------- */
*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg-page);
  color: var(--text-primary);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure { margin: 0; }
ul, ol { padding-left: 1.15em; }

a { color: var(--brand-blue); text-decoration: none; transition: color .15s ease; }
a:hover { color: var(--brand-violet); }

svg, img { max-width: 100%; }
button { font-family: inherit; }
hr { border: 0; border-top: 1px solid var(--border-soft); margin: 0; }

:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection { background: var(--violet-soft); color: var(--brand-violet); }

/* --------------------------------------------------------------------------
   Typography
   -------------------------------------------------------------------------- */
.eyebrow {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--brand-violet);
}

.page-title {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  color: var(--text-primary);
  margin-top: var(--sp-2);
}

.page-desc {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 820px;
  margin-top: var(--sp-2);
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.section-sub { font-size: 13px; color: var(--text-muted); font-weight: 400; }

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

.meta { font-size: 12px; color: var(--text-muted); }
.meta-sm { font-size: 11px; color: var(--text-muted); }
.body-lg { font-size: 15px; color: var(--text-secondary); }

.t-primary { color: var(--text-primary); }
.t-secondary { color: var(--text-secondary); }
.t-muted { color: var(--text-muted); }
.t-violet { color: var(--brand-violet); }
.t-blue { color: var(--brand-blue); }
.t-cyan { color: var(--cyan-ink); }
.t-aqua { color: var(--aqua-ink); }
.t-danger { color: var(--danger); }
.t-warning { color: var(--warning); }
.t-success { color: var(--success); }

.tnum { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   App layout
   -------------------------------------------------------------------------- */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: var(--sp-5) 14px var(--sp-6);
  overflow-y: auto;
  z-index: 40;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: 0 var(--sp-8);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: saturate(160%) blur(10px);
  -webkit-backdrop-filter: saturate(160%) blur(10px);
  border-bottom: 1px solid var(--border);
}

.content {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-8) var(--sp-10) var(--sp-16);
}

.page-header { margin-bottom: var(--sp-8); }
.page-header + .section { margin-top: 0; }

/* --------------------------------------------------------------------------
   Sidebar brand & navigation
   -------------------------------------------------------------------------- */
.side-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-1) var(--sp-2) var(--sp-5);
}

.brand-mark {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--brand-violet), var(--brand-blue));
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: .02em;
  box-shadow: 0 4px 12px rgba(67, 0, 255, 0.25);
}

.brand-text .brand-title {
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.brand-text small {
  display: block;
  margin-top: 2px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
}

.side-group {
  margin: var(--sp-5) var(--sp-2) var(--sp-2);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.side-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  margin: 2px 0;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background .15s ease, color .15s ease;
}

.side-link:hover { background: var(--bg-soft); color: var(--text-primary); }
.side-link .side-ico { flex: none; width: 18px; height: 18px; color: currentColor; opacity: .85; }

.side-link.active {
  background: var(--violet-soft);
  color: var(--brand-violet);
  font-weight: 600;
}

.side-link.active .side-ico { opacity: 1; }

.side-link.active::before {
  content: "";
  position: absolute;
  left: -14px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--brand-violet);
}

.side-foot {
  margin-top: auto;
  padding: var(--sp-4) var(--sp-2) 0;
  border-top: 1px solid var(--border-soft);
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.42);
  z-index: 35;
  opacity: 0;
  transition: opacity .2s ease;
}

.sidebar-backdrop.is-open { opacity: 1; }

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar-toggle {
  display: none;
  width: 44px;
  height: 44px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  background: var(--bg-surface);
  border-radius: var(--radius-xs);
  color: var(--text-primary);
  cursor: pointer;
}

.topbar-search {
  position: relative;
  flex: 1;
  max-width: 420px;
}

.topbar-search .search-ico {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  pointer-events: none;
}

.topbar-search input {
  width: 100%;
  height: 40px;
  padding: 0 14px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text-primary);
  font-size: 13.5px;
}

.topbar-search input::placeholder { color: var(--text-muted); }
.topbar-search input:focus {
  outline: none;
  border-color: var(--brand-blue);
  background: var(--bg-surface);
  box-shadow: 0 0 0 3px var(--blue-soft);
}

.topbar-right { display: flex; align-items: center; gap: var(--sp-4); margin-left: auto; }

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 30px;
  padding: 0 12px;
  border-radius: var(--radius-pill);
  background: var(--aqua-soft-2);
  border: 1px solid var(--aqua-line);
  color: var(--aqua-ink);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--success); }

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--violet-soft);
  color: var(--brand-violet);
  font-size: 12.5px;
  font-weight: 700;
  border: 1px solid rgba(67, 0, 255, 0.18);
}

/* --------------------------------------------------------------------------
   Utilities
   -------------------------------------------------------------------------- */
.stack-6 { display: flex; flex-direction: column; gap: var(--sp-6); }
.stack-8 { display: flex; flex-direction: column; gap: var(--sp-8); }
.section { margin-top: var(--sp-10); }
.section:first-child { margin-top: 0; }
.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-4);
}
.hstack { display: flex; align-items: center; gap: var(--sp-3); }
.vstack { display: flex; flex-direction: column; gap: var(--sp-2); }
.spacer { flex: 1; }
.hidden { display: none !important; }

.ico-xs { width: 13px; height: 13px; flex: none; }
.ico-sm { width: 15px; height: 15px; flex: none; }
.ico-md { width: 18px; height: 18px; flex: none; }
.divider { border-top: 1px solid var(--border-soft); }
.nowrap { white-space: nowrap; }
.clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Provenance / source footer */
.provenance {
  margin-top: var(--sp-12);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2) var(--sp-6);
  font-size: 12px;
  color: var(--text-muted);
}

.provenance .prov-item { display: inline-flex; align-items: center; gap: 6px; }
.provenance strong { color: var(--text-secondary); font-weight: 600; }

/* Skip link */
.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--brand-violet);
  color: #fff;
  padding: 8px 14px;
  border-radius: 0 0 8px 0;
  z-index: 100;
}
.skip-link:focus { left: 0; }
