/* ============================================================
   ELPA / MG Müşteri Takip — Modern Arayüz
   Açık & Koyu tema, yumuşak butonlar, sade 3B grafikler,
   animasyonlu menü, renkli liste & rapor görünümü.
   ============================================================ */

:root {
  --ink: #1b2430;
  --muted: #6b7686;
  --line: #e7eaf0;
  --paper: #f7f8fa;
  --panel: #ffffff;
  --panel-2: #f4f6f9;

  --blue: #6366f1;
  --blue-dark: #4f46e5;
  --blue-tint: #ecebfe;
  --green: #10b981;
  --green-tint: #e2f8f0;
  --red: #f43f5e;
  --red-tint: #fde7ec;
  --amber: #f59e0b;
  --amber-tint: #fef3e0;
  --teal: #0ea5e9;
  --teal-tint: #e3f4fd;
  --pink: #ec4899;
  --violet: #8b5cf6;

  --sidebar-bg: #ffffff;
  --sidebar-bg-2: #f2f3f8;
  --sidebar-text: #4c5566;
  --sidebar-text-strong: #14161c;
  --sidebar-line: #e7e9f0;
  --nav-hover-bg: #1f2230;
  --nav-hover-text: #ffffff;

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 26px;

  --shadow-sm: 0 2px 8px rgba(20, 26, 43, .06);
  --shadow-md: 0 10px 28px rgba(20, 26, 43, .09);
  --shadow-lg: 0 22px 60px rgba(20, 26, 43, .16);

  color-scheme: light;
}

[data-theme="dark"] {
  --ink: #edeef1;
  --muted: #9b9fa7;
  --line: #35383e;
  --paper: #1a1b1e;
  --panel: #222327;
  --panel-2: #28292e;

  --blue: #818cf8;
  --blue-dark: #a5b4fc;
  --blue-tint: #2c2c42;
  --green: #34d399;
  --green-tint: #1b3730;
  --red: #fb7185;
  --red-tint: #3a2229;
  --amber: #fbbf24;
  --amber-tint: #3a2f18;
  --teal: #38bdf8;
  --teal-tint: #1c2f3d;
  --pink: #f472b6;
  --violet: #a78bfa;

  --sidebar-bg: #101113;
  --sidebar-bg-2: #17181b;
  --sidebar-text: #9b9fa7;
  --sidebar-text-strong: #ffffff;
  --sidebar-line: #2d2f34;
  --nav-hover-bg: #2b2e35;
  --nav-hover-text: #ffffff;

  --shadow-sm: 0 2px 10px rgba(0, 0, 0, .4);
  --shadow-md: 0 12px 30px rgba(0, 0, 0, .5);
  --shadow-lg: 0 26px 70px rgba(0, 0, 0, .6);

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  transition: background-color .25s ease, color .25s ease;
}
.hidden { display: none !important; }

/* ---------------- Login ---------------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(1100px 520px at 12% -8%, rgba(99,102,241,.16), transparent 60%),
    radial-gradient(900px 480px at 110% 10%, rgba(16,185,129,.14), transparent 55%),
    var(--paper);
}
.login-card {
  width: min(420px, 100%);
  display: grid;
  gap: 14px;
  padding: 30px 28px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: pop-in .35s ease;
}
.login-card h1 { margin-top: 4px; font-size: 22px; }
.hint { font-size: 13px; color: var(--muted); }
.app-shell { min-height: 100vh; }

@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------------- Sidebar ---------------- */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: 246px;
  background: linear-gradient(180deg, var(--sidebar-bg), var(--sidebar-bg-2));
  color: var(--sidebar-text);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  border-right: 1px solid var(--sidebar-line);
  box-shadow: var(--shadow-sm);
}
.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 22px;
}
.brand span {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  font-weight: 800;
  background: linear-gradient(135deg, var(--blue), #7b93ff);
  color: white;
  box-shadow: 0 8px 18px rgba(99, 102, 241, .35);
}
.brand strong { font-size: 17px; color: var(--sidebar-text-strong); letter-spacing: .2px; }
.brand.dark { color: var(--ink); margin-bottom: 4px; }
.brand.dark span { box-shadow: 0 8px 18px rgba(99, 102, 241, .25); }

.user-box {
  padding: 13px 14px;
  margin-bottom: 12px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius-md);
  background: var(--sidebar-bg-2);
}
.user-box b, .user-box span { display: block; }
.user-box b { color: var(--sidebar-text-strong); }
.user-box span { color: var(--sidebar-text); font-size: 13px; margin-top: 2px; }

/* Theme toggle switch */
.theme-toggle {
  width: 100%;
  background: transparent;
  border: 1px solid var(--sidebar-line);
  border-radius: 999px;
  padding: 4px;
  margin-bottom: 16px;
  cursor: pointer;
  box-shadow: none;
}
.theme-toggle:hover { box-shadow: none; transform: none; filter: none; }
.theme-toggle-track {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  height: 34px;
  border-radius: 999px;
}
.theme-toggle-icon {
  position: relative;
  z-index: 1;
  text-align: center;
  font-size: 14px;
  color: var(--sidebar-text);
  transition: color .25s ease;
}
.theme-toggle-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: linear-gradient(135deg, var(--blue), #7b93ff);
  box-shadow: 0 4px 12px rgba(99, 102, 241, .4);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
[data-theme="dark"] .theme-toggle-thumb { transform: translateX(100%); }
[data-theme="dark"] .theme-toggle-icon.moon,
[data-theme="light"] .theme-toggle-icon.sun,
:root:not([data-theme]) .theme-toggle-icon.sun { color: white; font-weight: 700; }

.nav-list { display: flex; flex-direction: column; gap: 4px; margin-bottom: 10px; }
.nav {
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--sidebar-text);
  padding: 11px 14px;
  border-radius: var(--radius-md);
  text-align: left;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
  font-size: 14px;
  font-weight: 600;
  transition: background-color .2s ease, color .2s ease, transform .2s ease, padding-left .2s ease;
}
.nav-icon {
  width: 19px;
  height: 19px;
  flex-shrink: 0;
  color: currentColor;
  opacity: .85;
  transition: transform .25s ease;
}
.nav::before {
  content: "";
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--blue), #7b93ff);
  transition: height .22s ease;
}
.nav:hover {
  background: var(--nav-hover-bg);
  color: var(--nav-hover-text);
  padding-left: 17px;
}
.nav:hover .nav-icon { transform: scale(1.1); }
.nav.active {
  background: linear-gradient(135deg, rgba(99, 102, 241, .18), rgba(99, 102, 241, .06));
  color: var(--sidebar-text-strong);
}
.nav.active::before { height: 60%; }
.nav.active .nav-icon { opacity: 1; color: var(--blue-dark); }
.nav-badge {
  margin-left: auto;
  min-width: 22px;
  height: 20px;
  padding: 0 6px;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
}
.sound-button {
  width: 100%;
  margin-top: auto;
  background: linear-gradient(135deg, var(--green), #1ec38a);
  border-radius: var(--radius-md);
}
.logout {
  width: 100%;
  margin-top: 8px;
  border-radius: var(--radius-md);
}
.side-note {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--sidebar-line);
  border-radius: var(--radius-md);
  background: var(--sidebar-bg-2);
}
.side-note b { display: block; font-size: 26px; color: var(--sidebar-text-strong); }
.side-note span { color: var(--sidebar-text); font-size: 12.5px; }

/* ---------------- Layout ---------------- */
main {
  margin-left: 246px;
  padding: 26px 28px 40px;
}

/* Her sayfanın üstünde sabit duran hızlı Web Portal geçiş çubuğu */
.quick-portal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px 12px;
  margin: 0 0 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}
.quick-portal-nav::-webkit-scrollbar { height: 0; }
.quick-portal-btn {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 0 0 auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px 6px 8px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s ease, transform .1s ease;
}
.quick-portal-btn:hover { background: var(--blue-tint); }
.quick-portal-btn:active { transform: scale(.97); }
.quick-portal-icon { display: inline-grid; place-items: center; width: 18px; height: 18px; flex-shrink: 0; color: var(--blue); }
.quick-portal-icon img { width: 100%; height: 100%; object-fit: contain; border-radius: 4px; }
.quick-portal-count {
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 16px;
  text-align: center;
}
.quick-portal-count.zero { display: none; }
@media (max-width: 720px) {
  .quick-portal-nav { margin: 0 0 14px; }
  .quick-portal-label { display: none; }
  .quick-portal-btn { padding: 8px; border-radius: 50%; }
}

