/* ================================================================ tokens — red & white */
:root {
  color-scheme: light;
  --bg: #f7f7f8;
  --panel: #ffffff;
  --panel-2: #fafafa;
  --ink: #2b2b2e;          /* light black */
  --ink-2: #4a4a50;
  --muted: #84848c;
  --line: #ececee;
  --line-2: #dcdce0;
  --hover: #f4f4f5;
  --input: #ffffff;

  --red: #dc2638;
  --red-2: #b81d2e;
  --red-soft: #fdeef0;
  --red-soft-2: #fbdde1;
  --red-ink: #b31b2c;
  --on-red: #ffffff;
  --danger: #dc2638;
  --danger-soft: #fdeef0;

  --sidebar-bg: linear-gradient(180deg, #e0283b 0%, #c41e30 55%, #a8182a 100%);
  --sidebar-ink: rgba(255, 255, 255, .82);
  --sidebar-hover: rgba(255, 255, 255, .12);
  --sidebar-active-bg: #ffffff;
  --sidebar-active-ink: #c41e30;
  --sidebar-line: rgba(255, 255, 255, .18);

  /* service states */
  --none-bg: #fff3f4;    --none-bd: #f7cfd4;    --none-ink: #b31b2c;    --none-dot: #f0848f;
  --active-bg: #effaf3;  --active-bd: #b5e4c6;  --active-ink: #17773f;  --active-dot: #22a55a;
  --stopped-bg: #fff9e6; --stopped-bd: #f1d98a; --stopped-ink: #8a6100; --stopped-dot: #e5b000;

  --gold: #b7791f;
  --gold-soft: #fdf3dc;

  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(30, 20, 22, .04), 0 4px 16px rgba(30, 20, 22, .04);
  --shadow-lg: 0 12px 32px rgba(30, 20, 22, .14);
  --ring: 0 0 0 3px rgba(220, 38, 56, .18);
  --side-w: 248px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #111113; --panel: #1a1a1d; --panel-2: #1f1f23; --ink: #ececef; --ink-2: #c4c4ca; --muted: #8b8b94;
    --line: #2a2a2f; --line-2: #36363c; --hover: #232328; --input: #151517;
    --red: #f0475a; --red-2: #dc2638; --red-soft: #33171b; --red-soft-2: #44191f; --red-ink: #ff9aa5; --on-red: #ffffff;
    --danger: #f0475a; --danger-soft: #33171b;
    --sidebar-bg: linear-gradient(180deg, #1c1214 0%, #160e10 100%);
    --sidebar-ink: rgba(255, 255, 255, .72); --sidebar-hover: rgba(255, 255, 255, .06);
    --sidebar-active-bg: #dc2638; --sidebar-active-ink: #ffffff; --sidebar-line: rgba(255, 255, 255, .08);
    --none-bg: #2c1719; --none-bd: #5c2a2e; --none-ink: #fca5a5; --none-dot: #e06565;
    --active-bg: #10281c; --active-bd: #245c3b; --active-ink: #86efac; --active-dot: #34c46f;
    --stopped-bg: #2b2412; --stopped-bd: #62501c; --stopped-ink: #fcd34d; --stopped-dot: #eab308;
    --gold: #f5c35b; --gold-soft: #2e2613;
    --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
    --ring: 0 0 0 3px rgba(240, 71, 90, .28);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #111113; --panel: #1a1a1d; --panel-2: #1f1f23; --ink: #ececef; --ink-2: #c4c4ca; --muted: #8b8b94;
  --line: #2a2a2f; --line-2: #36363c; --hover: #232328; --input: #151517;
  --red: #f0475a; --red-2: #dc2638; --red-soft: #33171b; --red-soft-2: #44191f; --red-ink: #ff9aa5; --on-red: #ffffff;
  --danger: #f0475a; --danger-soft: #33171b;
  --sidebar-bg: linear-gradient(180deg, #1c1214 0%, #160e10 100%);
  --sidebar-ink: rgba(255, 255, 255, .72); --sidebar-hover: rgba(255, 255, 255, .06);
  --sidebar-active-bg: #dc2638; --sidebar-active-ink: #ffffff; --sidebar-line: rgba(255, 255, 255, .08);
  --none-bg: #2c1719; --none-bd: #5c2a2e; --none-ink: #fca5a5; --none-dot: #e06565;
  --active-bg: #10281c; --active-bd: #245c3b; --active-ink: #86efac; --active-dot: #34c46f;
  --stopped-bg: #2b2412; --stopped-bd: #62501c; --stopped-ink: #fcd34d; --stopped-dot: #eab308;
  --gold: #f5c35b; --gold-soft: #2e2613;
  --shadow: 0 1px 2px rgba(0, 0, 0, .35); --shadow-lg: 0 12px 32px rgba(0, 0, 0, .55);
  --ring: 0 0 0 3px rgba(240, 71, 90, .28);
}

/* ================================================================ base */
* { box-sizing: border-box; }
html { font-family: "Plus Jakarta Sans", Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; font-size: 14px; color: var(--ink); -webkit-font-smoothing: antialiased; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
a { color: var(--red); text-decoration: none; }
a:hover { color: var(--red-2); }
h1 { font-size: 24px; font-weight: 750; letter-spacing: -.02em; margin: 0; color: var(--ink); }
h2 { font-size: 15.5px; font-weight: 700; margin: 0; color: var(--ink); }
h3 { font-size: 14px; font-weight: 650; margin: 0; color: var(--ink); }
b { font-weight: 700; }
.ic { width: 18px; height: 18px; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ic.sm { width: 15px; height: 15px; }
.ic.xs { width: 13px; height: 13px; }
.ic.lg { width: 22px; height: 22px; }
.tnum { font-variant-numeric: tabular-nums; }
::selection { background: var(--red-soft-2); }

/* ================================================================ sidebar (red) */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--side-w); background: var(--sidebar-bg); color: #fff;
  display: flex; flex-direction: column; padding: 22px 16px 18px; gap: 26px; z-index: 30;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; padding: 0 6px; }
.brand:hover { color: #fff; }
.brand-mark { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: #dc2638; box-shadow: 0 6px 16px rgba(0, 0, 0, .18); }
.brand-text { display: flex; flex-direction: column; font-weight: 800; font-size: 17px; letter-spacing: -.01em; line-height: 1.15; }
.brand-text small { font-size: 11.5px; font-weight: 500; color: rgba(255, 255, 255, .7); letter-spacing: 0; margin-top: 2px; }
.sidebar nav { display: flex; flex-direction: column; gap: 4px; }
.sidebar nav .nav-label { font-size: 10.5px; font-weight: 700; color: rgba(255, 255, 255, .55); text-transform: uppercase; letter-spacing: .1em; padding: 0 12px 8px; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; color: var(--sidebar-ink); padding: 10px 14px; border-radius: 11px; font-weight: 550; transition: background .12s, color .12s; }
.sidebar nav a:hover { background: var(--sidebar-hover); color: #fff; }
.sidebar nav a.active { background: var(--sidebar-active-bg); color: var(--sidebar-active-ink); font-weight: 700; box-shadow: 0 4px 14px rgba(0, 0, 0, .14); }
.sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 12px; padding-top: 16px; border-top: 1px solid var(--sidebar-line); }
.theme-switch { display: grid; grid-template-columns: repeat(3, 1fr); background: rgba(0, 0, 0, .16); border-radius: 11px; padding: 3px; gap: 2px; }
.theme-switch button { border: 0; background: transparent; color: rgba(255, 255, 255, .75); padding: 7px 0; border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.theme-switch button:hover { color: #fff; }
.theme-switch button[aria-checked="true"] { background: #fff; color: #c41e30; }

/* ================================================================ app shell */
.app { margin-left: var(--side-w); min-height: 100vh; display: flex; flex-direction: column; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: 66px; display: flex; align-items: center; gap: 16px;
  padding: 0 32px; background: color-mix(in srgb, var(--panel) 92%, transparent); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.crumb { display: flex; align-items: center; gap: 8px; font-size: 13.5px; color: var(--muted); font-weight: 550; min-width: 0; white-space: nowrap; }
.crumb b { color: var(--ink); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.crumb .ic { color: var(--red); }
.top-search { margin-left: auto; position: relative; width: min(340px, 40vw); }
.top-search .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.top-search input { padding-left: 38px; background: var(--hover); border-color: transparent; border-radius: 999px; height: 40px; }
.top-search input:focus { background: var(--input); }
.topbar .btn.primary { border-radius: 999px; padding: 9px 18px; height: 40px; }

main { flex: 1; width: 100%; max-width: 1360px; padding: 28px 32px 110px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 24px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 6px; font-size: 13.5px; }
.head-left { display: flex; align-items: center; gap: 16px; min-width: 0; }

/* ================================================================ cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 22px; overflow: hidden; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 22px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.card-title { display: flex; align-items: center; gap: 14px; }
.card-title .hint { margin-top: 3px; }
.sec-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); flex-shrink: 0; }
.sec-icon.green, .sec-icon.amber, .sec-icon.gold { background: var(--red-soft); color: var(--red); }
.stat .sec-icon.gold { background: var(--gold-soft); color: var(--gold); }
.stat .sec-icon.green { background: var(--active-bg); color: var(--active-ink); }
.sec-num { font-size: 10.5px; font-weight: 750; color: var(--red); text-transform: uppercase; letter-spacing: .1em; margin-bottom: 1px; }
.card-body { padding: 20px 22px; }
.card-foot { padding: 13px 22px; border-top: 1px solid var(--line); background: var(--panel-2); }
.hint { color: var(--muted); font-size: 12.5px; }

/* ================================================================ forms */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px 20px; }
.field { display: flex; flex-direction: column; gap: 7px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field > label, .label { display: flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 650; color: var(--ink-2); }
.field > label .ic, .label .ic { color: var(--red); opacity: .85; }
.input-wrap { position: relative; }
.input-wrap > .ic { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; transition: color .12s; }
.input-wrap > input, table.edit .input-wrap > input { padding-left: 38px; }
.input-wrap:focus-within > .ic { color: var(--red); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--input); border: 1px solid var(--line-2);
  border-radius: var(--radius-sm); padding: 10px 12px; width: 100%; transition: border-color .12s, box-shadow .12s, background .12s;
}
input::placeholder, textarea::placeholder { color: var(--muted); opacity: .7; }
input:hover, select:hover, textarea:hover { border-color: #c4c4ca; }
input:focus, select:focus, textarea:focus { outline: 0; border-color: var(--red); box-shadow: var(--ring); }
textarea { resize: vertical; min-height: 80px; }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--red); }
input[type=number] { font-variant-numeric: tabular-nums; }
select { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2384848c' stroke-width='2.5' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }

.btn {
  font: inherit; font-weight: 650; font-size: 13.5px; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink);
  padding: 9px 16px; border-radius: var(--radius-sm); cursor: pointer; display: inline-flex; align-items: center; gap: 8px;
  transition: background .12s, border-color .12s, transform .05s, box-shadow .12s; white-space: nowrap;
}
.btn:hover { background: var(--hover); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--red); border-color: var(--red); color: var(--on-red); box-shadow: 0 4px 14px rgba(220, 38, 56, .28); }
.btn.primary:hover { background: var(--red-2); border-color: var(--red-2); color: var(--on-red); }
.btn.danger { color: var(--danger); border-color: var(--red-soft-2); }
.btn.danger:hover { background: var(--danger-soft); border-color: var(--danger); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 6px 12px; font-size: 12.5px; }
.card-head .btn.small, .btn.small:not(.primary) { color: var(--red); border-color: var(--red-soft-2); background: var(--red-soft); }
.card-head .btn.small:hover, .btn.small:not(.primary):hover { background: var(--red-soft-2); }
.icon-btn { border: 0; background: transparent; cursor: pointer; color: var(--muted); padding: 7px; border-radius: 9px; line-height: 0; transition: background .12s, color .12s; }
.icon-btn:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .3; cursor: default; background: transparent; }

/* switch */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding: 8px 0; font-weight: 600; color: var(--ink-2); }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch .track { width: 42px; height: 24px; border-radius: 12px; background: var(--line-2); position: relative; transition: background .15s; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); }
.switch input:checked + .track { background: var(--red); }
.switch input:checked + .track::after { left: 21px; }
.switch input:focus-visible + .track { box-shadow: var(--ring); }

/* chips */
.chip-input { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; border: 1px solid var(--line-2); border-radius: var(--radius-sm); padding: 6px 8px; background: var(--input); position: relative; min-height: 44px; }
.chip-input:focus-within { border-color: var(--red); box-shadow: var(--ring); }
.chip-input > .ic { color: var(--muted); margin: 0 2px 0 4px; }
.chip-input input { border: 0; outline: 0; padding: 4px; flex: 1; min-width: 140px; background: transparent; box-shadow: none; }
.chip { display: inline-flex; align-items: center; gap: 5px; background: var(--red-soft); color: var(--red-ink); border-radius: 999px; padding: 4px 6px 4px 11px; font-size: 12px; font-weight: 650; white-space: nowrap; }
.chip.interest { background: var(--hover); color: var(--ink-2); border: 1px solid var(--line-2); }
.chip.static { padding: 3px 10px; }
.chip button { border: 0; background: transparent; cursor: pointer; color: inherit; line-height: 0; padding: 2px; border-radius: 50%; opacity: .6; }
.chip button:hover { opacity: 1; background: rgba(0, 0, 0, .08); }
.suggest { position: absolute; left: 0; right: 0; top: calc(100% + 4px); background: var(--panel); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-lg); z-index: 30; max-height: 240px; overflow: auto; padding: 5px; }
.suggest div { padding: 8px 10px; cursor: pointer; border-radius: 8px; display: flex; align-items: center; gap: 8px; color: var(--ink-2); }
.suggest div.on, .suggest div:hover { background: var(--red-soft); color: var(--red-ink); }
.suggest .new { color: var(--red); font-weight: 650; }

/* contacts */
.rows { display: flex; flex-direction: column; gap: 8px; }
.row.contact { display: grid; grid-template-columns: 150px 1fr 1fr 36px; gap: 8px; align-items: center; }
.empty-inline { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ================================================================ services */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; }
.svc { display: flex; align-items: center; gap: 12px; padding: 13px 13px 13px 15px; border-radius: 14px; border: 1.5px solid; transition: background .15s, border-color .15s, transform .1s, box-shadow .15s; }
.svc:hover { transform: translateY(-1px); box-shadow: var(--shadow); }
.svc.none    { background: var(--none-bg);    border-color: var(--none-bd);    color: var(--none-ink); }
.svc.active  { background: var(--active-bg);  border-color: var(--active-bd);  color: var(--active-ink); }
.svc.stopped { background: var(--stopped-bg); border-color: var(--stopped-bd); color: var(--stopped-ink); }
.svc-icon { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--panel); border: 1px solid currentColor; flex-shrink: 0; }
.svc label { display: flex; align-items: center; gap: 12px; cursor: pointer; flex: 1; min-width: 0; }
.svc .svc-name { font-weight: 700; color: var(--ink); display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.svc .state { display: inline-flex; align-items: center; gap: 5px; font-size: 10.5px; font-weight: 750; text-transform: uppercase; letter-spacing: .06em; margin-top: 3px; }
.svc input[type=checkbox] { position: absolute; opacity: 0; pointer-events: none; }
.svc .box { width: 20px; height: 20px; border-radius: 6px; border: 2px solid currentColor; display: grid; place-items: center; flex-shrink: 0; background: var(--panel); }
.svc .box .ic { opacity: 0; }
.svc input:checked ~ .box { background: currentColor; }
.svc input:checked ~ .box .ic { opacity: 1; color: var(--panel); }
.svc input:focus-visible ~ .box { box-shadow: var(--ring); }
.svc .act { border: 1.5px solid currentColor; background: var(--panel); color: inherit; border-radius: 10px; width: 36px; height: 36px; display: grid; place-items: center; cursor: pointer; flex-shrink: 0; transition: background .12s; }
.svc .act:hover { background: currentColor; }
.svc .act:hover .ic { color: var(--panel); }
.svc-legend { display: flex; gap: 18px; margin-top: 16px; flex-wrap: wrap; }
.svc-legend span { display: inline-flex; align-items: center; gap: 6px; }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dot.none { background: var(--none-dot); }
.dot.active { background: var(--active-dot); }
.dot.stopped { background: var(--stopped-dot); }
.svc-dots { display: flex; gap: 5px; }
.svc-mini { width: 27px; height: 27px; border-radius: 8px; display: grid; place-items: center; border: 1px solid; }
.svc-mini.none { background: var(--none-bg); border-color: var(--none-bd); color: var(--none-ink); opacity: .7; }
.svc-mini.active { background: var(--active-bg); border-color: var(--active-bd); color: var(--active-ink); }
.svc-mini.stopped { background: var(--stopped-bg); border-color: var(--stopped-bd); color: var(--stopped-ink); }
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 999px; border: 1px solid; white-space: nowrap; }
.pill.none    { background: var(--none-bg);    border-color: var(--none-bd);    color: var(--none-ink); }
.pill.active  { background: var(--active-bg);  border-color: var(--active-bd);  color: var(--active-ink); }
.pill.stopped { background: var(--stopped-bg); border-color: var(--stopped-bd); color: var(--stopped-ink); }
.history { margin-top: 20px; padding-top: 16px; border-top: 1px dashed var(--line-2); }
.timeline { display: flex; flex-direction: column; max-height: 190px; overflow: auto; margin-top: 8px; }
.timeline div { display: flex; align-items: center; gap: 10px; font-size: 12.5px; color: var(--ink-2); padding: 6px 0; border-bottom: 1px solid var(--line); }
.timeline div:last-child { border-bottom: 0; }
.timeline time { color: var(--muted); font-variant-numeric: tabular-nums; min-width: 132px; }

/* ================================================================ tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); font-weight: 700; padding: 12px 16px; border-bottom: 1px solid var(--line); white-space: nowrap; background: var(--panel-2); }
td { padding: 14px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; color: var(--ink-2); }
td b { color: var(--ink); }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.link { cursor: pointer; transition: background .1s; }
tbody tr.link:hover { background: var(--red-soft); }
tbody tr.link:hover td:first-child { box-shadow: inset 3px 0 0 var(--red); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.edit td { padding: 8px 6px; }
table.edit td:first-child { padding-left: 16px; }
table.edit input { padding: 8px 10px; }
tfoot td { background: var(--panel-2); font-weight: 700; color: var(--ink); }
.empty { color: var(--muted); padding: 40px 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 12px; }
.empty .sec-icon { width: 52px; height: 52px; border-radius: 16px; }
.lead-cell { display: flex; align-items: center; gap: 12px; min-width: 200px; }
.lead-cell b { font-weight: 700; color: var(--ink); }
.avatar {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center; flex-shrink: 0;
  font-weight: 750; font-size: 13px; letter-spacing: .02em; background: var(--red-soft); color: var(--red); border: 1px solid var(--red-soft-2);
}
.avatar.lg { width: 60px; height: 60px; font-size: 21px; border-radius: 18px; background: var(--red); color: #fff; border: 0; box-shadow: 0 8px 20px rgba(220, 38, 56, .3); }
.hni { display: inline-flex; align-items: center; gap: 3px; background: var(--gold-soft); color: var(--gold); font-size: 10.5px; font-weight: 800; padding: 2px 7px; border-radius: 6px; letter-spacing: .05em; margin-left: 8px; vertical-align: 2px; }
.rank { width: 30px; height: 30px; border-radius: 10px; background: var(--hover); color: var(--ink-2); display: inline-grid; place-items: center; font-weight: 750; font-size: 12.5px; }
.rank.r1 { background: var(--red); color: #fff; box-shadow: 0 4px 10px rgba(220, 38, 56, .3); }
.rank.r2 { background: var(--red-soft-2); color: var(--red-ink); }
.rank.r3 { background: var(--red-soft); color: var(--red-ink); }
.sub-line { color: var(--muted); font-size: 12px; margin-top: 3px; display: flex; align-items: center; gap: 4px; }
.meta-line { display: inline-flex; align-items: center; gap: 6px; color: var(--ink-2); white-space: nowrap; }
.meta-line .ic { color: var(--muted); }
.score-bar { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }
.score-bar .bar { width: 52px; height: 6px; border-radius: 3px; background: var(--hover); overflow: hidden; }
.score-bar .bar i { display: block; height: 100%; background: linear-gradient(90deg, #f07784, var(--red)); border-radius: 3px; }
.score-bar b { color: var(--red-ink); }
@media (max-width: 1500px) { .score-bar .bar { display: none; } }

/* ================================================================ investments */
.inv { border: 1px solid var(--line); border-radius: 14px; margin-bottom: 10px; transition: border-color .15s, background .15s; overflow: hidden; }
.inv-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.inv-head label { display: flex; align-items: center; gap: 12px; font-weight: 650; cursor: pointer; flex: 1; color: var(--ink); }
.inv-head input[type=checkbox] { width: 18px; height: 18px; }
.inv-head .inv-icon { width: 38px; height: 38px; border-radius: 11px; display: grid; place-items: center; background: var(--hover); color: var(--muted); transition: all .15s; }
.inv-head .val { font-variant-numeric: tabular-nums; font-weight: 750; font-size: 15px; color: var(--red-ink); }
.inv:hover { border-color: var(--line-2); }
.inv.on { border-color: var(--red-soft-2); background: color-mix(in srgb, var(--red-soft) 40%, var(--panel)); }
.inv.on .inv-icon { background: var(--red); color: #fff; }
.inv-body { padding: 4px 16px 18px; display: none; }
.inv.on .inv-body { display: block; }
.inv-fields { display: grid; grid-template-columns: 260px 1fr; gap: 12px; margin-bottom: 12px; }
.inv-table { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--panel); }
.tag-soft { font-size: 11px; font-weight: 700; background: var(--red-soft); color: var(--red-ink); padding: 2px 9px; border-radius: 999px; }

/* ================================================================ dashboard */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); display: flex; gap: 14px; align-items: center; position: relative; overflow: hidden; }
.stat:first-child { background: var(--red); border-color: var(--red); color: #fff; box-shadow: 0 10px 24px rgba(220, 38, 56, .25); }
.stat:first-child .k { color: rgba(255, 255, 255, .8); }
.stat:first-child .v { color: #fff; }
.stat:first-child .sec-icon { background: rgba(255, 255, 255, .18); color: #fff; }
.stat .k { font-size: 12.5px; color: var(--muted); font-weight: 600; }
.stat .v { font-size: 25px; font-weight: 800; margin-top: 3px; font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--ink); }
.svc-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 14px; }
.svc-summary .item { border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; background: var(--panel); transition: border-color .15s; }
.svc-summary .item:hover { border-color: var(--red-soft-2); }
.svc-summary .item-head { display: flex; align-items: center; gap: 12px; }
.svc-summary .counts { display: flex; gap: 14px; margin-top: 14px; font-size: 12.5px; font-variant-numeric: tabular-nums; color: var(--ink-2); flex-wrap: wrap; }
.svc-summary .counts span { display: inline-flex; align-items: center; gap: 6px; }
.stack { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin-top: 12px; background: var(--none-bg); gap: 2px; }
.stack .a { background: var(--active-dot); }
.stack .s { background: var(--stopped-dot); }
.notice { display: flex; align-items: center; gap: 10px; background: var(--red-soft); border: 1px solid var(--red-soft-2); color: var(--red-ink); padding: 12px 16px; border-radius: 12px; }
.formula { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.formula code { font-family: inherit; background: var(--panel); border: 1px solid var(--line); padding: 2px 9px; border-radius: 7px; color: var(--ink-2); font-size: 12px; }
.formula .ic { color: var(--red); }

/* ================================================================ lead page */
.lead-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 22px; }
.kpi { display: flex; align-items: center; gap: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 13px 16px; box-shadow: var(--shadow); }
.kpi > .ic { color: var(--red); width: 34px; height: 34px; padding: 8px; background: var(--red-soft); border-radius: 10px; }
.kpi small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 600; }
.kpi b { font-variant-numeric: tabular-nums; font-size: 16px; color: var(--ink); }
.savebar {
  position: fixed; left: var(--side-w); right: 0; bottom: 0; background: color-mix(in srgb, var(--panel) 92%, transparent); border-top: 1px solid var(--line);
  padding: 13px 32px; display: flex; justify-content: flex-end; gap: 10px; align-items: center; backdrop-filter: blur(10px); z-index: 20;
  box-shadow: 0 -6px 20px rgba(0, 0, 0, .04);
}
.savebar .dirty { margin-right: auto; color: var(--red-ink); font-weight: 650; display: inline-flex; align-items: center; gap: 8px; visibility: hidden; }
.savebar .dirty.on { visibility: visible; }
.savebar .dirty .dot { background: var(--red); animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; box-shadow: var(--shadow); }
.filters select { width: auto; min-width: 150px; }
.filters .search { flex: 1; min-width: 260px; }

