/* Lambda — UI стил */
:root {
  --bg: #f3f5f8;
  --panel: #ffffff;
  --ink: #16212f;
  --ink-2: #5b6b7d;
  --line: #e3e8ef;
  --brand: #1d4ed8;
  --brand-2: #1e40af;
  --accent: #0ea5e9;
  --danger: #dc2626;
  --ok: #16a34a;
  --side: #101828;
  --side-ink: #cbd5e1;
  --radius: 10px;
}
* { box-sizing: border-box; }
/* Бутоните ни имат display, който иначе надвива вграденото поведение на hidden. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
/* Приложението е с фиксиран мащаб като native: два пръста местят страницата,
   но не я увеличават, а двойното докосване не прави zoom. */
html {
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 14.5px;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

.app { display: flex; min-height: 100vh; }

/* ------------------------------- Sidebar ------------------------------ */
.sidebar {
  width: 232px; flex-shrink: 0; background: var(--side); color: var(--side-ink);
  display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 16px; }
a.brand:hover { text-decoration: none; }
a.brand:hover .brand-name { color: #fff; opacity: 0.85; }
.brand-mark {
  width: 38px; height: 38px; border-radius: 10px; flex-shrink: 0;
  background: var(--side); overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; display: block; }
.brand-mark.big { width: 56px; height: 56px; margin: 0 auto 12px; }
.brand-name { font-weight: 600; color: #fff; font-size: 16px; }
.sidebar nav { flex: 1; padding: 8px; overflow-y: auto; }
.sidebar nav a {
  display: flex; align-items: center; gap: 10px; color: var(--side-ink);
  padding: 10px 12px; border-radius: 8px; margin-bottom: 2px; font-size: 14px;
}
.sidebar nav a:hover { background: rgba(255,255,255,0.06); text-decoration: none; }
.sidebar nav a.active { background: var(--brand); color: #fff; }
.sidebar nav .ic { width: 20px; text-align: center; }
.sidebar-foot { padding: 14px 16px; border-top: 1px solid rgba(255,255,255,0.08); }
.user-chip { color: #fff; font-weight: 600; margin-bottom: 4px; }
.link-quiet { color: var(--side-ink); font-size: 13px; }
.link-quiet.ver { float: right; opacity: 0.65; }

/* -------------------------------- Main -------------------------------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.topbar {
  display: flex; align-items: center; gap: 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
  padding: 12px 22px; position: sticky; top: 0; z-index: 5;
}
/* min-width: 0 позволява на заглавието да се свие, вместо да разпъне бара.
   Логото след него е с auto полета — застава по средата на празното място. */
.topbar h1 { font-size: 18px; margin: 0; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.burger { display: none; background: none; border: 0; font-size: 20px; cursor: pointer; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.45); }
.lang-switch { display: flex; gap: 4px; }
.lang-switch button {
  border: 1px solid var(--line); background: var(--panel); border-radius: 6px;
  padding: 4px 9px; cursor: pointer; font-size: 12px; color: var(--ink-2);
}
.lang-switch button.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.content { padding: 22px; max-width: 1180px; width: 100%; margin: 0 auto; }

/* ------------------------------- Panels ------------------------------- */
.panel {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; margin-bottom: 18px;
}
.panel h2 { font-size: 15px; margin: 0 0 12px; color: var(--ink); }
/* Заглавие с действие вдясно (напр. „Напомняния  + Ново"). */
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.panel-head h2 { margin: 0 0 12px; }
/* Предложените клаузи по договор: едно цъкане ги превръща в напомняне. */
.suggest { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.suggest p { margin: 0; width: 100%; }
.btn-chip {
  background: var(--panel); border: 1px dashed var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.btn-chip:hover { border-style: solid; border-color: var(--accent); color: var(--accent); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 18px; }
.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.card.warn { border-left: 4px solid var(--danger); }
/* Картите на началната страница водят към съответния списък. */
a.card { display: block; color: inherit; transition: border-color .15s ease, box-shadow .15s ease; }
a.card:hover { text-decoration: none; border-color: var(--brand); box-shadow: 0 2px 12px rgba(29, 78, 216, 0.12); }
a.card.warn:hover { border-left-color: var(--danger); }
.card-label { color: var(--ink-2); font-size: 12.5px; }
.card-num { font-size: 26px; font-weight: 700; margin: 2px 0; }
.card-sub { color: var(--ink-2); font-size: 13px; }

/* ------------------------------- Tables ------------------------------- */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; color: var(--ink-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.4px; }
.tbl th, .tbl td { padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num, .tbl th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tbl.kv td:first-child { color: var(--ink-2); width: 160px; }
.tbl tr.inactive td { opacity: 0.5; }
.tbl tr.totals td { font-weight: 600; background: #f8fafc; }
/* Цял ред като връзка към документа. */
tr[data-href] { cursor: pointer; }
tr[data-href]:hover > td { background: #f7f9fc; }
/* Името взима свободното място, останалите колони не се пренасят. */
.tbl.stack td.c-name { width: 99%; }
.tbl.stack td:not(.c-name) { white-space: nowrap; }
/* Таблица с повече колони от обичайното се плъзга сама, вместо да разпъне картата. */
.tbl-scroll { overflow-x: auto; }
.red { color: var(--danger); } .green { color: var(--ok); }
.quiet { color: var(--ink-2); font-size: 13px; }
.mono { font-family: Consolas, monospace; font-size: 12px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 12px; background: #eef2f7; color: var(--ink-2); }
.b-draft { background: #f1f5f9; color: #475569; }
.b-sent { background: #dbeafe; color: #1e40af; }
.b-accepted { background: #dcfce7; color: #166534; }
.b-rejected { background: #fee2e2; color: #991b1b; }
.b-converted { background: #ede9fe; color: #5b21b6; }
.b-active { background: #dcfce7; color: #166534; }
.b-suspended { background: #fef3c7; color: #92400e; }
.b-expired { background: #f1f5f9; color: #475569; }
.b-terminated { background: #fee2e2; color: #991b1b; }
.b-pending { background: #fef3c7; color: #92400e; }
.b-snoozed { background: #e0e7ff; color: #3730a3; }
.b-done { background: #dcfce7; color: #166534; }
.b-cancelled { background: #f1f5f9; color: #475569; }
.b-submitted { background: #dbeafe; color: #1e40af; }
.tender-interesting > td { background: #fffbeb; }
.link-btn.on, .btn-ghost.on { color: #b45309; border-color: #f59e0b; font-weight: 600; }
.tender-triage { white-space: nowrap; }
.tender-triage form { display: inline; margin: 0 0 0 6px; }
#tenders-inbox th.c-check,
#tenders-inbox td.c-check { width: 1.75rem; max-width: 1.75rem; padding-right: 4px; }
#tenders-inbox td.c-check input { width: auto; margin: 0; }
.tenders-bulk {
  display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center;
  margin: 0 0 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel);
}
.tenders-bulk label {
  display: flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-2);
}
.tenders-bulk select { width: auto; }
.tenders-bulk-count { min-width: 8rem; }
/* Десктоп: предметът е къс, цялото заглавие е в title при hover. */
@media (min-width: 861px) {
  #tenders-inbox td.c-subject {
    width: 10rem;
    max-width: 10rem;
    overflow: hidden;
  }
  #tenders-inbox td.c-subject a,
  #tenders-inbox td.c-subject .quiet {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

/* -------------------------------- Forms ------------------------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 18px; }
.form-grid.three { grid-template-columns: 1fr 1fr 1fr; }
.form-grid label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--ink-2); }
.form-grid .span2 { grid-column: span 2; }
.form-grid fieldset { border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px 14px; }
.form-grid legend { font-size: 12.5px; color: var(--ink-2); padding: 0 6px; }
input, select, textarea {
  font: inherit; color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; background: #fff; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(29, 78, 216, 0.25); border-color: var(--brand); }
label.check { flex-direction: row; align-items: center; gap: 8px; }
label.check input { width: auto; }
.two { display: flex; gap: 8px; }
.form-actions { display: flex; gap: 10px; margin-top: 8px; align-items: center; }
#archive-iphone .two input { flex: 1; min-width: 0; }
#archive-iphone .two .btn-ghost { flex-shrink: 0; width: auto; }
.iphone-steps { margin: 14px 0 8px; padding-left: 20px; }
.iphone-steps li { margin: 6px 0; color: var(--ink-2); line-height: 1.45; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; align-items: center; }
.inline-form input, .inline-form select { width: auto; }

.btn-primary {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: 9px 18px; font-size: 14px; cursor: pointer; display: inline-block; text-decoration: none;
}
.btn-primary:hover { background: var(--brand-2); text-decoration: none; }
.btn-ghost {
  background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 14px; font-size: 13.5px; cursor: pointer; display: inline-block;
}
.btn-ghost:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font-size: 13px; padding: 4px; }
.link-btn { background: none; border: 0; color: var(--brand); cursor: pointer; font-size: 13px; padding: 0; }
.tender-docs { white-space: normal; max-width: 280px; }
.tender-docs form { display: inline; margin: 0 0 0 6px; }
.tender-source-files { margin: 0 0 12px; padding-left: 18px; }
.tender-source-files li { margin: 4px 0; }
/* Бутоните на документа се пренасят на нов ред — иначе на тесен екран
   разпъват страницата настрани и картите излизат извън екрана. */
.row-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.row-actions form { margin: 0; }
/* Менюто с действия съществува само на телефон: тук съдържанието му се
   разлива обратно в лентата, а бутонът и заглавията на групите не се виждат. */
.act-menu, .act-list { display: contents; }
.act-toggle, .act-group { display: none; }
/* Отметка до бутон — например „Към счетоводство" при издаване на номер. */
.issue-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.check-inline {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap;
}
.check-inline input { width: auto; }

/* Бързо отбелязване на плащане: Банка / Кеш / Карта с днешна дата. */
.pay-quick { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 12px; }
.row-actions .pay-quick { margin-top: 0; }
.pay-hint { color: var(--ink-2); font-size: 12.5px; }
.row-actions .pay-hint { display: none; }
.btn-pay {
  background: var(--panel); color: var(--ink-2); border: 1px solid var(--line); border-radius: 20px;
  padding: 5px 12px; font-size: 12.5px; cursor: pointer; white-space: nowrap;
}
.btn-pay:hover { border-color: var(--ok); color: var(--ok); }
.btn-ghost.on { border-color: var(--brand); color: var(--brand); background: #eff4ff; }

/* ------------------------------ Страници ------------------------------ */
.pager {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line);
}
.pager-info { font-size: 12.5px; color: var(--ink-2); }
.pager-links { display: flex; gap: 4px; flex-wrap: wrap; }
.pager-btn {
  min-width: 34px; text-align: center; padding: 6px 9px; font-size: 13px;
  border: 1px solid var(--line); border-radius: 8px; color: var(--ink);
}
a.pager-btn:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
.pager-btn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager-btn.off { color: #cbd5e1; }
.pager-gap { padding: 6px 2px; color: var(--ink-2); }

/* Подредбата на списъка с имейли: на телефон заглавията на колоните ги няма. */
.only-mobile { display: none; }
.sort-pick { margin-bottom: 10px; }
.sort-pick label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-2); }
.sort-pick select { width: auto; flex: 1; }

.toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; gap: 12px; flex-wrap: wrap; }
.toolbar .search input { min-width: 240px; }
.flash {
  background: #ecfdf5; border: 1px solid #a7f3d0; color: #065f46;
  border-radius: 8px; padding: 10px 14px; margin-bottom: 14px;
}
.flash.err { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

/* -------------------------------- Login ------------------------------- */
/* Grid, не flex: iOS Safari маха интервалите в текста на flex дете. */
.login-body {
  display: grid; place-items: center;
  min-height: 100vh; min-height: 100dvh;
  padding: 24px 16px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  background: linear-gradient(150deg, #0f172a, #1e293b);
}
.login-card {
  background: #fff; border-radius: 14px; padding: 34px 36px; width: 380px; max-width: calc(100vw - 32px);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35); text-align: center;
}
.login-card h1,
.login-card p,
.login-card .flash,
.login-card .quiet,
.login-card .app-pass {
  display: block;
  white-space: pre-wrap;
  word-spacing: normal;
  letter-spacing: normal;
  line-height: 1.45;
}
.login-card h1 { font-size: 18px; margin: 0 0 18px; }
.login-card .hint { text-align: left; margin: 0 0 14px; }
.login-card form { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.login-card label { font-size: 13px; color: var(--ink-2); display: flex; flex-direction: column; gap: 5px; }
.login-card .btn-primary {
  display: block; width: 100%; margin-top: 4px; line-height: 44px;
}
.login-card .or { color: var(--ink-2); margin: 14px 0 10px; }
.login-card .app-pass {
  display: block; margin-top: 14px; font-size: 13px; line-height: 1.45;
}
.btn-google {
  display: block; border: 1px solid var(--line); border-radius: 8px; padding: 9px; color: var(--ink);
}

/* --------------------------------- Chat ------------------------------- */
.chat-wrap {
  display: flex; flex-direction: column;
  height: calc(100vh - 140px); min-height: 420px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.chat-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.chat-title { font-weight: 600; }
.chat-actions { display: flex; gap: 8px; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.me { align-self: flex-end; background: var(--brand); color: #fff; border-bottom-right-radius: 4px; }
.msg.ai { align-self: flex-start; background: #eef2f7; border-bottom-left-radius: 4px; }
.msg.err { align-self: flex-start; background: #fee2e2; color: #991b1b; }
.msg.typing { color: var(--ink-2); font-style: italic; }
.chat-confirm {
  border-top: 2px solid #f59e0b; background: #fffbeb; padding: 12px 16px;
}
.confirm-hint { font-size: 13px; color: #92400e; margin-bottom: 8px; }
.confirm-actions { display: flex; gap: 10px; }
.chat-input {
  display: flex; gap: 8px; padding: 12px 14px; border-top: 1px solid var(--line); align-items: flex-end;
}
.chat-input textarea { flex: 1; resize: none; max-height: 130px; }
.chat-input .send { padding: 9px 16px; }
.mic { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; font-size: 16px; cursor: pointer; padding: 8px 10px; }
.mic.rec { background: #fee2e2; border-color: var(--danger); animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: 0.6; } }

/* -------------------------------- Emails ------------------------------ */
.email-thread { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.email-msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.email-msg.in { border-left: 4px solid var(--accent); }
.email-msg.out { border-left: 4px solid var(--ok); }
.email-msg.draft { border-left: 4px solid #f59e0b; background: #fffbeb; }
.email-meta { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; flex-wrap: wrap; }
.email-body { line-height: 1.5; overflow-wrap: anywhere; }
.email-body img { max-width: 100%; height: auto; }
.email-body table { max-width: 100%; }
.email-draft-edit { width: 100%; margin-bottom: 8px; }
.email-fwd { margin-left: auto; font-size: 13px; }

/* Прикачените на едно писмо — ред от чипове под текста. */
.email-atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.email-att {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px;
  background: #f4f7fb; font-size: 13px;
}
.email-att > a:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 20rem; }
.email-att form { display: inline; }
.email-att-dl { text-decoration: none; }
.email-att-arc { border: 0; background: none; padding: 0; font-size: 12.5px; color: var(--ink-2); cursor: pointer; }
.email-att-arc:hover { color: var(--brand); text-decoration: underline; }

/* Избор кои прикачени да тръгнат при препращане. */
.fwd-atts { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; }
.fwd-att { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 14px; }
.fwd-att input { width: auto; margin: 0; }

/* ----------------------- CompanyBook lookup -------------------------- */
.cb-lookup {
  margin-bottom: 16px; padding: 14px; border: 1px dashed var(--brand);
  border-radius: var(--radius); background: #f5f8ff;
}
.cb-lookup > label { display: block; font-weight: 600; margin-bottom: 8px; }
.cb-row { display: flex; gap: 8px; }
.cb-row input {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px;
}
.cb-results { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.cb-item {
  text-align: left; padding: 9px 12px; border: 1px solid var(--line);
  background: var(--panel); border-radius: var(--radius); cursor: pointer;
  display: flex; flex-direction: column; gap: 2px; font-size: 14px;
}
.cb-item:hover { border-color: var(--brand); background: #eef3ff; }
.cb-uic { font-size: 12px; color: var(--muted, #64748b); }
.cb-msg { margin-top: 8px; font-size: 13px; }
.cb-msg.red { color: var(--danger); }
input.cb-filled, textarea.cb-filled { background: #eefaf0; }

/* ------------------ Избор на партньор с търсене ----------------------- */
.partner-field { display: flex; gap: 8px; align-items: flex-start; }
.partner-field .picker { flex: 1; }
.partner-field .btn-ghost { white-space: nowrap; padding: 8px 12px; }
.picker { position: relative; }
/* Оригиналният select стои под полето: пази стойността и валидацията. */
.picker-native {
  position: absolute; left: 0; bottom: 0; width: 100%; height: 1px;
  opacity: 0; pointer-events: none; border: 0; padding: 0;
}
.picker-list {
  position: absolute; z-index: 40; top: calc(100% + 4px); left: 0; right: 0;
  max-height: 260px; overflow-y: auto; background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(16, 24, 40, 0.12);
}
.picker-item {
  display: block; width: 100%; text-align: left; background: none; border: 0;
  padding: 9px 12px; font-size: 14px; color: var(--ink); cursor: pointer;
}
.picker-item:hover, .picker-item.active { background: #eef3ff; }
.picker-item.on { font-weight: 600; }
.picker-empty { padding: 10px 12px; font-size: 13px; color: var(--ink-2); }
.picker.invalid .picker-input { border-color: var(--danger); }

/* --------------------------- Модален прозорец ------------------------- */
.modal {
  position: fixed; inset: 0; z-index: 70; display: flex; align-items: center;
  justify-content: center; background: rgba(16, 24, 40, 0.5); padding: 16px;
  overflow-y: auto;
}
.modal[hidden] { display: none; }
.modal-card {
  background: var(--panel); border-radius: var(--radius); width: 100%; max-width: 44rem;
  max-height: calc(100vh - 32px); overflow-y: auto; padding: 18px 20px 20px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.28);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 17px; }
.modal-x { background: none; border: 0; font-size: 18px; color: var(--ink-2); cursor: pointer; padding: 4px 8px; }
.modal-x:hover { color: var(--ink); }
.modal-msg { font-size: 13px; min-height: 18px; }
.modal-msg.red { color: var(--danger); }
.modal .cb-lookup { margin-bottom: 0; }
body.modal-open { overflow: hidden; }

/* ------------------ Прикачване от системата към писмо ----------------- */
.attach-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.attach-head .btn-ghost { padding: 4px 10px; font-size: 13px; }
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-chip {
  display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
  border: 1px solid var(--line); border-radius: 999px; padding: 4px 6px 4px 12px;
  background: #f4f7fb; font-size: 13px;
}
.attach-chip-t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 22rem; }
.attach-swap {
  border: 1px solid var(--line); background: var(--panel); border-radius: 999px;
  padding: 1px 8px; font-size: 11.5px; color: var(--ink-2); cursor: pointer;
}
.attach-swap:hover { border-color: var(--brand); color: var(--ink); }
.attach-mark { font-size: 11.5px; color: var(--ink-2); }
.attach-x { border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 13px; padding: 0 4px; }
.attach-x:hover { color: var(--danger); }
.attach-search { width: 100%; }
.attach-results { margin-top: 10px; max-height: 50vh; overflow-y: auto; }
.attach-group {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--ink-2); padding: 10px 2px 4px;
}
.attach-result {
  display: block; width: 100%; text-align: left; background: none; cursor: pointer;
  border: 0; border-top: 1px solid var(--line); padding: 8px 4px;
}
.attach-result:hover { background: #eef3ff; }
.attach-title { display: block; font-size: 14px; color: var(--ink); }
.attach-sub { display: block; font-size: 12.5px; }

/* ----------------------------- Email search -------------------------- */
.email-boxes, .email-folders {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px;
}
.email-boxes a, .email-folders a {
  display: inline-block; padding: 5px 11px; border-radius: 999px;
  border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  font-size: 13px; background: #fff;
}
.email-boxes a:hover, .email-folders a:hover { border-color: var(--brand); color: var(--brand); }
.email-boxes a.active, .email-folders a.active {
  background: var(--brand); border-color: var(--brand); color: #fff;
}
.email-folder-pick { display: none; margin-bottom: 12px; }
.email-search { display: flex; gap: 8px; margin-bottom: 12px; }
.email-search input[type="search"] {
  flex: 1; padding: 9px 12px; border: 1px solid var(--line);
  border-radius: var(--radius); font-size: 14px;
}
/* Поръчки: полето е на цял ред, филтрите се пренасят под него. */
.tenders-search { flex-wrap: wrap; }
.tenders-search input[type="search"] { flex: 1 1 100%; min-width: 16rem; }
.tenders-search select,
.tenders-search .check,
.tenders-search .btn-ghost { width: auto; }
.tbl th a { color: inherit; display: inline-block; }
.tbl th a:hover { color: var(--brand); }
.tbl th a.active { color: var(--brand); font-weight: 700; }
.nowrap { white-space: nowrap; }

/* --------------------------- Email sync progress --------------------- */
.sync-item { padding: 12px 0; border-bottom: 1px solid var(--line); }
.sync-item:last-child { border-bottom: 0; }
.sync-head { margin-bottom: 8px; }
.progress { background: #e5eaf1; border-radius: 20px; height: 12px; overflow: hidden; }
.progress-bar {
  height: 100%; width: 0; border-radius: 20px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
  transition: width 0.35s ease;
}
.progress-bar.done { background: var(--ok); }
.progress-bar.err { background: var(--danger); }
.sync-status { margin-top: 6px; font-size: 13px; }

/* ------------------------------ Items editor -------------------------- */
.items-editor input { padding: 6px 8px; }
.items-editor .it-total { white-space: nowrap; }
/* Приспаднатият аванс е готов ред — показва се, но не се редактира. */
.items-editor tr.it-fixed td { background: #f8fafc; color: var(--ink-2); }

/* --------------------- Анулиране и сторниране ------------------------- */
.voided-note { border-left: 4px solid var(--danger); background: #fef2f2; }
.void-box { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }
.void-box summary { cursor: pointer; color: var(--danger); font-size: 13px; }
.void-box p { margin: 8px 0 0; }

/* --------------------------- Дата (дд.мм.гггг) ------------------------ */
.date-field { position: relative; display: flex; align-items: center; gap: 6px; }
.date-field .date-eu { flex: 1; min-width: 0; }
.date-field .date-native {
  position: absolute; left: 0; bottom: 0; width: 1px; height: 1px;
  opacity: 0; padding: 0; border: 0; pointer-events: none;
}
.date-field .date-btn {
  border: 1px solid var(--line); background: var(--panel); border-radius: var(--radius);
  padding: 7px 9px; cursor: pointer; line-height: 1; font-size: 14px;
}
.date-field .date-btn:hover { border-color: var(--brand); }

/* ------------------------------ Известия ------------------------------ */
/* Логото и в горния бар — на телефон менюто е скрито, а връзката към Начало трябва да е под ръка. */
.topbar-logo { display: flex; align-items: center; margin: 0 auto; }
.topbar-logo:hover { text-decoration: none; }
.topbar-logo .brand-mark { width: 30px; height: 30px; border-radius: 8px; }
.topbar-logo:hover .brand-mark { filter: brightness(1.12); }
.bell { position: relative; text-decoration: none; font-size: 18px; padding: 4px 8px; }
.bell-count {
  position: absolute; top: -2px; right: -2px; min-width: 17px; height: 17px;
  border-radius: 9px; background: var(--danger); color: #fff;
  font-size: 11px; line-height: 17px; text-align: center; padding: 0 4px; font-weight: 700;
}
.notif { padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 10px; }
.notif.pending { border-left: 4px solid var(--brand); background: #f5f8ff; }
.notif-title { font-weight: 600; margin-bottom: 4px; }
.notif-body { font-size: 14px; color: var(--ink-2); margin-bottom: 8px; }
.notif-actions { display: flex; gap: 8px; align-items: center; }

/* --------------------- Подписи и имейл шаблони ------------------------ */
.sig-preview {
  border: 1px dashed var(--line); border-radius: var(--radius);
  padding: 14px; background: #fff; overflow-x: auto;
}
.sig-preview img { max-width: 100%; height: auto; }
.tpl-help { margin-top: 14px; font-size: 13px; color: var(--ink-2); }
.tpl-help ul { margin: 6px 0 0; padding-left: 18px; }
.tpl-help li { margin: 2px 0; }
.tpl-help code, .quiet code {
  background: #eef2f7; border-radius: 4px; padding: 1px 5px; font-size: 12px;
}

/* --------------------------- Готови забележки ------------------------- */
.note-pick { display: flex; gap: 8px; align-items: center; margin-top: 6px; flex-wrap: wrap; }
.note-pick select { flex: 1; min-width: 180px; }

/* --------------------- Инсталиране като приложение -------------------- */
.install-btn {
  background: var(--brand); color: #fff; border: 0; border-radius: 8px;
  padding: 6px 14px; font-size: 13px; cursor: pointer; white-space: nowrap;
}
.install-btn:hover { background: var(--brand-2); }
.install-sheet {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end;
  justify-content: center; background: rgba(16, 24, 40, 0.5);
  padding: 0 12px calc(12px + env(safe-area-inset-bottom));
}
/* Задължително: правило с display побеждава вградения стил на hidden. */
.install-sheet[hidden] { display: none; }
.install-card {
  background: var(--panel); border-radius: var(--radius); padding: 20px;
  width: 100%; max-width: 26rem; box-shadow: 0 -8px 40px rgba(0,0,0,0.25);
}
.install-card h3 { margin: 0 0 10px; font-size: 17px; }
.install-steps { margin: 0 0 12px; padding-left: 20px; }
.install-steps li { margin: 6px 0; }
.install-card .btn-ghost { margin-top: 12px; }
@media (min-width: 861px) { .install-sheet { align-items: center; } }

.markup-box { margin-left: 14px; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.markup-input { width: 70px; padding: 4px 6px; }

/* Прикачен файл към чата */
.chat-attach { display: flex; align-items: center; gap: 8px; padding: 6px 14px; border-top: 1px solid var(--line); }
.chat-attach .chip { font-size: 13px; color: var(--ink-2); }
.chip-x { border: 0; background: none; cursor: pointer; color: var(--ink-2); font-size: 14px; }

/* ------------------------ Печати и подписи --------------------------- */
.mark-grid { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 14px; }
.mark-card {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px;
  width: 170px; background: repeating-conic-gradient(#f6f7f9 0% 25%, #fff 0% 50%) 50% / 14px 14px;
}
.mark-card img { max-width: 100%; max-height: 90px; display: block; margin: 0 auto 6px; }
.mark-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; background: var(--panel); }
.sign-pad-wrap { border: 1px dashed var(--line); border-radius: var(--radius); background: #fff; }
#signPad { width: 100%; height: 220px; display: block; touch-action: none; cursor: crosshair; }

/* Редактор: палитра отляво, страниците отдясно. */
.mark-editor { display: grid; grid-template-columns: 240px 1fr; gap: 16px; align-items: start; }
.mark-palette {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; position: sticky; top: 14px;
}
.mark-palette h3 { margin: 0 0 6px; font-size: 15px; }
.mark-chip {
  display: flex; align-items: center; gap: 8px; width: 100%; margin-top: 8px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: var(--panel); text-align: left;
}
.mark-chip:hover { border-color: var(--brand); }
.mark-chip.on { border-color: var(--brand); box-shadow: 0 0 0 2px rgba(29, 78, 216, 0.15); }
.mark-chip img { width: 46px; height: 36px; object-fit: contain; }
.mark-chip span { font-size: 12.5px; color: var(--ink-2); }
.mark-tools { margin-top: 14px; border-top: 1px solid var(--line); padding-top: 10px; }

.mark-pages { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.mark-page { position: relative; box-shadow: 0 2px 14px rgba(16, 24, 40, 0.16); background: #fff; max-width: 100%; }
.mark-page-img { display: block; width: 100%; height: auto; user-select: none; -webkit-user-drag: none; }
.mark-layer { position: absolute; inset: 0; }
.mark-pageno {
  position: absolute; right: -10px; top: -10px; background: var(--ink); color: #fff;
  border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center;
  justify-content: center; font-size: 12px;
}
.mark-item { position: absolute; cursor: move; touch-action: none; }
.mark-item img { width: 100%; height: auto; display: block; pointer-events: none; }
.mark-item.on { outline: 2px dashed var(--brand); outline-offset: 2px; }
.mark-x, .mark-size { position: absolute; display: none; }
.mark-item.on .mark-x, .mark-item.on .mark-size { display: flex; }
.mark-x {
  top: -11px; right: -11px; width: 22px; height: 22px; border-radius: 50%;
  background: var(--danger); color: #fff; align-items: center; justify-content: center;
  font-size: 12px; cursor: pointer;
}
.mark-size {
  right: -8px; bottom: -8px; width: 16px; height: 16px; background: var(--brand);
  border: 2px solid #fff; border-radius: 4px; cursor: nwse-resize;
}

.archive-preview { width: 100%; height: auto; border: 1px solid var(--line); border-radius: 6px; margin-bottom: 10px; }
.archive-text {
  white-space: pre-wrap; font-size: 12.5px; color: var(--ink-2); max-height: 420px;
  overflow: auto; background: #f8fafc; border: 1px solid var(--line); border-radius: 6px; padding: 10px; margin: 0;
}

/* ------------------------- За системата ------------------------------ */
.about-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; }
.about-head h2 { margin: 0 0 4px; }
.about-head p { margin: 0; }
.about-ver { display: flex; align-items: center; gap: 8px; }
.ver-badge {
  display: inline-block; background: #eef2ff; color: var(--brand-2); border: 1px solid #c7d2fe;
  border-radius: 999px; padding: 2px 10px; font-size: 12.5px; font-weight: 600;
}
.ver-badge.now { background: var(--brand); color: #fff; border-color: var(--brand); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a {
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink-2); font-size: 13.5px;
}
.tabs a:hover { text-decoration: none; border-color: var(--brand); }
.tabs a.on { background: var(--brand); border-color: var(--brand); color: #fff; }

.guide { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; align-items: start; }
.guide-card h3 { margin: 0 0 8px; font-size: 15.5px; display: flex; align-items: center; gap: 8px; }
.guide-ic {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 8px; background: #eef2ff;
  display: flex; align-items: center; justify-content: center; font-size: 15px;
}
.guide-card ol { margin: 0; padding-left: 20px; }
.guide-card li { margin: 6px 0; line-height: 1.5; }

.release { padding: 14px 0; border-bottom: 1px solid var(--line); }
.release:last-child { border-bottom: 0; padding-bottom: 0; }
.release:first-child { padding-top: 0; }
.release-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }
.release ul { margin: 0; padding-left: 20px; }
.release li { margin: 5px 0; line-height: 1.5; }

/* ---------------- Безопасна зона (изрез и лента на iPhone) ------------ */
.topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
.sidebar { padding-top: env(safe-area-inset-top); }
.sidebar-foot { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
.content { padding-bottom: calc(22px + env(safe-area-inset-bottom)); }

/* ------------------------------ Календар ------------------------------ */
.cal-month { min-width: 9.5rem; text-align: center; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .4px; color: var(--ink-2); padding: 2px 4px; }
.cal-day {
  min-height: 92px; border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  display: flex; flex-direction: column; gap: 2px; background: #fff;
}
.cal-day.out { background: #fafbfc; opacity: .6; }
.cal-day.today { border-color: var(--brand); box-shadow: inset 0 0 0 1px var(--brand); }
.cal-num { font-size: 12px; color: var(--ink-2); }
.cal-day.today .cal-num { color: var(--brand); font-weight: 700; }
.cal-ev {
  display: block; font-size: 11.5px; line-height: 1.35; padding: 2px 5px; border-radius: 5px;
  background: #eef2f7; color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cal-ev:hover { text-decoration: none; filter: brightness(0.96); }
.cal-ev.done { opacity: .5; text-decoration: line-through; }
.cal-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; background: #94a3b8; }
.k-reminder { background: #fef3c7; color: #92400e; }
.k-billing { background: #dbeafe; color: #1e40af; }
.k-contract_start { background: #dcfce7; color: #166534; }
.k-contract_end { background: #fee2e2; color: #991b1b; }
.k-contract_notice { background: #ffe4e6; color: #9f1239; }
.k-invoice_due { background: #ede9fe; color: #5b21b6; }

/* ------------------------------- Mobile ------------------------------- */
@media (max-width: 860px) {
  .sidebar {
    position: fixed; left: -240px; z-index: 30; transition: left 0.2s ease; height: 100vh;
  }
  .sidebar.open { left: 0; box-shadow: 0 0 40px rgba(0,0,0,0.4); }
  /* Затъмнението стои под менюто и поема цъкането извън него. */
  body.menu-open .sidebar-backdrop { display: block; }
  .burger { display: block; }
  /* На тесен екран барът събира повече елементи — по-малко въздух между тях. */
  .topbar { gap: 8px; padding-left: 12px; padding-right: 12px; }
  .topbar h1 { font-size: 16px; }
  .install-btn { padding: 5px 10px; font-size: 12px; }
  .lang-switch button { padding: 4px 7px; }
  .only-mobile { display: block; }
  .grid-2, .form-grid, .form-grid.three { grid-template-columns: 1fr; }
  .form-grid .span2 { grid-column: span 1; }
  .content { padding: 14px; padding-bottom: calc(14px + env(safe-area-inset-bottom)); }
  .chat-wrap { height: calc(100vh - 120px); }
  .msg { max-width: 92%; }
  .tbl { display: block; overflow-x: auto; white-space: nowrap; }

  /* Нищо в съдържанието не бива да е по-широко от екрана: иначе цялата
     страница се плъзга настрани и краищата на картите се отрязват. */
  .toolbar > *, .row-actions { max-width: 100%; }
  .toolbar .search, .toolbar .search input { min-width: 0; width: 100%; }
  .inline-form { flex-wrap: wrap; }
  .inline-form input, .inline-form select { flex: 1; min-width: 8rem; }

  /* Полетата са за пръст, не за мишка: по-високи и с по-едър текст. 16px е и
     прагът, под който iOS увеличава страницата при фокус в полето. */
  input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]),
  select, textarea { font-size: 16px; padding: 11px 12px; min-height: 44px; }
  textarea { min-height: 88px; }
  /* Скритите полета зад избирача на партньор и зад датата пазят размера си. */
  .picker-native, .date-field .date-native { min-height: 0; }
  .date-field .date-btn { min-height: 44px; padding: 7px 12px; }
  .btn-primary, .btn-ghost, .btn-pay, .btn-chip {
    min-height: 44px; display: inline-flex; align-items: center; justify-content: center;
  }

  /* Търсачката един ред: полето се смачква между падежа и бутона и не се вижда
     какво пишеш. На телефон трите застават едно под друго, на цяла ширина. */
  .email-folders { display: none; }
  .email-folder-pick { display: block; }
  .email-search, .note-pick, .cb-row { flex-direction: column; align-items: stretch; }
  .email-search > *, .note-pick > *, .cb-row > * { width: 100%; flex: none; }
  .note-pick select { min-width: 0; }
  .toolbar .search { display: flex; flex-direction: column; gap: 8px; }
  .markup-box { display: block; margin: 8px 0 0; white-space: normal; }
  .markup-input { width: 5.5rem; }
  /* Данните на документа са две колони с пренос, а не таблица със скрол. */
  .tbl.kv { display: table; white-space: normal; }
  .tbl.kv td { overflow-wrap: anywhere; }
  .tbl.kv td:first-child { width: 38%; }
  .partner-field { flex-direction: column; }
  .partner-field .picker, .partner-field .btn-ghost { width: 100%; }
  .guide { grid-template-columns: 1fr; }
  .mark-editor { grid-template-columns: 1fr; }
  .mark-palette { position: static; }
  .mark-grid { gap: 8px; }
  .mark-card { width: calc(50% - 4px); }
  .attach-chip-t { max-width: 11rem; }
  .modal { padding: 0; align-items: flex-end; }
  .modal-card { max-width: none; border-radius: var(--radius) var(--radius) 0 0; max-height: 92vh;
                padding-bottom: calc(20px + env(safe-area-inset-bottom)); }

  /* Списъците с документи се четат вертикално: име, номер, дата, сума, статус. */
  .tbl.stack { display: block; overflow: visible; white-space: normal; }
  .tbl.stack thead { display: none; }
  .tbl.stack tbody { display: block; }
  .tbl.stack tr { display: flex; flex-direction: column; gap: 2px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
  .tbl.stack tr:last-child { border-bottom: 0; }
  .tbl.stack td { display: block; border: 0; padding: 0; }
  .tbl.stack td:empty { display: none; }
  .tbl.stack td::before { content: attr(data-label) ": "; color: var(--ink-2); font-size: 12.5px; }
  /* В колона има място за пренос — дългите имена не се режат отдясно. */
  .tbl.stack td:not(.c-name) { white-space: normal; }
  .tbl.stack td.num, .tbl.stack td.nowrap { white-space: nowrap; }
  .tbl.stack td.num { text-align: left; }
  .tbl.stack td.c-name { order: -1; font-weight: 600; font-size: 15.5px; }
  .tbl.stack td.c-name::before { content: none; }
  .tbl.stack td.row-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
  .tbl.stack td.row-actions::before { content: none; }
  .tbl.stack td.c-check { order: -2; width: auto; max-width: none; }
  .tbl.stack td.c-check::before { content: none; }
  /* Изправеният списък няма нужда от собствен скрол — редовете вече са в колона. */
  .tbl-scroll { overflow-x: visible; }
  /* Редът с общите суми се чете като карта: заглавие, после сумите с имената им. */
  .tbl.stack tfoot { display: block; }
  .tbl.stack tr.totals td.t-label { order: -1; font-weight: 700; font-size: 15.5px; }
  .tbl.stack tr.totals td.t-label::before { content: none; }

  /* Лентата на документа събира до петнайсет действия — на тесен екран те стават
     стена от бутони. Второстепенните влизат в едно меню под „Действия". */
  .toolbar { position: relative; }
  .act-toggle { display: inline-flex; }
  .act-menu.open .act-toggle { border-color: var(--brand); color: var(--brand); background: #eff4ff; }
  .act-list {
    display: none; position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 6px);
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.18);
    padding: 6px; max-height: 70vh; overflow-y: auto;
  }
  .act-menu.open .act-list { display: block; }
  .act-list form { width: 100%; margin: 0; }
  .act-list .btn-ghost, .act-list .btn-primary, .act-list .link-danger {
    display: flex; width: 100%; justify-content: flex-start; text-align: left;
    min-height: 44px; padding: 11px 12px; border: 0; border-radius: 8px;
    background: none; color: var(--ink); font-size: 14.5px;
  }
  .act-list .link-danger { color: var(--danger); }
  /* Списъкът маха рамките на бутоните, затова избраният филтър се отбелязва тук наново. */
  .act-list .btn-ghost.on { background: #eff4ff; color: var(--brand); font-weight: 600; }
  .act-list .btn-ghost.on::after { content: '✓'; margin-left: auto; }
  .act-list .btn-ghost:active, .act-list .btn-primary:active,
  .act-list .link-danger:active { background: #eef3ff; }
  /* Тънка черта над всяко заглавие — иначе групите се сливат в един дълъг списък. */
  .act-group {
    display: block; padding: 10px 12px 4px; margin-top: 4px; border-top: 1px solid var(--line);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.4px; color: var(--ink-2);
  }
  .act-list > .act-group:first-child { margin-top: 0; border-top: 0; }

  /* Редовете на документа са карти: наименование, мярка, количество и цена
     един под друг. В таблица полетата стават по няколко знака широки, а сумите
     отдясно се режат извън екрана. */
  .items-editor,
  .items-editor tbody, .items-editor tfoot,
  .items-editor tr, .items-editor td { display: block; width: auto; }
  .items-editor { overflow: visible; white-space: normal; }
  .items-editor thead { display: none; }
  .items-editor tbody tr {
    border: 1px solid var(--line); border-radius: var(--radius);
    padding: 10px 12px; margin-bottom: 10px;
  }
  .items-editor tbody tr.it-fixed { background: #f8fafc; }
  .items-editor tbody tr.it-fixed td { background: none; }
  .items-editor tbody td { border: 0; padding: 5px 0; }
  .items-editor tbody td.num { text-align: left; }
  .items-editor tbody td::before {
    content: attr(data-label); display: block;
    color: var(--ink-2); font-size: 12.5px; margin-bottom: 3px;
  }
  .items-editor tbody td:empty { display: none; }
  .items-editor td.it-actions { text-align: right; padding-top: 8px; }
  .items-editor td.it-actions::before { content: none; }
  .items-editor .it-del { min-width: 44px; min-height: 44px; font-size: 17px; }

  /* Сумите отдолу: името отляво, числото отдясно — на цялата ширина. */
  .items-editor tfoot tr { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
  .items-editor tfoot td { border: 0; padding: 0; }
  .items-editor tfoot td:empty { display: none; }
  .items-editor tfoot td:first-child { text-align: left; }
  .items-editor tfoot tr.totals {
    font-weight: 700; font-size: 15.5px;
    background: #f8fafc; border-radius: 8px; padding: 10px;
  }
  .items-editor tfoot tr.totals td { background: none; }

  /* Календарът на телефон: по-ниски клетки, само точки вместо заглавия. */
  .cal-grid { gap: 2px; }
  .cal-day { min-height: 62px; padding: 3px; }
  .cal-ev { font-size: 0; padding: 0; height: 6px; border-radius: 3px; }
  .cal-ev b { font-size: 0; }
}

