/* ==========================================================================
   Shine Vision — Admin Dashboard
   ========================================================================== */

html, body.admin-body {
  background: var(--bg);
  height: 100%;
}
body.admin-body {
  overflow: hidden;
}

/* ---------------------------------- Login screen ---------------------------------- */
.login-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: var(--sp-6);
  position: relative;
  overflow-y: auto;
  background: var(--grad-midnight);
}
.login-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(50% 45% at 12% 8%, rgba(111, 208, 255, 0.28), transparent 60%),
    radial-gradient(45% 45% at 92% 92%, rgba(0, 112, 201, 0.35), transparent 60%);
}
.login-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px), linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 56px 56px;
  mask-image: radial-gradient(60% 60% at 50% 40%, black, transparent 80%);
  -webkit-mask-image: radial-gradient(60% 60% at 50% 40%, black, transparent 80%);
}
.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 420px;
  background: rgba(255, 255, 255, 0.96);
  border-radius: var(--radius-xl);
  padding: var(--sp-10) var(--sp-8);
  box-shadow: var(--shadow-lg);
  animation: login-in 0.7s var(--ease-out);
}
@keyframes login-in {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.login-card.is-shaking { animation: login-shake 0.45s var(--ease-in-out); }
@keyframes login-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-10px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(4px); }
}
@media (prefers-reduced-motion: reduce) {
  .login-card.is-shaking { animation: none; }
}
.login-logo {
  display: flex;
  justify-content: center;
  margin-bottom: var(--sp-6);
}
.login-logo img { height: 56px; }
.login-card h1 {
  font-size: var(--fs-xl);
  text-align: center;
  margin-bottom: var(--sp-2);
}
.login-card .sub {
  text-align: center;
  color: var(--ink-500);
  font-size: var(--fs-sm);
  margin-bottom: var(--sp-8);
}
.login-form { display: flex; flex-direction: column; gap: var(--sp-5); }
.login-row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: var(--fs-xs);
  color: var(--ink-500);
}
.login-row-between label { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.login-error {
  display: none;
  align-items: center;
  gap: var(--sp-2);
  background: var(--danger-bg);
  color: #c72645;
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.login-error.is-visible { display: flex; }
.login-error svg { width: 16px; height: 16px; flex-shrink: 0; }
.login-hint {
  margin-top: var(--sp-6);
  text-align: center;
  font-size: var(--fs-xs);
  color: var(--ink-400);
  background: var(--bg-alt);
  border-radius: var(--radius-sm);
  padding: var(--sp-3);
}
.login-hint code {
  background: var(--white);
  border: 1px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--primary-700);
  font-weight: 700;
}
.login-back {
  display: block;
  text-align: center;
  margin-top: var(--sp-6);
  font-size: var(--fs-xs);
  color: rgba(255, 255, 255, 0.7);
  position: relative;
  z-index: 1;
}
.login-back:hover { color: #fff; }

/* ---------------------------------- App shell ---------------------------------- */
.admin-app {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--midnight-900);
  color: rgba(255, 255, 255, 0.72);
  display: flex;
  flex-direction: column;
  padding: var(--sp-6) var(--sp-5);
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-2) var(--sp-8);
}
.sidebar-brand .badge {
  background: #fff;
  border-radius: 12px;
  padding: 6px 8px;
  display: inline-flex;
}
.sidebar-brand .badge img { height: 26px; }
.sidebar-brand span {
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: var(--fs-sm);
  line-height: 1.2;
}
.sidebar-brand small { display: block; color: var(--cyan-300); font-weight: 600; font-size: 10px; letter-spacing: 0.08em; }

