/* ============================================================
   LocalAgent — Local Web SA internal system
   Design system & layout. Mobile-first, dark theme.
   Brand-aligned: near-black navy, electric-blue primary,
   cyan accent, editorial serif display headings.
   ============================================================ */

:root {
  /* Palette — aligned with the Local Web SA brand:
     near-black navy, electric-blue primary, cyan accent. */
  --bg:          #0a0e1a;
  --bg-2:        #0e1424;
  --surface:     #131a2c;
  --surface-2:   #1a2238;
  --surface-3:   #232e49;
  --border:      #253149;
  --border-soft: #1b2236;

  --text:        #f1f4fb;
  --text-dim:    #9aa6bd;
  --text-faint:  #6b7593;

  --brand:       #2b5bff;   /* electric cobalt — Local Web SA primary */
  --brand-2:     #1d3fd8;   /* royal blue — gradient depth */
  --accent:      #22d3ee;   /* cyan/teal — brand secondary (circuitry) */

  --green:       #2fce8f;
  --amber:       #f5b14e;
  --red:         #f8636b;
  --blue:        #4d82ff;
  --purple:      #8b7bff;
  --cyan:        #22d3ee;
  --pink:        #f472b6;

  --radius:      16px;
  --radius-sm:   11px;
  --radius-lg:   22px;
  --shadow:      0 10px 30px rgba(0,0,0,.4);
  --shadow-sm:   0 4px 14px rgba(0,0,0,.3);

  --nav-h:       66px;
  --max-w:       760px;

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
          Arial, "Apple Color Emoji", "Segoe UI Emoji", sans-serif;
  /* Editorial serif for display headings — mirrors the brand site.
     System-only stack so it stays fast and works fully offline. */
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino,
          "Book Antiqua", Georgia, "Times New Roman", serif;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}