/* Müşteri telefon numarasının yanındaki arama ikonu */
.phone-link { display: inline-flex; align-items: center; gap: 5px; }
.phone-call-icon {
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--green-tint);
  color: var(--green);
  flex-shrink: 0;
  cursor: pointer;
}
.phone-call-icon svg { width: 12px; height: 12px; }
.thread-phone { display: inline-flex; align-items: center; gap: 5px; }
.view { display: none; }
.view.active { display: block; animation: fade-up .25s ease; }
@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 20px;
}
h1 { margin: 0 0 4px; font-size: 26px; letter-spacing: -.2px; font-weight: 800; }
h2 { margin: 0 0 14px; font-size: 17px; letter-spacing: 0; font-weight: 750; }
p { color: var(--muted); margin: 0; }

.search-box, .group, .program-card, .table-wrap, .home-section, .metric-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: background-color .25s ease, border-color .25s ease, box-shadow .2s ease, transform .2s ease;
}
.search-box {
  padding: 16px;
  margin-bottom: 16px;
  position: relative;
}
label {
  display: grid;
  gap: 6px;
  font-size: 13px;
  font-weight: 650;
  color: var(--muted);
}
input, select, textarea {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  color: var(--ink);
  background: var(--panel-2);
  transition: border-color .18s ease, box-shadow .18s ease, background-color .25s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, .16);
  background: var(--panel);
}
textarea { resize: vertical; }
.search-results {
  position: absolute;
  z-index: 5;
  left: 16px;
  right: 16px;
  top: 76px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 260px;
  overflow: auto;
  display: none;
}
.search-results button {
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  font-weight: 500;
}
.search-results button:hover { background: var(--panel-2); }

/* ---------------- Metric cards ---------------- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}
.metric-card {
  color: var(--ink);
  text-align: left;
  padding: 20px;
  min-height: 150px;
  position: relative;
  overflow: hidden;
}
.metric-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  margin-bottom: 10px;
}
.metric-icon svg { width: 22px; height: 22px; }
.metric-card.tone-blue .metric-icon { background: var(--blue-tint); color: var(--blue); }
.metric-card.tone-amber .metric-icon { background: var(--amber-tint); color: var(--amber); }
.metric-card.tone-red .metric-icon { background: var(--red-tint); color: var(--red); }
.metric-card.tone-green .metric-icon { background: var(--green-tint); color: var(--green); }
.metric-card > span:not(.metric-icon) {
  display: block;
  color: var(--muted);
  font-weight: 700;
  font-size: 13px;
}
.metric-card strong {
  display: block;
  margin: 10px 0 2px;
  font-size: 38px;
  line-height: 1;
  font-weight: 800;
}
.metric-card small {
  color: var(--muted);
  font-weight: 600;
  font-size: 12.5px;
}
.metric-card::after {
  content: "";
  position: absolute;
  right: -30px;
  bottom: -30px;
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0;
  transition: opacity .25s ease, transform .25s ease;
  transform: scale(.8);
}
.metric-card.tone-blue::after { color: var(--blue); }
.metric-card.tone-amber::after { color: var(--amber); }
.metric-card.tone-red::after { color: var(--red); }
.metric-card.tone-green::after { color: var(--green); }
.metric-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}
.metric-card:hover::after { opacity: .05; transform: scale(1); }

.home-section {
  padding: 20px;
  margin-bottom: 16px;
}
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.section-head h2 { margin: 0; }
.small { padding: 8px 12px; }

/* ---------------- Sade 3B grafikler ---------------- */
.chart {
  display: grid;
  gap: 18px;
}
.chart-row {
  display: grid;
  gap: 9px;
}
.chart-label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--ink);
  font-weight: 650;
}
.chart-label span { color: var(--muted); font-weight: 600; }
.bar {
  height: 20px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  overflow: hidden;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, .06);
}
.bar i {
  display: block;
  height: 100%;
  border-radius: inherit;
  position: relative;
  transition: width .7s cubic-bezier(.22, 1, .36, 1);
  box-shadow:
    inset 0 8px 10px -4px rgba(255, 255, 255, .5),
    inset 0 -8px 12px -4px rgba(0, 0, 0, .28);
  background-blend-mode: overlay;
}

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 28px;
  flex-wrap: wrap;
  padding-bottom: 6px;
}
.donut {
  position: relative;
  width: 168px;
  height: 168px;
  border-radius: 50%;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  box-shadow:
    0 16px 30px -10px rgba(20, 26, 43, .35),
    inset 0 3px 6px rgba(255, 255, 255, .45),
    inset 0 -6px 10px rgba(0, 0, 0, .25);
  transition: background .5s ease;
}
.donut-hole {
  width: 66%;
  height: 66%;
  border-radius: 50%;
  background: var(--panel);
  display: grid;
  place-items: center;
  text-align: center;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, .08);
}
.donut-hole strong { font-size: 26px; line-height: 1; font-weight: 800; color: var(--ink); }
.donut-hole span { font-size: 11px; color: var(--muted); font-weight: 650; margin-top: 2px; }
.donut-legend { display: grid; gap: 10px; }
.legend-row { display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 650; color: var(--ink); }
.legend-row i {
  width: 12px;
  height: 12px;
  border-radius: 4px;
  box-shadow: inset 0 1px 2px rgba(255, 255, 255, .5), inset 0 -1px 2px rgba(0, 0, 0, .2);
}
.legend-row span { color: var(--muted); font-weight: 600; min-width: 128px; }
.legend-row b { font-size: 14px; }

/* ---------------- Forms ---------------- */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(280px, 1fr));
  gap: 16px;
}
.group {
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(180px, 1fr));
  gap: 13px;
  align-content: start;
}
.group h2, .span-2 { grid-column: 1 / -1; }
#customerFinanceOptions .hint, #customerFinanceInstitutions { grid-column: 1 / -1; }
.finance-embed-wrap { display: flex; justify-content: stretch; align-items: stretch; padding: 0; height: 100%; width: 100%; overflow: hidden; }
.finance-embed-wrap iframe { width: 100% !important; height: 100% !important; max-width: none; border: none; border-radius: 0; flex: 1 1 auto; }
.group.wide { grid-column: 1 / -1; }
.reminder-group { border-top: 4px solid var(--amber); border-radius: var(--radius-lg) var(--radius-lg) var(--radius-lg) var(--radius-lg); }
.panel-tools { border-top: 4px solid var(--blue); }
.tool-buttons {
  display: grid;
  grid-template-columns: repeat(3, minmax(180px, 1fr));
  gap: 10px;
}
.status-box { border-top: 4px solid var(--muted); }
.loss-reason-wrap.hidden { display: none; }
.form-actions {
  grid-column: 1 / -1;
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px;
  background: color-mix(in srgb, var(--panel) 88%, transparent);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(10px);
}
.actions, .modal-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---------------- Buttons (yumuşak) ---------------- */
button {
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  font-weight: 700;
  font-size: 13.5px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .28);
  transition: transform .15s ease, box-shadow .2s ease, filter .15s ease, opacity .15s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(99, 102, 241, .34); filter: brightness(1.03); }