.sidebar-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.sidebar-nav button {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 0.85rem var(--sp-4);
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 600;
  color: rgba(255, 255, 255, 0.62);
  text-align: left;
  width: 100%;
  transition: background var(--dur-fast) var(--ease-out), color var(--dur-fast) var(--ease-out);
}
.sidebar-nav button svg { width: 19px; height: 19px; flex-shrink: 0; }
.sidebar-nav button:hover { background: rgba(255, 255, 255, 0.06); color: #fff; }
.sidebar-nav button.is-active {
  background: linear-gradient(120deg, rgba(0, 112, 201, 0.35), rgba(63, 193, 240, 0.18));
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.sidebar-nav .badge-count {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.sidebar-nav button.is-active .badge-count { background: var(--primary-500); }

.sidebar-foot {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--sp-5);
  margin-top: var(--sp-6);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}
.sidebar-user-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: var(--grad-brand);
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-weight: 700;
  color: #fff;
  font-size: var(--fs-xs);
  flex-shrink: 0;
}
.sidebar-foot-info { flex: 1; min-width: 0; }
.sidebar-foot-info strong { display: block; font-size: var(--fs-xs); color: #fff; }
.sidebar-foot-info span { font-size: 11px; color: var(--ink-400); }
.sidebar-foot button {
  width: 34px; height: 34px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: rgba(255, 255, 255, 0.6);
  flex-shrink: 0;
  transition: all var(--dur-fast) var(--ease-out);
}
.sidebar-foot button:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.sidebar-foot button svg { width: 18px; height: 18px; }

.sidebar-close { display: none; }

/* ---- Main column ---- */
.admin-main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.admin-topbar {
  display: flex;
  align-items: center;
  gap: var(--sp-5);
  padding: var(--sp-5) var(--sp-8);
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(14px);
  flex-shrink: 0;
}
.topbar-menu-btn { display: none; }
.topbar-title { flex-shrink: 0; }
.topbar-title h1 {
  font-size: var(--fs-lg);
}
.topbar-title p { font-size: var(--fs-xs); color: var(--ink-500); margin-top: 2px; }

.topbar-search {
  flex: 1;
  max-width: 340px;
  position: relative;
  display: none;
}
.topbar-search svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--ink-400);
}
.topbar-search input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-alt);
  font-size: var(--fs-sm);
}
.topbar-search input:focus { background: #fff; border-color: var(--primary-400); outline: none; }

.period-filter {
  display: flex;
  background: var(--bg-alt);
  border-radius: var(--radius-full);
  padding: 4px;
  margin-left: auto;
  flex-shrink: 0;
}
.period-filter button {
  padding: 0.5rem 0.95rem;
  border-radius: var(--radius-full);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-500);
  transition: all var(--dur-fast) var(--ease-out);
  white-space: nowrap;
}
.period-filter button.is-active {
  background: var(--white);
  color: var(--primary-700);
  box-shadow: var(--shadow-xs);
}

.topbar-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--grad-brand);
  color: #fff;
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: var(--fs-xs);
  flex-shrink: 0;
}

.admin-content {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-8);
}

.admin-view { display: none; animation: view-in 0.45s var(--ease-out); }
.admin-view.is-active { display: block; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
  flex-wrap: wrap;
}
.view-head h2 { font-size: var(--fs-xl); }
.view-head p { color: var(--ink-500); font-size: var(--fs-sm); margin-top: 4px; }
.view-actions { display: flex; gap: var(--sp-3); flex-wrap: wrap; }

/* ---------------------------------- KPI cards ---------------------------------- */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-8);
}
.kpi-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
  position: relative;
  overflow: hidden;
  transition: transform var(--dur-base) var(--ease-out), box-shadow var(--dur-base) var(--ease-out);
}
.kpi-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.kpi-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}
.kpi-ic {
  width: 44px; height: 44px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: var(--grad-brand-soft);
  color: var(--primary-600);
}
.kpi-ic svg { width: 21px; height: 21px; }
.kpi-trend {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--radius-full);
}
.kpi-trend svg { width: 12px; height: 12px; }
.kpi-trend.up { background: var(--success-bg); color: #0a9a67; }
.kpi-trend.down { background: var(--danger-bg); color: #c72645; }
.kpi-trend.flat { background: var(--ink-100); color: var(--ink-500); }
.kpi-value {
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 800;
  color: var(--ink-900);
  letter-spacing: -0.02em;
  line-height: 1;
}
.kpi-label {
  font-size: var(--fs-xs);
  font-weight: 600;
  color: var(--ink-500);
  margin-top: var(--sp-2);
}
.kpi-sub {
  font-size: 11px;
  color: var(--ink-400);
  margin-top: var(--sp-2);
}

/* ---------------------------------- Charts row ---------------------------------- */
.charts-row {
  display: grid;
  grid-template-columns: 1.7fr 1fr;
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.chart-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.chart-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}
.chart-card-head h3 { font-size: var(--fs-md); }
.chart-legend-dots { display: flex; gap: var(--sp-4); font-size: var(--fs-xs); color: var(--ink-500); }
.chart-legend-dots span { display: flex; align-items: center; gap: 6px; }
.chart-legend-dots i { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.chart-canvas-wrap { position: relative; height: 280px; }
.chart-canvas-wrap.donut { height: 240px; }

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.donut-center strong { font-family: var(--font-display); font-size: var(--fs-xl); color: var(--ink-900); }
.donut-center span { font-size: var(--fs-xs); color: var(--ink-500); }

.status-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}
.status-legend .row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-size: var(--fs-xs);
}
.status-legend i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-legend .name { color: var(--ink-600); flex: 1; }
.status-legend .count { font-weight: 700; color: var(--ink-900); }

.bottom-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--sp-5);
}

