/* Dr Ducu Leads — design: sidebar închis, listă bej, detaliu alb, fără colțuri rotunjite. */
:root {
  --ink: #1C1B1A;
  --ink-soft: #3A3633;
  --muted: #8A8379;
  --line: #E2DBD1;
  --line-strong: #CFC6BA;
  --page: #F7F5F2;
  --list: #EFEAE4;
  --white: #FFFFFF;
  --side: #2A2623;
  --side-text: #E8E2DA;
  --side-muted: #8C847B;
  --side-active: #EDE6DD;
  --dark: #2A2623;
  --note: #F3EFEA;
  --danger: #A23B33;
  --ok: #2E5E45;
  --serif: 'EB Garamond', Georgia, 'Times New Roman', serif;
  --sans: 'Mulish', -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); font-size: 15px; line-height: 1.45; color: var(--ink); background: var(--page); -webkit-font-smoothing: antialiased; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--serif); font-weight: 500; margin: 0; }
[hidden] { display: none !important; }

/* Etichete de secțiune: 12px, 800, majuscule, spațiere 1.7px */
.eyebrow { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.7px; color: var(--muted); }

/* Butoane */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 16px; border: 1px solid var(--dark); background: var(--white); color: var(--ink); font-weight: 600; font-size: 14px; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--page); }
.btn-dark { background: var(--dark); color: var(--white); }
.btn-dark:hover { background: #3D3733; }
.btn-light { border-color: var(--line-strong); }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: default; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; cursor: pointer; font-size: 14px; }

/* Câmpuri */
.field { display: block; margin-bottom: 14px; }
.field > span { display: block; font-size: 14px; margin-bottom: 6px; color: var(--ink-soft); }
.input, .textarea, .select { width: 100%; min-height: 44px; padding: 10px 12px; border: 1px solid var(--line-strong); background: var(--white); outline: none; }
.input:focus, .textarea:focus, .select:focus { border-color: var(--dark); }
.textarea { min-height: 84px; resize: vertical; }
.error { color: var(--danger); font-size: 14px; margin: 6px 0 0; }
.status { color: var(--ok); font-size: 14px; margin: 0 0 14px; }

