/* Stiluri specifice CRM, peste sistemul de design comun (app.css). Fără stiluri inline (CSP strictă). */

.demo-banner { background: var(--warning-soft); color: var(--warning-text, var(--text)); border-bottom: 1px solid var(--warning-border, var(--border)); }

/* ---------- Bara de căsuțe și foldere ---------- */
.mailbar { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; margin-bottom: var(--s-4); }
.mailbar .segmented { flex-wrap: wrap; }
.acc-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.acc-chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 13px; user-select: none; }
.acc-chip input { accent-color: var(--primary); margin: 0; }
.acc-chip:has(input:checked) { border-color: var(--primary-border); background: var(--primary-soft); color: var(--primary-text); }
.acc-tag { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; line-height: 1; padding: 3px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.acc-c0 { background: #e0e7ff; color: #3730a3; } .acc-c1 { background: #dcfce7; color: #166534; }
.acc-c2 { background: #fef3c7; color: #92400e; } .acc-c3 { background: #fce7f3; color: #9d174d; }
.acc-c4 { background: #e0f2fe; color: #075985; } .acc-c5 { background: #f3e8ff; color: #6b21a8; }
.acc-c6 { background: #ffedd5; color: #9a3412; } .acc-c7 { background: #ccfbf1; color: #115e59; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) [class*="acc-c"] { filter: saturate(.8) brightness(.85); } }
:root[data-theme="dark"] [class*="acc-c"] { filter: saturate(.8) brightness(.85); }

/* ---------- Lista de conversații ---------- */
.thread-list { list-style: none; margin: 0; padding: 0; }
.thread-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: var(--s-3); padding: 12px var(--s-4); border-bottom: 1px solid var(--border-soft); color: inherit; text-decoration: none; align-items: start; }
.thread-row:hover { background: var(--row-hover); text-decoration: none; }
.thread-row:last-child { border-bottom: 0; }
.thread-row.is-unread .thread-from, .thread-row.is-unread .thread-subject { font-weight: 650; color: var(--text); }
.thread-row.is-new { animation: crm-flash 2.4s ease-out; }
@keyframes crm-flash { from { background: var(--primary-soft); } to { background: transparent; } }
.thread-main { min-width: 0; }
.thread-top { display: flex; gap: var(--s-2); align-items: center; min-width: 0; }
.thread-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); }
.thread-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-2); margin-top: 1px; }
.thread-snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-muted); font-size: 13px; margin-top: 2px; }
.thread-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--text-muted); white-space: nowrap; }
.thread-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 6px; }
.unread-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary); display: inline-block; flex: none; }
.dir-icon { color: var(--text-muted); }
.new-mail-bar { position: sticky; top: 64px; z-index: 5; display: flex; justify-content: center; margin-bottom: var(--s-3); }