button:active { transform: translateY(0); }
button.secondary {
  background: var(--panel-2);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--line);
}
button.secondary:hover { box-shadow: var(--shadow-md); filter: none; background: var(--panel); }
button.danger, .danger-button {
  background: linear-gradient(135deg, var(--red), #c93a3f);
  box-shadow: 0 6px 16px rgba(244, 63, 94, .28);
}
.danger-button:hover { filter: brightness(1.05); }
button:disabled {
  opacity: .45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.table-filter { max-width: 280px; }
.toolbar-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.owner-info {
  margin-top: 8px;
  font-weight: 750;
  color: var(--blue);
}
.name-cell { display: inline-flex; align-items: center; gap: 9px; }
.avatar-chip {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  color: white;
  font-size: 11.5px;
  font-weight: 800;
  letter-spacing: .2px;
  box-shadow: inset 0 2px 3px rgba(255, 255, 255, .4), inset 0 -2px 4px rgba(0, 0, 0, .2), 0 3px 8px rgba(0, 0, 0, .18);
}
.phone-link {
  color: var(--blue);
  font-weight: 750;
  text-decoration: none;
}
.phone-link:hover { text-decoration: underline; }
.filter-row th {
  top: 42px;
  background: var(--panel);
  padding: 6px;
}
.filter-row input {
  min-width: 110px;
  padding: 7px 9px;
  font-size: 12px;
  border-radius: 8px;
}
.small-action { margin-top: 6px; padding: 7px 11px; font-size: 12px; }
.history-action {
  background: var(--teal-tint);
  color: var(--teal);
  border: 1px solid transparent;
  box-shadow: none;
}
.history-action:hover { background: var(--teal); color: white; box-shadow: 0 6px 14px rgba(14, 165, 233, .25); }
.whatsapp-action {
  background: linear-gradient(135deg, #22c55e, #16a34a);
  box-shadow: 0 6px 16px rgba(34, 197, 94, .28);
}
.whatsapp-action:hover { filter: brightness(1.05); }
.date-filter {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 14px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.date-filter input { width: 160px; }
.date-filter button {
  background: var(--panel-2);
  color: var(--ink);
  box-shadow: none;
  border: 1px solid var(--line);
  padding: 9px 14px;
}
.date-filter button:hover { background: var(--blue-tint); color: var(--blue-dark); }

.report-tabs, .portal-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}
.report-tab, .portal-tab {
  background: var(--panel);
  color: var(--muted);
  border: 1px solid var(--line);
  box-shadow: none;
  padding: 10px 16px;
}
.report-tab.active, .portal-tab.active {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: white;
  box-shadow: 0 6px 16px rgba(99, 102, 241, .28);
  border-color: transparent;
}
.report-panel { display: none; }
.report-panel.active { display: block; animation: fade-up .2s ease; }

/* Web Portal - kanal seçim merkezi (hub) */
.portal-channel-hub {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.portal-channel-hub.hidden { display: none; }
.portal-channel-tile {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: 0 6px 0 rgba(0,0,0,.06), var(--shadow-sm);
  cursor: pointer;
  transition: transform .12s ease;
}
.portal-channel-tile:hover { transform: translateY(-2px); }
.portal-channel-tile:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.06); }
.portal-channel-icon {
  width: 52px; height: 52px;
  border-radius: 16px;
  display: grid; place-items: center;
  overflow: hidden;
  background: var(--blue-tint, rgba(99,102,241,.12));
  color: var(--blue);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,.04);
}
.portal-channel-icon img { width: 100%; height: 100%; object-fit: cover; }
.portal-channel-icon-new { background: rgba(99,102,241,.15); color: var(--blue); }
.portal-channel-icon-mine { background: rgba(16,185,129,.15); color: #10b981; }
.portal-channel-icon-all { background: rgba(245,158,11,.15); color: #f59e0b; }
.portal-channel-tile b { font-size: 12.5px; text-align: center; line-height: 1.25; }
.portal-channel-tile em {
  font-style: normal;
  font-size: 20px;
  font-weight: 800;
  color: white;
  background: var(--blue);
  border-radius: 999px;
  min-width: 30px;
  line-height: 1.3;
  padding: 2px 9px;
}
.portal-channel-tile[data-portal-filter="new"] em { background: #e5484d; }

/* ---------------- Tables / Lists (renkli & şık) ---------------- */
.table-wrap {
  overflow: auto;
  -webkit-overflow-scrolling: touch; /* mobilde parmakla kaydırmada momentum/akıcılık */
  scrollbar-width: thin;
  cursor: grab;
}
.table-wrap.dragging { cursor: grabbing; user-select: none; }
table { width: 100%; border-collapse: collapse; min-width: 1480px; }
th, td {
  padding: 12px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}
th {
  position: sticky;
  top: 0;
  background: var(--panel-2);
  color: var(--muted);
  z-index: 1;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: .3px;
}
tbody tr {
  transition: background-color .18s ease, transform .18s ease, box-shadow .18s ease;
  position: relative;
}
tbody tr:nth-child(even) { background: color-mix(in srgb, var(--panel-2) 55%, transparent); }
tbody tr:hover {
  background: var(--blue-tint);
  transform: scale(1.003);
  box-shadow: 0 6px 18px rgba(20, 26, 43, .08);
  z-index: 1;
  position: relative;
}
tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--blue); }

.status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--blue-tint);
  color: var(--blue-dark);
  font-weight: 750;
  font-size: 12px;
  white-space: nowrap;
}
.status::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: currentColor;
}
.status[data-status="Satış Yapıldı"] { background: var(--green-tint); color: var(--green); }
.status[data-status="Kaybedildi"] { background: var(--red-tint); color: var(--red); }
.status[data-status="Takipte"] { background: var(--blue-tint); color: var(--blue-dark); }
.status[data-status="Aranacak"] { background: var(--amber-tint); color: var(--amber); }

.overdue-date { color: var(--red); font-weight: 800; }
.overdue-card { border-color: var(--red); background: var(--red-tint); }

