/* AsemanCRM · samin panel — Author: SPSDEVNIC.NET */
@font-face {
  font-family: "Vazirmatn";
  src: url("../fonts/Vazirmatn-wght.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --canvas: #e4ddf1;
  --canvas-2: #d9cfee;
  --shell: #f6f5f1;
  --card: #ffffff;
  --ink: #17171a;
  --ink-2: #3b3a41;
  --muted: #8d8c94;
  --muted-2: #b4b3ba;
  --line: #eeece6;
  --line-2: #e2e0d9;
  --field: #fbfaf7;
  --blue: #dde7fc;
  --blue-ink: #2e4a86;
  --lav: #e8dffb;
  --lav-ink: #4a3a8e;
  --pink: #f9dcf2;
  --pink-ink: #8b2c76;
  --yellow: #faf6c6;
  --yellow-ink: #6c6214;
  --purple: #8f7df2;
  --purple-2: #b7abf7;
  --magenta: #d43db6;
  --lime: #ddf58f;
  --lime-2: #c9ec5b;
  --lime-ink: #2c4608;
  --dark: #1c1c20;
  --dark-2: #2a2a30;
  --danger: #c2366e;
  --ok: #3e7d10;
  --r-shell: 38px;
  --r-card: 24px;
  --r-field: 14px;
  --shadow: 0 30px 80px -40px rgba(60, 40, 110, .35);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Vazirmatn", Tahoma, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--ink);
  background: var(--canvas);
  font-feature-settings: "ss01";
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 500; letter-spacing: -.01em; }
.ic { width: 20px; height: 20px; flex: none; }
[hidden] { display: none !important; }
.num { font-feature-settings: "tnum"; white-space: nowrap; }
.muted { color: var(--muted); }
.ltr { direction: ltr; unicode-bidi: plaintext; }

/* ---------- canvas & shell ---------- */
.canvas {
  min-height: 100vh;
  padding: 28px;
  background:
    radial-gradient(900px 500px at 85% -10%, #efe9fa 0%, transparent 60%),
    radial-gradient(700px 600px at -10% 110%, var(--canvas-2) 0%, transparent 60%),
    var(--canvas);
}
.shell {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  min-height: calc(100vh - 56px);
  background: var(--shell);
  border-radius: var(--r-shell);
  box-shadow: var(--shadow);
}

/* ---------- icon rail ---------- */
.rail {
  position: sticky;
  z-index: 40; /* sticky makes its own stacking context; keep tooltips above the cards */
  top: 28px;
  align-self: start;
  height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 28px 0 24px;
  gap: 8px;
  overflow-y: auto;
  scrollbar-width: none;
}
.rail::-webkit-scrollbar { display: none; }
.brand {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 1.5px solid #d8d6de;
  background: #fff;
  display: grid; place-items: center;
  overflow: hidden;
  margin-bottom: 22px; flex: none;
  transition: border-color .2s, box-shadow .2s;
}
.brand img { width: 100%; height: 100%; object-fit: contain; display: block; padding: 10px; }
.brand:hover { border-color: #1e9ad6; box-shadow: 0 6px 18px -8px rgba(30, 154, 214, .6); }
.rail-ver { font-size: 10.5px; color: var(--muted-2); margin-top: 10px; direction: ltr; letter-spacing: .02em; }
.rail-nav { display: flex; flex-direction: column; gap: 8px; align-items: center; }
.rail-link {
  position: relative;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border-radius: 50%;
  color: #8f8e96;
  transition: background .2s, color .2s;
}
.rail-link em { display: none; font-style: normal; }
.rail-link:hover { color: var(--ink); background: #ecebe5; }
.rail-link.is-on { background: var(--dark); color: #fff; }
.rail-link.is-on .ic { color: var(--lime); }
.rail-out { margin-top: auto; }
.rail-badge {
  position: absolute; top: -2px; left: -4px;
  min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--magenta); color: #fff; font-size: 10.5px; font-weight: 600; font-style: normal;
  line-height: 18px; text-align: center; box-shadow: 0 0 0 2px var(--shell);
}
.float-tip {
  position: fixed; z-index: 1100; pointer-events: none;
  background: var(--dark); color: #fff; font-size: 12px; white-space: nowrap;
  padding: 4px 10px; border-radius: 8px; transform: translateY(-50%);
}

/* ---------- main & header ---------- */
.main { min-width: 0; padding: 30px 8px 34px 36px; }
.top {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 56px;
  margin-bottom: 26px;
}
.top-head { display: flex; flex-direction: column; margin-left: 10px; min-width: 0; }
.top-brand { font-size: 12px; color: #1e78b8; font-weight: 500; letter-spacing: -.01em; white-space: nowrap; line-height: 1.4; }
.top-title { font-size: 28px; font-weight: 500; white-space: nowrap; line-height: 1.35; }
.icon-btn {
  position: relative;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  border: 0; background: transparent;
  border-radius: 50%;
  color: #8a8991;
  cursor: pointer;
}
.icon-btn:hover { color: var(--ink); background: #ecebe5; }
.icon-btn .ic { width: 22px; height: 22px; }
.bell b {
  position: absolute; top: 2px; right: 0;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: var(--dark); color: #fff;
  font-size: 11px; font-weight: 500; line-height: 18px; text-align: center;
}
.search {
  position: relative;
  flex: 0 1 300px;
  margin-inline: auto;
  display: flex; align-items: center; gap: 8px;
  height: 44px;
  padding: 0 16px;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.search:focus-within { border-color: #b8aee6; background: #fff; }
.search input { border: 0; outline: 0; background: transparent; width: 100%; color: var(--ink); }
.search input::placeholder { color: var(--muted); }
.search-pop {
  position: absolute; top: calc(100% + 8px); right: 0; left: 0;
  background: #fff; border-radius: 18px; box-shadow: 0 18px 50px -18px rgba(30, 20, 60, .3);
  padding: 8px; z-index: 50; max-height: 420px; overflow: auto;
}
.search-pop a { display: flex; gap: 10px; align-items: center; padding: 9px 10px; border-radius: 12px; color: var(--ink); }
.search-pop a:hover, .search-pop a.is-on { background: var(--shell); }
.search-pop small { color: var(--muted); margin-inline-start: auto; }
.search-pop .sp-head { font-size: 12px; color: var(--muted); padding: 6px 10px 2px; }
.top-tools { display: flex; align-items: center; gap: 10px; }
.pill-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 42px; padding: 0 12px 0 14px;
  border: 1px solid var(--line-2); border-radius: 999px;
  background: #fff; cursor: pointer; font-weight: 500;
}
.pill-btn .ic { width: 16px; height: 16px; color: var(--muted); }
.flag-dot { width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--purple) 0 33%, var(--pink) 0 66%, var(--lime-2) 0); }
.avatar {
  width: 56px; height: 56px; border-radius: 50%;
  border: 0; background: var(--dark); color: #fff;
  font-size: 22px; font-weight: 600; cursor: pointer;
  margin-inline-start: 8px;
  overflow: hidden; padding: 0;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* dropdowns */
.dd { position: relative; }
.dd-menu {
  position: absolute; top: calc(100% + 8px); right: 0;
  min-width: 200px; z-index: 60;
  background: #fff; border-radius: 18px; padding: 8px;
  box-shadow: 0 20px 60px -20px rgba(30, 20, 60, .35);
}
.dd-menu.dd-left { right: auto; left: 0; }
.dd-menu form { margin: 0; }
.dd-head { font-size: 12px; color: var(--muted); padding: 6px 10px; }
.dd-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 10px; border: 0; border-radius: 12px;
  background: transparent; text-align: right; cursor: pointer;
}
.dd-item:hover { background: var(--shell); }
.dd-item.is-on { background: var(--lav); color: var(--lav-ink); font-weight: 500; }
.dd-item .ic { width: 18px; height: 18px; color: var(--muted); }

/* ---------- tabs row ---------- */
.tabs-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin-bottom: 26px; }
.tabs { display: flex; gap: 26px; flex-wrap: wrap; margin-inline-end: auto; }
.tab { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); font-size: 15px; white-space: nowrap; }
.tab i {
  font-style: normal; font-size: 11px;
  width: 24px; height: 24px; border-radius: 50%;
  border: 1px solid var(--muted-2); display: grid; place-items: center;
}
.tab.is-on { color: var(--ink); }
.tab.is-on i { border-color: var(--ink); }
.tab:hover { color: var(--ink); }
.range-pill {
  display: inline-flex; align-items: center; gap: 10px;
  height: 44px; padding: 0 18px;
  border: 1px solid var(--line-2); border-radius: 999px;
  color: var(--muted); white-space: nowrap;
}
.range-pill b { color: var(--ink); font-weight: 500; }
.range-pill .ic { width: 18px; height: 18px; }
.fab {
  width: 44px; height: 44px; border-radius: 50%;
  border: 0; background: var(--dark); color: var(--lime);
  display: grid; place-items: center; cursor: pointer;
}
.fab .ic { width: 20px; height: 20px; border: 1.6px solid var(--lime); border-radius: 6px; padding: 1px; }

/* ---------- cards & grids ---------- */
.content { min-width: 0; }
.grid { display: grid; gap: 24px; }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g-main { grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr); }
.mt { margin-top: 24px; }
.card {
  position: relative;
  background: var(--card);
  border-radius: var(--r-card);
  padding: 22px 24px 24px;
  min-width: 0;
}
.card-grip { position: absolute; top: 6px; left: 50%; transform: translateX(-50%); color: #c9c8cd; }
.card-grip .ic { width: 16px; height: 16px; transform: rotate(90deg); }
.card-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.card-head h2 { font-size: 21px; margin-inline-end: auto; }
.card-head .more { color: var(--muted-2); }
.card-head .legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--ink-2); flex-wrap: wrap; }
.legend i { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-left: 5px; }
.card-sub { color: var(--muted); font-size: 12.5px; }
.card.flat { background: transparent; padding: 0; }
.empty { text-align: center; color: var(--muted); padding: 44px 20px; }
.empty h2 { color: var(--ink); margin-bottom: 6px; }

/* pastel summary list */
.plist { display: flex; flex-direction: column; gap: 9px; }
.plist a, .plist div {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 16px;
  border-radius: 12px; font-size: 15px;
  transition: transform .15s;
}
.plist a:hover { transform: translateX(-3px); }
.plist .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid currentColor; opacity: .6; }
.plist .n { margin-inline-start: auto; font-size: 14px; }
.p-blue { background: var(--blue); color: var(--blue-ink); }
.p-lav { background: var(--lav); color: var(--lav-ink); }
.p-pink { background: var(--pink); color: var(--pink-ink); }
.p-yellow { background: var(--yellow); color: var(--yellow-ink); }
.p-lime { background: var(--lime); color: var(--lime-ink); }