/* Recent activity list */
.activity-list { display: flex; flex-direction: column; }
.activity-item {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) 0;
  border-bottom: 1px solid var(--border);
}
.activity-item:last-child { border-bottom: none; }
.activity-ic {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--info-bg);
  color: var(--primary-600);
  flex-shrink: 0;
}
.activity-ic svg { width: 17px; height: 17px; }
.activity-body { flex: 1; min-width: 0; }
.activity-body strong { display: block; font-size: var(--fs-sm); color: var(--ink-800); }
.activity-body span { font-size: 11px; color: var(--ink-500); }
.activity-meta { text-align: right; flex-shrink: 0; }
.activity-meta strong { display: block; font-size: var(--fs-sm); color: var(--ink-900); }
.activity-meta span { font-size: 11px; color: var(--ink-400); }

/* ---------------------------------- Toolbar (CRM / Orders) ---------------------------------- */
.data-toolbar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
}
.data-search {
  position: relative;
  flex: 1;
  min-width: 200px;
}
.data-search svg { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-400); }
.data-search input {
  width: 100%;
  padding: 0.7rem 1rem 0.7rem 2.4rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: #fff;
  font-size: var(--fs-sm);
}
.filter-chip-row { display: flex; gap: var(--sp-2); flex-wrap: wrap; }
.filter-chip {
  padding: 0.55rem 1rem;
  border-radius: var(--radius-full);
  border: 1.5px solid var(--border-strong);
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-600);
  background: #fff;
  transition: all var(--dur-fast) var(--ease-out);
}
.filter-chip.is-active {
  background: var(--grad-brand);
  border-color: transparent;
  color: #fff;
}

/* ---------------------------------- Tables ---------------------------------- */
.table-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--ink-500);
  font-weight: 700;
  padding: var(--sp-4) var(--sp-5);
  background: var(--bg-alt);
  white-space: nowrap;
}
.data-table td {
  padding: var(--sp-4) var(--sp-5);
  font-size: var(--fs-sm);
  color: var(--ink-700);
  border-top: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr { transition: background var(--dur-fast) var(--ease-out); }
.data-table tbody tr:hover { background: var(--bg-alt); }
.cell-primary { font-weight: 700; color: var(--ink-900); }
.cell-sub { font-size: 11px; color: var(--ink-500); margin-top: 2px; }
.cell-avatar-row { display: flex; align-items: center; gap: var(--sp-3); }
.mini-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--grad-brand-soft);
  color: var(--primary-700);
  display: grid;
  place-items: center;
  font-weight: 700;
  font-size: 11px;
  flex-shrink: 0;
}
.row-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; }
.row-actions button {
  width: 32px; height: 32px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: var(--ink-500);
  border: 1px solid var(--border);
  transition: all var(--dur-fast) var(--ease-out);
}
.row-actions button svg { width: 15px; height: 15px; }
.row-actions button:hover { background: var(--primary-600); color: #fff; border-color: var(--primary-600); }
.row-actions button.danger:hover { background: var(--danger); border-color: var(--danger); }

.status-select {
  appearance: none;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.4rem 2rem 0.4rem 0.9rem;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  background-repeat: no-repeat;
  background-position: right 0.7rem center;
  background-size: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23647392' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
}

.table-empty {
  text-align: center;
  padding: var(--sp-16) var(--sp-6);
  color: var(--ink-400);
}
.table-empty svg { width: 40px; height: 40px; margin: 0 auto var(--sp-4); opacity: 0.5; }

.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--ink-500);
}

/* ---------------------------------- Calendar (admin) ---------------------------------- */
.admin-calendar-wrap {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: var(--sp-5);
  align-items: start;
}
.admin-cal-card { padding: var(--sp-6); }
/* Muss exakt dieselben Spalten/Abstände wie .admin-cal-grid darunter haben,
   sonst stehen die Wochentags-Kürzel nicht über den passenden Datumszahlen.
   admin.html lädt css/public.css bewusst nicht mit (siehe <link>-Liste im
   <head>), daher hier eine eigene, zu .admin-cal-grid passende Definition —
   nicht die gleichnamige Regel aus public.css, die für admin.html nie griff. */