/* admin */
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(390px, 1fr)); gap: 22px; align-items: start; }
.cat-row { display: grid; grid-template-columns: auto 36px 1fr auto auto auto; gap: 8px; align-items: center; padding: 9px 0; border-bottom: 1px solid var(--line); }
.cat-row:last-of-type { border-bottom: 0; }
.cat-row .row-icon { width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.cat-row.hidden-item input[type=text] { color: var(--muted); text-decoration: line-through; }
.cat-row.hidden-item .row-icon { opacity: .4; }
.move { display: flex; flex-direction: column; }
.move button { border: 0; background: transparent; cursor: pointer; color: var(--muted); line-height: 0; padding: 1px; border-radius: 4px; }
.move button:hover:not(:disabled) { color: var(--red); background: var(--red-soft); }
.move button:disabled { opacity: .25; cursor: default; }
.flag { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); white-space: nowrap; cursor: pointer; }
.add-row { display: flex; gap: 8px; margin-top: 14px; }

#toast {
  position: fixed; bottom: 84px; left: 50%; transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 11px 18px; border-radius: 12px; transition: all .2s; pointer-events: none; z-index: 60;
  display: flex; align-items: center; gap: 8px; font-weight: 600; box-shadow: var(--shadow-lg);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: var(--red); color: #fff; }