.loss-chart {
  display: grid;
  gap: 13px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.loss-row {
  display: grid;
  grid-template-columns: minmax(180px, 260px) 1fr 50px;
  gap: 12px;
  align-items: center;
  font-weight: 600;
}
.loss-row .bar i { background: linear-gradient(135deg, var(--red), #c93a3f); }

.user-form {
  display: grid;
  grid-template-columns: repeat(5, minmax(160px, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---------------- Web Portal ---------------- */
.portal-test-panel {
  display: grid;
  grid-template-columns: auto 160px repeat(3, minmax(140px, 1fr)) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

/* ---- Otomatik Cevap / AI Asistanı ayar paneli (sade, geniş, tek sütun) ---- */
.ai-settings-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  margin-bottom: 16px;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  max-width: 780px;
}
.ai-settings-panel.collapsed { display: none; }
.ai-settings-section { display: flex; flex-direction: column; gap: 10px; }
.ai-settings-section h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 800;
  color: var(--ink);
}
.ai-settings-hint { margin: 0; font-size: 13px; color: var(--muted, #7a7f8a); line-height: 1.5; }
.ai-master-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  font-size: 15px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--line);
}
.ai-master-toggle input { width: 18px; height: 18px; }

/* Mod seçim kartları */
.ai-mode-cards { display: flex; gap: 14px; flex-wrap: wrap; }
.ai-mode-card {
  flex: 1 1 260px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-md);
  cursor: pointer;
  background: var(--panel-2);
  transition: border-color .15s ease, background .15s ease;
}
.ai-mode-card:hover { border-color: var(--blue); }
.ai-mode-card.active { border-color: var(--blue); background: var(--blue-tint); }
.ai-mode-card b { font-size: 14.5px; }
.ai-mode-card span { font-size: 12.5px; color: var(--muted, #7a7f8a); line-height: 1.4; }
.ai-mode-card input { display: none; }

.ai-field-label { font-weight: 700; font-size: 13.5px; color: var(--ink); }
.ai-settings-panel textarea,
.ai-settings-panel input[type=text],
.ai-settings-panel input[type=number] {
  width: 100%;
  resize: vertical;
  font: inherit;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
}
.ai-inline-fields { display: flex; gap: 20px; flex-wrap: wrap; }
.ai-inline-fields > div { flex: 1 1 160px; }
.ai-days-row { display: flex; gap: 12px; flex-wrap: wrap; }
.ai-days-row label { display: flex; align-items: center; gap: 5px; font-size: 13px; }
.ai-save-row { display: flex; }
.ai-save-row button {
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 10px 22px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

/* Bilgi bankası */
.ai-kb-form { display: flex; flex-direction: column; gap: 8px; }
.ai-kb-add-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.ai-kb-add-row button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  padding: 9px 16px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}
.ai-kb-add-row .ai-kb-primary { background: var(--blue); color: #fff; border-color: var(--blue); }
.ai-kb-list { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.ai-knowledge-item {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  background: var(--panel-2);
}
.ai-knowledge-item b { font-size: 14px; }
.ai-knowledge-item p { margin: 6px 0 8px; white-space: pre-wrap; font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.ai-knowledge-item button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--red, #d33);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  cursor: pointer;
}
.ai-kb-empty { color: var(--muted, #7a7f8a); font-size: 13.5px; }

.portal-layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 16px;
  height: calc(100vh - 180px);
  min-height: 460px;
}
.portal-list-col, .portal-chat {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.portal-list-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 15px;
}
.portal-hub-back-btn {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--panel-2); border: none; color: var(--ink); font-size: 16px; flex-shrink: 0; cursor: pointer;
}
.portal-list {
  padding: 10px;
  display: grid;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}
.portal-thread {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 4px 10px;
  color: var(--ink);
  background: var(--panel-2);
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  position: relative;
  padding: 10px;
  transition: background-color .15s ease, border-color .15s ease, transform .15s ease;
}
.portal-thread.active, .portal-thread:hover {
  background: var(--blue-tint);
  border-color: var(--blue);
  transform: translateX(2px);
}
.portal-thread b, .portal-thread small, .portal-thread p { grid-column: 2; margin: 0; }
.portal-thread p { color: var(--muted); font-weight: 500; }
.thread-unread {
  position: absolute;
  right: 10px;
  top: 10px;
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--red);
  color: white;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}
.channel-badge {
  grid-row: 1 / span 3;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: white;
  font-weight: 800;
  font-size: 12px;
  overflow: hidden;
}
.channel-badge img { width: 100%; height: 100%; object-fit: cover; display: block; }
.channel-badge span { display: none; }
.channel-badge.whatsapp { background: linear-gradient(135deg, #22c55e, #16a34a); }
.channel-badge.instagram { background: linear-gradient(135deg, #f472b6, #db2777); }
.channel-badge.facebook { background: linear-gradient(135deg, #60a5fa, #2563eb); }
.portal-realtime-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 15px;
  border-radius: 999px;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  border: 1px solid var(--line);
}
.portal-realtime-badge::before {
  content: "";
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: currentColor;
  opacity: .9;
}
.portal-realtime-badge[data-state="live"] { background: var(--green-tint); color: var(--green); border-color: transparent; }
.portal-realtime-badge[data-state="connecting"],
.portal-realtime-badge[data-state="polling"] { background: var(--amber-tint); color: var(--amber); border-color: transparent; }
.portal-realtime-badge[data-state="idle"] { background: var(--panel-2); color: var(--muted); }
.portal-chat { display: grid; grid-template-rows: auto 1fr auto auto; min-height: 0; overflow: hidden; }
.portal-chat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.portal-chat-head .channel-badge { display: inline-grid; margin-right: 8px; vertical-align: middle; }
.portal-chat-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.portal-messages { padding: 14px; display: grid; align-content: start; gap: 8px; overflow-y: auto; min-height: 0; font-size: 13.5px; }
.portal-message {
  width: min(680px, 78%);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  background: var(--panel-2);
  box-shadow: var(--shadow-sm);
  font-size: 13.5px;
  line-height: 1.42;
}
.portal-message.out { justify-self: end; background: var(--blue-tint); }
.portal-message p { color: var(--ink); }
.portal-message small { color: var(--muted); }
.message-meta { display: flex; justify-content: space-between; gap: 12px; align-items: center; margin-top: 6px; font-size: 12px; }
.portal-message.out .message-meta span:last-child { margin-left: auto; font-weight: 700; color: var(--blue); white-space: nowrap; }
.portal-message.out.message-failed .message-meta span:last-child { color: #e5484d; }
.message-fail-reason { display: block; margin-top: 4px; font-size: 11px; color: #e5484d; }
.portal-reply, .portal-customer-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.portal-reply { position: relative; grid-template-columns: auto 1fr auto; align-items: end; max-height: 200px; overflow: visible; }
.attach-button {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel-2);
  font-size: 20px;
  cursor: pointer;
  box-shadow: none;
  color: var(--ink);
}
.attach-button:hover { background: var(--blue-tint); transform: none; }
.attach-menu {
  position: absolute;
  left: 12px;
  bottom: calc(100% + 8px);
  display: grid;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  gap: 4px;
  min-width: 180px;
  z-index: 10;
}
.attach-menu button {
  text-align: left;
  background: transparent;
  border: none;
  padding: 9px 11px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--ink);
  box-shadow: none;
  font-weight: 600;
}
.attach-menu button:hover { background: var(--panel-2); transform: none; }
.portal-customer-form { grid-template-columns: 1fr 1fr auto; }
.portal-customer-form h3 { grid-column: 1 / -1; margin: 0; }

/* ---------------- Program cards ---------------- */
.program-list { display: grid; gap: 12px; }
.program-list.compact .program-card { box-shadow: none; }
.program-card {
  padding: 16px;
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 16px;
  align-items: center;
  border-left: 5px solid var(--line);
  transition: border-color .2s ease, transform .18s ease, box-shadow .2s ease;
}
.program-card[data-status="Takipte"] { border-left-color: var(--blue); }
.program-card[data-status="Aranacak"] { border-left-color: var(--amber); }
.program-card[data-status="Kaybedildi"] { border-left-color: var(--red); }
.program-card[data-status="Satış Yapıldı"] { border-left-color: var(--green); }
.program-card:hover { transform: translateX(3px); box-shadow: var(--shadow-md); }
.time { font-size: 21px; font-weight: 800; color: var(--blue); }
.empty {
  padding: 30px;
  background: var(--panel);
  border: 1.5px dashed var(--line);
  border-radius: var(--radius-lg);
  color: var(--muted);
  text-align: center;
}

/* ---------------- Modals (şık pencereler) ---------------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: grid;
  place-items: center;
  background: rgba(10, 14, 26, .45);
  backdrop-filter: blur(3px);
  animation: modal-fade .18s ease;
}
.modal.hidden { display: none; }
@keyframes modal-fade { from { opacity: 0; } to { opacity: 1; } }
.modal-card {
  width: min(520px, calc(100vw - 32px));
  padding: 26px;
  background: var(--panel);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  display: grid;
  gap: 14px;
  animation: modal-pop .22s cubic-bezier(.34, 1.3, .64, 1);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(14px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-card-wide { width: min(760px, calc(100vw - 32px)); }
.meeting-history { display: grid; gap: 10px; max-height: min(62vh, 560px); overflow: auto; }
.history-item {
  display: grid;
  gap: 6px;
  padding: 13px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
}
.history-item b { color: var(--ink); }
.history-item small { color: var(--blue); font-weight: 750; }
.history-item p { color: var(--ink); opacity: .85; white-space: pre-wrap; }
.modal.overdue .modal-card { border-top: 6px solid var(--red); }

.toast-layer { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 10px; z-index: 30; }
.toast {
  /* Açık temada --sidebar-bg beyaz olduğundan beyaz metin okunmuyordu;
     tema ne olursa olsun koyu kalan --nav-hover-bg kullanılıyor. */
  background: var(--nav-hover-bg);
  color: #ffffff;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  animation: toast-in .22s ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------- Scrollbars ---------------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: color-mix(in srgb, var(--muted) 45%, transparent); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: color-mix(in srgb, var(--muted) 65%, transparent); }

/* ---------------- Responsive ---------------- */
@media (max-width: 1050px) {
  .sidebar {
    position: static;
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .brand { margin: 0 12px 0 0; }
  .nav-list { flex-direction: row; flex-wrap: wrap; }
  .nav { width: auto; }
  .theme-toggle { width: auto; }
  .side-note { display: none; }
  main { margin-left: 0; padding: 16px; }
  .metric-grid, .form-grid, .group, .tool-buttons { grid-template-columns: 1fr; }
  .user-form, .loss-row, .portal-layout, .portal-test-panel, .portal-customer-form, .portal-reply { grid-template-columns: 1fr; }
  .portal-reply { gap: 8px; }
  .attach-menu { left: auto; right: 12px; }
  .group.wide, .group h2, .span-2, .form-actions { grid-column: auto; }
  .topbar, .program-card { align-items: stretch; grid-template-columns: 1fr; flex-direction: column; }
}

/* Bildirim merkezi (notification bell) */
.notif-bell {
  position: fixed;
  top: 16px;
  right: 22px;
  z-index: 900;
}
.notif-bell-btn {
  position: relative;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--text, #fff);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
}
.notif-bell-btn img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.25));
  transition: transform .15s ease;
}
.notif-bell-btn:hover img { transform: scale(1.06); }
.notif-bell-btn:active img { transform: scale(.96); }
.notif-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
}
.notif-badge.hidden { display: none; }
.notif-panel {
  position: absolute;
  top: 52px;
  right: 0;
  width: 360px;
  max-height: 460px;
  overflow-y: auto;
  background: var(--surface, #1c1f2b);
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  border-radius: 12px;
  box-shadow: 0 8px 30px rgba(0,0,0,0.35);
}
.notif-panel.hidden { display: none; }
.notif-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.12));
  font-weight: 700;
}
.notif-panel-header button {
  background: none;
  border: none;
  color: var(--blue, #7c8cff);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.notif-list { display: flex; flex-direction: column; }
.notif-empty { padding: 24px 14px; text-align: center; opacity: 0.6; font-size: 13px; }
.notif-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border, rgba(255,255,255,0.08));
  cursor: pointer;
  text-align: left;
}
.notif-item:hover { background: rgba(124, 140, 255, 0.08); }
.notif-item.unread { background: rgba(124, 140, 255, 0.06); }
.notif-item.unread .notif-item-title::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #e5484d;
  margin-right: 6px;
}
.notif-item-title { font-weight: 700; font-size: 13px; }
.notif-item-subtitle { font-size: 12.5px; opacity: 0.85; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.notif-item-time { font-size: 11px; opacity: 0.5; }
@media (max-width: 720px) {
  .notif-panel { width: calc(100vw - 32px); right: -6px; }
}

#autoReplyPanel.collapsed { display: none; }

/* Araç Yönetimi */
.vehicle-models-list { display: flex; flex-direction: column; gap: 16px; }
.vehicle-model-card {
  border: 1px solid var(--border, rgba(255,255,255,0.15));
  border-radius: 12px;
  padding: 16px;
  background: var(--surface, #1c1f2b);
}
.vehicle-model-card h3 { margin: 0 0 10px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.vehicle-model-card h3 button { font-size: 12px; }
.vehicle-model-section { margin-top: 12px; }
.vehicle-model-section label { display: block; font-weight: 600; margin-bottom: 4px; font-size: 13px; }
.vehicle-model-section textarea { width: 100%; resize: vertical; }
.vehicle-media-grid { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.vehicle-media-thumb { position: relative; width: 84px; height: 84px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border, rgba(255,255,255,0.15)); }
.vehicle-media-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.vehicle-media-thumb .vehicle-media-del {
  position: absolute; top: 2px; right: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: rgba(0,0,0,0.6); color: #fff; border: none; font-size: 12px; cursor: pointer; line-height: 20px; padding: 0;
}
.vehicle-media-thumb .vehicle-media-color-label {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.55); color: #fff; font-size: 10px;
  text-align: center; padding: 2px 0;
}
.vehicle-media-upload-row { display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.vehicle-brochure-row { display: flex; gap: 10px; align-items: center; margin-top: 6px; }

.portal-attachment-file { display: inline-block; margin-bottom: 6px; color: var(--blue, #7c8cff); text-decoration: underline; font-size: 13px; }

/* Mesaj yazma kutusu (textarea) */
#portalReplyText {
  resize: none;
  overflow-y: auto;
  max-height: 160px;
  min-height: 40px;
  line-height: 1.4;
  padding: 10px 12px;
  font-family: inherit;
  font-size: inherit;
}

/* Görüşme listesinde telefon numarası */
.thread-phone { color: var(--muted); font-size: 12px; direction: ltr; unicode-bidi: embed; }

/* Katalog (Hazır Dökümanlar) seçici */
.catalog-option-list { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
.catalog-option {
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--ink);
  font-weight: 600;
  cursor: pointer;
}
.catalog-option:hover:not(:disabled) { background: var(--blue-tint); border-color: var(--blue); }
.catalog-option:disabled { opacity: .5; cursor: not-allowed; }

/* ============================================================
   MOBİL UYGULAMA MODU (telefon genişliğinde)
   ============================================================ */
.bottom-nav { display: none; }
.quick-actions { display: none; }
.portal-back-btn { display: none; }

@media (max-width: 720px) {
  body { padding-bottom: env(safe-area-inset-bottom, 0); }
  .sidebar { display: none !important; }
  main { margin-left: 0 !important; padding: 14px 14px 90px; }

  /* Alt sekme menüsü */
  .bottom-nav {
    display: flex;
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 850;
    background: var(--panel);
    border-top: 1px solid var(--line);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0));
    box-shadow: 0 -4px 18px rgba(0,0,0,.12);
  }
  .bottom-nav .nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    background: none;
    border: none;
    color: var(--muted);
    font-size: 11px;
    font-weight: 600;
    padding: 6px 2px;
    border-radius: 10px;
  }
  .bottom-nav .nav .nav-icon { width: 21px; height: 21px; }
  .bottom-nav .nav.active { color: var(--blue); }
  .bottom-nav .nav-fab {
    position: relative;
    top: -16px;
    flex: 0 0 54px;
    width: 54px; height: 54px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--blue), #7b93ff);
    box-shadow: 0 8px 18px rgba(99,102,241,.45);
    display: grid;
    place-items: center;
  }
  .bottom-nav .nav-fab span { display: none; }

  /* Ana Sayfa - hızlı işlemler */
  .quick-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0; }
  .quick-action {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md);
    padding: 14px 6px; font-size: 11.5px; font-weight: 700; color: var(--ink);
    box-shadow: var(--shadow-sm);
  }
  .quick-action-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--blue-tint, rgba(99,102,241,.12)); color: var(--blue); }
  .quick-action-icon svg { width: 18px; height: 18px; }
  .quick-action.manager-only.hidden { display: none; }

  .metric-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .metric-card { padding: 14px; }

  #pastProgramSection { display: none; }

  /* Web Portal - WhatsApp tarzı liste -> tam ekran sohbet */
  .portal-layout { display: block; height: auto; min-height: 0; }
  .portal-list-col { display: block; border: none; box-shadow: none; padding: 0; background: none; }
  .portal-list-header { display: none; }
  .portal-list { display: block; overflow-y: visible; border: none; box-shadow: none; padding: 0; }
  .portal-thread { padding: 12px 8px; }
  .portal-chat { display: none; }
  .portal-layout.chat-open .portal-list-col { display: none; }
  .portal-layout.chat-open .portal-chat {
    display: grid;
    position: fixed;
    inset: 0;
    z-index: 950;
    border-radius: 0;
    height: 100dvh;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .portal-tabs, #autoReplyPanel, .portal-test-panel { overflow-x: auto; }
  .portal-channel-hub { grid-template-columns: repeat(3, 1fr); gap: 10px; }
  .portal-channel-tile { padding: 14px 4px 10px; }
  .portal-back-btn {
    display: inline-grid; place-items: center;
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--panel-2); border: none; color: var(--ink); font-size: 18px; margin-right: 6px; flex-shrink: 0;
  }

  /* Mesajlaşma ekranı mobilde daha küçük/sık ve okunaklı olsun */
  .portal-chat-head { padding: 10px 12px; }
  .portal-messages { padding: 10px; gap: 8px; }
  .portal-message { width: min(680px, 88%); padding: 8px 12px; }
  .portal-message p { font-size: 13.5px; line-height: 1.4; margin: 0; }
  .portal-message small { font-size: 11px; }
  .message-meta { font-size: 10.5px; margin-top: 4px; }
  .portal-thread { font-size: 12.5px; }
  .portal-thread p { font-size: 12px; }

  /* Görüşmeler / Müşteriler tablosu -> kart görünümü */
  #listView .table-wrap { overflow-x: hidden; }
  #listView .table-wrap table, #listView .table-wrap thead, #listView .table-wrap tbody,
  #listView .table-wrap tr, #listView .table-wrap td { display: block; width: 100%; min-width: 0; }
  #listView .table-wrap thead { display: none; }
  #listView .table-wrap tr {
    background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius-md);
    margin-bottom: 10px; padding: 10px 12px; box-shadow: var(--shadow-sm);
  }
  #listView .table-wrap td {
    display: flex; justify-content: space-between; align-items: center; gap: 10px;
    padding: 7px 0; border-bottom: 1px dashed var(--line); text-align: right; font-size: 13px;
    white-space: normal; word-break: break-word;
  }
  #listView .table-wrap td:last-child { border-bottom: none; }
  #listView .table-wrap td::before { content: attr(data-label); font-weight: 700; color: var(--muted); text-align: left; font-size: 12px; flex-shrink: 0; }
  #listView .table-wrap .filter-row { display: none; }
}

