/* GW CRM — base styles (Kommo-like light theme). Page scripts add their own blocks below the core. */
:root {
  --nav: 220px; --top: 52px;
  --bg: #f3f5f8; --panel: #fff; --line: #e3e7ee; --line2: #eef1f5;
  --text: #1f2a37; --muted: #6b7686; --faint: #9aa4b2;
  --primary: #2f6fde; --primary-d: #255bb8; --primary-l: #e8f0fd;
  --ok: #1f9d55; --warn: #d97706; --bad: #d63b3b;
  --nav-bg: #1d2533; --nav-text: #c9d1dc; --nav-active: #2c3647;
  --radius: 6px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
.boot { padding: 40px; color: var(--muted); }

/* layout */
.nav { position: fixed; left: 0; top: 0; bottom: 0; width: var(--nav); background: var(--nav-bg); color: var(--nav-text);
  display: flex; flex-direction: column; z-index: 3; }
.nav .brand { padding: 14px 18px; font-weight: 700; font-size: 17px; color: #fff; letter-spacing: .3px; }
.nav .brand small { display: block; font-weight: 400; font-size: 11px; color: var(--faint); }
.nav .acc { margin: 0 12px 10px; }
.nav .acc select { width: 100%; background: #2a3445; color: #fff; border: 1px solid #3a4558; border-radius: var(--radius); padding: 6px 8px; }
.nav a.item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; color: var(--nav-text); font-size: 14px; }
.nav a.item:hover { background: var(--nav-active); text-decoration: none; color: #fff; }
.nav a.item.on { background: var(--nav-active); color: #fff; box-shadow: inset 3px 0 0 var(--primary); }
.nav a.item.soon { opacity: .55; }
.nav a.item .ic { width: 20px; text-align: center; }
.nav .grow { flex: 1; }
.nav .foot { padding: 10px 14px; font-size: 12px; color: var(--faint); border-top: 1px solid #2a3445; }
.top { position: fixed; left: var(--nav); right: 0; top: 0; height: var(--top); background: var(--panel); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; padding: 0 20px; z-index: 2; }
.top h1 { font-size: 18px; font-weight: 600; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .who { color: var(--muted); font-size: 13px; white-space: nowrap; }
main { margin-left: var(--nav); padding: calc(var(--top) + 18px) 20px 40px; min-height: 100vh; }

/* language switcher */
.i18n-sw { display: inline-flex; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.i18n-sw button { border: 0; background: #fff; padding: 3px 8px; font-size: 12px; cursor: pointer; color: var(--muted); }
.i18n-sw button.on { background: var(--primary); color: #fff; }

/* controls */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border: 1px solid var(--line); border-radius: var(--radius);
  background: #fff; cursor: pointer; white-space: nowrap; }
.btn:hover { background: #f6f8fb; }
.btn.primary { background: var(--primary); border-color: var(--primary-d); color: #fff; }
.btn.primary:hover { background: var(--primary-d); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 3px 8px; font-size: 12px; }
.btn[disabled] { opacity: .5; cursor: default; }
input[type=text], input[type=password], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  border: 1px solid #cfd6df; border-radius: var(--radius); padding: 6px 9px; background: #fff; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary-l); border-color: var(--primary); }
label.chk { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
.panel > h2, .panel > .head { margin: 0; padding: 12px 14px; font-size: 15px; font-weight: 600; border-bottom: 1px solid var(--line2);
  display: flex; align-items: center; gap: 10px; }
.panel > .body { padding: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 12px; }
.sp { flex: 1; }
.tag { display: inline-block; padding: 1px 8px; border-radius: 10px; font-size: 12px; background: #eef1f5; color: #3b4656; margin: 1px 2px; }
.badge { display: inline-block; padding: 0 7px; border-radius: 9px; font-size: 11px; background: #eef1f5; color: var(--muted); }
.badge.ok { background: #e3f6ea; color: var(--ok); }
.badge.bad { background: #fde8e8; color: var(--bad); }
.badge.warn { background: #fdf2e1; color: var(--warn); }
.badge.blue { background: var(--primary-l); color: var(--primary); }

table.t { width: 100%; border-collapse: collapse; }
table.t th { text-align: left; font-weight: 500; color: var(--muted); font-size: 12px; padding: 8px 10px; border-bottom: 1px solid var(--line); background: #fafbfc; }
table.t td { padding: 7px 10px; border-bottom: 1px solid var(--line2); vertical-align: top; }
table.t tr:hover td { background: #fafcff; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 8px 14px; cursor: pointer; color: var(--muted); border-bottom: 2px solid transparent; }
.tabs button.on { color: var(--text); border-bottom-color: var(--primary); font-weight: 600; }

.empty { padding: 30px; text-align: center; color: var(--muted); }
.err { color: var(--bad); }
.note { padding: 10px 12px; border-radius: var(--radius); background: var(--primary-l); color: #22446f; }
.note.warn { background: #fdf2e1; color: #7a4a06; }
.note.bad { background: #fde8e8; color: #8a1f1f; }

/* toast + modal */
.toast { position: fixed; right: 18px; bottom: 18px; background: #1f2a37; color: #fff; padding: 10px 14px; border-radius: var(--radius);
  box-shadow: 0 6px 20px rgba(0,0,0,.2); z-index: 50; max-width: 420px; }
.toast.bad { background: var(--bad); }
.modal-bg { position: fixed; inset: 0; background: rgba(15, 23, 35, .45); display: flex; align-items: flex-start; justify-content: center;
  padding: 60px 16px; z-index: 40; overflow: auto; }
.modal { background: #fff; border-radius: 8px; width: min(560px, 100%); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(1000px, 100%); }
.modal > h3 { margin: 0; padding: 14px 16px; border-bottom: 1px solid var(--line2); font-size: 16px; }
.modal > .body { padding: 16px; }
.modal > .foot { padding: 12px 16px; border-top: 1px solid var(--line2); display: flex; gap: 8px; justify-content: flex-end; }
.form { display: grid; grid-template-columns: 150px 1fr; gap: 10px 12px; align-items: center; }
.form > label { color: var(--muted); font-size: 13px; }
.form input, .form select, .form textarea { width: 100%; }

/* login */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login { width: min(380px, 100%); background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 26px; box-shadow: 0 10px 30px rgba(0,0,0,.06); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login .muted { margin-bottom: 18px; }
.login input[type=text], .login input[type=password] { width: 100%; margin-bottom: 10px; padding: 9px 11px; }
.login .btn.primary { width: 100%; justify-content: center; padding: 9px; margin-top: 6px; }
.login .alt { margin-top: 16px; font-size: 13px; color: var(--muted); text-align: center; }

/* stage bar (pipelines) */
.stages { display: flex; gap: 3px; flex-wrap: wrap; }
.stage { padding: 3px 10px; border-radius: 4px; font-size: 12px; color: #1f2a37; border: 1px solid rgba(0,0,0,.06); }
.stage.won { outline: 2px solid var(--ok); }
.stage.lost { outline: 2px solid var(--bad); }
.stage.unsorted { font-style: italic; }

@media (max-width: 760px) {
  :root { --nav: 0px; }
  .nav { display: none; }
  .nav.open { display: flex; width: 240px; }
  .top .menu { display: inline-flex !important; }
  .form { grid-template-columns: 1fr; }
}
.top .menu { display: none; }

/* ---- lead card ---- */
.card-wrap { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(320px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .card-wrap { grid-template-columns: 1fr; } }
.card .card-head { padding: 12px 14px; border-bottom: 1px solid var(--line2); }
.card .lead-name { width: 100%; font-size: 20px; font-weight: 600; border: 1px solid transparent; padding: 4px 6px; margin-top: 6px; }
.card .lead-name:hover, .card .lead-name:focus { border-color: #cfd6df; }
.card .tags { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; margin-top: 6px; }
.card .tags input { border: 1px dashed #cfd6df; padding: 2px 8px; font-size: 12px; width: 120px; border-radius: 10px; }
.card .tags a { color: var(--muted); text-decoration: none; }
.stagebar { display: flex; gap: 2px; margin-top: 8px; flex-wrap: wrap; }
.stagebar .st { border: 0; padding: 6px 10px; font-size: 12px; cursor: pointer; background: #eef1f5; color: #4b5563; border-radius: 3px; max-width: 170px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-bottom: 3px solid var(--c); }
.stagebar .st.on { background: var(--c); color: #111; font-weight: 600; }
.stagebar .st.won.on { box-shadow: inset 0 0 0 2px var(--ok); }
.stagebar .st.lost.on { box-shadow: inset 0 0 0 2px var(--bad); }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 12px; margin-top: 8px; }
.card .fr { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 4px 10px; padding: 4px 0; align-items: start; }
.card .grid3 .fr { grid-template-columns: 1fr; }
.card .fr > label { color: var(--muted); font-size: 13px; padding-top: 6px; }
.card .fr .req { color: var(--bad); margin-left: 2px; display: none; }
.card .fr.need .req { display: inline; }
.card .fr.off { display: none; }
.card .fr input[type=text], .card .fr input[type=email], .card .fr input[type=date], .card .fr input[type=datetime-local], .card .fr select, .card .fr textarea { width: 100%; }
.card .ferr { color: var(--bad); font-size: 12px; }
.card .tabbody { padding: 4px 14px 14px; }
.card h4 { margin: 14px 0 4px; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); }
.card .tabs button.bad { color: var(--bad); }
.card .tabs button.bad::after { content: " !"; }
.card .card-foot { position: sticky; bottom: 0; background: #fff; border-top: 1px solid var(--line2); padding: 10px 14px; display: flex; gap: 8px; align-items: center; border-radius: 0 0 var(--radius) var(--radius); }
details.ms { border: 1px solid #cfd6df; border-radius: var(--radius); padding: 5px 9px; background: #fff; }
details.ms summary { cursor: pointer; }
details.ms label { display: flex; margin: 3px 0; }
.mt .mt-row { margin-bottom: 4px; flex-wrap: nowrap; }
.mt .mt-row select { width: 120px !important; flex: none; }
.feed { position: sticky; top: calc(var(--top) + 18px); display: flex; flex-direction: column; max-height: calc(100vh - var(--top) - 36px); }
.feed .feed-head { padding: 8px 12px 0; border-bottom: 1px solid var(--line2); }
.feed .feed-head .tabs { margin: 0; border: 0; }
.feed .feed-head .tabs button { padding: 6px 8px; font-size: 13px; }
.feed .compose { padding: 8px 0; }
.feed .feed-list { overflow: auto; padding: 10px 12px; flex: 1; }
.fi { border: 1px solid var(--line2); border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; background: #fff; }
.fi .ic { margin-right: 6px; }
.fi .txt { white-space: pre-wrap; margin-top: 4px; }
.fi .acts { margin-top: 6px; display: none; }
.fi:hover .acts { display: block; }
.fi.k-task { border-left: 3px solid var(--primary); }
.fi.k-call { border-left: 3px solid #8b5cf6; }
.fi.k-meeting { border-left: 3px solid #0ea5e9; }
.fi.closed { opacity: .65; }
.fi img.thumb { max-width: 120px; max-height: 90px; border-radius: 4px; vertical-align: middle; margin-right: 8px; }

/* ---- leads views: filter panel, list, board, dashboard ---- */
.views { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 14px; align-items: start; }
@media (max-width: 900px) { .views { grid-template-columns: 1fr; } }
.fpanel { padding: 10px; position: sticky; top: calc(var(--top) + 18px); max-height: calc(100vh - var(--top) - 36px); overflow: auto; font-size: 13px; }
.fpanel .fq { width: 100%; margin-bottom: 8px; }
.fpanel .presets a, .fpanel .periods a, .dctl a.pr { display: flex; justify-content: space-between; padding: 3px 6px; border-radius: 4px; color: var(--text); text-decoration: none; }
.dctl a.pr { display: inline-block; border: 1px solid var(--line); background: #fff; }
.fpanel .presets a:hover, .fpanel .periods a:hover { background: #f1f4f8; }
.fpanel a.pr.on, .dctl a.pr.on { background: var(--primary-l); color: var(--primary); font-weight: 600; }
.fpanel .cnt { color: var(--muted); font-size: 12px; }
.fpanel .cnt.z { color: var(--faint); }
.fpanel .fsec { border-top: 1px solid var(--line2); padding: 6px 0; }
.fpanel .fsec summary { cursor: pointer; font-weight: 600; color: #374151; }
.fpanel .fsec > div { padding: 6px 0 2px; display: flex; flex-direction: column; gap: 3px; }
.fpanel .fsec select, .fpanel .addcf { width: 100%; }
.fpanel label.chk { justify-content: flex-start; }
.fpanel .taglist { max-height: 220px; overflow: auto; display: flex; flex-direction: column; gap: 2px; }
.fpanel .saved { margin: 6px 0; padding: 6px 0; border-top: 1px solid var(--line2); }
.fpanel .clear { display: block; margin-top: 10px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 5px; vertical-align: middle; }
.vtop { margin-bottom: 8px; }
.vtop a.vt { padding: 6px 12px; border-radius: var(--radius); color: var(--muted); text-decoration: none; border: 1px solid transparent; }
.vtop a.vt.on { background: #fff; border-color: var(--line); color: var(--text); font-weight: 600; }
.chips { margin-bottom: 8px; display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: var(--primary-l); color: var(--primary); padding: 2px 9px; border-radius: 12px; font-size: 12px; text-decoration: none; }
.bulk { background: #fff8e6; border: 1px solid #f3d58b; border-radius: var(--radius); padding: 8px 10px; margin-bottom: 8px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
table.lt tr.selr td { background: #eef5ff; }
.colpick { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px 12px; max-height: 60vh; overflow: auto; }
.board { display: flex; gap: 10px; overflow-x: auto; padding-bottom: 10px; align-items: flex-start; }
.bcol { flex: 0 0 240px; background: #eef1f5; border-radius: var(--radius); padding: 6px; min-height: 200px; }
.bcol.narrow { flex-basis: 170px; }
.bcol.nopipe { background: #f6f1e7; }
.bcol.over { outline: 2px dashed var(--primary); }
.bcol .bhead { background: #fff; border-top: 4px solid; border-radius: 4px; padding: 6px 8px; margin-bottom: 6px; }
.bcol .qadd { display: block; margin: 0 2px 6px; }
.bcard { background: #fff; border: 1px solid var(--line); border-radius: 5px; padding: 7px 8px; margin-bottom: 6px; cursor: grab; }
.bcard.drag { opacity: .5; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; margin-bottom: 14px; }
.tile { padding: 12px 14px; }
.tile .big { font-size: 26px; font-weight: 600; margin: 4px 0; }
.tile .big a { color: var(--text); }
.ok { color: var(--ok); }
.dctl { gap: 4px; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.bars .bar { flex: 1; display: flex; align-items: flex-end; gap: 1px; height: 100%; }
.bars .bar i { flex: 1; display: block; min-height: 1px; }
.bars i.n, .lg.n { background: #5b8def; }
.bars i.w, .lg.w { background: #1f9d55; }
.bars i.l, .lg.l { background: #d63b3b; }
.lg { display: inline-block; width: 10px; height: 10px; margin: 0 4px 0 10px; vertical-align: middle; }

/* ---- contact / company record page (Dynamics style) ---- */
.av { display: inline-flex; align-items: center; justify-content: center; border-radius: 50%; background: #6b8fd6; color: #fff; font-weight: 600; flex: none; }
.av.co { background: #8b6fd6; border-radius: 8px; }
.av.sm { width: 26px; height: 26px; font-size: 11px; margin-right: 8px; vertical-align: middle; }
.av.lg { width: 56px; height: 56px; font-size: 20px; }
.dyn-head { display: flex; gap: 14px; align-items: center; padding: 14px 16px; margin-bottom: 14px; }
.dyn-title { font-size: 22px; font-weight: 600; }
.dyn { display: grid; grid-template-columns: minmax(0, 1fr) minmax(360px, 1fr); gap: 14px; align-items: start; }
@media (max-width: 1100px) { .dyn { grid-template-columns: 1fr; } }
.dyn-side { position: sticky; top: calc(var(--top) + 18px); max-height: calc(100vh - var(--top) - 36px); display: flex; flex-direction: column; }
.dyn-side .side-body { overflow: auto; padding: 10px 12px; }
.dyn-side h4 { margin: 10px 0 4px; font-size: 12px; text-transform: uppercase; color: var(--muted); }
.tl { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line2); }
.tl-ic { width: 30px; height: 30px; border-radius: 50%; background: #eef1f5; display: flex; align-items: center; justify-content: center; flex: none; }
.tl.k-task .tl-ic { background: var(--primary-l); }
.tl.k-email .tl-ic { background: #fdf2e1; }
.tl.k-call .tl-ic { background: #efe9fd; }
.tl-b { flex: 1; min-width: 0; }
.tl-s { font-weight: 600; margin-top: 2px; }
.tl .txt { white-space: pre-wrap; margin-top: 4px; }
.tl .acts { display: none; margin-top: 4px; }
.tl:hover .acts { display: block; }