/* KPI strip */
/* KPI cards wrap into rows (4 per row on wide screens = the 7 cards fit in two rows) */
.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 18px;
  padding: 2px;
}
@media (max-width: 1100px) { .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 760px) { .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; } }
@media (max-width: 420px) { .kpis { grid-template-columns: minmax(0, 1fr); } }
.kpi {
  position: relative;
  border: 1px solid var(--line-2);
  background: var(--card);
  border-radius: 22px;
  padding: 16px 18px 14px;
  min-height: 118px;
  display: flex; flex-direction: column;
}
.kpi h3 { font-size: 15px; font-weight: 500; }
.kpi .kpi-sub { font-size: 11.5px; color: var(--muted); }
.kpi .kpi-val { font-size: 18px; color: var(--ink-2); margin-top: 10px; font-weight: 500; overflow-wrap: anywhere; }
.kpi .kpi-base { font-size: 11.5px; color: var(--muted); }
.kpi .chip { position: absolute; left: 16px; bottom: 16px; }
.kpi .kpi-more { position: absolute; left: 14px; top: 12px; color: var(--muted-2); }
.kpi-dark { background: var(--dark); border-color: var(--dark); color: #fff; }
.kpi-dark .kpi-val { color: #fff; }
.kpi-dark .kpi-sub, .kpi-dark .kpi-base { color: #a7a6ad; }
a.kpi:hover { border-color: #c9c3e6; }

/* chips & tags */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  height: 26px; padding: 0 10px;
  border-radius: 9px; font-size: 12px; font-weight: 500; white-space: nowrap;
}
.chip .ic { width: 13px; height: 13px; stroke-width: 2.2; }
.chip-lime { background: var(--lime); color: var(--lime-ink); }
.chip-pink { background: #f7c8ec; color: #7d1f69; }
.chip-mute { background: #f0efeb; color: var(--muted); }
.chip-dark { background: var(--dark); color: #fff; }
.tag {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 9px; border-radius: 8px;
  font-size: 12px; white-space: nowrap;
}
.tag-paid { background: var(--lime); color: var(--lime-ink); }
.tag-due { background: var(--pink); color: var(--pink-ink); }
.tag-part { background: var(--yellow); color: var(--yellow-ink); }
.tag-pre { background: var(--lav); color: var(--lav-ink); }
.tag-off { background: var(--blue); color: var(--blue-ink); }
.tag-mute { background: #f0efeb; color: var(--muted); }
.avatar-sm {
  width: 22px; height: 22px; border-radius: 50%;
  display: inline-grid; place-items: center; flex: none;
  font-size: 11px; font-weight: 600;
}

/* ---------- tables ---------- */
.tbl-wrap { margin: 0 -6px; padding: 0 6px; max-width: 100%; }
.tbl-wrap .tbl { width: 100%; }
.tbl td, .tbl th { overflow-wrap: break-word; }
@media (max-width: 760px) { .tbl-wrap { overflow-x: auto; } }
.tbl { width: 100%; border-collapse: collapse; }
.tbl th {
  text-align: right; font-weight: 400; font-size: 12.5px; color: var(--muted);
  padding: 8px 10px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 11px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tbody tr:last-child td { border-bottom: 0; }
.tbl tbody tr:hover td { background: #fbfaf7; }
.tbl .t-end { text-align: left; }
.tbl .t-c { text-align: center; }
.tbl .strong { font-weight: 600; }
.tbl tfoot td { font-weight: 600; border-top: 1px solid var(--line-2); border-bottom: 0; }
.tbl.compact td { padding: 8px 6px; border: 0; }
.tbl.compact th { border: 0; padding: 4px 6px 8px; }
.row-link { cursor: pointer; }
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.row-actions .icon-btn { width: 32px; height: 32px; }
.row-actions .icon-btn .ic { width: 18px; height: 18px; }
.cell-title { font-weight: 500; }
.cell-sub { display: block; font-size: 12px; color: var(--muted); }
.hl { color: var(--magenta); font-weight: 600; }

/* ---------- toolbar, forms & buttons ---------- */
.toolbar { display: flex; align-items: flex-end; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.toolbar .grow { flex: 1 1 220px; }
.toolbar .spacer { margin-inline-start: auto; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 20px;
  border: 1px solid var(--dark); border-radius: 999px;
  background: var(--dark); color: #fff;
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: transform .12s, background .2s;
}
.btn:hover { background: #000; }
.btn:active { transform: scale(.98); }
.btn .ic { width: 18px; height: 18px; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--line-2); }
.btn-ghost:hover { background: #fff; border-color: #cfccd8; }
.btn-lime { background: var(--lime); border-color: var(--lime); color: var(--lime-ink); }
.btn-lime:hover { background: var(--lime-2); }
.btn-danger { background: transparent; color: var(--danger); border-color: #efc4d8; }
.btn-danger:hover { background: #fdf0f6; }
.btn-sm { height: 34px; padding: 0 14px; font-size: 13px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px 18px; }
.c3 { grid-column: span 3; } .c4 { grid-column: span 4; } .c6 { grid-column: span 6; }
.c8 { grid-column: span 8; } .c12 { grid-column: span 12; } .c2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span, .field > label { font-size: 12.5px; color: var(--muted); }
.field .req::after { content: " *"; color: var(--magenta); }
.inp, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
  width: 100%; height: 44px; padding: 0 14px;
  border: 1px solid var(--line-2); border-radius: var(--r-field);
  background: var(--field); outline: 0;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
.field textarea { height: auto; min-height: 90px; padding: 10px 14px; resize: vertical; line-height: 1.8; }
.inp:focus, .field input:focus, .field select:focus, .field textarea:focus {
  border-color: #b3a7ee; background: #fff; box-shadow: 0 0 0 4px rgba(143, 125, 242, .14);
}
.field input[readonly] { background: #f3f2ee; color: var(--ink-2); }
.field .hint { font-size: 11.5px; color: var(--muted); }
.field.err input, .field.err select { border-color: var(--danger); }
.field-row { display: flex; gap: 8px; align-items: center; }
.field-row > * { flex: 1; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--dark); }
.seg { display: inline-flex; padding: 4px; background: #efeee9; border-radius: 999px; gap: 2px; flex-wrap: wrap; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 6px 16px; border-radius: 999px; color: var(--muted); font-size: 13.5px; }
.seg input:checked + span { background: #fff; color: var(--ink); box-shadow: 0 2px 8px -3px rgba(0, 0, 0, .2); }
.seg input:focus-visible + span { outline: 2px solid var(--purple); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.form-actions .spacer { margin-inline-start: auto; }
.section-title { font-size: 15px; font-weight: 600; margin: 6px 0 12px; display: flex; align-items: center; gap: 8px; }
.err-box { background: #fdeef5; color: #8d1f55; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; }
.err-box ul { margin: 4px 0 0; padding-right: 18px; }

/* autocomplete */
.ac { position: relative; }
.ac-pop {
  position: fixed; z-index: 1000;
  background: #fff; border-radius: 14px;
  overscroll-behavior: contain;
  box-shadow: 0 18px 50px -18px rgba(30, 20, 60, .35);
  max-height: 280px; overflow: auto; padding: 6px;
}
.ac-pop button {
  display: flex; width: 100%; gap: 10px; align-items: center;
  border: 0; background: transparent; text-align: right;
  padding: 8px 10px; border-radius: 10px; cursor: pointer;
}
.ac-pop button:hover, .ac-pop button.is-on { background: var(--shell); }
.ac-pop small { color: var(--muted); margin-inline-start: auto; }
.ac-ok { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--ok); }
.ac-ok .ic { width: 18px; height: 18px; }

.ac-bad { border-color: #e6a1c4 !important; }
.link-btn { border: 0; background: none; padding: 0; color: var(--purple); cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }

/* jalali date picker (fixed: works inside modal dialogs too) */
.jdp {
  position: fixed; z-index: 1000; width: 284px;
  background: #fff; border-radius: 18px; padding: 12px;
  box-shadow: 0 22px 60px -20px rgba(30, 20, 60, .4);
}
.jdp-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.jdp-head b { font-weight: 600; }
.jdp-head button { width: 30px; height: 30px; border: 0; border-radius: 50%; background: var(--shell); cursor: pointer; display: grid; place-items: center; }
.jdp-head .ic { width: 16px; height: 16px; }
.jdp-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; }
.jdp-grid span { font-size: 11px; color: var(--muted); padding: 4px 0; }
.jdp-grid button { height: 34px; border: 0; border-radius: 10px; background: transparent; cursor: pointer; }
.jdp-grid button:hover { background: var(--shell); }
.jdp-grid button.is-today { box-shadow: inset 0 0 0 1px var(--purple); }
.jdp-grid button.is-on { background: var(--dark); color: #fff; }
.jdp-foot { display: flex; justify-content: space-between; margin-top: 8px; }
.jdp-foot button { border: 0; background: transparent; color: var(--purple); cursor: pointer; font-size: 13px; }

/* toasts */
.toast {
  position: fixed; left: 28px; bottom: 28px; z-index: 90;
  display: flex; align-items: center; gap: 12px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 12px 14px 12px 12px; border-radius: 16px;
  background: var(--dark); color: #fff;
  box-shadow: 0 20px 50px -20px rgba(0, 0, 0, .5);
  animation: toast-in .35s cubic-bezier(.2, .8, .2, 1);
}
.toast + .toast { bottom: 92px; }
.toast-ok::before { content: ""; width: 10px; height: 10px; border-radius: 50%; background: var(--lime); flex: none; }
.toast-err { background: #7d1f4d; }
.toast-x { border: 0; background: transparent; color: #aaa; cursor: pointer; display: grid; place-items: center; margin-inline-start: auto; }
.toast-x .ic { width: 16px; height: 16px; }
@keyframes toast-in { from { opacity: 0; transform: translateY(14px); } }

/* modal */
.modal {
  border: 0; padding: 0; border-radius: 26px; width: min(560px, calc(100vw - 32px));
  background: var(--card); color: var(--ink);
  box-shadow: 0 40px 100px -30px rgba(20, 10, 50, .5);
}
.modal::backdrop { background: rgba(30, 24, 50, .35); backdrop-filter: blur(2px); }
.modal-body { padding: 24px; }
.modal-head { display: flex; align-items: center; margin-bottom: 16px; }
.modal-head h2 { font-size: 19px; margin-inline-end: auto; }
.modal.wide { width: min(860px, calc(100vw - 32px)); }

/* pager */
.pager { display: flex; gap: 6px; justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.pager a { min-width: 36px; height: 36px; padding: 0 8px; border-radius: 12px; display: grid; place-items: center; color: var(--muted); }
.pager a:hover { background: #fff; color: var(--ink); }
.pager a.is-on { background: var(--dark); color: #fff; }
.pager-gap { color: var(--muted-2); padding: 0 4px; align-self: center; }

/* ---------- charts ---------- */
.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { font-size: 10px; fill: var(--muted); font-family: inherit; }
.chart .grid-line { stroke: #efeee9; stroke-width: 1; }
.chart-tip {
  position: absolute; pointer-events: none; z-index: 5;
  background: var(--dark); color: #fff; font-size: 12px;
  padding: 6px 10px; border-radius: 10px; white-space: nowrap;
  transform: translate(50%, -120%);
}
.chart-tip.pink { background: #f7c8ec; color: #7d1f69; }
.donut-wrap { position: relative; text-align: center; }
.donut-total { color: var(--muted); font-size: 13px; margin-top: 4px; }
.donut-big { font-size: 38px; font-weight: 600; letter-spacing: -.02em; line-height: 1.2; }
.donut-tag {
  position: absolute; left: 50%; bottom: 6px; transform: translateX(-50%);
  background: #f2f1ec; border-radius: 12px; padding: 6px 14px; min-width: 120px;
  box-shadow: 0 0 0 6px #fff;
}
.donut-tag b { display: block; font-size: 16px; font-weight: 600; }
.donut-tag span { font-size: 11.5px; color: var(--muted); }
.bars-legend { display: flex; flex-wrap: wrap; gap: 6px 14px; justify-content: center; margin-top: 10px; font-size: 12px; color: var(--ink-2); }

/* lists inside dashboard cards */
.mini-list { display: flex; flex-direction: column; }
.mini-list > * { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mini-list > *:last-child { border-bottom: 0; }
.mini-list .grow { flex: 1; min-width: 0; }
.mini-list .grow b { font-weight: 500; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-list .grow span { font-size: 12px; color: var(--muted); }

/* stat line */
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.stat { background: var(--card); border-radius: 18px; padding: 12px 18px; min-width: 150px; }
.stat span { display: block; font-size: 12px; color: var(--muted); }
.stat b { font-size: 17px; font-weight: 600; }
.stat.dark { background: var(--dark); color: #fff; }
.stat.dark span { color: #a7a6ad; }

/* invoice editor */
.lines .tbl td { padding: 6px 6px; }
.lines .inp { height: 40px; padding: 0 10px; }
.lines .c-name { min-width: 220px; }
.lines .c-qty { width: 90px; }
.lines .c-price { width: 160px; }
.lines .c-off { width: 140px; }
.lines .c-date { width: 130px; }
.lines .c-sum { width: 150px; }
.totals { display: grid; gap: 10px; }
.totals .t-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.totals .t-row > span { color: var(--muted); }
.totals .t-row .inp { width: 90px; height: 38px; text-align: center; }
.totals .t-grand { padding-top: 12px; border-top: 1px dashed var(--line-2); font-size: 18px; font-weight: 600; }
.totals .t-grand > span { color: var(--ink); }
.in-words { font-size: 12.5px; color: var(--muted); }

/* ---------- top navigation (staff + portal) ---------- */
body.top-nav .shell, body.portal-top .shell { display: block; }
.topbar {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 16px;
  padding: 14px 26px; border-radius: var(--r-shell) var(--r-shell) 0 0;
  background: rgba(246, 245, 241, .94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.tb-brand { display: flex; align-items: center; gap: 10px; flex: none; }
.tb-brand img { width: 42px; height: auto; }
.tb-brand span { display: flex; flex-direction: column; line-height: 1.3; }
.tb-brand b { font-size: 14.5px; font-weight: 700; color: var(--ink); }
.tb-brand small { font-size: 11px; color: #1e78b8; }
.tb-nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.tb-item {
  position: relative; display: inline-flex; align-items: center; gap: 7px;
  height: 42px; padding: 0 13px; border-radius: 999px; white-space: nowrap;
  border: 0; background: transparent; font: inherit; font-size: 14px; color: #5f5e66; cursor: pointer;
  transition: background .15s, color .15s;
}
.tb-item .ic { width: 18px; height: 18px; }
.tb-item .tb-chev { width: 14px; height: 14px; opacity: .6; }
.tb-item:hover, .tb-group:hover > .tb-item, .tb-group:focus-within > .tb-item { background: #ecebe5; color: var(--ink); }
.tb-item.is-on, .tb-group.is-on > .tb-item { background: var(--dark); color: #fff; }
.tb-item.is-on .ic, .tb-group.is-on > .tb-item .ic { color: var(--lime); }
.tb-group { position: relative; }
.tb-sub {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 70; min-width: 220px;
  display: none; flex-direction: column; padding: 8px;
  background: #fff; border-radius: 18px; box-shadow: 0 22px 60px -20px rgba(30, 20, 60, .35);
}
.tb-sub::before { content: ""; position: absolute; top: -8px; right: 0; left: 0; height: 8px; }
.tb-group:hover > .tb-sub, .tb-group:focus-within > .tb-sub, .tb-group.open > .tb-sub { display: flex; }
.tb-sub a { display: flex; align-items: center; gap: 8px; padding: 9px 12px; border-radius: 12px; white-space: nowrap; font-size: 14px; }
.tb-sub a:hover { background: var(--shell); }
.tb-badge { min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--magenta); color: #fff; font-size: 10.5px; font-style: normal; line-height: 18px; text-align: center; margin-inline-start: auto; }
.tb-item .tb-badge { margin-inline-start: 2px; }
.topbar .top-tools { flex: none; margin: 0; gap: 6px; }
.topbar .avatar { width: 44px; height: 44px; font-size: 17px; margin: 0; }
.tb-search { width: min(420px, 90vw); padding: 10px; }
.tb-search .search { margin: 0; width: 100%; flex: none; background: #fff; }
body.top-nav .main, body.portal-top .main { padding: 24px 34px 34px; }
.page-head { display: flex; align-items: baseline; gap: 14px; margin-bottom: 18px; }
.only-mobile-flex { display: none !important; }
@media (max-width: 1320px) { .tb-item span { display: none; } .tb-item { padding: 0 11px; } .tb-item.is-on span, .tb-group.is-on > .tb-item span { display: inline; } .tb-brand small { display: none; } }
@media (max-width: 980px) {
  .topbar { border-radius: 0; padding: 10px 14px; flex-wrap: wrap; gap: 8px; }
  .tb-brand b { font-size: 13px; }
  .topbar .top-tools { margin-inline-start: auto; }
  .tb-nav { order: 5; flex: 1 1 100%; display: none; flex-direction: column; align-items: stretch; gap: 2px; padding-top: 6px; max-height: 70vh; overflow-y: auto; }
  body.rail-open .tb-nav { display: flex; }
  body.rail-open::after { display: none; }
  .tb-item { height: 46px; border-radius: 14px; width: 100%; }
  .tb-item span { display: inline !important; }
  .tb-group > .tb-sub { position: static; display: flex; box-shadow: none; background: transparent; padding: 0 22px 6px 0; min-width: 0; }
  .tb-chev { display: none; }
  .only-mobile-flex { display: inline-flex !important; }
  body.top-nav .main, body.portal-top .main { padding: 16px 16px 90px; }
}

/* letters: recipients + editor */
.rc-list { display: flex; flex-direction: column; gap: 8px; }
.rc-row { display: flex; gap: 8px; align-items: center; }
.rc-row .ac { min-width: 0; }
@media (max-width: 980px) { .rc-row { flex-wrap: wrap; } .rc-row > * { flex: 1 1 100% !important; width: auto !important; } }
.editor { border: 1px solid var(--line-2); border-radius: 16px; overflow: hidden; background: #fff; }
.ed-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; padding: 6px; background: var(--field); border-bottom: 1px solid var(--line-2); position: sticky; top: 0; z-index: 3; }
.ed-bar button, .ed-bar select, .ed-color {
  height: 34px; min-width: 34px; padding: 0 8px; border: 0; border-radius: 9px; background: transparent;
  display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); font-size: 12.5px;
}
.ed-bar button:hover, .ed-color:hover { background: #ecebe5; }
.ed-bar button .ic { width: 17px; height: 17px; }
.ed-bar select { border: 1px solid var(--line-2); background: #fff; }
.ed-sep { width: 1px; height: 22px; background: var(--line-2); margin: 0 4px; }
.ed-color { position: relative; font-weight: 700; }
.ed-color input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.ed-color.hl span { color: #e8c547; }
.ed-area { min-height: 380px; padding: 22px 26px; outline: 0; }
.letter-body { font-size: 14px; line-height: 2.1; text-align: justify; }
.letter-body p { margin: 0 0 6px; }
.letter-body table { border-collapse: collapse; width: 100%; margin: 8px 0; }
.letter-body td, .letter-body th { border: 1px solid #9aa4b2; padding: 4px 8px; }
.letter-body blockquote { margin: 0 24px 0 0; }
.letter-body [dir=ltr] { text-align: left; }
/* letter pages: the editable box has the printed A4 text width and type size */
.pg-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.pg-tabs { display: flex; flex-wrap: wrap; gap: 6px; }
.pg-tab { height: 34px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; font: inherit; font-size: 13px; cursor: pointer; color: var(--ink-2); }
.pg-tab.on { background: var(--ink); border-color: var(--ink); color: #fff; }
.pg-tools { display: inline-flex; gap: 2px; }
.pg-tools .icon-btn:disabled { opacity: .35; cursor: default; }
.pg-fill { margin-inline-start: auto; display: inline-flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }
.pg-fill::before { content: "پرشدگی صفحه"; }
.pg-fill i { display: block; width: 110px; height: 7px; border-radius: 5px; --c: #8f7df2; background: linear-gradient(to left, var(--c) var(--p, 0%), #e6e8ee var(--p, 0%)); }
.pg-fill.over b { color: #c23a3a; font-weight: 700; }
.pg-fill.over i { --c: #d94848; }
.ed-paper { background: #eef0f4; padding: 18px; }
.ed-paper .ed-area { width: 170mm; max-width: 100%; margin: 0 auto; background: #fff; box-shadow: 0 8px 24px -18px rgba(20, 40, 90, .5); font-size: 12.2pt; line-height: 2.15; min-height: 120mm; }

/* projects */
.prj-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.prj-tile { position: relative; background: #fff; border-radius: 22px; padding: 22px 20px 16px; overflow: hidden; transition: transform .15s, box-shadow .15s; }
.prj-tile:hover { transform: translateY(-2px); box-shadow: 0 18px 40px -24px rgba(30, 40, 90, .45); }
.prj-band { position: absolute; top: 0; right: 0; left: 0; height: 6px; background: var(--pc); }
.prj-link { position: absolute; inset: 0; z-index: 1; }
.prj-tile h3 { font-size: 17px; font-weight: 600; }
.prj-tile p { font-size: 13px; margin: 6px 0 0; }
.prj-tile .cell-sub .ic { width: 13px; height: 13px; vertical-align: -2px; }
.prj-tile .meter { height: 7px; border-radius: 5px; background: #eef0f4; overflow: hidden; margin: 14px 0 8px; }
.prj-tile .meter i { display: block; height: 100%; background: var(--pc); border-radius: 5px; }
.prj-foot { display: flex; align-items: center; gap: 8px; font-size: 12.5px; }
.avatars { margin-inline-start: auto; display: flex; }
.avatars i, .kb-av { width: 26px; height: 26px; border-radius: 50%; background: var(--lav); color: var(--lav-ink); display: inline-grid; place-items: center; font-style: normal; font-size: 11px; font-weight: 700; border: 2px solid #fff; overflow: hidden; flex: none; }
.avatars i + i { margin-inline-start: -8px; }
.avatars img, .kb-av img { width: 100%; height: 100%; object-fit: cover; }
.prj-tools { position: relative; z-index: 2; display: flex; justify-content: flex-end; gap: 2px; margin-top: 8px; }
.prj-tools form { margin: 0; }
.prj-title { display: flex; align-items: center; gap: 10px; }
.prj-title h3 { min-width: 0; }
.prj-logo { width: 40px; height: 40px; flex: none; border-radius: 12px; display: inline-grid; place-items: center; overflow: hidden; background: var(--pc, #1e9ad6); color: #fff; font-weight: 700; font-size: 16px; }
.prj-logo:has(img) { background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.prj-logo img { width: 100%; height: 100%; object-fit: contain; }
.prj-logo .ic { width: 20px; height: 20px; }
.prj-logo.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 12px; }
.prj-chip { position: relative; z-index: 2; gap: 3px; text-decoration: none; }
.prj-chip .ic { width: 13px; height: 13px; }
.rem-prj { display: inline-flex; align-items: center; gap: 4px; margin-top: 4px; font-size: 12px; color: var(--pc, #1e9ad6); font-weight: 600; text-decoration: none; }
.rem-prj .ic { width: 13px; height: 13px; }
.rem-prj:hover { text-decoration: underline; }
.ann-cell { display: flex; align-items: center; gap: 10px; }
.ann-cell > span { min-width: 0; }
.ann-thumb { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; background: #eef0f4; }
.ann-thumb.lg { width: 96px; height: 64px; }
.logo-pick { display: flex; align-items: center; gap: 12px; }
.logo-pick .prj-logo { width: 54px; height: 54px; }
.logo-pick input[type=file] { font-size: 12px; max-width: 100%; }
.prj-tools .icon-btn { width: 30px; height: 30px; }
.prj-tools .icon-btn .ic { width: 16px; height: 16px; }
.swatches { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; min-height: 44px; }
.swatches input { position: absolute; opacity: 0; }
.swatches i { display: block; width: 26px; height: 26px; border-radius: 50%; cursor: pointer; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .6); }
.swatches input:checked + i { outline: 3px solid var(--ink); outline-offset: 2px; }
.chips-check { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-check input { position: absolute; opacity: 0; }
.chips-check span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); cursor: pointer; font-size: 13px; }
.chips-check input:checked + span { background: var(--dark); color: #fff; border-color: var(--dark); }
.label-names { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.label-names label { display: flex; align-items: center; gap: 6px; }
.label-names i { width: 22px; height: 22px; border-radius: 6px; flex: none; }
.label-names .inp { height: 38px; }

/* kanban board */
body.is-board .content { overflow: visible; }
.kb-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); align-items: start; gap: 14px; padding: 4px 2px 18px; min-height: 60vh; }
.kb-list { min-width: 0; max-height: calc(100vh - 220px); display: flex; flex-direction: column; background: #eceef3; border-radius: 18px; padding: 10px; }
.kb-list header { display: flex; align-items: center; gap: 6px; padding: 2px 4px 8px; }
.kb-list h3 { font-size: 14.5px; font-weight: 600; flex: 1; cursor: text; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-count { font-size: 12px; color: var(--muted); background: #fff; border-radius: 8px; padding: 0 7px; }
.kb-grip { color: #a5a9b4; cursor: grab; display: grid; touch-action: none; }
.kb-grip .ic, .kb-x .ic { width: 16px; height: 16px; }
.kb-x { border: 0; background: transparent; color: #9aa0ab; cursor: pointer; display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; }
.kb-x:hover { background: rgba(0, 0, 0, .06); color: var(--danger); }
.kb-cards { display: flex; flex-direction: column; gap: 8px; overflow-y: auto; min-height: 12px; padding: 2px; }
.kb-card {
  background: #fff; border-radius: 12px; padding: 10px 12px; cursor: pointer;
  box-shadow: 0 1px 0 rgba(20, 30, 60, .08), 0 6px 14px -12px rgba(20, 30, 60, .5);
  border-inline-start: 3px solid var(--pc, #1e9ad6); user-select: none;
}
.kb-card:hover { box-shadow: 0 0 0 2px rgba(30, 154, 214, .35); }
.kb-card.is-done { opacity: .7; }
.kb-card.is-done .kb-title { text-decoration: line-through; text-decoration-color: rgba(0, 0, 0, .3); }
.kb-card.is-arch { background: #f6f6f3; border-style: dashed; }
.kb-labels { display: flex; gap: 4px; margin-bottom: 6px; }
.kb-labels i { width: 34px; height: 7px; border-radius: 4px; }
.kb-title { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.kb-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; font-size: 11.5px; color: var(--muted); }
.kb-meta .ic { width: 13px; height: 13px; }
.kb-b { display: inline-flex; align-items: center; gap: 3px; }
.kb-b.ok { color: #2f7d4b; }
.kb-due { display: inline-flex; align-items: center; gap: 3px; padding: 1px 6px; border-radius: 6px; background: #f0f1f4; font-size: 11.5px; }
.kb-due .ic { width: 13px; height: 13px; }
.kb-due.overdue { background: #fbe0e7; color: #9c1f4f; }
.kb-due.soon { background: #fdf0cf; color: #7a5a08; }
.kb-due.done { background: #d8f1e3; color: #1d6b3c; }
.kb-pri { padding: 1px 6px; border-radius: 6px; font-size: 11px; }
.kb-pri.p2 { background: #fdf0cf; color: #7a5a08; }
.kb-pri.p3 { background: #fbe0e7; color: #9c1f4f; }
.kb-avs { margin-inline-start: auto; display: flex; }
.kb-avs .kb-av + .kb-av { margin-inline-start: -7px; }
.kb-av.sm { width: 22px; height: 22px; font-size: 10px; }
.kb-new { margin-top: 8px; border: 0; background: transparent; color: var(--muted); display: flex; align-items: center; gap: 6px; padding: 8px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 13px; }
.kb-new:hover { background: rgba(0, 0, 0, .05); color: var(--ink); }
.kb-new .ic { width: 16px; height: 16px; }
.kb-add { display: none; margin-top: 8px; }
.kb-add textarea { width: 100%; border: 0; border-radius: 10px; padding: 8px 10px; font: inherit; resize: none; box-shadow: 0 0 0 2px rgba(30, 154, 214, .4); outline: 0; }
.kb-add div { display: flex; gap: 6px; margin-top: 6px; align-items: center; }
.kb-list.adding .kb-add { display: block; }
.kb-list.adding .kb-new { display: none; }
.kb-list-new { background: rgba(255, 255, 255, .55); }
.kb-list-new form { display: flex; gap: 6px; }
.kb-list-new .inp { height: 38px; background: #fff; }
.kb-ph { border-radius: 12px; background: rgba(30, 154, 214, .12); border: 2px dashed rgba(30, 154, 214, .45); flex: none; }
.kb-ph-list { background: rgba(30, 154, 214, .1); border: 2px dashed rgba(30, 154, 214, .45); }
.kb-ghost { position: fixed; z-index: 1200; pointer-events: none; transform: rotate(-2.5deg); box-shadow: 0 24px 50px -20px rgba(20, 30, 60, .6); opacity: .95; }
.kb-loading { padding: 40px; text-align: center; }
/* card window */
.kb-modal { width: min(980px, calc(100vw - 24px)); }
.kb-mhead { margin-bottom: 8px; }
.kb-mtitle { flex: 1; border: 0; font: inherit; font-size: 20px; font-weight: 600; padding: 6px 8px; border-radius: 10px; outline: 0; background: transparent; }
.kb-mtitle:focus { background: var(--field); box-shadow: 0 0 0 2px rgba(30, 154, 214, .3); }
.kb-mgrid { display: grid; grid-template-columns: minmax(0, 1fr) 260px; gap: 22px; }
.kb-sec { margin-bottom: 20px; }
.kb-sec h4 { font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 8px; }
.kb-labs { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-lab { border: 0; border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 12.5px; cursor: pointer; color: #fff; background: var(--lc); opacity: .35; }
.kb-lab.on { opacity: 1; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--lc); }
.kb-body { height: auto; min-height: 110px; padding: 10px 12px; line-height: 1.9; resize: vertical; margin-bottom: 6px; }
.kb-cl { background: var(--field); border-radius: 14px; padding: 12px; margin-bottom: 10px; }
.kb-cl-head { display: flex; align-items: center; gap: 8px; }
.kb-cl-head b { flex: 1; }
.kb-cl .meter { height: 6px; border-radius: 4px; background: #e6e8ee; overflow: hidden; margin: 8px 0; }
.kb-cl .meter i { display: block; height: 100%; background: var(--pc, #1e9ad6); }
.kb-it { display: flex; align-items: center; gap: 8px; padding: 5px 0; }
.kb-it .check { flex: 1; }
.kb-it.done .check span { text-decoration: line-through; color: var(--muted); }
.kb-it-add { display: flex; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.kb-rem { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 12px; background: var(--yellow); color: var(--yellow-ink); margin-bottom: 6px; font-size: 12.5px; }
.kb-rem.seen { background: #eef0f4; color: var(--muted); }
.kb-rem > .ic { width: 15px; height: 15px; flex: none; }
.kb-rem span { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.kb-rem small { opacity: .8; }
.kb-rem-add { display: flex; flex-wrap: wrap; gap: 6px; }
.kb-rem-add .inp { height: 34px; flex: 1 1 100px; }
.kb-rem-add .btn { flex: 1 1 100%; }
.kb-rem-add .btn .ic { width: 15px; height: 15px; }
.kb-it-add .inp { height: 36px; }
.kb-it-add .inp:first-child { flex: 1 1 160px; }
.kb-cl-add { display: flex; gap: 6px; }
.kb-cl-add .inp { height: 36px; flex: 1; }
.kb-cm-add { display: flex; gap: 6px; align-items: flex-end; margin-bottom: 12px; }
.kb-cm-add textarea { height: auto; min-height: 60px; padding: 8px 10px; flex: 1; }
.kb-cm { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.kb-cm p { margin: 4px 0 0; line-height: 1.9; }
.kb-mems { display: flex; flex-direction: column; gap: 4px; }
.kb-mem { display: flex; align-items: center; gap: 8px; border: 0; background: transparent; padding: 5px 8px; border-radius: 10px; cursor: pointer; font: inherit; font-size: 13px; text-align: right; opacity: .55; }
.kb-mem.on { opacity: 1; background: var(--lav); }
.kb-log { list-style: none; margin: 0; padding: 0; font-size: 12px; line-height: 1.9; max-height: 220px; overflow: auto; }
@media (max-width: 860px) { .kb-mgrid { grid-template-columns: minmax(0, 1fr); } .label-names { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* sortable dashboard */
.dash { display: grid; gap: 24px; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: start; grid-auto-flow: row dense; }
.dash > .w-2 { grid-column: span 2; }
.dash > .w-3 { grid-column: 1 / -1; }
.card-grip { cursor: grab; padding: 2px 10px; z-index: 2; touch-action: none; }
.card-grip:hover { color: var(--muted); }
.w-grip { display: flex; justify-content: center; color: #c9c8cd; margin-bottom: 4px; }
.w-grip .card-grip { position: static; transform: none; }
.w-dragging { opacity: .55; outline: 2px dashed #9fb6e6; outline-offset: 4px; border-radius: var(--r-card); }
body.is-sorting, body.is-sorting * { cursor: grabbing !important; user-select: none; }
.layout-hint { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.layout-hint button { border: 0; background: none; color: #1e78b8; cursor: pointer; font: inherit; padding: 0; }
@media (max-width: 1280px) { .dash { grid-template-columns: repeat(2, minmax(0, 1fr)); } .dash > .w-2 { grid-column: 1 / -1; } }
@media (max-width: 980px) { .dash { grid-template-columns: minmax(0, 1fr); gap: 16px; } .dash > * { grid-column: 1 / -1 !important; } }

.portal-box { border: 1px dashed #b9d6ee; background: #f4f9fd; border-radius: 18px; padding: 16px 18px 18px; }

/* ticket thread */
.thread { display: flex; flex-direction: column; gap: 14px; }
.msg { max-width: min(82%, 760px); border-radius: 20px; padding: 14px 18px 16px; background: #fff; }
.msg header { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.msg header time { margin-inline-start: auto; color: var(--muted); font-size: 12px; }
.msg header .tag .ic { width: 13px; height: 13px; }
.msg-body { line-height: 2; overflow-wrap: anywhere; }
.msg-body a { color: #1e78b8; text-decoration: underline; }
.msg-cust { align-self: flex-start; border: 1px solid var(--line-2); border-start-start-radius: 6px; }
.msg-staff { align-self: flex-end; background: #e4f1fb; border-start-end-radius: 6px; }
.msg-note { align-self: flex-end; background: #fff8d9; border: 1px dashed #e3cf73; border-start-end-radius: 6px; }
.msg-files { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.msg-files a { display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 10px; background: rgba(255, 255, 255, .7); border: 1px solid var(--line-2); font-size: 12.5px; }
.msg-files a:hover { border-color: #9fc6e6; }
.msg-files .ic { width: 15px; height: 15px; }
.msg-files small { color: var(--muted); }
@media (max-width: 980px) { .msg { max-width: 100%; } }

/* footer */
.site-foot {
  display: flex; flex-wrap: wrap; gap: 6px 18px; justify-content: space-between;
  margin-top: 34px; padding-top: 16px; border-top: 1px solid var(--line-2);
  font-size: 12px; color: var(--muted);
}
.site-foot a { color: #1e78b8; }
.site-foot a:hover { text-decoration: underline; }
@media print { .site-foot { display: none; } }

/* login */
.login-body { background: var(--canvas); }
.login-split {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(0, 1.15fr);
  padding: 22px;
  gap: 22px;
}
.login-side {
  background: var(--shell);
  border-radius: 34px;
  display: grid; place-items: center;
  padding: 40px 28px;
  box-shadow: var(--shadow);
}
.login-form { width: min(380px, 100%); }
.login-logo { width: 230px; max-width: 100%; height: auto; display: block; margin: 0 0 26px; }
.login-form h1 { font-size: 28px; margin-bottom: 2px; }
.login-form > p { color: var(--muted); margin: 0 0 24px; }
.login-form .btn { width: 100%; margin-top: 10px; height: 52px; font-size: 15px; }
.login-foot { text-align: center; font-size: 12px; color: var(--muted); margin-top: 20px; }
.login-art {
  position: relative; overflow: hidden;
  border-radius: 34px;
  background:
    radial-gradient(700px 500px at 85% 10%, #3fb6ec 0%, transparent 60%),
    linear-gradient(150deg, #1e9ad6 0%, #1b5fa6 45%, #1a2463 100%);
  color: #fff;
  display: flex; align-items: flex-end;
}
.login-pixels { position: absolute; inset: 0; width: 100%; height: 100%; }
.login-px { position: absolute; left: -2%; bottom: -1px; width: 78%; height: auto; filter: brightness(0) invert(1); opacity: .16; pointer-events: none; }
.login-mark { position: absolute; top: 44px; left: 48px; width: 136px; height: auto; padding: 18px; border-radius: 30px; background: rgba(255, 255, 255, .94); box-shadow: 0 24px 50px -20px rgba(10, 20, 70, .55); animation: mark-float 6s ease-in-out infinite alternate; }
@keyframes mark-float { to { transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .login-mark { animation: none; } }
.login-art-inner { position: relative; padding: 48px; max-width: 620px; }
.login-chip { display: inline-block; font-size: 12.5px; padding: 6px 14px; border-radius: 999px; background: rgba(255, 255, 255, .16); backdrop-filter: blur(6px); margin-bottom: 18px; }
.login-art h2 { font-size: clamp(26px, 3vw, 40px); font-weight: 600; line-height: 1.45; margin-bottom: 14px; }
.login-art p { color: rgba(255, 255, 255, .82); line-height: 2; margin: 0 0 28px; max-width: 520px; }
.login-cards { display: flex; gap: 12px; flex-wrap: wrap; }
.lc {
  display: flex; align-items: center; gap: 10px;
  background: rgba(255, 255, 255, .14); border: 1px solid rgba(255, 255, 255, .22);
  backdrop-filter: blur(10px); border-radius: 18px; padding: 12px 14px; min-width: 190px;
}
.lc i { width: 34px; height: 34px; border-radius: 12px; flex: none; background: var(--lime); }
.lc-b i { background: var(--pink); }
.lc b { display: block; font-weight: 600; font-size: 13.5px; }
.lc span { font-size: 11.5px; color: rgba(255, 255, 255, .75); }
.lc-c { flex-direction: column; align-items: stretch; gap: 4px; min-width: 180px; }
.lc-c svg { width: 160px; height: 46px; }
@media (max-width: 900px) {
  .login-split { grid-template-columns: minmax(0, 1fr); padding: 12px; }
  .login-art { order: -1; min-height: 220px; }
  .login-art-inner { padding: 26px; }
  .login-art p, .login-cards { display: none; }
  .login-art h2 { font-size: 22px; margin: 0; }
  .login-mark { width: 76px; padding: 10px; border-radius: 18px; top: 22px; left: 22px; }
}

/* ---------- responsive ---------- */
.only-mobile { display: none; }
@media (max-width: 1280px) {
  .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g3 > .span-all { grid-column: 1 / -1; }
  .g-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 980px) {
  .canvas { padding: 0; }
  .shell { display: block; border-radius: 0; min-height: 100vh; box-shadow: none; }
  .rail {
    position: fixed; top: 0; bottom: 0; right: 0; z-index: 80;
    height: 100vh; width: 250px; align-items: stretch;
    padding: 22px 16px; background: var(--shell);
    transform: translateX(105%); transition: transform .25s cubic-bezier(.2, .8, .2, 1);
    box-shadow: -30px 0 60px -30px rgba(0, 0, 0, .35);
    overflow-y: auto;
  }
  body.rail-open .rail { transform: none; }
  body.rail-open::after { content: ""; position: fixed; inset: 0; background: rgba(30, 24, 50, .3); z-index: 79; }
  .brand { margin: 0 4px 18px; }
  .rail-nav { align-items: stretch; gap: 4px; }
  .rail-link { width: auto; height: 44px; border-radius: 14px; display: flex; gap: 12px; padding: 0 12px; justify-content: flex-start; }
  .rail-link em { display: inline; color: var(--ink); }
  .rail-link.is-on em { color: #fff; }
  .main { padding: 14px 16px 90px; }
  .only-mobile { display: grid; }
  .hide-mobile { display: none; }
  .top { flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
  .top-title { font-size: 22px; margin: 0; }
  .top-tools { margin-inline-start: auto; gap: 4px; }
  .avatar { width: 42px; height: 42px; font-size: 17px; margin: 0; }
  .search { order: 5; flex: 1 1 100%; margin: 0; }
  .pill-btn { height: 38px; }
  .g3, .g2 { grid-template-columns: minmax(0, 1fr); }
  .grid { gap: 16px; }
  .card { padding: 20px 16px; border-radius: 20px; }
  .tabs { gap: 8px 16px; flex-wrap: wrap; padding-bottom: 4px; max-width: 100%; }
  .tabs-row { gap: 10px; margin-bottom: 18px; }
  .range-pill span { display: none; }
  .form-grid { grid-template-columns: minmax(0, 1fr); }
  .form-grid > * { grid-column: 1 / -1; }
  .toast { left: 16px; right: 16px; bottom: 16px; }
}

/* ---------- print (invoice & reports) ---------- */
@media print {
  @page { size: A4; margin: 12mm; }
  body { background: #fff; }
  .canvas { padding: 0; background: #fff; }
  .shell { display: block; background: #fff; box-shadow: none; border-radius: 0; min-height: 0; }
  .rail, .top, .tabs-row, .no-print, .toast { display: none !important; }
  .main { padding: 0; }
  .card { padding: 0; border-radius: 0; }
}

/* ---------- staff chat (page + floating box) ---------- */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - 230px); min-height: 480px; background: #fff; border-radius: 24px; overflow: hidden; box-shadow: 0 1px 0 var(--line-2); }
.chat-side { display: flex; flex-direction: column; min-height: 0; border-inline-end: 1px solid var(--line-2); background: #fbfbf8; }
.chat-side-head { display: flex; align-items: center; gap: 4px; padding: 14px 14px 8px; }
.chat-side-head b { font-size: 15px; }
.chat-side-head .spacer { flex: 1; }
.chat-search { padding: 0 12px 8px; }
.chat-search .inp { height: 38px; width: 100%; }
.chat-rooms { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.chat-empty { padding: 24px 12px; text-align: center; font-size: 13px; }
.c-room { display: flex; align-items: center; gap: 10px; width: 100%; border: 0; background: transparent; padding: 9px 8px; border-radius: 14px; cursor: pointer; text-align: start; font: inherit; color: inherit; }
.c-room:hover { background: #f1f0ea; }
.c-room.is-on { background: var(--lav); }
.c-room-t { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.c-room-t b { font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-room-t small, .c-room-m small { font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.c-room-m { display: flex; flex-direction: column; align-items: flex-end; gap: 3px; flex: none; }
.c-room-m i { font-style: normal; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #1e9ad6; color: #fff; font-size: 11px; display: inline-grid; place-items: center; }
.c-av { width: 38px; height: 38px; border-radius: 50%; flex: none; display: inline-grid; place-items: center; overflow: hidden; background: var(--lav); color: var(--lav-ink); font-weight: 700; font-size: 14px; }
.c-av img { width: 100%; height: 100%; object-fit: cover; }
.c-av .ic { width: 18px; height: 18px; }
.c-av.ghost { visibility: hidden; }
.chat-new { margin: 0 12px 8px; padding: 10px; border-radius: 16px; background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.chat-new-tabs { display: flex; gap: 4px; margin-bottom: 8px; }
.chat-new-tabs button { flex: 1; height: 32px; border: 0; border-radius: 10px; background: #f1f0ea; font: inherit; font-size: 12.5px; cursor: pointer; }
.chat-new-tabs button.is-on { background: var(--ink); color: #fff; }
.chat-users { display: flex; flex-direction: column; gap: 2px; max-height: 220px; overflow-y: auto; }
.chat-users + .btn, [data-chat-group] .btn { margin-top: 8px; width: 100%; }
[data-chat-group] .inp { width: 100%; height: 36px; margin-bottom: 6px; }
.c-user { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border: 0; background: transparent; border-radius: 10px; cursor: pointer; font: inherit; font-size: 13px; text-align: start; }
.c-user:hover { background: #f1f0ea; }
.c-user .c-av { width: 30px; height: 30px; font-size: 12px; }

.chat-main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #f6f5f0 linear-gradient(180deg, #f8f7f3, #f1f0ea); }
.chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: #fff; border-bottom: 1px solid var(--line-2); min-height: 62px; }
.chat-head .btn { margin-inline-start: auto; }
.chat-head .btn .ic { width: 15px; height: 15px; }
.c-head-t { display: flex; flex-direction: column; min-width: 0; }
.c-head-t b { font-size: 14.5px; }
.c-head-t small { font-size: 12px; color: var(--muted); }
.chat-back { display: none; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px 18px; display: flex; flex-direction: column; gap: 4px; }
.c-day { text-align: center; margin: 10px 0 6px; }
.c-day span { display: inline-block; padding: 3px 12px; border-radius: 999px; background: rgba(28, 28, 32, .07); font-size: 11.5px; color: var(--ink-2); }
.c-msg { display: flex; align-items: flex-end; gap: 8px; max-width: 78%; }
.c-msg .c-av { width: 30px; height: 30px; font-size: 12px; }
.c-msg.mine { align-self: flex-end; flex-direction: row-reverse; }
.c-bub { position: relative; background: #fff; border-radius: 18px 18px 18px 6px; padding: 8px 12px 6px; box-shadow: 0 1px 2px rgba(20, 30, 60, .08); min-width: 90px; }
.c-msg.mine .c-bub { background: #e6f3fb; border-radius: 18px 18px 6px 18px; }
.c-name { display: block; font-size: 12px; color: #1e9ad6; margin-bottom: 2px; }
.c-text { font-size: 14px; line-height: 1.9; white-space: normal; word-wrap: break-word; overflow-wrap: anywhere; }
.c-text a { color: #1e7fbf; }
.c-del { color: var(--muted); font-size: 13px; }
.c-meta { display: flex; justify-content: flex-end; gap: 4px; align-items: center; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.c-tick::before { content: "✓"; color: #9aa4b2; }
.c-msg.seen .c-tick::before { content: "✓✓"; color: #1e9ad6; letter-spacing: -3px; }
.c-img img { display: block; max-width: 260px; max-height: 260px; border-radius: 12px; object-fit: cover; margin: 2px 0 4px; }
.c-file { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 12px; background: rgba(28, 28, 32, .05); color: inherit; text-decoration: none; margin: 2px 0 4px; }
.c-file .ic { width: 26px; height: 26px; color: #1e9ad6; flex: none; }
.c-file span { display: flex; flex-direction: column; min-width: 0; }
.c-file b { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.c-file small { font-size: 11px; color: var(--muted); }
.c-bub audio { display: block; width: 240px; max-width: 100%; height: 38px; margin: 2px 0; }
.c-dur { font-size: 11px; color: var(--muted); }
.c-tools { position: absolute; top: -12px; inset-inline-start: -8px; display: flex; align-items: center; gap: 2px; padding: 2px 4px; border-radius: 999px; background: #fff; box-shadow: 0 4px 14px -6px rgba(20, 30, 60, .35); }
.c-msg.mine .c-tools { inset-inline-start: auto; inset-inline-end: -8px; }
.c-tools button { width: 24px; height: 24px; border: 0; background: transparent; border-radius: 50%; display: inline-grid; place-items: center; cursor: pointer; color: var(--ink-2); }
.c-tools button:hover { background: #f1f0ea; }
.c-tools button .ic { width: 13px; height: 13px; }
.c-tools em { font-style: normal; font-size: 11px; color: #c23a3a; min-width: 14px; text-align: center; }

.chat-compose { background: #fff; border-top: 1px solid var(--line-2); padding: 10px 12px; }
.chat-input { display: flex; align-items: flex-end; gap: 6px; }
.chat-input textarea { flex: 1; resize: none; min-height: 42px; max-height: 140px; padding: 9px 14px; border-radius: 21px; line-height: 1.7; }
.chat-input .icon-btn { width: 40px; height: 40px; flex: none; cursor: pointer; }
.chat-send { width: 44px; height: 42px; padding: 0; border-radius: 50%; flex: none; display: inline-grid; place-items: center; }
.chat-send .ic { transform: scaleX(-1); }
.chat-rec, .chat-edit-bar { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.chat-rec .spacer, .chat-edit-bar .spacer { flex: 1; }
.chat-edit-bar { color: #1e7fbf; }
.chat-edit-bar .ic { width: 15px; height: 15px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #e5484d; animation: recblink 1s infinite; }
@keyframes recblink { 50% { opacity: .25; } }
.chat-compose.is-rec .chat-input { display: none; }

/* floating box */
.chat-float { position: fixed; z-index: 60; bottom: 22px; left: 22px; }
.chat-fab { width: 56px; height: 56px; border-radius: 50%; border: 0; background: #1c1c20; color: #fff; display: grid; place-items: center; cursor: pointer; box-shadow: 0 14px 30px -12px rgba(20, 20, 40, .6); position: relative; }
.chat-fab .ic { width: 24px; height: 24px; }
.chat-fab b { position: absolute; top: -3px; right: -3px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: #e5484d; color: #fff; font-size: 11.5px; display: grid; place-items: center; border: 2px solid #fff; }
.chat-float.open .chat-fab { background: #1e9ad6; }
.chat-pop { position: absolute; bottom: 70px; left: 0; width: 380px; height: min(600px, calc(100vh - 120px)); border-radius: 24px; overflow: hidden; box-shadow: 0 30px 70px -20px rgba(20, 30, 60, .45); }
.chat.compact { grid-template-columns: 1fr; height: 100%; min-height: 0; border-radius: 24px; }
.chat.compact .chat-main { display: none; }
.chat.compact.show-main .chat-side { display: none; }
.chat.compact.show-main .chat-main { display: flex; }
.chat.compact .chat-back { display: inline-grid; }
.chat.compact .c-msg { max-width: 88%; }
.chat.compact .c-img img { max-width: 200px; }
body.is-chat .content > .chat { margin-top: 2px; }
@media (max-width: 860px) {
  .chat:not(.compact) { grid-template-columns: 1fr; height: calc(100vh - 190px); }
  .chat:not(.compact) .chat-main { display: none; }
  .chat:not(.compact).show-main .chat-side { display: none; }
  .chat:not(.compact).show-main .chat-main { display: flex; }
  .chat .chat-back { display: inline-grid; }
  .chat-float { bottom: 84px; left: 14px; }
  .chat-pop { width: calc(100vw - 28px); height: calc(100vh - 170px); }
  .c-msg { max-width: 90%; }
}
@media print { .chat-float { display: none !important; } }
.perm-name { cursor: pointer; user-select: none; }
.perm-name:hover { color: #1e7fbf; text-decoration: underline dotted; }
.cust-logo { width: 34px; height: 34px; border-radius: 10px; flex: none; display: inline-grid; place-items: center; overflow: hidden; background: var(--lav); color: var(--lav-ink); font-weight: 700; font-size: 14px; vertical-align: middle; }
.cust-logo:has(img) { background: #fff; box-shadow: 0 0 0 1px var(--line-2); }
.cust-logo img { width: 100%; height: 100%; object-fit: contain; }
.cust-logo.lg { width: 54px; height: 54px; border-radius: 14px; font-size: 20px; }
.cust-logo.xl { width: 64px; height: 64px; border-radius: 18px; font-size: 24px; }
.cust-hero { display: flex; align-items: center; gap: 14px; margin-bottom: 14px; }
.cust-hero b { display: block; font-size: 17px; font-weight: 600; }
.cust-hero span { font-size: 12.5px; color: var(--muted); }
.cust-cell { display: flex; align-items: center; gap: 10px; }

/* comprehensive reports */
.rep-filter { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; margin-bottom: 18px; }
.rep-filter .field { min-width: 120px; }
.rep-filter .field.grow { flex: 1 1 280px; }
.rep-filter .spacer { flex: 1; }
.rep-head { display: flex; align-items: center; gap: 16px; margin: 4px 0 18px; }
.rep-head > img:first-child { height: 46px; }
.rep-head h2 { font-size: 20px; font-weight: 600; margin: 0; }
.rep-head span { font-size: 13px; color: var(--muted); }
.rep-head .rep-brand { height: 40px; margin-inline-start: auto; }
.rep-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 1100px) { .rep-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.rep-info { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px 18px; }
.rep-info div { display: flex; flex-direction: column; font-size: 13px; }
.rep-info div.wide { grid-column: span 2; }
.rep-info span { color: var(--muted); font-size: 12px; }
.rep-info b { font-weight: 500; }
@media (max-width: 760px) { .rep-info { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media print {
  .topbar, .page-head, .chat-float, .site-foot, .rep-filter { display: none !important; }
  .rep-kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; }
  .rep-pair { grid-template-columns: 1fr 1fr !important; }
  .kpi { min-height: 0; padding: 10px 12px; break-inside: avoid; }
  .card, .rep-pair > * { break-inside: avoid; }
  .kpi-dark { background: #fff !important; color: var(--ink) !important; border-color: var(--line-2) !important; }
  .kpi-dark .kpi-val { color: var(--ink) !important; }
}
.note-box { background: #fff8e1; color: #7a5a00; padding: 12px 16px; border-radius: 14px; margin-bottom: 16px; }
.note-box ul { margin: 4px 0 0; padding-right: 18px; }
.tax-pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: #f6f6f3; border-radius: 12px; padding: 10px 12px; margin: 6px 0 0; max-height: 360px; overflow: auto; font-family: Consolas, monospace; }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip-link { height: 32px; padding: 0 14px; border-radius: 999px; background: #f1f0ea; color: var(--ink-2); display: inline-flex; align-items: center; font-size: 13px; text-decoration: none; }
.chip-link.is-on { background: var(--ink); color: #fff; }
.vat-print-head { display: none; align-items: center; gap: 14px; margin-bottom: 10px; }
.vat-print-head img { height: 40px; }
.vat-print-head b { display: block; font-size: 15px; }
.vat-print-head span { font-size: 12px; color: var(--muted); }
.vat-list .vat-sub td { background: #f6f5f0; font-weight: 600; border-bottom: 2px solid var(--line-2); }
.vat-list .vat-grand td { background: var(--ink); color: #fff; font-weight: 700; }
@media print { .vat-print-head { display: flex; } .vat-list .vat-grand td { background: #e9e8e3 !important; color: var(--ink) !important; } .vat-list tbody { break-inside: auto; } .vat-list tr { break-inside: avoid; } }

/* KPIs inside a narrow column (customer profile) */
.kpis.kpis-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.kpis-2 .kpi { min-height: 0; padding: 14px 16px 12px; }
.kpis-2 .kpi .kpi-val { font-size: 16.5px; white-space: normal; }
.kpis-2 .kpi .kpi-base { white-space: normal; }
@media (max-width: 420px) { .kpis.kpis-2 { grid-template-columns: minmax(0, 1fr); } }

/* install-the-app card (dashboards) */
.pwa-card { display: flex; align-items: center; gap: 14px; background: linear-gradient(120deg, #1a2463, #1e78b8); color: #fff; border-radius: 22px; padding: 14px 16px; margin-bottom: 18px; }
.pwa-card[hidden] { display: none; }
.pwa-card img { width: 52px; height: 52px; border-radius: 14px; flex: none; background: #fff; }
.pwa-card .pwa-txt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pwa-card b { font-size: 15px; }
.pwa-card span { font-size: 12.5px; opacity: .85; line-height: 1.8; }
.pwa-card .pwa-steps { opacity: 1; background: rgba(255,255,255,.14); border-radius: 12px; padding: 8px 10px; margin-top: 6px; }
.pwa-card .btn { background: #fff; color: #1a2463; border-color: #fff; flex: none; }
.pwa-card .icon-btn { color: #fff; flex: none; }
@media (max-width: 640px) {
  .pwa-card { position: relative; flex-wrap: wrap; align-items: flex-start; padding: 16px 14px 14px; }
  .pwa-card img { width: 44px; height: 44px; }
  .pwa-card .pwa-txt { flex: 1 1 calc(100% - 100px); }
  .pwa-card .btn { flex: 1 1 100%; justify-content: center; }
  .pwa-card .icon-btn { position: absolute; top: 8px; left: 8px; }
}

/* ---------- phones: tables become stacked cards, top-bar menus fit the screen ---------- */
@media (max-width: 760px) {
  .tbl-wrap { margin: 0; padding: 0; }
  .tbl.stack, .tbl.stack > tbody, .tbl.stack > tfoot, .tbl.stack > tbody > tr, .tbl.stack > tfoot > tr { display: block; width: 100%; }
  .tbl.stack > thead { display: none; }
  .tbl.stack > tbody > tr, .tbl.stack > tfoot > tr { border: 1px solid var(--line-2); border-radius: 16px; padding: 4px 14px; margin-bottom: 10px; background: #fff; }
  .tbl.stack > tbody > tr:hover > td { background: transparent; }
  .tbl.stack > tbody > tr > td, .tbl.stack > tfoot > tr > td {
    display: flex; justify-content: space-between; align-items: center; gap: 12px;
    padding: 8px 0; border-bottom: 1px dashed var(--line); text-align: left; white-space: normal;
  }
  .tbl.stack td:last-child { border-bottom: 0; }
  .tbl.stack td[data-label]::before { content: attr(data-label); flex: none; max-width: 42%; color: var(--muted); font-size: 12px; text-align: right; }
  .tbl.stack td > .td-v { min-width: 0; text-align: left; overflow-wrap: break-word; }
  .tbl.stack td > .td-v .cell-sub { display: block; }
  .tbl.stack td.full, .tbl.stack td:not([data-label]) { display: block; text-align: right; }
  .tbl.stack td:empty, .tbl.stack td.no-val, .tbl.stack td[data-label="#"] { display: none; }
  .tbl.stack .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .tbl.stack > tbody > tr > td, .tbl.stack > tfoot > tr > td { width: auto !important; min-width: 0 !important; max-width: none !important; }
  .tbl.stack td.has-in > .td-v { flex: 1 1 auto; max-width: 66%; }
  .tbl.stack .td-v input:not([type=checkbox]):not([type=radio]):not([type=hidden]), .tbl.stack .td-v select, .tbl.stack .td-v textarea, .tbl.stack .td-v .ac { width: 100% !important; max-width: 100%; min-width: 0; }
  .tbl.stack tr.vat-sub, .tbl.stack tr.vat-grand { border-radius: 12px; }
  /* top-bar menus open under the bar across the screen */
  .topbar .top-tools .dd { position: static; }
  .topbar .top-tools .dd-menu { left: 10px !important; right: 10px !important; top: 100%; min-width: 0; width: auto; max-height: 72vh; overflow-y: auto; }
  .tb-search { width: auto; }
  .dd-menu { max-width: calc(100vw - 20px); }
}
@media print { .tbl.stack > thead { display: table-header-group; } }