/* Login */
.auth { min-height: 100%; display: flex; align-items: center; justify-content: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--dark); padding: 28px; }
.auth-card h1 { font-size: 30px; line-height: 1.1; margin-bottom: 8px; }
.auth-card h1 em { font-style: normal; color: #B8977A; }
.auth-card p.lead { color: var(--ink-soft); margin: 0 0 20px; }
.auth-card .small { color: var(--muted); font-size: 12px; margin: 16px 0 0; }
.auth-card .code-input { font-size: 26px; letter-spacing: 8px; text-align: center; }

/* Aplicația: trei coloane pe calculator */
.app { display: grid; grid-template-columns: 240px minmax(320px, 400px) 1fr; height: 100vh; height: 100dvh; }

/* Sidebar */
.side { background: var(--side); color: var(--side-text); display: flex; flex-direction: column; min-height: 0; }
.side-scroll { overflow-y: auto; overflow-x: hidden; flex: 1; padding-bottom: 12px; }
.brand { display: flex; align-items: center; gap: 12px; padding: 18px 20px 14px; text-decoration: none; }
.brand-mark { width: 38px; height: 38px; background: var(--side-active); color: var(--dark); display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 18px; flex: none; }
.brand-name { font-family: var(--serif); font-size: 19px; line-height: 1.05; color: var(--white); }
.brand-sub { font-size: 10px; font-weight: 800; letter-spacing: 2px; color: var(--side-muted); text-transform: uppercase; }
.side-label { font-size: 11px; font-weight: 800; letter-spacing: 1.7px; text-transform: uppercase; color: var(--side-muted); padding: 16px 20px 6px; }
.side-item { display: flex; align-items: center; gap: 10px; margin: 0 12px; padding: 7px 8px; color: var(--side-text); text-decoration: none; font-size: 14px; min-height: 34px; }
.side-item:hover { background: rgba(255, 255, 255, .06); }
.side-item.active { background: var(--side-active); color: var(--dark); font-weight: 600; }
.side-item .lbl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-item .count { margin-left: auto; font-size: 12px; color: var(--side-muted); flex: none; }
.side-item.active .count { color: var(--dark); }
.side-item .count.hot { color: var(--white); font-weight: 800; }
.side-item.active .count.hot { color: var(--dark); }
.swatch { width: 9px; height: 9px; flex: none; display: inline-block; }
.mini-avatar { width: 20px; height: 20px; border: 1px solid var(--side-muted); font-size: 10px; display: inline-flex; align-items: center; justify-content: center; flex: none; }
.side-item.active .mini-avatar { border-color: var(--dark); }
/* Meniul ca arbore: submeniul secțiunii deschise (ACCOUNTS · INBOXES · STAGES · TEAM) stă sub rândul ei, spre dreapta */
.side-sub { margin: 2px 0 8px 20px; border-left: 1px solid rgba(255, 255, 255, .1); }
.side-sub .side-label { padding: 12px 12px 4px 14px; }
.side-sub .side-item { margin: 0 12px 0 6px; }
.side-foot { border-top: 1px solid rgba(255, 255, 255, .1); padding: 12px 16px 14px; }
.side-foot .who { margin-bottom: 10px; min-width: 0; }
.side-foot .who b, .side-foot .who span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-foot .who b { font-size: 14px; font-weight: 600; }
.side-foot .who span { font-size: 12px; color: var(--side-muted); }
/* butoanele de jos: pe rândul lor, trec pe rândul următor dacă nu încap (nu se suprapun niciodată) */
.foot-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.foot-actions form { display: flex; margin: 0; }
.foot-btn { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 32px; padding: 5px 10px; border: 1px solid rgba(255, 255, 255, .22); background: transparent; color: var(--side-text); font-size: 12.5px; font-weight: 600; text-decoration: none; cursor: pointer; white-space: nowrap; }
.foot-btn:hover { background: rgba(255, 255, 255, .08); }
.icon-btn { width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(255, 255, 255, .18); background: transparent; color: var(--side-text); cursor: pointer; text-decoration: none; font-size: 15px; flex: none; }
.icon-btn:hover { background: rgba(255, 255, 255, .08); }

/* Lista */
.list { background: var(--list); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.list-head { padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.list-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin-bottom: 12px; }
.list-title h1 { font-size: 30px; min-width: 0; overflow-wrap: anywhere; }
.list-title .total { margin-left: auto; font-size: 13px; color: var(--muted); }
.list-scroll { overflow-y: auto; flex: 1; }
.banner { margin: 12px 18px 0; padding: 12px 14px; background: var(--white); border: 1px solid var(--line); font-size: 14px; }
.banner p { margin: 0 0 8px; color: var(--ink-soft); }
.banner-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.row { display: flex; gap: 14px; padding: 14px 18px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.row:hover { background: rgba(255, 255, 255, .45); }
.row.active { background: var(--white); }
.avatar { width: 36px; height: 36px; border: 1px solid var(--line-strong); background: var(--white); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--ink-soft); flex: none; }
.row-main { flex: 1; min-width: 0; }
.row-name { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-sub { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side { text-align: right; font-size: 12px; color: var(--muted); flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; max-width: 42%; }
.row-side > span { max-width: 100%; }
/* data și ora mereu pe un rând; cea mai lungă („28 May 2025, 23:48”) are ~111px, încape în 42% și pe un telefon de 320px (~119px) */
.row-side .row-date { white-space: nowrap; }
.row-side .stage { color: var(--ink-soft); display: inline-flex; align-items: center; gap: 6px; }
.row-side .stage .swatch { flex: none; }
.row-side .txt, .row-side .agent { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-side .agent { color: var(--ink-soft); }
.row-notes { font-size: 12px; color: var(--muted); }
/* contul fiecărui rând („Instagram · drducu.clinics”, „Meta Lead Ads · Dr Ducu Clinics”) */
.row-account { display: block; font-size: 12px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 40px 18px; color: var(--muted); text-align: center; }
.more { padding: 14px 18px; text-align: center; }

/* Detaliul */
.detail { background: var(--white); overflow-y: auto; min-height: 0; }
.detail-inner { max-width: 760px; padding: 32px 40px 60px; }
.detail-back { display: none; }
.detail-empty { height: 100%; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.lead-name { font-size: 46px; line-height: 1.05; margin: 8px 0 6px; overflow-wrap: anywhere; }
.lead-received { color: var(--muted); margin-bottom: 22px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 28px; }
.section { padding: 18px 0; }
.section + .section.ruled { border-top: 1px solid var(--line); }
.section .eyebrow { display: block; margin-bottom: 10px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 8px; min-height: 36px; padding: 6px 12px; border: 1px solid var(--line-strong); background: var(--white); cursor: pointer; font-size: 14px; color: var(--ink); }
.chip:hover { border-color: var(--dark); }
.chip.current { color: var(--white); border-color: transparent; font-weight: 600; }
.chip.current .swatch { background: rgba(255, 255, 255, .85) !important; }
.chip.dark.current { background: var(--dark); }
.chip-menu { position: relative; display: inline-block; }
.menu { position: absolute; z-index: 20; top: 100%; left: 0; margin-top: 4px; min-width: 190px; max-width: calc(100vw - 32px); max-height: 60vh; overflow-y: auto; background: var(--white); border: 1px solid var(--line-strong); box-shadow: 0 6px 18px rgba(0, 0, 0, .08); padding: 4px 0; }
.menu.align-right { left: auto; right: 0; }
.menu button { display: block; width: 100%; text-align: left; padding: 9px 14px; border: 0; background: none; cursor: pointer; font-size: 14px; }
.menu button:hover { background: var(--page); }
.qa { padding: 12px 0; border-bottom: 1px solid var(--line); }
.qa:last-child { border-bottom: 0; }
.qa .q { color: var(--muted); font-size: 14px; }
.qa .a { font-weight: 700; font-size: 17px; white-space: pre-wrap; word-break: break-word; }
.note { background: var(--note); padding: 12px 14px; margin-bottom: 8px; }
.note .meta { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.note .body { white-space: pre-wrap; word-break: break-word; }
.note-form { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.history { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.history li { padding: 6px 0; border-bottom: 1px dashed var(--line); display: flex; gap: 12px; }
.history time { color: var(--muted); flex: none; width: 120px; }
.history span { min-width: 0; overflow-wrap: anywhere; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 6px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }
details summary { cursor: pointer; list-style: none; }
details summary::-webkit-details-marker { display: none; }
details summary .eyebrow::after { content: ' +'; }
details[open] summary .eyebrow::after { content: ' −'; }
.same { display: flex; flex-direction: column; gap: 6px; }
.same a { text-decoration: none; display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: center; font-size: 14px; }
.same a span { color: var(--muted); }

/* Pagini simple (setări, tabel, jurnal) */
.page { max-width: 1100px; margin: 0 auto; padding: 24px 16px 60px; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin: 18px 0 20px; }
.page-head h1 { font-size: 36px; min-width: 0; overflow-wrap: anywhere; }
.page-head .spacer { flex: 1; }
.card { background: var(--white); border: 1px solid var(--line); border-top: 4px solid var(--dark); padding: 20px; margin-bottom: 20px; }
.card > .eyebrow { display: block; margin-bottom: 14px; }
.card .hint { color: var(--muted); font-size: 13px; margin: 12px 0 0; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 1.4px; color: var(--muted); padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table th a { text-decoration: none; }
.table td { padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table .input, .table .select { min-height: 36px; padding: 6px 8px; }
.table input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line-strong); background: var(--white); }
.table .num { width: 70px; }
.filters { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.filters .input, .filters .select { width: auto; min-height: 40px; }
.secret { font-family: ui-monospace, Menlo, Consolas, monospace; background: var(--note); padding: 10px 12px; word-break: break-all; margin: 10px 0; }

/* Filtrele de lângă căutare */
.search-row { display: flex; gap: 8px; align-items: stretch; }
.search-row .input { flex: 1; min-width: 0; }
.filter-toggle { flex: none; gap: 6px; }
.filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; background: var(--dark); color: var(--white); font-size: 11px; font-weight: 800; }
.filter-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; margin-top: 12px; padding: 12px; background: var(--white); border: 1px solid var(--line); }
.filter-panel .field { margin-bottom: 10px; min-width: 0; }
.filter-panel .field > span { font-size: 12px; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.filter-panel .select, .filter-panel .input { min-height: 40px; padding: 8px 10px; }
.filter-panel .custom-dates { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.filter-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; }
.filter-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.fchip { display: inline-block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 600; background: var(--white); border: 1px solid var(--line-strong); padding: 3px 8px; }
/* contul, stage-ul și omul alese în meniu, sub titlul listei: fiecare cip e un link care scoate filtrul */
.list-chips { margin: -4px 0 12px; }
a.fchip { text-decoration: none; color: var(--ink); }
a.fchip:hover { border-color: var(--dark); }
a.fchip span { color: var(--muted); }

/* Mesaje scurte */
.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--dark); color: var(--white); padding: 12px 18px; font-size: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .2); max-width: calc(100% - 32px); }
.toast.bad { background: var(--danger); }

.mobile-top { display: none; }
.scrim { display: none; }

/* Pe ecrane foarte înguste, filtrele stau pe o singură coloană */
@media (max-width: 380px) {
  .filter-panel, .filter-panel .custom-dates { grid-template-columns: 1fr; }
}

/* Ecrane medii (tabletă în landscape, laptop mic): coloane mai strânse */
@media (min-width: 901px) and (max-width: 1200px) {
  .app { grid-template-columns: 210px minmax(280px, 340px) 1fr; }
  .detail-inner { padding: 24px 24px 60px; }
  .lead-name { font-size: 38px; }
}

/* Telefon: o coloană; meniul e sertar, detaliul pe tot ecranul */
@media (max-width: 900px) {
  .app { display: block; height: auto; min-height: 100vh; }
  .mobile-top { display: flex; align-items: center; gap: 12px; position: sticky; top: 0; z-index: 30; background: var(--side); color: var(--side-text); padding: 8px 12px; min-height: 52px; }
  .mobile-top .brand-name { font-size: 17px; }
  .side { position: fixed; z-index: 50; top: 0; bottom: 0; left: 0; width: 280px; max-width: 85vw; transform: translateX(-100%); transition: transform .2s ease; }
  body.menu-open .side { transform: none; }
  body.menu-open .scrim { display: block; position: fixed; inset: 0; z-index: 40; background: rgba(0, 0, 0, .35); }
  .list { border-right: 0; min-height: calc(100vh - 52px); }
  .list-scroll { overflow: visible; }
  .detail { position: fixed; z-index: 35; inset: 0; display: none; }
  body.detail-open .detail { display: block; }
  body.detail-open { overflow: hidden; }
  .detail-inner { padding: 12px 16px 60px; }
  .detail-back { display: flex; position: sticky; top: 0; z-index: 2; background: var(--white); margin: -12px -16px 8px; padding: 6px 8px; border-bottom: 1px solid var(--line); }
  .detail-back .btn { border: 0; min-height: 44px; }
  .lead-name { font-size: 36px; }
  .btn, .chip { min-height: 44px; }
  .side-item { min-height: 44px; }
  a.fchip { padding: 8px 10px; }
  .foot-btn { min-height: 44px; padding: 8px 14px; font-size: 14px; }
  .history time { width: 92px; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 8px; }
  .page-head h1 { font-size: 30px; }
  .filter-toggle { min-height: 44px; }
  .menu, .menu.align-right { position: fixed; left: 16px; right: 16px; top: auto; bottom: 16px; min-width: 0; max-width: none; z-index: 60; box-shadow: 0 8px 28px rgba(0, 0, 0, .25); }
  .menu button { min-height: 44px; }
}

/* Lead: conversația aceleiași persoane (Instagram DM / WhatsApp / Facebook) */
.lead-conversation { margin: -14px 0 22px; font-size: 14px; color: var(--ink-soft); }
.lead-conversation .link { margin-left: 6px; }

/* Setări: tab-uri, conturile de mesaje și comutatoarele lor */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.tabs .btn { min-height: 36px; padding: 6px 14px; }
.account-box { border: 1px solid var(--line); padding: 14px; margin-bottom: 14px; }
.account-head { font-size: 14px; color: var(--ink-soft); margin-bottom: 10px; overflow-wrap: anywhere; }
.account-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0 14px; }
.switches { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 8px 18px; margin-top: 6px; }
.switch { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.switch input { margin-top: 3px; flex: none; width: 18px; height: 18px; }
.switch b { display: block; font-weight: 700; }
.switch small { display: block; color: var(--muted); font-size: 12px; line-height: 1.35; }
.muted { color: var(--muted); }
@media (max-width: 900px) { .tabs .btn { min-height: 44px; } }