/* Brand glow — pinned to the viewport (not the scrolling document) with
   centres pushed off-screen, so the soft falloff never forms a visible
   "seam" line as the page scrolls. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(135% 90% at 90% -25%, rgba(43,91,255,.22), transparent 72%),
    radial-gradient(120% 80% at -20% -10%, rgba(34,211,238,.09), transparent 70%);
}

button, input, select, textarea { font-family: inherit; font-size: inherit; color: inherit; }
button { cursor: pointer; border: none; background: none; }
a { color: var(--brand); text-decoration: none; }
ul { margin: 0; padding: 0; list-style: none; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -.01em; }

/* ---------- App frame ---------- */
.app {
  max-width: var(--max-w);
  margin: 0 auto;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px calc(14px + env(safe-area-inset-top, 0px));
  padding-top: max(14px, env(safe-area-inset-top, 0px));
  background: linear-gradient(180deg, rgba(10,14,26,.94), rgba(10,14,26,.72));
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--border-soft);
}
.topbar .logo {
  width: 36px; height: 36px; border-radius: 11px;
  display: grid; place-items: center;
  background: linear-gradient(160deg, #2d5bff, #1c3fd6);
  color: #fff; font-weight: 800; font-size: 13px; letter-spacing: -.04em;
  box-shadow: 0 4px 14px rgba(43,91,255,.5), inset 0 1px 0 rgba(255,255,255,.18);
}
.topbar .titles { line-height: 1.1; flex: 1; min-width: 0; }
.topbar .titles h1 { font-size: 17px; }
.topbar .titles .sub { font-size: 11.5px; color: var(--text-faint); margin-top: 2px; }
.topbar .bell {
  position: relative;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center; font-size: 18px;
  background: var(--surface); border: 1px solid var(--border-soft);
}
.topbar .bell .dot {
  position: absolute; top: 7px; right: 8px;
  min-width: 16px; height: 16px; padding: 0 4px;
  border-radius: 9px; background: var(--red);
  font-size: 10px; font-weight: 800; color: #fff;
  display: grid; place-items: center; border: 2px solid var(--bg);
}

/* ---------- Main scroll area ---------- */
main {
  flex: 1;
  padding: 16px 16px calc(var(--nav-h) + 28px + env(safe-area-inset-bottom, 0px));
  animation: fade .26s ease;
}
@keyframes fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.view-head { margin: 2px 2px 14px; }
.view-head h2 { font-family: var(--font-display); font-size: 27px; font-weight: 600; letter-spacing: 0; }
.view-head p { margin: 5px 0 0; color: var(--text-dim); font-size: 13px; }

.section-title {
  display: flex; align-items: center; justify-content: space-between;
  margin: 22px 4px 10px; font-size: 13px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; color: var(--text-faint);
}
.section-title:first-child { margin-top: 4px; }

/* ---------- Cards ---------- */
.card {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}
.card.pad { padding: 16px; }
.card + .card { margin-top: 12px; }
.list .card { margin-bottom: 10px; }

.row {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
}
.row + .row { border-top: 1px solid var(--border-soft); }
.row .grow { flex: 1; min-width: 0; }
.row .title { font-weight: 650; font-size: 15px; }
.row .meta { color: var(--text-dim); font-size: 12.5px; margin-top: 3px; }
.row .truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.avatar {
  width: 42px; height: 42px; flex: none; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  background: linear-gradient(135deg, var(--surface-2), var(--surface-3));
  color: var(--text); border: 1px solid var(--border-soft);
}
.avatar.emoji { font-size: 20px; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stat {
  padding: 15px 16px; border-radius: var(--radius);
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border-soft); box-shadow: var(--shadow-sm);
  position: relative; overflow: hidden;
}
.stat .ic { font-size: 16px; opacity: .9; }
.stat .label { color: var(--text-dim); font-size: 12px; margin-top: 8px; font-weight: 600; }
.stat .value { font-size: 23px; font-weight: 800; letter-spacing: -.02em; margin-top: 3px; }
.stat .delta { font-size: 11.5px; margin-top: 4px; font-weight: 650; }
.stat .delta.up { color: var(--green); }
.stat .delta.down { color: var(--red); }
.stat.tap { cursor: pointer; transition: transform .12s ease; }
.stat.tap:active { transform: scale(.98); }

/* ---------- Badges / pills ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  font-size: 11.5px; font-weight: 700; letter-spacing: .01em;
  background: var(--surface-2); color: var(--text-dim);
  border: 1px solid var(--border-soft); white-space: nowrap;
}
.pill .dotc { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.green  { color: var(--green);  background: rgba(52,211,158,.12);  border-color: rgba(52,211,158,.25); }
.pill.amber  { color: var(--amber);  background: rgba(245,182,81,.12);  border-color: rgba(245,182,81,.25); }
.pill.red    { color: var(--red);    background: rgba(248,99,107,.13);  border-color: rgba(248,99,107,.26); }
.pill.blue   { color: var(--blue);   background: rgba(89,166,255,.12);  border-color: rgba(89,166,255,.25); }
.pill.purple { color: var(--purple); background: rgba(167,139,250,.13); border-color: rgba(167,139,250,.26); }
.pill.gray   { color: var(--text-faint); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 11px 16px; border-radius: 12px; font-weight: 700; font-size: 14px;
  background: var(--surface-2); color: var(--text); border: 1px solid var(--border);
  transition: transform .1s ease, background .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); border: none; color: #fff; box-shadow: 0 6px 18px rgba(43,91,255,.42); }
.btn.ghost { background: transparent; }
.btn.danger { background: rgba(248,99,107,.14); color: var(--red); border-color: rgba(248,99,107,.3); }
.btn.sm { padding: 7px 12px; font-size: 12.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-row .btn { flex: 1; }

.icon-btn {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: grid; place-items: center; font-size: 17px;
  background: var(--surface-2); border: 1px solid var(--border-soft); color: var(--text-dim);
}

/* Floating action button */
.fab {
  position: fixed;
  right: max(18px, calc((100vw - var(--max-w))/2 + 18px));
  bottom: calc(var(--nav-h) + 18px + env(safe-area-inset-bottom, 0px));
  width: 56px; height: 56px; border-radius: 18px;
  display: grid; place-items: center; font-size: 26px; color: #fff;
  background: linear-gradient(135deg, var(--brand), var(--brand-2));
  box-shadow: 0 10px 26px rgba(43,91,255,.55); z-index: 40;
  transition: transform .12s ease;
}
.fab:active { transform: scale(.92); }

/* ---------- Bottom navigation ---------- */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
  margin: 0 auto; max-width: var(--max-w);
  display: grid; grid-template-columns: repeat(8, 1fr);
  background: rgba(10,14,26,.88);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  border-top: 1px solid var(--border-soft);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}