/* ================================================================ responsive */
@media (max-width: 1100px) { :root { --side-w: 76px; } .brand-text, .sidebar nav a span, .nav-label { display: none; } .sidebar { padding: 18px 12px; align-items: center; } .sidebar nav a { justify-content: center; padding: 11px; } .theme-switch { grid-template-columns: 1fr; } .brand { padding: 0; } }
@media (max-width: 760px) {
  :root { --side-w: 0px; }
  .sidebar { position: sticky; top: 0; inset: auto; width: auto; height: auto; flex-direction: row; align-items: center; padding: 10px 14px; gap: 10px; }
  .sidebar nav { flex-direction: row; gap: 2px; }
  .sidebar nav a { padding: 9px; }
  .sidebar-foot { margin: 0 0 0 auto; border: 0; padding: 0; }
  .theme-switch { grid-template-columns: repeat(3, 1fr); width: 104px; }
  .brand-mark { width: 34px; height: 34px; }
  .topbar { position: static; height: auto; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .crumb { display: none; }
  .top-search { margin: 0; flex: 1; width: auto; }
  main { padding: 18px 16px 100px; }
  .savebar { padding: 10px 16px; }
  .row.contact { grid-template-columns: 110px 1fr 36px; }
  .row.contact .c-label { display: none; }
  .inv-fields { grid-template-columns: 1fr; }
  .filters .search { min-width: 0; width: 100%; flex-basis: 100%; }
  .admin-grid { grid-template-columns: 1fr; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .stat { padding: 13px; gap: 10px; } .stat .v { font-size: 19px; } .stat .sec-icon { display: none; }
  h1 { font-size: 20px; }
}

/* ================================================================ auth: login page */
body.auth .sidebar, body.auth .app { display: none; }
#login { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, 1fr); }
.login-brand { background: var(--sidebar-bg); color: #fff; display: flex; align-items: center; justify-content: center; padding: 48px; position: relative; overflow: hidden; }
.login-brand::after { content: ""; position: absolute; width: 520px; height: 520px; border-radius: 50%; border: 70px solid rgba(255, 255, 255, .06); right: -180px; bottom: -200px; }
.login-brand-inner { max-width: 420px; position: relative; z-index: 1; }
.login-brand .brand-mark { width: 56px; height: 56px; border-radius: 16px; }
.login-brand h1 { color: #fff; font-size: 34px; margin: 22px 0 10px; }
.login-brand p { color: rgba(255, 255, 255, .82); font-size: 15px; line-height: 1.55; margin: 0 0 26px; }
.login-brand ul { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 14px; }
.login-brand li { display: flex; align-items: center; gap: 12px; color: rgba(255, 255, 255, .92); font-weight: 550; }
.login-brand li .ic { width: 32px; height: 32px; padding: 8px; border-radius: 10px; background: rgba(255, 255, 255, .14); }
.login-panel { display: flex; align-items: center; justify-content: center; padding: 40px 24px; background: var(--bg); }
.login-card { width: 100%; max-width: 400px; background: var(--panel); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow-lg); padding: 34px 32px; display: flex; flex-direction: column; gap: 16px; }
.login-card h2 { font-size: 22px; margin: 4px 0 -8px; }
.login-icon { width: 52px; height: 52px; border-radius: 15px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); }
.login-btn { justify-content: center; height: 46px; font-size: 15px; margin-top: 4px; }
.login-foot { display: flex; align-items: center; gap: 6px; margin: 0; }
.login-msg { display: none; align-items: flex-start; gap: 9px; padding: 11px 13px; border-radius: 11px; font-size: 13px; line-height: 1.45; border: 1px solid; }
.login-msg.error, .login-msg.info, .login-msg.locked { display: flex; }
.login-msg.error { background: var(--red-soft); border-color: var(--red-soft-2); color: var(--red-ink); }
.login-msg.info { background: var(--hover); border-color: var(--line-2); color: var(--ink-2); }
.login-msg.locked { background: var(--stopped-bg); border-color: var(--stopped-bd); color: var(--stopped-ink); }
.login-msg .ic { margin-top: 1px; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--muted); padding: 7px; border-radius: 8px; cursor: pointer; line-height: 0; }
.pw-toggle:hover { color: var(--red); background: var(--red-soft); }

/* ================================================================ sidebar user card */
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; background: rgba(0, 0, 0, .14); }
.uc-avatar { width: 34px; height: 34px; border-radius: 10px; background: #fff; color: #c41e30; display: grid; place-items: center; font-weight: 800; flex-shrink: 0; }
.uc-text { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.2; }
.uc-text b { color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.uc-text small { color: rgba(255, 255, 255, .7); font-size: 11.5px; }
.uc-btn { border: 0; background: transparent; color: rgba(255, 255, 255, .8); padding: 7px; border-radius: 8px; cursor: pointer; line-height: 0; }
.uc-btn:hover { background: rgba(255, 255, 255, .16); color: #fff; }

/* ================================================================ modal */
.modal-back { position: fixed; inset: 0; background: rgba(20, 12, 14, .45); backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 70; padding: 16px; animation: fade .15s; }
.modal { width: 100%; max-width: 420px; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow-lg); padding: 24px; }
.modal-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
@keyframes fade { from { opacity: 0; } }

/* ================================================================ users table */
.row-actions { display: flex; gap: 6px; justify-content: flex-end; align-items: center; flex-wrap: wrap; }
.role-select { width: auto; min-width: 110px; padding-top: 7px; padding-bottom: 7px; }

@media (max-width: 1100px) { .uc-text, .user-card #btn-password { display: none; } .user-card { flex-direction: column; padding: 6px; } }
@media (max-width: 860px) {
  #login { grid-template-columns: 1fr; }
  .login-brand { padding: 28px 24px; }
  .login-brand h1 { font-size: 26px; margin: 14px 0 6px; }
  .login-brand ul, .login-brand::after { display: none; }
  .login-brand p { margin: 0; }
  .login-card { padding: 26px 22px; }
}
@media (max-width: 760px) { .user-card { flex-direction: row; background: transparent; padding: 0; } .uc-avatar { display: none; } }

/* ================================================================ lead audit (created / modified by) */
.audit-row { display: flex; gap: 10px; flex-wrap: wrap; }
.audit { display: flex; align-items: center; gap: 10px; padding: 8px 14px 8px 8px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel-2); min-width: 190px; }
.audit-icon { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; background: var(--red-soft); color: var(--red); flex-shrink: 0; }
.audit small { display: block; font-size: 10.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.audit b { display: block; color: var(--ink); font-size: 13.5px; line-height: 1.3; }
.audit .sub-line { margin-top: 1px; white-space: nowrap; }
.muted { color: var(--muted); font-weight: 500; }
.who b { font-weight: 650; color: var(--ink); white-space: nowrap; }
.who .sub-line { white-space: nowrap; }
@media (max-width: 760px) { .audit-row { width: 100%; } .audit { flex: 1; min-width: 0; } }

/* ================================================================ layout fixes: tables fit the page */
.num-input { text-align: right; }
.cell-qty input { max-width: 120px; margin-left: auto; display: block; }
.cell-unit input { max-width: 150px; }
.m-only { display: none; }
.tf-label { padding: 12px 16px !important; }
.tf-value { padding: 12px 14px !important; }

/* Leads list: compact padding + wrapping cells so the table fits the page width (no sideways scroll). */
.leads-table th, .leads-table td { padding-left: 11px; padding-right: 11px; }
.leads-table th:first-child, .leads-table td:first-child { padding-left: 18px; }
.leads-table th:last-child, .leads-table td:last-child { padding-right: 18px; }
.leads-table .lead-cell { min-width: 0; }
.leads-table .lead-cell b { word-break: break-word; }
.meta-line.wrap { white-space: normal; align-items: flex-start; }
.meta-line.wrap .ic { margin-top: 3px; }
.wrap-cell { min-width: 110px; }
.chip-wrap { display: flex; flex-wrap: wrap; gap: 4px; max-width: 170px; }
.svc-dots { flex-wrap: wrap; }
.num-sub { justify-content: flex-end; white-space: nowrap; }
.score { color: var(--red-ink); }
@media (max-width: 1320px) and (min-width: 761px) { .col-tags { display: none; } }

/* ================================================================ mobile: rows become bordered cards */
@media (max-width: 760px) {
  .card .table-wrap { overflow: visible; }
  table.responsive thead { display: none; }
  table.responsive, table.responsive tbody, table.responsive tfoot, table.responsive tr, table.responsive td { display: block; width: 100%; }
  table.responsive tbody { display: flex; flex-direction: column; gap: 12px; padding: 14px; }
  table.responsive tr {
    position: relative; border: 1px solid var(--line-2); border-radius: 14px; background: var(--panel);
    box-shadow: var(--shadow); overflow: hidden; transition: border-color .15s, box-shadow .15s;
  }
  table.responsive tr.link:active, table.responsive tr.link:hover { border-color: var(--red-soft-2); background: var(--panel); }
  table.responsive tr.link:hover td:first-child { box-shadow: none; }
  table.responsive td {
    display: flex; align-items: center; justify-content: space-between; gap: 14px;
    padding: 11px 14px; border-bottom: 1px solid var(--line); text-align: right; min-width: 0;
  }
  table.responsive td:last-child { border-bottom: 0; }
  table.responsive td[data-label]::before {
    content: attr(data-label); flex-shrink: 0; text-align: left;
    font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em;
  }
  table.responsive td.num { white-space: normal; }
  table.responsive td.col-tags { display: flex; }
  table.responsive td.cell-primary { background: var(--panel-2); justify-content: flex-start; text-align: left; padding: 13px 14px; }
  table.responsive td.cell-rank { position: absolute; top: 13px; right: 14px; padding: 0; border: 0; width: auto; background: none; }
  table.responsive .chip-wrap { justify-content: flex-end; max-width: none; }
  table.responsive .wrap-cell, table.responsive .who { text-align: right; min-width: 0; }
  table.responsive .meta-line.wrap, table.responsive .sub-line { justify-content: flex-end; }
  table.responsive .lead-cell .sub-line { justify-content: flex-start; }
  table.responsive .score-bar .bar { display: none; }
  table.responsive .row-actions { justify-content: flex-end; }

  /* Edit tables (businesses, assets): one bordered card per row, label above each field. */
  table.edit.responsive td { display: block; text-align: left; padding: 10px 14px; }
  table.edit.responsive td:first-child { padding-left: 14px; }
  table.edit.responsive td[data-label]::before { display: block; margin-bottom: 6px; }
  table.edit.responsive td.cell-action { display: flex; justify-content: flex-end; width: 100% !important; padding: 8px 10px; background: var(--panel-2); }
  table.edit.responsive .cell-qty input, table.edit.responsive .cell-unit input { max-width: none; margin: 0; }
  table.edit.responsive .num-input { text-align: left; }
  table.edit.responsive tr.row-empty { border-style: dashed; box-shadow: none; }
  table.edit.responsive tfoot tr { display: flex; justify-content: space-between; align-items: center; margin: 0 14px 14px; width: auto; border-radius: 12px; }
  table.edit.responsive tfoot td { width: auto; border: 0; background: transparent; }
  table.edit.responsive tfoot .tf-pad { display: none; }
  .m-only { display: inline; margin-left: 6px; font-size: 13px; font-weight: 600; }
  .cell-action .icon-btn { display: inline-flex; align-items: center; line-height: 1; padding: 8px 10px; color: var(--danger); }
  .inv-table { border: 0; background: transparent; overflow: visible; }
  .inv-table table.responsive tbody { padding: 0; }

  /* Top bar: brand + account/theme on row 1, navigation evenly spread on row 2. */
  .sidebar { flex-wrap: wrap; row-gap: 8px; padding: 10px 12px 8px; }
  .brand { order: 1; }
  .sidebar-foot { order: 2; margin-left: auto; flex-direction: row; align-items: center; gap: 8px; }
  .sidebar nav { order: 3; width: 100%; justify-content: space-between; overflow: visible; }
  .sidebar nav a { flex: 1; justify-content: center; padding: 9px 0; }
  .user-card { flex-direction: row; gap: 2px; padding: 0; background: transparent; }
  .user-card #btn-password { display: inline-grid; }
  .theme-switch { width: 96px; }

  /* Lead page */
  .page-head .hide-mobile { display: none; }
  .head-left { gap: 12px; }
  .avatar.lg { width: 50px; height: 50px; font-size: 18px; border-radius: 15px; }
  .lead-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 10px 12px; gap: 10px; min-width: 0; }
  .kpi > .ic { width: 30px; height: 30px; padding: 7px; }
  .kpi b { font-size: 14.5px; }
  .audit-row { width: 100%; flex-direction: column; }
  .audit { width: 100%; min-width: 0; }
  .card-head { padding: 15px 16px; }
  .card-body { padding: 16px; }
  .grid { gap: 14px; }

  /* Comfortable, smooth fields on touch screens (16px stops iOS zooming into inputs). */
  input, select, textarea { font-size: 16px; min-height: 46px; border-radius: 12px; }
  textarea { min-height: 96px; }
  .chip-input { min-height: 48px; border-radius: 12px; }
  .chip-input input { font-size: 16px; min-height: 0; }
  .input-wrap > .ic { left: 13px; }
  .field { gap: 6px; }
  .services { grid-template-columns: 1fr; }
  .svc { padding: 12px; }
}
.leads-table .svc-dots { flex-wrap: nowrap; }
.num-stack { display: flex; flex-direction: column; align-items: flex-end; }