.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.calendar-weekdays span {
  text-align: center;
  font-size: var(--fs-xs);
  font-weight: 700;
  color: var(--ink-400);
}
.admin-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}
.admin-cal-day {
  min-height: 84px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all var(--dur-fast) var(--ease-out);
}
.admin-cal-day:hover { border-color: var(--primary-400); }
.admin-cal-day.is-empty { visibility: hidden; }
.admin-cal-day.is-today { border-color: var(--primary-500); box-shadow: 0 0 0 1px var(--primary-500); }
.admin-cal-day.is-selected { background: var(--info-bg); border-color: var(--primary-500); }
.admin-cal-day .num { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-700); }
.admin-cal-dots { display: flex; flex-wrap: wrap; gap: 3px; margin-top: auto; }
.admin-cal-dots i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }

.agenda-card { padding: var(--sp-6); max-height: 640px; overflow-y: auto; }
.agenda-card h3 { font-size: var(--fs-md); margin-bottom: var(--sp-1); }
.agenda-card .date-sub { font-size: var(--fs-xs); color: var(--ink-500); margin-bottom: var(--sp-5); }
.agenda-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: var(--sp-4);
  margin-bottom: var(--sp-3);
}
.agenda-item-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: var(--sp-2); }
.agenda-item-head strong { font-size: var(--fs-sm); }
.agenda-item p { font-size: var(--fs-xs); color: var(--ink-500); margin-bottom: var(--sp-1); }

/* ---------------------------------- Finance ---------------------------------- */
.finance-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--sp-5);
  margin-bottom: var(--sp-5);
}
.finance-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--sp-6);
}
.finance-card .label { font-size: var(--fs-xs); font-weight: 700; color: var(--ink-500); margin-bottom: var(--sp-3); }
.finance-card .value { font-family: var(--font-display); font-size: var(--fs-2xl); font-weight: 800; }
.finance-card.rev .value { color: var(--primary-700); }
.finance-card.cost .value { color: var(--warning); }
.finance-card.profit .value { color: var(--success); }

/* ---------------------------------- Kundenchat ---------------------------------- */
.chat-admin-wrap {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: var(--sp-5);
  align-items: start;
  height: calc(100vh - 260px);
  min-height: 480px;
}
.chat-conv-list-card, .chat-thread-card { height: 100%; display: flex; flex-direction: column; overflow: hidden; }

.chat-conv-search { position: relative; padding: var(--sp-4); border-bottom: 1px solid var(--border); flex-shrink: 0; }
.chat-conv-search svg { position: absolute; left: calc(var(--sp-4) + 14px); top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--ink-400); }
.chat-conv-search input {
  width: 100%;
  padding: 0.65rem 1rem 0.65rem 2.4rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border-strong);
  background: var(--bg-alt);
  font-size: var(--fs-sm);
}

.chat-conv-list { flex: 1; overflow-y: auto; }
.chat-conv-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  padding: var(--sp-4);
  border-bottom: 1px solid var(--border);
  text-align: left;
  transition: background var(--dur-fast) var(--ease-out);
  position: relative;
}
.chat-conv-item:hover { background: var(--bg-alt); }
.chat-conv-item.is-active { background: var(--info-bg); }
.chat-conv-item .mini-avatar { flex-shrink: 0; }
.chat-conv-item-body { flex: 1; min-width: 0; }
.chat-conv-item-body .name-row { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); }
.chat-conv-item-body strong { font-size: var(--fs-sm); color: var(--ink-900); }
.chat-conv-item-body time { font-size: 10px; color: var(--ink-400); flex-shrink: 0; }
.chat-conv-item-body p { font-size: var(--fs-xs); color: var(--ink-500); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-item.has-unread p, .chat-conv-item.has-unread strong { color: var(--ink-900); font-weight: 700; }
.chat-conv-unread-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary-500); flex-shrink: 0; }
.chat-conv-source-pill { font-size: 10px; font-weight: 700; color: var(--primary-600); background: var(--info-bg); padding: 1px 7px; border-radius: var(--radius-full); flex-shrink: 0; }