.nav button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint); font-size: 9.5px; font-weight: 700;
  position: relative; padding: 6px 0;
}
.nav button .ni { font-size: 19px; line-height: 1; filter: grayscale(.4) opacity(.75); transition: .15s; }
.nav button.active { color: var(--text); }
.nav button.active .ni { filter: none; transform: translateY(-1px); }
.nav button.active::before {
  content: ""; position: absolute; top: 0; width: 22px; height: 3px; border-radius: 3px;
  background: linear-gradient(90deg, var(--brand), var(--brand-2));
}
.nav button .nb {
  position: absolute; top: 4px; right: calc(50% - 18px);
  min-width: 15px; height: 15px; padding: 0 3px; border-radius: 8px;
  background: var(--red); color: #fff; font-size: 9px; font-weight: 800;
  display: grid; place-items: center; border: 2px solid #0a0e1a;
}

/* ---------- Kanban (pipeline) ---------- */
.kanban { display: flex; gap: 12px; overflow-x: auto; padding: 2px 2px 8px; scroll-snap-type: x mandatory; }
.kanban::-webkit-scrollbar { height: 0; }
.kcol {
  flex: 0 0 78%; max-width: 300px; scroll-snap-align: start;
  background: var(--bg-2); border: 1px solid var(--border-soft);
  border-radius: var(--radius); padding: 10px;
}
.kcol h4 { font-size: 13px; display: flex; align-items: center; gap: 8px; padding: 4px 4px 10px; }
.kcol h4 .count { margin-left: auto; font-size: 11px; color: var(--text-faint); background: var(--surface-2); padding: 1px 8px; border-radius: 999px; }
.kcard {
  background: linear-gradient(180deg, var(--surface), var(--bg-2));
  border: 1px solid var(--border-soft); border-radius: 12px; padding: 11px 12px; margin-bottom: 9px;
}
.kcard:active { border-color: var(--brand); }
.kcard .knm { font-weight: 700; font-size: 14px; }
.kcard .kmeta { color: var(--text-dim); font-size: 12px; margin-top: 5px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.kcard .kval { font-weight: 800; color: var(--text); }

/* ---------- Checklist ---------- */
.check {
  display: flex; align-items: flex-start; gap: 12px; padding: 13px 16px;
}
.check + .check { border-top: 1px solid var(--border-soft); }
.check .box {
  width: 22px; height: 22px; flex: none; margin-top: 1px; border-radius: 7px;
  border: 2px solid var(--border); display: grid; place-items: center;
  font-size: 13px; color: transparent; transition: .12s;
}
.check.done .box { background: var(--green); border-color: var(--green); color: #07120d; }
.check.done .ctext { color: var(--text-faint); text-decoration: line-through; }
.check .ctext { font-size: 14.5px; line-height: 1.35; flex: 1; }
.check .csub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* progress bar */
.progress { height: 7px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--brand), var(--accent)); transition: width .4s ease; }