/* ---------- Conversație ---------- */
.msg { border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); margin-bottom: var(--s-3); scroll-margin-top: 80px; }
.msg-out { border-color: var(--primary-border); }
.msg-head { display: flex; gap: var(--s-3); align-items: flex-start; padding: var(--s-3) var(--s-4); border-bottom: 1px solid var(--border-soft); }
.msg-head .flex-1 { min-width: 0; }
.msg-from { font-weight: 600; }
.msg-addr { color: var(--text-muted); font-size: 13px; overflow-wrap: anywhere; }
.msg-body { padding: var(--s-3) var(--s-4); }
.msg-frame { width: 100%; min-height: 40px; height: 60px; border: 0; display: block; background: transparent; }
.msg-attachments { display: flex; flex-wrap: wrap; gap: var(--s-2); padding: 0 var(--s-4) var(--s-3); }
.msg-attachments .chip { max-width: 100%; min-width: 0; }
.msg-attachments .att-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
@media (max-width: 640px) { .msg-attachments .chip { height: 36px; } }
.msg.is-collapsed .msg-body, .msg.is-collapsed .msg-attachments { display: none; }
.msg.is-collapsed .msg-head { border-bottom: 0; cursor: pointer; }
.msg-snippet { color: var(--text-muted); font-size: 13px; display: none; }
.msg.is-collapsed .msg-snippet { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-box { scroll-margin-top: 80px; }
.reply-box textarea { min-height: 140px; }

/* ---------- Astăzi ---------- */
.today-grid { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1024px) { .today-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); } }
.top-actions { counter-reset: top; list-style: none; margin: 0; padding: 0; }
.top-actions li { counter-increment: top; }
.top-action { display: grid; grid-template-columns: 32px minmax(0, 1fr) auto; gap: var(--s-3); align-items: center; padding: 12px var(--s-4); border-bottom: 1px solid var(--border-soft); color: inherit; text-decoration: none; }
.top-action:hover { background: var(--row-hover); text-decoration: none; }
.top-action::before { content: counter(top); width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-soft); color: var(--primary-text); font-weight: 700; font-size: 13px; }
li:last-child > .top-action { border-bottom: 0; }
.event-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: var(--s-3); padding: 10px var(--s-4); border-bottom: 1px solid var(--border-soft); color: inherit; text-decoration: none; }
.event-row:hover { background: var(--row-hover); text-decoration: none; }
.event-time { font-variant-numeric: tabular-nums; color: var(--text-2); font-weight: 600; font-size: 13px; }
.event-row.is-cancelled .event-title { text-decoration: line-through; color: var(--text-muted); }
.compact-row { display: flex; gap: var(--s-3); align-items: center; padding: 10px var(--s-4); border-bottom: 1px solid var(--border-soft); color: inherit; text-decoration: none; min-width: 0; }
.compact-row:hover { background: var(--row-hover); text-decoration: none; }
.compact-row:last-child { border-bottom: 0; }
.compact-row .flex-1 { min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Sarcini (4 coloane) ---------- */
.board { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 900px) { .board { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (min-width: 1400px) { .board { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.board-col { background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: var(--radius-lg); padding: var(--s-3); min-width: 0; }
.board-col-head { display: flex; align-items: center; gap: var(--s-2); padding: 4px 4px var(--s-3); font-weight: 600; }
.task-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: var(--s-2); }
.task-card.is-overdue { border-left: 3px solid var(--danger); }
.task-card.is-suggested { border-style: dashed; }
.task-title { font-weight: 550; color: var(--text); text-decoration: none; display: block; }
.task-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--text-muted); }
.task-actions { display: flex; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.task-actions form { display: inline; }
.task-excerpt { font-size: 12.5px; color: var(--text-muted); border-left: 2px solid var(--border); padding-left: 8px; margin-top: 6px; }

/* ---------- Chat ---------- */
.chat-layout { display: grid; gap: var(--s-4); grid-template-columns: minmax(0, 1fr); }
@media (min-width: 1100px) { .chat-layout { grid-template-columns: 260px minmax(0, 1fr); } }
.chat-pane { display: flex; flex-direction: column; min-height: calc(100vh - 180px); }
.chat-log { flex: 1; display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-4); overflow-y: auto; }
.bubble { max-width: min(760px, 92%); padding: 12px 14px; border-radius: 14px; line-height: 1.55; overflow-wrap: anywhere; }
.bubble-user { align-self: flex-end; background: var(--primary); color: var(--text-inverse); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.bubble-ai { align-self: flex-start; background: var(--surface); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble-ai .cite { font-size: 11px; font-weight: 700; vertical-align: super; text-decoration: none; padding: 0 2px; }
.bubble-sources { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); font-size: 12.5px; }
.bubble-sources ol { margin: 4px 0 0; padding-left: 18px; }
.bubble-foot { font-size: 11.5px; color: var(--text-muted); margin-top: 6px; }
.chat-form { display: flex; gap: var(--s-2); padding: var(--s-3); border-top: 1px solid var(--border); background: var(--surface); position: sticky; bottom: 0; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }
.chat-form textarea { flex: 1; min-height: 46px; max-height: 200px; resize: vertical; }
.chat-suggestions { display: flex; flex-wrap: wrap; gap: var(--s-2); justify-content: center; }
.proposal { border: 1px solid var(--primary-border); background: var(--primary-soft); border-radius: var(--radius-sm); padding: 10px 12px; margin-top: 10px; color: var(--text); }
.proposal.is-done { border-color: var(--success-border); background: var(--success-soft); }
.proposal.is-cancelled, .proposal.is-failed { border-color: var(--border); background: var(--surface-2); }
.proposal dl { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 12px; margin: 6px 0; font-size: 13px; }
.proposal dt { color: var(--text-muted); }
.proposal dd { margin: 0; overflow-wrap: anywhere; }
.typing { display: inline-flex; gap: 4px; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); animation: crm-typing 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes crm-typing { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* ---------- Calendar ---------- */
.cal-day { margin-bottom: var(--s-4); }
.cal-day-head { display: flex; align-items: baseline; gap: var(--s-2); padding: var(--s-2) 0; font-weight: 600; }
.cal-day-head.is-today { color: var(--primary-text); }
.slot-list { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- Setări ---------- */
.folder-table td, .folder-table th { vertical-align: middle; }
.acc-card + .acc-card { margin-top: var(--s-4); }
.code-box { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; white-space: pre; }
.qr-box { background: #fff; padding: 12px; border-radius: 12px; display: inline-block; }
.qr-box img { display: block; width: 200px; height: 200px; }
.codes-grid { display: grid; grid-template-columns: repeat(2, max-content); gap: 6px 24px; font-family: var(--font-mono); }
.status-ok { color: var(--success); } .status-warn { color: var(--warning); } .status-bad { color: var(--danger); }
.mt-2 { margin-top: var(--s-2); } .mt-3 { margin-top: var(--s-3); } .mt-4 { margin-top: var(--s-4); } .mb-3 { margin-bottom: var(--s-3); } .mb-4 { margin-bottom: var(--s-4); }
.gap-2 { gap: var(--s-2); }
.prewrap { white-space: pre-wrap; }
.nav-count { margin-left: auto; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 999px; background: var(--primary); color: var(--text-inverse); }
.sidebar-collapsed .nav-count { display: none; }
@media (max-width: 767px) {
  .thread-row { grid-template-columns: minmax(0, 1fr) auto; padding: 12px; }
  .thread-row .avatar { display: none; }
  .event-row { grid-template-columns: 70px minmax(0, 1fr); }
  .top-action { grid-template-columns: 32px minmax(0, 1fr); row-gap: 6px; }
  .top-action > .badge { grid-column: 2; justify-self: start; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
  .mail-toolbar { flex-wrap: wrap; }
  .mail-toolbar > .segmented { flex: 1 1 100%; }
  .mail-toolbar > .segmented > .segmented-item { flex: 1 1 0; width: auto; padding: 0 6px; }
  .mail-toolbar > form { flex: 1 1 100%; flex-wrap: nowrap; min-width: 0; }
  .mail-toolbar > form .input { flex: 1 1 0; width: 0; min-width: 0; }
}

/* ---------- Telefon și ecrane tactile ---------- */
.matrix-hit { display: grid; place-items: center; min-height: 40px; margin: -6px 0; cursor: pointer; }
.btn { max-width: 100%; }
@media (max-width: 600px) {
  /* textele lungi din butoane trec pe rândul următor în loc să iasă din ecran */
  .btn { white-space: normal; height: auto; min-height: var(--btn-h); padding-top: 6px; padding-bottom: 6px; line-height: 1.25; text-align: center; }
}
@media (pointer: coarse) {
  /* ținte de atingere mai mari pe telefon (degetul nu e un cursor) */
  .btn { --btn-h: 40px; }
  .btn-sm { --btn-h: 36px; }
  .btn-xs { --btn-h: 32px; }
  .segmented-item > span, a.segmented-item, button.segmented-item { min-height: 36px; }
  .page-back { padding: 8px 8px 8px 0; margin-top: -8px; margin-bottom: 0; }
  input[type="checkbox"]:not(.switch-input):not(.sr-only), input[type="radio"]:not(.sr-only) { width: 22px; height: 22px; }
  input[type="checkbox"]:not(.switch-input):not(.sr-only)::before { width: 14px; height: 14px; }
  input[type="radio"]:not(.sr-only)::before { width: 10px; height: 10px; }
  .bubble-ai .cite { padding: 6px 4px; }
  .compact-row, .top-action, .thread-row { min-height: 48px; }
}

/* ---------- Pagini publice (confidențialitate) ---------- */
.auth-card-doc { max-width: 760px; }
.legal-doc h2 { font-size: var(--fs-md); font-weight: 650; margin: var(--s-6) 0 var(--s-2); }
.legal-doc p, .legal-doc li { color: var(--text-2); line-height: 1.6; }
.legal-doc p { margin: 0 0 var(--s-3); }
.legal-doc ul { margin: 0 0 var(--s-3); padding-left: 1.2em; }
.legal-doc li + li { margin-top: 6px; }
.min-w-0 { min-width: 0; } .d-block { display: block; } .w-full { width: 100%; }
.cluster .select, .cluster .input { width: auto; }
.cluster .label { margin: 0; }
.thread-card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; margin-bottom: var(--s-2); color: inherit; text-decoration: none; }
.thread-card:hover { border-color: var(--primary-border); text-decoration: none; }
.board-sub { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); margin: var(--s-3) 4px var(--s-2); font-weight: 600; }

/* ---------- Rapoarte ---------- */
:root { --series-in: #257de0; --series-out: #f47230; }
:root[data-theme="dark"] { --series-in: #338ced; --series-out: #e76624; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]):not([data-theme="dark"]) { --series-in: #338ced; --series-out: #e76624; } }
.report-filters { align-items: center; }
.report-filters .select { width: auto; min-width: 220px; }
.report-chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart-grid { stroke: var(--border); stroke-width: 1; vector-effect: non-scaling-stroke; }
.chart-axis { fill: var(--text-muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.chart-line { stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.chart-line-in { stroke: var(--series-in); }
.chart-line-out { stroke: var(--series-out); }
.chart-dot { opacity: 0; stroke: var(--surface); stroke-width: 2; vector-effect: non-scaling-stroke; }
.chart-dot-in { fill: var(--series-in); }
.chart-dot-out { fill: var(--series-out); }
.chart-cross { stroke: var(--text-muted); stroke-width: 1; stroke-dasharray: 3 3; opacity: 0; vector-effect: non-scaling-stroke; }
.chart-hit { fill: transparent; cursor: crosshair; }
.chart-col:hover .chart-dot, .chart-col:hover .chart-cross { opacity: 1; }
.chart-legend { display: flex; gap: var(--s-3); font-size: var(--fs-xs); color: var(--text-2); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 14px; height: 3px; border-radius: 2px; }
.legend-in { background: var(--series-in); }
.legend-out { background: var(--series-out); }
.report-kv { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s-3) var(--s-4); margin: 0; }
.report-kv div { display: flex; justify-content: space-between; gap: var(--s-2); border-bottom: 1px solid var(--border); padding-bottom: var(--s-2); }
.report-kv dt { color: var(--text-muted); font-size: var(--fs-sm); }
.report-kv dd { margin: 0; font-weight: 600; }
@media (max-width: 560px) { .report-kv { grid-template-columns: minmax(0, 1fr); } .report-filters .select { min-width: 0; width: 100%; } }

/* ---------- Administrare ---------- */
.admin-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--s-4); }
@media (max-width: 1000px) { .admin-tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
/* Backup (Administrare › Sistem) */
.backup-list > summary { cursor: pointer; font-weight: 500; padding: 4px 0; }
.backup-list > ul { margin-top: var(--s-2); }
.backup-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s-2) var(--s-3); padding: var(--s-2) 0; }
.backup-row form { display: inline; margin: 0; }
@media (max-width: 560px) { .admin-tiles { grid-template-columns: minmax(0, 1fr); } }
.admin-tiles > .card { margin-top: 0; }
.admin-tile { display: flex; flex-direction: column; gap: var(--s-2); color: inherit; text-decoration: none; }
.admin-tile:hover { border-color: var(--primary-border); }
.admin-tile .card-body { display: flex; flex-direction: column; gap: var(--s-2); height: 100%; }
.admin-tile-head { display: flex; align-items: center; gap: var(--s-2); font-weight: 600; }
.admin-tile-head .icon { color: var(--primary-text); }
.key-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: var(--s-3) var(--s-4); align-items: start; padding: var(--s-3) 0; border-bottom: 1px solid var(--border); }
.key-row:last-child { border-bottom: 0; }
@media (max-width: 760px) { .key-row { grid-template-columns: minmax(0, 1fr); } }
.preset-switch { flex-wrap: wrap; align-self: flex-start; max-width: 100%; }
.preset-switch > .segmented-item { flex: 0 0 auto; width: auto; }

.text-2xl { font-size: 1.625rem; line-height: 1.2; }
.tabular { font-variant-numeric: tabular-nums; }

.setup-steps { list-style: none; margin: 0; padding: 0; }
.setup-step { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border); }
.setup-step:first-child { border-top: 0; }
.setup-step-body { flex: 1; min-width: 0; }
.setup-step-mark { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%; background: var(--surface-3); color: var(--text-muted); font-size: var(--fs-xs); font-weight: 600; }
.setup-step.is-done .setup-step-mark { background: var(--success-soft); color: var(--success-text); }
.setup-step.is-warn .setup-step-mark { background: var(--warning-soft); color: var(--warning-text); }
@media (max-width: 560px) { .setup-step { flex-wrap: wrap; padding: var(--s-3) var(--s-4); } .setup-step > form, .setup-step > .btn { margin-left: 38px; } }

/* Asistentul de instalare și paginile fără sesiune */
.install-card { max-width: 640px; }
.install-form { display: flex; flex-direction: column; gap: var(--s-6); }
.install-section { display: flex; flex-direction: column; gap: var(--s-3); margin-bottom: var(--s-6); }
.install-form .install-section { margin-bottom: 0; }
.install-h { display: flex; align-items: center; gap: var(--s-2); margin: 0; font-size: var(--fs-md, 15px); font-weight: 650; }
.install-n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; border-radius: 50%; background: var(--surface-3); color: var(--text-2); font-size: var(--fs-xs); font-weight: 650; flex: none; }
.install-checks { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.install-check { display: flex; align-items: flex-start; gap: var(--s-2); line-height: 1.45; }
.install-check .icon { flex: none; margin-top: 2px; }
.install-check.is-ok .icon { color: var(--success); }
.install-check.is-warn .icon { color: var(--warning); }
.install-check.is-bad .icon { color: var(--danger); }
.install-more { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: var(--s-2) var(--s-3); }
.install-more > summary { cursor: pointer; font-size: var(--fs-sm); color: var(--text-2); font-weight: 550; }
.install-more[open] > summary { margin-bottom: var(--s-3); }
.install-more > .form-grid, .install-more > .field, .install-more > .help, .install-more > .code-box { margin-top: var(--s-2); }
.install-steps { margin: 0 0 var(--s-4); padding-left: 1.2em; display: flex; flex-direction: column; gap: 6px; font-size: var(--fs-sm); }
.install-section .code-box { white-space: pre-wrap; word-break: break-all; }
/* o comandă de lipit (cronul) rămâne pe un singur rând: ruptă la jumătate ar părea că are un spațiu sau un Enter */
.install-section .code-box.code-line { white-space: pre; word-break: normal; overflow-x: auto; }
.install-section > .btn { align-self: flex-start; }
.auth-card .install-section .btn-primary, .auth-card .install-form .btn-secondary { width: auto; height: auto; }
.auth-card .install-form > .btn-primary { width: 100%; height: 42px; }

/* Pe telefon: bara de navigare de jos (stil aplicație Android), zone sigure, ținte de atingere */
.bottom-nav { display: none; }
@media (max-width: 767px) {
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 35;
    display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
    height: calc(60px + env(safe-area-inset-bottom)); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    background: var(--surface); border-top: 1px solid var(--border);
    box-shadow: 0 -6px 18px rgba(16, 24, 40, 0.06);
  }
  .nav-open .bottom-nav { z-index: 20; }
  .bottom-nav-item {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-width: 0;
    padding: 6px 2px 5px; border: 0; background: none; color: var(--text-muted); text-decoration: none;
    font: inherit; font-size: 11.5px; font-weight: 550; cursor: pointer; -webkit-tap-highlight-color: transparent;
  }
  .bottom-nav-item:hover { color: var(--text); text-decoration: none; }
  .bottom-nav-item.is-active { color: var(--primary-text, var(--primary)); }
  .bottom-nav-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 56px; height: 30px; border-radius: 15px; transition: background 0.15s; }
  .bottom-nav-item.is-active .bottom-nav-icon { background: var(--primary-soft); }
  .bottom-nav-item:active .bottom-nav-icon { background: var(--surface-3); }
  .bottom-nav-icon .icon { width: 22px; height: 22px; }
  .bottom-nav-count {
    position: absolute; top: -3px; right: 5px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--danger-solid, var(--danger)); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 18px; text-align: center;
    box-shadow: 0 0 0 2px var(--surface);
  }
  .bottom-nav-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .app-body .content { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
  .app-body .toast-region { bottom: calc(72px + env(safe-area-inset-bottom)); }
  .topbar { padding-left: max(var(--s-3), env(safe-area-inset-left)); padding-right: max(var(--s-3), env(safe-area-inset-right)); }
  /* câmpurile de 16px nu declanșează mărirea automată a paginii pe telefon */
  .input, .select, .textarea, .topbar-search-input { font-size: 16px; }
  .btn { min-height: 40px; }
  .btn-sm { min-height: 34px; }
}
/* Aplicația instalată (fără bara browserului) */
.is-standalone .topbar { padding-top: env(safe-area-inset-top); }
.share-preview { white-space: pre-wrap; word-break: break-word; font-family: inherit; font-size: var(--fs-sm); max-height: 50vh; overflow: auto; }

/* Notificări */
.notif { position: relative; }
.notif-bell { position: relative; }
.notif-count {
  position: absolute; top: 2px; right: 1px; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
  background: var(--danger-solid, var(--danger)); color: #fff; font-size: 10.5px; font-weight: 700; line-height: 17px; text-align: center;
  box-shadow: 0 0 0 2px var(--surface); pointer-events: none;
}
.notif-menu { width: min(380px, calc(100vw - 24px)); padding: 0; overflow: hidden; }
.notif-menu-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-3) var(--s-3) var(--s-2) var(--s-4); border-bottom: 1px solid var(--border-soft); }
.notif-menu-title { font-weight: 650; font-size: var(--fs-md); }
.notif-menu-list { max-height: min(60vh, 460px); overflow-y: auto; overscroll-behavior: contain; }
.notif-menu-foot { display: flex; justify-content: space-between; align-items: center; gap: var(--s-3); padding: var(--s-2) var(--s-4); border-top: 1px solid var(--border-soft); font-size: var(--fs-sm); }
.notif-menu-foot a { display: inline-flex; align-items: center; gap: 4px; }
.notif-empty { margin: 0; padding: var(--s-6) var(--s-4); text-align: center; color: var(--text-muted); font-size: var(--fs-sm); }
.notif-item {
  position: relative; display: flex; align-items: flex-start; gap: var(--s-3); padding: var(--s-3) var(--s-4);
  color: var(--text); text-decoration: none; border-bottom: 1px solid var(--border-soft);
}
.notif-item:last-child { border-bottom: 0; }
.notif-item:hover { background: var(--row-hover); text-decoration: none; color: var(--text); }
.notif-item.is-unread { background: var(--primary-soft); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); }
.notif-item.is-unread:hover { background: var(--primary-soft); }
.notif-icon { flex: 0 0 auto; display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border-radius: 50%; background: var(--neutral-soft); color: var(--neutral-text); }
.notif-icon .icon { width: 17px; height: 17px; }
.notif-g-mail { background: var(--info-soft); color: var(--info-text); }
.notif-g-work { background: var(--warning-soft); color: var(--warning-text); }
.notif-g-ai { background: var(--primary-soft); color: var(--primary-text, var(--primary)); }
.notif-g-system { background: var(--danger-soft); color: var(--danger-text); }
.notif-g-ok { background: var(--success-soft); color: var(--success-text); }
.notif-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.notif-title { font-weight: 600; font-size: var(--fs-sm); line-height: 1.35; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-item:not(.is-unread) .notif-title { font-weight: 500; }
.notif-body { color: var(--text-2); font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; white-space: pre-line; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.notif-detail { color: var(--text-muted); font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; }
.notif-time { color: var(--text-muted); font-size: var(--fs-xs); }
.notif-dot { flex: 0 0 auto; width: 9px; height: 9px; margin-top: 6px; border-radius: 50%; background: var(--primary); }
.notif-page { padding: 0; overflow: hidden; }
.notif-page .notif-item { padding: var(--s-3) var(--s-5); }
.notif-page .notif-body { -webkit-line-clamp: 3; }
.notif-day { margin: 0; padding: var(--s-3) var(--s-5) var(--s-2); font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); background: var(--surface-2); border-bottom: 1px solid var(--border-soft); }
.notif-promo .card-body { display: flex; align-items: center; gap: var(--s-4); flex-wrap: wrap; }
.notif-promo-icon { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--primary-soft); color: var(--primary-text, var(--primary)); }
.notif-matrix td, .notif-matrix th { vertical-align: middle; }
.notif-matrix-group th { padding-top: var(--s-4); font-size: var(--fs-xs); font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-muted); background: transparent; }
.notif-matrix-label { display: inline-flex; align-items: center; gap: var(--s-2); font-weight: 550; }
.notif-matrix-label .icon { color: var(--text-muted); }
.notif-matrix-help { display: block; margin-top: 2px; padding-left: 22px; font-size: var(--fs-xs); color: var(--text-muted); }
.notif-narrow { max-width: 280px; }
.card-header-sub { border-top: 1px solid var(--border-soft); }
.card-header-sub .card-title { font-size: var(--fs-md); }
.notif-accounts { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: var(--s-2) var(--s-4); }
.tg-link { display: flex; gap: var(--s-4); align-items: center; flex-wrap: wrap; }
.tg-link .qr-box img { display: block; width: 180px; height: 180px; }
.device-list > li { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); border-top: 1px solid var(--border-soft); }
.device-list > li:first-child { border-top: 0; }
.device-icon { display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); }
.device-name { display: block; font-weight: 550; font-size: var(--fs-sm); overflow-wrap: anywhere; }
.field-error { margin: 4px 0 0; font-size: var(--fs-xs); color: var(--danger-text); }
/* pe telefon și tabletă, „Pe acest dispozitiv” vine primul: e pasul care contează acolo */
@media (max-width: 1100px) { .notif-settings > aside { order: -1; } }
@media (max-width: 767px) {
  .notif-menu { position: fixed; left: 12px; right: 12px; top: calc(var(--topbar-h, 56px) + env(safe-area-inset-top) + 4px); width: auto; }
  /* loc pentru bara de sus, antet, subsol și bara de jos a telefonului */
  .notif-menu-list { max-height: calc(100vh - 330px); max-height: calc(100dvh - 330px); }
  .notif-page .notif-item { padding: var(--s-3) var(--s-4); }
  .notif-matrix-help { display: none; }
  .notif-matrix .table th, .notif-matrix .table td { padding-left: 8px; padding-right: 8px; }
  .notif-matrix thead th.nowrap { white-space: normal; width: 76px; font-size: var(--fs-xs); line-height: 1.3; }
  .notif-matrix thead th .icon { display: none; }
}

