/* LNG One CRM — design tokens and components.
   Light, dense, neutral, one accent. No serif anywhere.
   Brand doc pending: only --accent (and maybe --navy) should need to change when it lands. */

:root {
  --canvas: #F7F8FA;
  --surface: #FFFFFF;
  --ink: #141A24;
  --ink-muted: #6B7280;
  --hairline: #E7E9EE;
  --accent: #2F5FE0;
  --accent-soft: #EBF0FD;
  --navy: #1B2440;
  --navy-2: #2A3558;
  --success: #1F9D55;
  --success-soft: #E6F5EC;
  --warning: #D97706;
  --warning-soft: #FDF3E4;
  --danger: #DC2626;
  --danger-soft: #FDECEC;
  --neutral: #9CA3AF;
  --neutral-soft: #F1F2F4;

  --radius: 10px;
  --radius-lg: 12px;
  --sidebar-w: 224px;
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; }
.muted { color: var(--ink-muted); }
.mono { font-family: var(--mono); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* ── App layout ── */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.main { min-width: 0; display: flex; flex-direction: column; }
.content { padding: 20px 24px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1440px; width: 100%; }

/* ── Sidebar ── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--hairline);
  display: flex; flex-direction: column;
  padding: 14px 10px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; font-weight: 700; font-size: 15px; letter-spacing: -0.01em; }
.brand-mark { width: 26px; height: 26px; border-radius: 7px; background: var(--navy); color: #fff; display: grid; place-items: center; font-size: 11px; font-weight: 700; }
.brand small { display: block; font-weight: 500; font-size: 11px; color: var(--ink-muted); }

.segmented { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--neutral-soft); border-radius: 8px; padding: 3px; gap: 2px; }
.segmented button, .segmented a {
  border: 0; background: transparent; border-radius: 6px; padding: 5px 10px; font-size: 12.5px; font-weight: 600; color: var(--ink-muted); cursor: pointer; text-align: center; text-decoration: none;
}
.segmented .on { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(20,26,36,.08); }
.sidebar .segmented { margin: 0 4px 14px; }

.nav { display: flex; flex-direction: column; gap: 1px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 10px; border-radius: 7px;
  color: var(--ink); font-weight: 500; text-decoration: none; position: relative;
}
.nav a:hover { background: var(--canvas); }
.nav a.active { background: var(--accent-soft); color: var(--accent); }
.nav a.active::before { content: ""; position: absolute; left: -10px; top: 6px; bottom: 6px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.nav svg { width: 16px; height: 16px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav .badge { margin-left: auto; }
.nav-group { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-muted); font-weight: 600; padding: 16px 10px 6px; }
.sidebar .spacer { flex: 1; }
.me { display: flex; align-items: center; gap: 8px; padding: 10px 8px 2px; border-top: 1px solid var(--hairline); margin-top: 10px; }
.me .who { min-width: 0; flex: 1; font-size: 12.5px; }
.me .who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Top bar ── */
.topbar {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 24px 14px; background: var(--canvas);
  border-bottom: 1px solid var(--hairline);
  position: sticky; top: 0; z-index: 5;
}
.title-block { flex: 1; min-width: 0; }
.title-block h1 { font-size: 21px; letter-spacing: -0.01em; }
.title-block p { margin: 2px 0 0; font-size: 12px; color: var(--ink-muted); }
.btn.menu-btn { display: none; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--hairline); background: var(--surface); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font-weight: 600; font-size: 13px; cursor: pointer; white-space: nowrap; text-decoration: none;
}
.btn:hover { border-color: #D3D7DF; text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { padding: 3px 8px; font-size: 12px; border-radius: 6px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
.btn svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; }
.btn.hood-on { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ── Cards ── */
.card { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); min-width: 0; }
.card-head { display: flex; align-items: baseline; gap: 8px; padding: 12px 16px 10px; min-width: 0; }
.card-head h3 { font-size: 13.5px; white-space: nowrap; }
.card-head .desc { color: var(--ink-muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.card-head .action { margin-left: auto; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.card-body { padding: 4px 16px 14px; }
.card-body.flush { padding: 0; }
.helper { font-size: 12px; color: var(--ink-muted); margin: 0; }

.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.main-side { grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); }

/* ── KPI row: first tile navy (signature move) ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius-lg); padding: 12px 14px; }
.kpi .label { font-size: 11.5px; color: var(--ink-muted); font-weight: 500; }
.kpi .value { font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 11.5px; color: var(--ink-muted); margin-top: 2px; }
.kpis .kpi:first-child { background: var(--navy); border-color: var(--navy); color: #fff; }
.kpis .kpi:first-child .label, .kpis .kpi:first-child .sub { color: rgba(255,255,255,.7); }

/* ── Tables ── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: 10.5px; text-transform: uppercase; letter-spacing: .07em;
  color: var(--ink-muted); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--hairline); white-space: nowrap;
}
.table td { padding: 9px 12px; border-bottom: 1px solid var(--hairline); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #FAFBFC; }
.table .r { text-align: right; }
.table-wrap { overflow-x: auto; }

/* ── Chips, badges, tags ── */
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600; background: var(--neutral-soft); color: var(--ink-muted); white-space: nowrap; line-height: 18px; }
.chip.accent { background: var(--accent-soft); color: var(--accent); }
.chip.success { background: var(--success-soft); color: var(--success); }
.chip.warning { background: var(--warning-soft); color: var(--warning); }
.chip.danger { background: var(--danger-soft); color: var(--danger); }
.chip.navy { background: var(--navy); color: #fff; }
.chip .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tag { display: inline-block; font-family: var(--mono); font-size: 11px; padding: 0 6px; border-radius: 5px; border: 1px solid var(--hairline); background: var(--canvas); color: var(--ink); line-height: 18px; white-space: nowrap; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 10.5px; font-weight: 700; }
.badge.danger { background: var(--danger); }
.badge.muted { background: var(--neutral-soft); color: var(--ink-muted); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }

.filter-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-chips button { border: 1px solid var(--hairline); background: var(--surface); border-radius: 999px; padding: 3px 11px; font-size: 12.5px; font-weight: 500; cursor: pointer; }
.filter-chips button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* ── Avatars ── */
.avatar { width: 28px; height: 28px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; letter-spacing: .02em; }
.avatar.sm { width: 22px; height: 22px; font-size: 9.5px; }
.avatar.lg { width: 48px; height: 48px; font-size: 16px; }
.avatar-stack { display: flex; }
.avatar-stack .avatar { border: 2px solid var(--surface); margin-left: -6px; }
.avatar-stack .avatar:first-child { margin-left: 0; }
.person { display: flex; align-items: center; gap: 8px; min-width: 0; }
.person .nm { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.person .sub { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── Bars ── */
.bars { display: flex; flex-direction: column; gap: 9px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 84px; gap: 10px; align-items: center; font-size: 12.5px; }
.bar-row .lbl { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .val { text-align: right; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.bar { height: 8px; border-radius: 4px; background: var(--neutral-soft); overflow: hidden; }
.bar > span { display: block; height: 100%; border-radius: 4px; background: var(--accent); }
.bar.success > span { background: var(--success); }
.bar.neutral > span { background: var(--neutral); }
.mini-bar { width: 56px; height: 5px; border-radius: 3px; background: var(--neutral-soft); overflow: hidden; display: inline-block; vertical-align: middle; }
.mini-bar > span { display: block; height: 100%; background: var(--accent); }

/* ── Forms ── */
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; font-weight: 600; color: var(--ink-muted); }
.input, .select, textarea.input {
  border: 1px solid var(--hairline); background: var(--surface); border-radius: 8px; padding: 7px 10px; outline: none; width: 100%;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.search { position: relative; }
.search .input { padding-left: 30px; }
.search svg { position: absolute; left: 9px; top: 50%; transform: translateY(-50%); width: 14px; height: 14px; stroke: var(--ink-muted); fill: none; stroke-width: 2; }

/* iOS-style toggle */
.toggle { position: relative; width: 34px; height: 20px; flex: none; display: inline-block; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; border-radius: 10px; background: #D5D9E0; transition: background .15s; cursor: pointer; }
.toggle span::after { content: ""; position: absolute; left: 2px; top: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: transform .15s; }
.toggle input:checked + span { background: var(--accent); }
.toggle input:checked + span::after { transform: translateX(14px); }
.toggle input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-soft); }

/* ── Lists (tasks, activity, conversations) ── */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 9px 16px; border-top: 1px solid var(--hairline); min-width: 0; }
.list-item:first-child { border-top: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item .s { font-size: 12px; color: var(--ink-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-item time { font-size: 11.5px; color: var(--ink-muted); white-space: nowrap; }
.ico { width: 26px; height: 26px; border-radius: 7px; display: grid; place-items: center; background: var(--neutral-soft); color: var(--ink-muted); flex: none; }
.ico svg { width: 14px; height: 14px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* ── Navy code panel (JSON / curl) ── */
.code { background: var(--navy); color: #DCE3F5; border-radius: var(--radius); padding: 12px 14px; font-family: var(--mono); font-size: 12px; line-height: 1.6; overflow-x: auto; white-space: pre; margin: 0; }
.code .k { color: #8FB4FF; }
.code .s { color: #A7E3B5; }
.code .c { color: #7D8AAE; }

/* ── Empty / placeholder ── */
.empty { text-align: center; padding: 48px 16px; color: var(--ink-muted); }
.empty h2 { color: var(--ink); font-size: 16px; margin-bottom: 6px; }
.placeholder-note { display: inline-flex; gap: 6px; align-items: center; font-size: 11.5px; color: var(--warning); background: var(--warning-soft); border-radius: 6px; padding: 2px 8px; font-weight: 600; }

/* ── Under the hood overlay ── */
body.hood [data-hood] { position: relative; outline: 1.5px dashed rgba(47, 95, 224, .55); outline-offset: 2px; }
body.hood [data-hood]::after {
  content: attr(data-hood);
  position: absolute; top: -9px; right: 8px; z-index: 4;
  background: var(--navy); color: #fff; font-family: var(--mono); font-size: 10.5px; font-weight: 500;
  padding: 1px 7px; border-radius: 5px; white-space: nowrap; pointer-events: none; max-width: 90%; overflow: hidden; text-overflow: ellipsis;
}
.hood-log {
  position: fixed; right: 16px; bottom: 16px; width: min(460px, calc(100vw - 32px)); max-height: 46vh; z-index: 30;
  display: none; flex-direction: column; background: var(--navy); color: #DCE3F5; border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(20,26,36,.25); overflow: hidden;
}
body.hood .hood-log { display: flex; }
.hood-log header { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--navy-2); font-size: 12px; font-weight: 600; color: #fff; }
.hood-log header span { color: #8E9AC0; font-weight: 400; }
.hood-log ol { list-style: none; margin: 0; padding: 6px 0; overflow-y: auto; font-family: var(--mono); font-size: 11.5px; }
.hood-log li { padding: 3px 14px; display: grid; grid-template-columns: 44px 1fr 34px 46px; gap: 8px; cursor: pointer; }
.hood-log li:hover { background: var(--navy-2); }
.hood-log li .m { color: #8FB4FF; }
.hood-log li .ok { color: #A7E3B5; }
.hood-log li .err { color: #FCA5A5; }
.hood-log li .ms { color: #7D8AAE; text-align: right; }
.hood-log pre { margin: 2px 0 6px; grid-column: 1 / -1; color: #C9D3EE; white-space: pre-wrap; }

/* ── Toast ── */
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.2); }
.toast.error { background: var(--danger); }

/* ── Login ── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.auth-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--hairline); border-radius: 14px; padding: 28px 26px; }
.auth-card .brand { padding: 0 0 18px; }
.auth-card h1 { font-size: 19px; margin-bottom: 4px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; }
.auth-card .btn { justify-content: center; padding: 9px 12px; }
.code-input { font-size: 22px; letter-spacing: 10px; text-align: center; font-family: var(--mono); }
.auth-foot { font-size: 12px; color: var(--ink-muted); margin-top: 16px; text-align: center; }
.error-text { color: var(--danger); font-size: 12.5px; }

/* ── Gallery helpers ── */
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.swatch { border: 1px solid var(--hairline); border-radius: var(--radius); overflow: hidden; font-size: 12px; }
.swatch div { height: 44px; }
.swatch p { margin: 0; padding: 6px 10px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.stack { display: flex; flex-direction: column; gap: 10px; }

/* ── Responsive ── */
@media (max-width: 1100px) {
  .grid.cols-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid.main-side { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.15); }
  body.nav-open .sidebar { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; flex-wrap: wrap; }
  .content { padding: 16px 16px 40px; }
  .grid.cols-2, .grid.cols-3 { grid-template-columns: 1fr; }
  .topbar .btn svg + .lbl { display: none; }
  .topbar .title-block h1 { font-size: 18px; }
  .bar-row { grid-template-columns: 96px 1fr 72px; }
}

body.hood .sidebar[data-hood]::after { top: auto; bottom: 4px; right: 4px; }