.trade-summary { margin: 4px 0 10px; color: var(--muted); font-size: 13.5px; }

/* Bildirim zili sallanma animasyonu */
@keyframes notif-bell-shake-kf {
  0%, 100% { transform: rotate(0deg); }
  15% { transform: rotate(-14deg); }
  30% { transform: rotate(11deg); }
  45% { transform: rotate(-8deg); }
  60% { transform: rotate(5deg); }
  75% { transform: rotate(-3deg); }
}
.notif-bell-shake { animation: notif-bell-shake-kf .6s ease; transform-origin: 50% 0%; }

.template-preview {
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  padding: 12px;
  font-size: 13.5px;
  margin: 8px 0 12px;
  white-space: pre-wrap;
}

/* Ana Sayfa Web Portal hızlı işlem kırmızı bildirim rozeti */
.quick-action-icon { position: relative; }
.quick-action-badge {
  position: absolute;
  top: -6px; right: -6px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #e5484d;
  color: #fff;
  font-style: normal;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px var(--panel);
}
.quick-action-badge.hidden { display: none; }

/* Mobil - her zaman erişilebilir geri butonu (sol alt köşe, başparmakla erişilebilir) */
.mobile-top-back { display: none; }
@media (max-width: 720px) {
  .mobile-top-back {
    display: inline-grid;
    place-items: center;
    position: fixed;
    left: 14px;
    bottom: calc(78px + env(safe-area-inset-bottom, 0));
    width: 46px; height: 46px;
    border-radius: 50%;
    background: var(--panel);
    border: 1px solid var(--line);
    color: var(--ink);
    font-size: 18px;
    padding: 0;
    z-index: 970;
    box-shadow: var(--shadow-md);
  }
  .mobile-top-back img { width: 22px; height: 22px; object-fit: contain; }
  .mobile-top-back.hidden { display: none; }
  /* Tam ekran sohbet görünümünde kendi "Listeye dön" butonu zaten var, çakışmasın. */
  body.chat-fullscreen .mobile-top-back { display: none; }
}

.loss-row { cursor: pointer; transition: background .12s ease; border-radius: 8px; padding: 4px 6px; }
.loss-row:hover { background: var(--panel-2); }
.loss-reason-detail { margin-top: 16px; }
.loss-reason-detail.hidden { display: none; }