.chat-thread-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--sp-3);
  color: var(--ink-400);
  font-size: var(--fs-sm);
  padding: var(--sp-8);
  text-align: center;
}
.chat-thread-empty svg { width: 42px; height: 42px; opacity: 0.5; }

.chat-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.chat-thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.chat-thread-head h4 { font-size: var(--fs-sm); }
.chat-thread-head span { font-size: var(--fs-xs); color: var(--ink-500); }
.chat-thread-head-actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; }

.chat-thread-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.chat-msg-row { display: flex; }
.chat-msg-row.mine { justify-content: flex-end; }
.chat-msg-row.system { justify-content: center; }
.chat-bubble {
  max-width: 70%;
  background: var(--bg-alt);
  color: var(--ink-800);
  padding: 0.65rem 0.9rem;
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
  font-size: var(--fs-sm);
  line-height: 1.45;
  white-space: pre-line;
}
.chat-msg-row.mine .chat-bubble {
  background: var(--grad-brand-btn);
  color: #fff;
  border-bottom-left-radius: var(--radius-md);
  border-bottom-right-radius: 4px;
}
.chat-bubble time { display: block; font-size: 10px; opacity: 0.65; margin-top: 4px; text-align: right; }
.chat-bubble.system { background: var(--ink-100); color: var(--ink-600); font-size: var(--fs-xs); border-radius: var(--radius-full); padding: 0.4rem 0.9rem; max-width: 90%; text-align: center; white-space: normal; }
.chat-bubble.offer { background: var(--info-bg); border: 1.5px solid rgba(0, 112, 201, 0.25); color: var(--primary-700); }
.chat-offer-label { font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.06em; }
.chat-bubble.offer p { margin-top: 4px; color: var(--ink-700); }

.chat-offer-panel {
  margin: 0 var(--sp-5) var(--sp-4);
  padding: var(--sp-4);
  border-radius: var(--radius-md);
  background: var(--bg-alt);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.chat-offer-panel .row { display: flex; gap: var(--sp-2); align-items: center; flex-wrap: wrap; }
.chat-offer-panel .row input { flex-shrink: 0; width: 110px; }
.chat-offer-panel input, .chat-offer-panel textarea {
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.8rem;
  font-size: var(--fs-sm);
  background: #fff;
}
.chat-offer-panel > textarea { resize: none; min-height: 40px; width: 100%; }
.chat-offer-panel > button { width: 100%; }
.chat-offer-pending {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  flex-wrap: wrap;
}
.chat-offer-pending strong { color: var(--primary-700); }
.chat-offer-pending span { display: block; font-size: var(--fs-xs); color: var(--ink-500); }
.chat-order-status { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); flex-wrap: wrap; }

.chat-input-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-row input {
  flex: 1;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  padding: 0.7rem 1.1rem;
  font-size: var(--fs-sm);
}
.chat-input-row input:focus { outline: none; border-color: var(--primary-400); }
.chat-input-row button {
  width: 42px; height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--grad-brand-btn);
  color: #fff;
  flex-shrink: 0;
  transition: transform var(--dur-fast) var(--ease-out);
}
.chat-input-row button:hover { transform: scale(1.06); }
.chat-input-row button svg { width: 17px; height: 17px; }

@media (max-width: 980px) {
  .chat-admin-wrap { grid-template-columns: 1fr; height: auto; }
  .chat-conv-list-card { height: 320px; }
  .chat-thread-card { height: 560px; }
}

/* ---------------------------------- Modal ---------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(6, 20, 41, 0.55);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-5);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-base) var(--ease-out);
}
.modal-overlay.is-open { opacity: 1; pointer-events: auto; }
.modal-box {
  background: #fff;
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 460px;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  transform: translateY(18px) scale(0.97);
  transition: transform var(--dur-base) var(--ease-out);
}
.modal-overlay.is-open .modal-box { transform: translateY(0) scale(1); }
.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-6) var(--sp-6) 0;
}
.modal-head h3 { font-size: var(--fs-md); }
.modal-head button {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--ink-500);
}
.modal-head button:hover { background: var(--bg-alt); }
.modal-body { padding: var(--sp-6); display: flex; flex-direction: column; gap: var(--sp-4); }
.modal-foot { display: flex; gap: var(--sp-3); padding: 0 var(--sp-6) var(--sp-6); }
.modal-foot .btn { flex: 1; }
.modal-danger-icon {
  width: 56px; height: 56px;
  border-radius: 50%;
  background: var(--danger-bg);
  color: var(--danger);
  display: grid;
  place-items: center;
  margin: 0 auto;
}
.modal-danger-icon svg { width: 26px; height: 26px; }

/* ---------------------------------- Toasts ---------------------------------- */
.toast-stack {
  position: fixed;
  bottom: var(--sp-6);
  right: var(--sp-6);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  background: var(--midnight-900);
  color: #fff;
  padding: var(--sp-4) var(--sp-5);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-sm);
  font-weight: 600;
  transform: translateX(120%);
  transition: transform var(--dur-base) var(--ease-out);
  min-width: 260px;
}
.toast.is-visible { transform: translateX(0); }
.toast .ic { width: 22px; height: 22px; color: var(--success); flex-shrink: 0; }
.toast .ic svg { width: 100%; height: 100%; }

