/* Lafin design system: shared by Lafin CRM and Lafin Academy (AI Trainer).
   Brand palette from Lafin Group logo sheet: #0f796f navy, #4bc3c8 cyan, #fdda40 yellow, #48494b charcoal.
   Layout: fixed left app rail + content column; collapses to a top bar under 860px. */
:root {
  --teal: #0f796f;
  --teal-700: #0b5f57;
  --teal-50: #e7f3f1;
  --aqua: #4bc3c8;
  --aqua-ink: #0b6a61;      /* teal text on white (AA) */
  --mint: #7dcdca;          /* site top-bar teal */
  --aqua-50: #e9f7f6;
  --yellow: #fdda40;
  --yellow-50: #fff8d6;
  --ink: #141414;
  --charcoal: #3d3f40;
  --muted: #696b6b;
  --line: #e0e7e5;
  --line-soft: #eef3f2;
  --bg: #f7f9f8;
  --card: #ffffff;
  /* semantic, deliberately separate from brand */
  --ok: #1a7f52;   --ok-50: #e3f4ec;
  --warn: #b26a00; --warn-50: #fdf1dc;
  --bad: #c0392b;  --bad-50: #fbe7e4;
  --display: "Be Vietnam Pro", "Avenir Next", "Segoe UI", sans-serif;
  --body: "Inter", "Segoe UI", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --r: 10px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--body); }
h1, h2, h3 { font-family: var(--display); color: var(--ink); margin: 0; text-wrap: balance; letter-spacing: -0.01em; }
h1 { font-size: 22px; font-weight: 700; }
h2 { font-size: 16px; font-weight: 700; }
h3 { font-size: 13px; font-weight: 700; }
a { color: var(--aqua-ink); }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--aqua); outline-offset: 2px; }
.num { font-variant-numeric: tabular-nums; }
.label { font-size: 11px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- App shell ---------- */
.app { display: grid; grid-template-columns: 236px 1fr; min-height: 100%; }
.rail { background: var(--card); border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 18px; padding: 18px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; flex-direction: column; gap: 6px; padding: 0 6px; }
.brand img { width: 170px; height: auto; }
.brand .product { font-family: var(--display); font-weight: 700; font-size: 13px; color: var(--teal); display: flex; align-items: center; gap: 8px; }
.brand .product::before { content: ""; width: 18px; height: 4px; background: var(--yellow); border-radius: 2px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .label { padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: 8px; color: var(--charcoal); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--line-soft); }
.nav a.on { background: var(--teal); color: #fff; }
.nav a .ct { margin-left: auto; font-size: 11px; background: var(--aqua-50); color: var(--aqua-ink); border-radius: 99px; padding: 0 7px; font-weight: 600; }
.nav a.on .ct { background: rgba(255,255,255,.18); color: #fff; }
.ico { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.switcher { margin-top: auto; border: 1px solid var(--line); border-radius: var(--r); padding: 10px; display: flex; flex-direction: column; gap: 6px; }
.switcher a { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--teal); font-weight: 600; font-size: 13px; padding: 6px 8px; border-radius: 6px; background: var(--teal-50); }
.switcher a:hover { background: var(--aqua-50); }
.me { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.av { width: 30px; height: 30px; border-radius: 50%; background: var(--teal); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 12px; flex: none; }
.av.c { background: var(--aqua); } .av.y { background: var(--yellow); color: var(--teal); } .av.g { background: var(--charcoal); }

.main { min-width: 0; display: flex; flex-direction: column; }
.top { box-shadow: inset 0 3px 0 var(--mint); display: flex; align-items: center; gap: 14px; padding: 14px max(16px, env(safe-area-inset-right, 0px)) 14px 28px; background: var(--card); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.search { flex: 1; max-width: 460px; display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; color: var(--muted); background: var(--bg); }
.search input { border: 0; background: transparent; outline: 0; font: inherit; width: 100%; color: var(--ink); }
.demo { font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; background: var(--yellow-50); color: #7a6200; border: 1px solid #f3df7a; padding: 3px 8px; border-radius: 99px; white-space: nowrap; }
.content { padding: 24px 28px 48px; display: flex; flex-direction: column; gap: 20px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head p { margin: 4px 0 0; color: var(--muted); }

/* ---------- Components ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; min-width: 0; }
.card > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.side { grid-template-columns: minmax(0, 1fr) 340px; }
.btn { text-decoration: none; border: 1px solid var(--line); background: var(--card); color: var(--teal); border-radius: 8px; padding: 8px 14px; font-weight: 600; display: inline-flex; align-items: center; gap: 8px; }
.btn:hover { border-color: var(--aqua); }
.btn.pri { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn.pri:hover { background: var(--teal-700); }
.btn.cta { background: var(--yellow); border-color: var(--yellow); color: var(--ink); }
.btn.cta:hover { background: #f5cf22; border-color: #f5cf22; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { padding: 5px 10px; font-size: 12px; }
.btn.danger { color: var(--bad); }
.chip { display: inline-flex; align-items: center; gap: 5px; font-size: 11.5px; font-weight: 600; border-radius: 99px; padding: 2px 9px; white-space: nowrap; }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.ok { background: var(--ok-50); color: var(--ok); }
.chip.warn { background: var(--warn-50); color: var(--warn); }
.chip.bad { background: var(--bad-50); color: var(--bad); }
.chip.info { background: var(--aqua-50); color: var(--aqua-ink); }
.chip.neutral { background: var(--line-soft); color: var(--charcoal); }
.chip.ai { background: var(--yellow-50); color: #6d5600; }
.chip.ai::before { background: var(--yellow); }
.kpi { display: flex; flex-direction: column; gap: 4px; }
.kpi .v { font-family: var(--display); font-size: 26px; font-weight: 700; color: var(--teal); font-variant-numeric: tabular-nums; }
.kpi .d { font-size: 12px; color: var(--muted); }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th { text-align: left; font-size: 11px; font-weight: 600; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.scroll { overflow-x: auto; }
.bar { height: 8px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--aqua); border-radius: 99px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 12px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs button.on { color: var(--teal); border-bottom-color: var(--teal); }
.list { display: flex; flex-direction: column; }
.list > div { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.list > div:last-child { border-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.stack { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.toast { position: fixed; right: 20px; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); background: var(--teal); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: 0 8px 24px rgba(15,121,111,.25); }
.view[hidden] { display: none !important; }

@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0,1fr)); } .side { grid-template-columns: minmax(0,1fr); } }
@media (max-width: 860px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .rail { min-width: 0; position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; padding: 10px 16px; gap: 14px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand img { width: 120px; }
  .nav { flex-direction: row; }
  .nav .label, .switcher .label, .me { display: none; }
  .nav a { white-space: nowrap; }
  .switcher { margin: 0; flex-direction: row; border: 0; padding: 0; }
  .switcher a { white-space: nowrap; }
  .top { padding-left: max(16px, env(safe-area-inset-left, 0px)); }
  .content { padding: 18px max(16px, env(safe-area-inset-right, 0px)) 40px max(16px, env(safe-area-inset-left, 0px)); }
  .g2, .g3 { grid-template-columns: minmax(0,1fr); }
}
@media (max-width: 520px) { .g4 { grid-template-columns: minmax(0,1fr); } .search { display: none; } .top .btn.pri { padding: 7px 10px; font-size: 12px; } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