/* Furnizori e-mail */
.mail-status.is-warning { color: var(--warning-text); }
.mail-status.is-busy::before {
  content: ""; display: inline-block; width: 10px; height: 10px; margin-right: 6px; vertical-align: -1px;
  border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin 0.8s linear infinite;
}
.mail-provider { display: flex; flex-direction: column; gap: var(--s-2); padding: var(--s-3) var(--s-4); border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-2); }
.mail-provider-head { display: flex; align-items: center; gap: var(--s-3); }
.mail-steps, .mail-notes { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 4px; font-size: var(--fs-sm); line-height: 1.45; }
.mail-notes { color: var(--text-muted); }
.mail-links { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.mail-secret > .mail-reveal { flex: none; height: 100%; min-height: 0; border: 0; border-left: 1px solid var(--border); border-radius: 0; }
.mail-ms-btn { align-self: flex-start; }
.mail-advanced > summary {
  display: flex; align-items: center; gap: var(--s-3); padding: var(--s-4) var(--s-5); min-height: 56px;
  cursor: pointer; list-style: none; -webkit-tap-highlight-color: transparent;
}
.mail-advanced > summary::-webkit-details-marker { display: none; }
.mail-advanced > summary:focus-visible { outline: 2px solid var(--primary); outline-offset: -2px; border-radius: var(--radius); }
.mail-advanced[open] > summary { border-bottom: 1px solid var(--border-soft); }
.mail-advanced-chevron { margin-left: auto; flex: none; color: var(--text-muted); transition: transform 0.15s; }
.mail-advanced[open] .mail-advanced-chevron { transform: rotate(180deg); }
.folder-role { min-width: 124px; }
/* adresele lungi (fără spații) se rup doar când nu încap pe rând, ca pagina să nu se lărgească pe telefon */
.mail-wrap { overflow-wrap: anywhere; }
@media (max-width: 767px) {
  .mail-provider { padding: var(--s-3); }
  .mail-ms-btn { align-self: stretch; width: 100%; }
  .mail-secret { height: 44px; }
  .mail-secret > .mail-reveal { width: 48px; }
  .mail-links > .btn { flex: 1 1 auto; }
  .mail-setup .form-actions > .btn { width: 100%; }
  .mail-advanced > summary { padding: var(--s-3) var(--s-4); }
}

/* Ajutor: ghidurile din docs/, de citit în CRM */
.doc { line-height: 1.6; overflow-wrap: break-word; }
.doc > :first-child { margin-top: 0; }
.doc h1 { font-size: var(--fs-2xl); margin: 0 0 var(--s-4); }
.doc h2 { font-size: var(--fs-xl); margin: var(--s-6) 0 var(--s-3); padding-top: var(--s-4); border-top: 1px solid var(--border-soft); }
.doc h3 { font-size: var(--fs-lg); margin: var(--s-5) 0 var(--s-2); }
.doc h4 { font-size: var(--fs-md); margin: var(--s-4) 0 var(--s-2); }
.doc p, .doc ul, .doc ol, .doc blockquote, .doc pre, .doc table { margin: 0 0 var(--s-3); }
.doc ul, .doc ol { padding-left: 1.4em; }
.doc li + li { margin-top: 4px; }
.doc li > ul, .doc li > ol { margin: 4px 0 0; }
.doc a { color: var(--link); text-decoration: underline; text-underline-offset: 2px; }
.doc code { font-family: var(--font-mono); font-size: 0.9em; background: var(--surface-2); border: 1px solid var(--border-soft); border-radius: 4px; padding: 1px 4px; overflow-wrap: anywhere; }
.doc pre { font-family: var(--font-mono); font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; overflow-x: auto; white-space: pre; }
.doc pre code { background: none; border: 0; padding: 0; font-size: inherit; overflow-wrap: normal; }
.doc blockquote { border-left: 3px solid var(--primary-border); background: var(--primary-soft); padding: var(--s-3) var(--s-4); border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }
.doc blockquote > :last-child { margin-bottom: 0; }
/* tabelele late (de exemplu „Ce vezi / De ce / Ce faci”) se derulează în lateral pe telefon, nu lățesc pagina */
.doc table { display: block; max-width: 100%; overflow-x: auto; border-collapse: collapse; font-size: var(--fs-sm); }
.doc th, .doc td { border: 1px solid var(--border); padding: 6px 10px; vertical-align: top; text-align: left; min-width: 9em; }
.doc th { background: var(--surface-2); font-weight: 600; }
.doc hr { border: 0; border-top: 1px solid var(--border-soft); margin: var(--s-5) 0; }
.help-nav .list-plain { padding: var(--s-2) 0; }
.help-nav-link { display: block; padding: 8px var(--s-5); color: inherit; text-decoration: none; font-size: var(--fs-sm); }
.help-nav-link:hover { background: var(--nav-hover-bg); }
.help-nav-link.is-active { background: var(--nav-active-bg); color: var(--nav-active-text); font-weight: 600; }
@media (max-width: 900px) { .help-nav .list-plain { display: flex; flex-wrap: wrap; gap: 4px; padding: var(--s-3); } .help-nav .list-divided > * + * { border-top: 0; } .help-nav-link { padding: 4px 10px; border: 1px solid var(--border); border-radius: 999px; } }

/* Clienți: fișa completată automat (Pe scurt, Ce s-a făcut, Ce mai e de făcut) și datele de contact */
.profile-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.profile-list li { display: block; line-height: 1.45; overflow-wrap: anywhere; }
.profile-list .badge { margin-right: 4px; vertical-align: 1px; }
.profile-list .icon { color: var(--success-text); vertical-align: -2px; }
.details-list { margin: 0; display: grid; gap: 6px; }
.details-list > div { align-items: baseline; }
.details-list dd { max-width: 65%; }
.form-grid-tight { gap: 12px 12px; }
.is-updated { animation: profile-flash 1.6s ease-out; }
@keyframes profile-flash { from { background-color: var(--primary-soft); } to { background-color: transparent; } }
@media (prefers-reduced-motion: reduce) { .is-updated { animation: none; } }

/* v6: fișierele clientului */
.file-row { display: flex; gap: var(--s-2); align-items: center; padding: 8px var(--s-4); border-bottom: 1px solid var(--border-soft); min-width: 0; }
.file-row:last-of-type { border-bottom: 0; }
.file-row:hover { background: var(--row-hover); }
.file-main { color: inherit; text-decoration: none; }
.file-main:hover { text-decoration: none; }
.file-icon { display: inline-flex; width: 32px; height: 32px; flex: none; align-items: center; justify-content: center; border-radius: var(--radius-sm); background: var(--surface-2, var(--row-hover)); color: var(--text-muted); }
.file-preview { overflow: hidden; }
.file-frame { display: block; width: 100%; height: 75vh; border: 0; background: #fff; }
.file-image { display: block; max-width: 100%; height: auto; margin: 0 auto; }
.file-text { max-height: 60vh; overflow: auto; font-size: var(--fs-sm); }
@media (max-width: 640px) { .file-row .btn-label { display: none; } }
.doc-preview { max-height: 320px; overflow: auto; padding: var(--s-2); border: 1px solid var(--border-soft); border-radius: var(--radius-sm); }
.chat-files { display: flex; flex-wrap: wrap; gap: var(--s-1); align-items: center; padding: var(--s-2) var(--s-4) 0; }
.chat-attach { flex: none; cursor: pointer; }
.bubble-files { display: flex; flex-wrap: wrap; gap: var(--s-2); margin-top: var(--s-1); font-size: var(--fs-sm); }
.bubble-files a { color: inherit; text-decoration: underline; display: inline-flex; gap: 4px; align-items: center; }

/* v6: tutorialul de pe fiecare pagină și bara „Reconectează” */
.topbar-tutorial { gap: 6px; }
@media (max-width: 900px) { .topbar-tutorial .btn-label { display: none; } }
.tutorial { width: min(620px, calc(100vw - 32px)); max-height: calc(100vh - 48px); padding: 0; border: 1px solid var(--border); border-radius: var(--radius-lg, 12px); background: var(--surface); color: var(--text); box-shadow: 0 24px 60px rgba(0, 0, 0, .25); }
.tutorial::backdrop { background: rgba(10, 12, 18, .45); }
.tutorial[open] { display: flex; flex-direction: column; }
.tutorial-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-5) var(--s-2); }
.tutorial-head > .icon { color: var(--accent, var(--primary)); }
.tutorial-title { margin: 0; font-size: var(--fs-lg); }
.tutorial-body { padding: 0 var(--s-5) var(--s-4); overflow: auto; line-height: 1.55; }
.tutorial-steps { padding-left: 1.3em; margin: var(--s-3) 0; display: grid; gap: var(--s-2); }
.tutorial-tips { padding: var(--s-3); border-radius: var(--radius-sm); background: var(--row-hover); font-size: var(--fs-sm); }
.tutorial-tips ul { margin: var(--s-1) 0 0; padding-left: 1.2em; }
.tutorial-foot { display: flex; gap: var(--s-2); flex-wrap: wrap; padding: var(--s-3) var(--s-5); border-top: 1px solid var(--border-soft); }
.reconnect-bar { display: flex; align-items: center; gap: var(--s-3); margin-bottom: var(--s-4); padding: var(--s-3) var(--s-4); border: 1px solid var(--danger-border, #f1b0b0); border-radius: var(--radius-md, 10px); background: var(--danger-soft, #fdecec); color: var(--danger-text, #8a1c1c); }
.reconnect-bar > .icon { flex: none; }
@media (max-width: 640px) { .reconnect-bar { flex-wrap: wrap; } }