/* Raporlar güncellemesi: son çalışan tasarımın geri kalanına dokunmadan eklenmiştir. */
.reports-summary-grid { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:14px; margin:4px 0 16px; }
.reports-summary-card { display:flex; align-items:center; gap:13px; min-height:88px; padding:14px 16px; border:1px solid #e4e7ec; border-radius:14px; background:#fff; box-shadow:0 5px 16px rgba(16,24,40,.06); cursor:pointer; text-align:left; transition:transform .18s ease,box-shadow .18s ease; }
.reports-summary-card:hover { transform:translateY(-2px); box-shadow:0 9px 22px rgba(16,24,40,.1); }
.reports-summary-icon { display:grid; place-items:center; width:48px; height:48px; flex:0 0 48px; border-radius:14px; color:#fff; font-size:24px; font-weight:800; }
.reports-summary-card.blue { background:linear-gradient(135deg,#f5f9ff,#eef6ff); border-color:#cfe1ff; } .reports-summary-card.blue .reports-summary-icon { background:#3b82f6; }
.reports-summary-card.red { background:linear-gradient(135deg,#fff7f7,#fff0f0); border-color:#ffd4d4; } .reports-summary-card.red .reports-summary-icon { background:#ef4444; }
.reports-summary-card.green { background:linear-gradient(135deg,#f4fffa,#edfff7); border-color:#c8f0df; } .reports-summary-card.green .reports-summary-icon { background:#16a06a; }
.reports-summary-card.purple { background:linear-gradient(135deg,#fbf8ff,#f5efff); border-color:#e5d5ff; } .reports-summary-card.purple .reports-summary-icon { background:#7c3aed; }
.reports-summary-card strong { display:block; color:#344054; font-size:15px; } .reports-summary-card small { display:block; margin-top:5px; color:#667085; font-size:11px; line-height:1.35; }
.reports-action-bar { display:flex; justify-content:flex-end; align-items:center; gap:8px; position:fixed; top:18px; right:76px; margin:0; z-index:901; padding:3px; border-radius:10px; background:rgba(255,255,255,.94); box-shadow:0 2px 10px rgba(16,24,40,.06); }
.reports-action-bar #reportSearch { width:230px; min-height:38px; padding:0 12px; border:1px solid #d0d5dd; border-radius:9px; color:#344054; }
.reports-action-bar button { min-height:38px; } .report-tabs-hidden { display:none !important; }
.reports-filter-bar { display:flex; flex-wrap:wrap; align-items:center; gap:10px; padding:12px 14px; margin-bottom:14px; border:1px solid #eaecf0; border-radius:12px; background:#fff; box-shadow:0 3px 12px rgba(16,24,40,.04); }
.reports-filter-bar .date-filter { display:contents; } .reports-filter-spacer { flex:1; }
.report-status-buttons { display:flex; align-items:center; gap:7px; flex-wrap:wrap; }
.report-status-buttons button { min-height:34px; padding:0 12px; border:1px solid #d0d5dd; border-radius:8px; background:#fff; color:#344054; cursor:pointer; }
.report-status-buttons button.active { background:#635bdb; border-color:#635bdb; color:#fff; }
@media(max-width:900px){.reports-summary-grid{grid-template-columns:repeat(2,minmax(0,1fr));}.reports-action-bar{top:12px;right:66px;}.reports-filter-spacer{display:none;}}
@media(max-width:560px){.reports-summary-grid{grid-template-columns:1fr;}.reports-action-bar{top:10px;right:58px;gap:4px;}.reports-action-bar #reportSearch{width:145px;}.reports-action-bar button{padding:0 8px;font-size:12px;}}

.report-top-filter { min-width:145px; width:auto; min-height:36px; padding:8px 10px; }
.customers-report-toolbar { display:flex; justify-content:flex-start; gap:10px; margin:10px 0; }
.report-update-cell { white-space:nowrap; }
.report-update-cell button { min-height:30px; padding:5px 9px; font-size:12px; }
@media(max-width:900px){.report-top-filter{min-width:125px; flex:1 1 150px;}.reports-filter-bar .date-filter{width:100%;}}

.report-top-filter{min-width:145px;width:auto;min-height:36px;padding:8px 10px}.customers-report-toolbar{display:flex;justify-content:flex-start;gap:10px;margin:10px 0}.report-update-cell{white-space:nowrap}.report-update-cell button{min-height:30px;padding:5px 9px;font-size:12px}@media(max-width:900px){.report-top-filter{min-width:125px;flex:1 1 150px}.reports-filter-bar .date-filter{width:100%}}

.history-loss-reason{margin:-4px 0 14px;padding:10px 12px;border:1px solid #ffd6d6;border-radius:9px;background:#fff5f5;color:#b42318;font-size:13px;font-weight:700}.history-loss-reason.hidden{display:none!important}.meeting-history-action{white-space:nowrap}.customer-activity-button{min-width:66px;white-space:nowrap}.reports-summary-card{min-width:0;padding:11px 12px;gap:9px}.reports-summary-card strong{font-size:13px;white-space:nowrap}.reports-summary-card small{font-size:10px;white-space:nowrap}.reports-summary-icon{width:40px;height:40px;flex-basis:40px;font-size:19px}@media(max-width:900px){.reports-summary-card{padding:9px}.reports-summary-card strong{font-size:12px}.reports-summary-card small{display:none}}

.finance-manager-panel{padding:18px;margin-bottom:20px;border:1px solid var(--line);border-radius:14px;background:var(--panel);box-shadow:var(--shadow-sm)}.finance-manager-panel h2{margin-top:0}.finance-upload-grid{display:grid;grid-template-columns:repeat(2,minmax(220px,1fr));gap:12px;margin-bottom:12px}.finance-upload-grid label{display:grid;gap:6px}.finance-institutions-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:16px}.finance-institution-card{padding:16px;border:1px solid var(--line);border-radius:14px;background:var(--panel);box-shadow:var(--shadow-sm)}.finance-institution-head{display:flex;align-items:center;gap:12px;margin-bottom:14px}.finance-logo{width:76px;height:76px;object-fit:contain;border-radius:10px;border:1px solid var(--line);background:#fff}.finance-institution-head h3{margin:0;font-size:17px}.finance-table-links{display:grid;gap:8px}.finance-table-link{display:block;width:100%;padding:10px 12px;text-align:left;border:1px solid var(--line);border-radius:9px;background:var(--panel-2);color:var(--ink);cursor:pointer}.finance-table-link:hover{border-color:var(--blue);background:var(--blue-tint)}.finance-table-content{overflow:auto;max-height:70vh}.finance-table-content table{width:100%;border-collapse:collapse;font-size:13px}.finance-table-content th,.finance-table-content td{border:1px solid var(--line);padding:7px 9px;text-align:left;white-space:nowrap}.finance-table-content th{background:var(--blue-tint);font-weight:700}.finance-table-modal-card{max-width:min(1100px,94vw)}.finance-table-modal-card .section-head{display:flex;align-items:center;justify-content:space-between}.finance-table-modal-card .section-head h2{margin:0}@media(max-width:700px){.finance-upload-grid{grid-template-columns:1fr}.finance-institutions-list{grid-template-columns:1fr}}

.finance-institution-card{cursor:grab}.finance-institution-card.finance-dragging{opacity:.45;transform:scale(.98)}.finance-institution-card.finance-drag-over{border:2px dashed var(--blue)}.finance-sort-hint{font-size:11px;color:var(--muted);margin:0 0 12px}.finance-table-modal-card{width:100vw;max-width:none;height:100vh;max-height:none;border-radius:0;margin:0}.finance-table-modal-card .finance-table-content{height:calc(100vh - 72px);max-height:none;overflow:hidden}.finance-table-modal-card .section-head{padding:8px 12px;height:56px;box-sizing:border-box}.finance-panel-institutions{display:grid;grid-template-columns:repeat(auto-fill,minmax(180px,1fr));gap:12px}.finance-panel-institution{border:1px solid var(--line);border-radius:12px;padding:10px;background:var(--panel);text-align:center}.finance-panel-institution img{width:86px;height:86px;object-fit:contain;display:block;margin:0 auto 8px;background:#fff;border-radius:8px}.finance-panel-institution strong{display:block;margin-bottom:8px}.finance-panel-tables{display:grid;gap:5px}.finance-panel-tables button{font-size:12px;padding:6px;border:1px solid var(--line);border-radius:7px;background:var(--panel-2);color:var(--ink);cursor:pointer}.customer-finance-options{margin-top:12px}.jspreadsheet{font-size:13px}.jspreadsheet tbody td{min-width:90px}

.finance-institutions-list>.finance-sort-hint{grid-column:1/-1}.finance-institution-card{position:relative}.finance-card-actions{display:flex;gap:6px;margin-top:12px;flex-wrap:wrap}.finance-card-actions button,.finance-table-delete{font-size:11px;padding:5px 8px;border:1px solid var(--line);border-radius:7px;cursor:pointer}.finance-table-delete{color:#b42318;background:#fff5f5;float:right;margin-left:8px}.finance-edit-btn{background:var(--panel-2);color:var(--ink)}.finance-delete-btn{background:#fff5f5;color:#b42318}.finance-table-link{overflow:hidden;text-overflow:ellipsis}.finance-fallback-grid{width:100%;border-collapse:collapse;font-size:13px}.finance-fallback-grid td,.finance-fallback-grid th{border:1px solid var(--line);padding:7px 9px;min-width:90px;white-space:nowrap}.finance-fallback-grid td[contenteditable=true]{background:#fffdf0}.finance-fallback-note{padding:8px 10px;margin-bottom:8px;background:#fff8e6;border:1px solid #f4d58a;border-radius:7px;color:#795500;font-size:12px}

/* Kredi Seçenekleri: banka logoları soldan sağa yatay sırada */
#customerFinanceInstitutions.finance-panel-institutions,.finance-panel-institutions{display:flex;flex-direction:row;flex-wrap:nowrap;overflow-x:auto;align-items:flex-start;justify-content:flex-start;gap:14px;width:100%;padding-bottom:4px;}
.finance-panel-institution{flex:0 0 auto;min-width:180px;}
#customerFinanceInstitutions .finance-panel-institution{flex:0 0 180px;width:180px;max-width:180px;}

.finance-modal-actions{display:flex;gap:8px;align-items:center}.finance-modal-actions a{text-decoration:none;display:inline-flex;align-items:center}.finance-sheet-tabs{display:flex;gap:4px;overflow-x:auto;padding:7px 12px;border-bottom:1px solid var(--line);background:var(--panel-2)}.finance-sheet-tab{border:1px solid var(--line);background:var(--panel);color:var(--ink);border-radius:6px;padding:6px 12px;cursor:pointer;white-space:nowrap}.finance-sheet-tab.active{background:var(--blue);color:#fff;border-color:var(--blue)}

.finance-calc-status{font-size:11px;color:var(--muted);white-space:nowrap}.finance-modal-actions{display:flex;align-items:center;gap:6px;flex-wrap:wrap}.finance-modal-actions .small{white-space:nowrap}@media(max-width:900px){.finance-modal-actions{justify-content:flex-end}.finance-calc-status{display:none}}
/* Unified conversation inbox */
.portal-unified-layout { grid-template-columns: 360px minmax(0, 1fr); height: calc(100vh - 135px); min-height: 520px; }
.portal-unified-layout .portal-list-col { min-width: 0; }
.portal-unified-layout .portal-list-header { justify-content: space-between; }
.portal-unified-layout .portal-list-header .portal-realtime-badge { padding: 5px 8px; font-size: 10px; }
.portal-chat-identity { display: flex; align-items: center; gap: 8px; min-width: 0; }
.portal-chat-identity > div { min-width: 0; }
.portal-chat-identity p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.portal-chat-identity b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.track-customer-btn { background: var(--green, #16a34a); color: #fff; }
.track-customer-btn:disabled { opacity: .55; cursor: not-allowed; }
.portal-customer-modal-card { width: min(440px, calc(100vw - 28px)); }
.portal-customer-modal-form { display: grid; gap: 12px; }
.portal-customer-modal-form .modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.mg-brand-logo { width: 38px; height: 38px; object-fit: contain; flex: 0 0 auto; }
.mg-logo-light { display: none; }
[data-theme="dark"] .mg-logo-dark { display: none; }
[data-theme="dark"] .mg-logo-light { display: block; }
@media (max-width: 820px) {
  .portal-unified-layout { grid-template-columns: 300px minmax(0, 1fr); gap: 8px; }
  .portal-chat-head { padding: 10px; gap: 8px; }
  .portal-chat-actions { gap: 5px; }
  .portal-chat-actions button { padding: 7px 8px; font-size: 11px; }
}
@media (max-width: 720px) {
  .portal-unified-layout { display: block; height: calc(100vh - 110px); min-height: 0; }
  .portal-unified-layout .portal-list-col { height: 100%; }
  .portal-unified-layout .portal-chat { display: none; height: 100%; }
  .portal-unified-layout.chat-open .portal-list-col { display: none; }
  .portal-unified-layout.chat-open .portal-chat { display: grid; }
  .portal-unified-layout .portal-list { padding: 8px; }
  .portal-unified-layout .portal-thread { padding: 9px; }
  .portal-chat-head { align-items: flex-start; }
  .portal-chat-actions { flex-direction: column; align-items: stretch; }
  .portal-chat-actions button { white-space: nowrap; }
}

/* Final mobile portal and branding adjustments */
.mg-brand-logo { display: block !important; width: 64px; height: 64px; object-fit: contain; flex: 0 0 auto; }
.brand .mg-brand-logo { width: 52px; height: 52px; }
.brand.dark .mg-brand-logo { width: 58px; height: 58px; }
.mobile-home-brand { display: none; }
.mobile-home-theme-btn { display: none; }
@media (max-width: 720px) {
  .mobile-home-brand { display: flex; align-items: center; gap: 9px; min-height: 76px; padding: 6px 4px 10px; border-bottom: 1px solid var(--line); }
  .mobile-home-brand .mg-brand-logo { width: 64px; height: 64px; }
  .mobile-home-brand strong { font-size: 16px; color: var(--ink); }
  .home-topbar { display: flex; justify-content: flex-end; align-items: center; }
  .home-title-copy { display: none; }
  .mobile-home-theme-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 50%; background: var(--panel); color: var(--ink); font-size: 19px; padding: 0; }
  #homeMobilePager { touch-action: pan-y; }
  #homeMobilePager > .home-mobile-page { width: 100%; min-width: 100%; max-width: 100%; }
  #homeMobilePager { overflow-x: hidden; }
  .portal-unified-layout.chat-open .portal-chat,
  .portal-unified-layout .portal-chat { grid-template-rows: auto minmax(0, 1fr) auto; min-height: 0; overflow: hidden; }
  .portal-unified-layout.chat-open .portal-messages,
  .portal-unified-layout .portal-messages { min-height: 0; height: auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
  #assistantLauncher { width: 44px; height: 44px; right: 16px; bottom: 76px; font-size: 18px; z-index: 980; }
  #assistantPanel { right: 12px; bottom: 128px; max-height: calc(100vh - 180px); }
}

/* Mobile portal list/chat final layout */
@media (max-width: 720px) {
  .portal-unified-layout { height: 100dvh; min-height: 0; overflow: hidden; }
  .portal-unified-layout:not(.chat-open) { display: flex; flex-direction: column; }
  .portal-unified-layout:not(.chat-open) .portal-list-col { display: flex; flex: 1 1 auto; min-height: 0; height: auto; flex-direction: column; overflow: hidden; }
  .portal-unified-layout:not(.chat-open) .portal-list { display: block; flex: 1 1 auto; min-height: 0; height: auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
  .portal-unified-layout:not(.chat-open) .portal-thread { flex: 0 0 auto; }
  .portal-unified-layout.chat-open { position: fixed; inset: 0; height: 100dvh; min-height: 0; z-index: 940; background: var(--panel); }
  .portal-unified-layout.chat-open .portal-chat { position: absolute; inset: 0; display: grid; width: 100%; height: 100dvh; min-height: 0; padding: 0 0 env(safe-area-inset-bottom, 0); overflow: hidden; grid-template-rows: auto minmax(0, 1fr) auto; }
  .portal-unified-layout.chat-open .portal-chat-head { display: grid; grid-template-columns: 34px minmax(0, 1fr); align-items: start; gap: 6px; padding: 8px 10px 7px; min-height: 0; }
  .portal-unified-layout.chat-open .portal-chat-identity { min-width: 0; grid-column: 2; }
  .portal-unified-layout.chat-open .portal-chat-actions { grid-column: 2; display: flex; flex-direction: row; align-items: center; justify-content: flex-start; gap: 5px; padding-top: 3px; flex-wrap: nowrap; overflow-x: auto; }
  .portal-unified-layout.chat-open .portal-chat-actions button { flex: 0 0 auto; padding: 5px 8px; min-height: 26px; border-radius: 6px; font-size: 10px; line-height: 1.1; white-space: nowrap; }
  .portal-unified-layout.chat-open .portal-messages { min-height: 0; height: auto; overflow-y: auto; overflow-x: hidden; -webkit-overflow-scrolling: touch; touch-action: pan-y; overscroll-behavior: contain; }
  .portal-unified-layout.chat-open .portal-reply { min-height: 58px; max-height: 92px; padding: 8px 10px; padding-bottom: max(8px, env(safe-area-inset-bottom, 0)); }
  body.chat-fullscreen .mobile-bottom-nav, body.chat-fullscreen #mobileBottomNav, body.chat-fullscreen .mobile-shortcuts { display: none !important; }
}

/* Mobile reply must sit above the persistent shortcut bar */
@media (max-width: 720px) {
  .portal-unified-layout.chat-open { bottom: 58px; height: calc(100dvh - 58px); }
  .portal-unified-layout.chat-open .portal-chat { bottom: 0; height: 100%; }
  .portal-unified-layout.chat-open .portal-reply { position: relative; z-index: 5; margin-bottom: 0; }
}

/* Approved compact portal cards */
.portal-thread { grid-template-columns: minmax(0, 1fr) 76px; gap: 3px 6px; padding: 9px 82px 9px 10px; min-height: 68px; }
.portal-thread b, .portal-thread small, .portal-thread p { grid-column: 1; }
.portal-thread b { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-thread .thread-phone, .portal-thread .thread-sales { display: block; font-size: 11px; line-height: 1.25; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.portal-thread .thread-sales { color: var(--ink); opacity: .78; }
.portal-thread .thread-last-date { position: absolute; right: 7px; top: 31px; width: 68px; text-align: center; font-size: 9px; line-height: 1.15; color: var(--muted); white-space: normal; }
.portal-thread .thread-fav-btn { right: 29px; top: 7px; z-index: 2; font-size: 17px; }
.portal-thread .thread-unread { display: none; }

/* WhatsApp Web-inspired conversation panel (general layout, not a brand clone) */
.portal-unified-layout .portal-chat { background: #efeae2; }
.portal-unified-layout .portal-chat-head { background: #f0f2f5; border-bottom-color: #d9dee3; }
.portal-unified-layout .portal-messages { background-color: #efeae2; background-image: radial-gradient(#d7cfc4 1px, transparent 1px); background-size: 22px 22px; padding: 20px 7%; }
.portal-unified-layout .portal-message { position: relative; max-width: 68%; padding: 8px 10px 6px; border-radius: 8px; background: #fff; box-shadow: 0 1px 1px rgba(0,0,0,.12); color: #202c33; }
.portal-unified-layout .portal-message.out { background: #d9fdd3; }
.portal-unified-layout .portal-message p { color: #202c33; }
.portal-unified-layout .portal-message small { color: #667781; }
.portal-unified-layout .portal-reply { background: #f0f2f5; border-top-color: #d9dee3; }
.portal-unified-layout .portal-reply input, .portal-unified-layout .portal-reply textarea { background: #fff; border: 0; border-radius: 8px; }
.portal-unified-layout .portal-reply .send-button, .portal-unified-layout .portal-reply button[type="submit"] { background: #00a884; color: #fff; border-radius: 50%; }
@media (max-width: 720px) {
  .portal-thread { grid-template-columns: minmax(0, 1fr) 62px; padding: 9px 68px 9px 9px; min-height: 66px; }
  .portal-thread .thread-fav-btn { right: 24px; top: 6px; }
  .portal-thread .thread-last-date { right: 3px; width: 58px; top: 29px; font-size: 8px; }
  .portal-unified-layout .portal-messages { padding: 14px 8px; }
  .portal-unified-layout .portal-message { max-width: 84%; }
}

/* Channel logos on portal conversation cards */
.portal-thread { grid-template-columns: 28px minmax(0, 1fr) 76px; padding-left: 8px; padding-right: 82px; }
.portal-thread .thread-channel-logo { grid-column: 1; grid-row: 1 / span 3; align-self: start; margin-top: 1px; }
.thread-channel-logo { width: 23px; height: 23px; border-radius: 7px; display: grid; place-items: center; color: #fff; flex: 0 0 auto; }
.thread-channel-logo svg { width: 17px; height: 17px; display: block; }
.thread-channel-logo.whatsapp { background: #25d366; }
.thread-channel-logo.facebook { background: #1877f2; }
.thread-channel-logo.instagram { background: linear-gradient(135deg, #833ab4, #fd1d1d 55%, #fcb045); }
.thread-channel-logo.other { background: var(--muted); }
.portal-thread b, .portal-thread small { grid-column: 2; }
@media (max-width: 720px) {
  .portal-thread { grid-template-columns: 26px minmax(0, 1fr) 62px; padding-left: 7px; padding-right: 68px; }
  .thread-channel-logo { width: 22px; height: 22px; }
  .thread-channel-logo svg { width: 16px; height: 16px; }
}

/* Hard override: mobile composer is always one horizontal row */
@media (max-width: 720px) {
  body #portalReplyForm.portal-reply {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: stretch !important;
    gap: 5px !important;
    width: 100% !important;
    height: 46px !important;
    min-height: 46px !important;
    max-height: 46px !important;
    padding: 4px 7px !important;
    box-sizing: border-box !important;
    overflow: visible !important;
  }
  body #portalReplyForm.portal-reply > .attach-button {
    position: relative !important;
    inset: auto !important;
    display: flex !important;
    flex: 0 0 30px !important;
    width: 30px !important;
    min-width: 30px !important;
    max-width: 30px !important;
    height: 30px !important;
    min-height: 30px !important;
    margin: 0 !important;
    padding: 0 !important;
    align-items: center !important;
    justify-content: center !important;
    border: 1px solid var(--line) !important;
    border-radius: 50% !important;
    background: var(--panel-2) !important;
    color: var(--ink) !important;
    font-size: 25px !important;
    line-height: 30px !important;
    text-align: center !important;
  }
  body #portalReplyForm.portal-reply > textarea {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    margin: 0 !important;
    padding: 7px 10px !important;
    resize: none !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    line-height: 16px !important;
  }
  body #portalReplyForm.portal-reply > button[type="submit"] {
    position: relative !important;
    inset: auto !important;
    display: block !important;
    flex: 0 0 58px !important;
    width: 58px !important;
    min-width: 58px !important;
    max-width: 58px !important;
    height: 30px !important;
    min-height: 30px !important;
    margin: 0 !important;
    padding: 0 6px !important;
    border-radius: 999px !important;
    line-height: 30px !important;
    white-space: nowrap !important;
  }
  body #portalReplyForm.portal-reply > .attach-menu {
    position: absolute !important;
    left: 7px !important;
    bottom: calc(100% + 5px) !important;
  }
}

/* Final small lift above the mobile bottom navigation */
@media (max-width: 720px) {
  body #portalReplyForm.portal-reply {
    transform: translateY(-4px) !important;
    margin-bottom: 4px !important;
  }
}

/* Growing mobile composer: textarea expands as the message wraps */
@media (max-width: 720px) {
  body #portalReplyForm.portal-reply {
    align-items: flex-end !important;
    height: auto !important;
    min-height: 46px !important;
    max-height: 40vh !important;
    transform: translateY(-10px) !important;
    margin-bottom: 10px !important;
    overflow: visible !important;
  }
  body #portalReplyForm.portal-reply > textarea {
    align-self: flex-end !important;
    height: 30px !important;
    min-height: 30px !important;
    max-height: 40vh !important;
    overflow-y: auto !important;
    line-height: 17px !important;
    padding-top: 7px !important;
    padding-bottom: 6px !important;
  }
  body #portalReplyForm.portal-reply > .attach-button,
  body #portalReplyForm.portal-reply > button[type="submit"] {
    align-self: flex-end !important;
    margin-bottom: 0 !important;
  }
}

/* Final fix: the mobile composer grows with wrapped text; never clip line two */
@media (max-width: 720px) {
  body #portalReplyForm.portal-reply {
    height: auto !important;
    min-height: 46px !important;
    max-height: 42vh !important;
    align-items: flex-end !important;
    transform: translateY(-10px) !important;
    margin-bottom: 10px !important;
    overflow: visible !important;
  }
  body #portalReplyForm.portal-reply > textarea {
    flex: 1 1 auto !important;
    height: 30px;
    min-height: 30px !important;
    max-height: 42vh !important;
    overflow-y: hidden;
    white-space: pre-wrap !important;
    overflow-wrap: anywhere !important;
    resize: none !important;
  }
  body #portalReplyForm.portal-reply > .attach-button,
  body #portalReplyForm.portal-reply > button[type="submit"] {
    flex: 0 0 auto !important;
    align-self: flex-end !important;
    margin-bottom: 0 !important;
  }
}

/* Lost customers: keep history action visible in responsive report tables */
.customer-report-actions { white-space: nowrap; }
@media (max-width: 720px) {
  .customer-report-actions { display: flex !important; min-width: 130px; padding: 8px !important; }
  .customer-report-actions .history-action { display: inline-flex !important; visibility: visible !important; }
}