/* ---------- Tabs / segmented ---------- */
.seg { display: flex; gap: 6px; background: var(--bg-2); padding: 5px; border-radius: 13px; border: 1px solid var(--border-soft); }
.seg button { flex: 1; padding: 9px 6px; border-radius: 9px; font-weight: 700; font-size: 13px; color: var(--text-dim); }
.seg button.active { background: var(--surface-3); color: var(--text); box-shadow: var(--shadow-sm); }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px; margin-bottom: 4px; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 7px 13px; border-radius: 999px; font-size: 13px; font-weight: 650; background: var(--surface); border: 1px solid var(--border-soft); color: var(--text-dim); }
.chip.active { background: var(--surface-3); color: var(--text); border-color: var(--border); }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 24px; color: var(--text-faint); }
.empty .ei { font-size: 40px; }
.empty p { margin: 12px 0 0; font-size: 14px; }

/* ---------- Modal / sheet ---------- */
.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(5,7,14,.6);
  backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center;
  animation: fade .2s ease;
}
.sheet {
  width: 100%; max-width: var(--max-w);
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  max-height: 92vh; overflow-y: auto;
  padding: 8px 18px calc(24px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 40px rgba(0,0,0,.5);
  animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
}
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
.sheet .grip { width: 40px; height: 5px; border-radius: 3px; background: var(--surface-3); margin: 8px auto 14px; }
.sheet h3 { font-family: var(--font-display); font-weight: 600; font-size: 22px; margin-bottom: 4px; }
.sheet .sub { color: var(--text-dim); font-size: 13px; margin-bottom: 16px; }

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 7px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 12px 13px; border-radius: 12px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
  outline: none; transition: border .15s;
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--brand); }
.field textarea { resize: vertical; min-height: 78px; }
.field .two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* detail rows */
.kv { display: flex; justify-content: space-between; gap: 14px; padding: 11px 0; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--border-soft); }
.kv .k { color: var(--text-dim); }
.kv .v { font-weight: 650; text-align: right; }

/* ---------- Knowledge article ---------- */
.kb-body { font-size: 14.5px; line-height: 1.62; color: var(--text); }
.kb-body h3 { font-size: 16px; margin: 20px 0 8px; }
.kb-body h4 { font-size: 14px; margin: 16px 0 6px; color: var(--brand); }
.kb-body p { margin: 0 0 12px; color: var(--text-dim); }
.kb-body ul { margin: 0 0 12px; padding-left: 4px; }
.kb-body li { padding: 5px 0 5px 26px; position: relative; color: var(--text-dim); }
.kb-body li::before { content: "▹"; position: absolute; left: 6px; color: var(--brand); }
.kb-body strong { color: var(--text); }
.kb-body .callout { background: var(--surface); border: 1px solid var(--border-soft); border-left: 3px solid var(--brand); border-radius: 10px; padding: 12px 14px; margin: 0 0 14px; }
.kb-body table { width: 100%; border-collapse: collapse; margin: 0 0 14px; font-size: 13.5px; }
.kb-body th, .kb-body td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border-soft); }
.kb-body th { color: var(--text-faint); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; }

/* ---------- Toast ---------- */
.toast-wrap { position: fixed; left: 0; right: 0; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom,0px)); z-index: 80; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast {
  background: var(--surface-3); color: var(--text); border: 1px solid var(--border);
  padding: 11px 16px; border-radius: 12px; font-size: 13.5px; font-weight: 650;
  box-shadow: var(--shadow); display: flex; align-items: center; gap: 9px;
  animation: toastIn .3s ease; max-width: 90%;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
.toast.ok { border-color: rgba(52,211,158,.4); }
.toast.err { border-color: rgba(248,99,107,.4); }

/* misc helpers */
.muted { color: var(--text-faint); }
.right { text-align: right; }
.mono { font-variant-numeric: tabular-nums; }
.spacer { height: 8px; }
.hr { height: 1px; background: var(--border-soft); margin: 16px 0; border: 0; }
.flex { display: flex; align-items: center; gap: 10px; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wrap { flex-wrap: wrap; }
.tap { cursor: pointer; }
.tap:active { opacity: .7; }
.nowrap { white-space: nowrap; }