/* ---------------------------------- Mobile overlay for sidebar ---------------------------------- */
.sidebar-scrim {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(6, 20, 41, 0.5);
  z-index: 149;
}

/* ---------------------------------- Responsive ---------------------------------- */
@media (max-width: 1180px) {
  .kpi-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-row { grid-template-columns: 1fr; }
  .bottom-row { grid-template-columns: 1fr; }
  .admin-calendar-wrap { grid-template-columns: 1fr; }
  .finance-grid { grid-template-columns: 1fr; }
}

@media (max-width: 980px) {
  .admin-app { grid-template-columns: 84px 1fr; }
  .sidebar { padding-inline: var(--sp-3); align-items: center; }
  .sidebar-brand { justify-content: center; padding-inline: 0; }
  .sidebar-brand span, .sidebar-brand small { display: none; }
  .sidebar-nav button span:not(.badge-count) { display: none; }
  .sidebar-nav button { justify-content: center; padding: 0.85rem; }
  .sidebar-nav button .badge-count { position: absolute; top: 4px; right: 4px; margin: 0; }
  .sidebar-nav button { position: relative; }
  .sidebar-foot-info { display: none; }
  .sidebar-foot { justify-content: center; }
  .topbar-search { display: none; }
}

@media (max-width: 760px) {
  .admin-app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    width: 260px;
    z-index: 150;
    transform: translateX(-100%);
    transition: transform var(--dur-slow) var(--ease-out);
    align-items: stretch;
  }
  .sidebar.is-open { transform: translateX(0); }
  .sidebar-scrim.is-open { display: block; }
  .sidebar-brand { justify-content: space-between; padding-inline: var(--sp-2); }
  .sidebar-brand span, .sidebar-brand small { display: block; }
  .sidebar-nav button { justify-content: flex-start; padding: 0.85rem var(--sp-4); }
  .sidebar-nav button span:not(.badge-count) { display: inline; }
  .sidebar-nav button .badge-count { position: static; margin-left: auto; }
  .sidebar-foot-info { display: block; }
  .sidebar-close { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; color: #fff; }
  .sidebar-close:hover { background: rgba(255,255,255,0.1); }

  .topbar-menu-btn { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border); flex-shrink: 0; }
  .topbar-menu-btn svg { width: 20px; height: 20px; }
  .admin-topbar { padding: var(--sp-4); gap: var(--sp-3); }
  .topbar-title h1 { font-size: var(--fs-md); }
  .topbar-title p { display: none; }
  .period-filter { order: 4; width: 100%; margin-left: 0; }
  .admin-content { padding: var(--sp-4); }

  .kpi-grid { grid-template-columns: 1fr 1fr; gap: var(--sp-3); }
  .kpi-value { font-size: var(--fs-lg); }

  /* Table -> Card view */
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-3);
    padding: var(--sp-2) var(--sp-4);
    background: #fff;
  }
  .data-table td {
    border-top: none;
    border-bottom: 1px dashed var(--border);
    padding: var(--sp-3) 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    text-align: right;
  }
  .data-table td:last-child { border-bottom: none; }
  .data-table td::before {
    content: attr(data-label);
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--ink-400);
    text-align: left;
  }
  .data-table .cell-avatar-row { flex-direction: row-reverse; }
  .row-actions { justify-content: flex-end; }

  .calendar-weekdays { gap: 4px; }
  .admin-cal-grid { gap: 4px; }
  .admin-cal-day { min-height: 56px; }
  .admin-cal-day .num { font-size: 11px; }
}

@media (max-width: 480px) {
  .kpi-grid { grid-template-columns: 1fr; }
  .finance-grid { grid-template-columns: 1fr; }
}
