/* CSA Admin — dashboard styles (matches site design tokens) */

:root {
  --bg-0: #0a0a0f;
  --bg-1: #111118;
  --bg-2: #16161f;
  --bg-3: #1d1d28;
  --border: rgba(255,255,255,0.08);
  --border-hover: rgba(110,160,184,0.3);
  --text: #f0f2f5;
  --text-dim: #a0a8b4;
  --text-muted: #6b7280;
  --accent: #6ea0b8;
  --accent-light: #8fbdd4;
  --accent-bright: #a3d5e8;
  --danger: #e06d6d;
  --success: #7fc492;
  --warning: #e4b15e;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 10px 40px rgba(0,0,0,0.5);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-0);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, textarea, select { font-family: inherit; }
a { color: var(--accent-light); }

/* ============ LOGIN ============ */
.login-screen {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(800px 600px at 30% 40%, rgba(110,160,184,0.12), transparent 60%),
    radial-gradient(700px 500px at 70% 70%, rgba(163,213,232,0.06), transparent 70%),
    var(--bg-0);
  z-index: 100;
}
.login-card {
  width: min(400px, 92vw);
  padding: 48px 40px;
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.login-card h1 {
  font-size: 28px; font-weight: 600; margin-bottom: 6px;
  background: linear-gradient(135deg, var(--accent-bright), var(--accent));
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 32px; }
.login-card label {
  display: block; margin-bottom: 20px;
  font-size: 12px; text-transform: uppercase; color: var(--text-dim); letter-spacing: 0.5px;
}
.login-card input {
  display: block; width: 100%; margin-top: 8px;
  padding: 12px 14px; font-size: 15px;
  background: var(--bg-1); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none;
}
.login-card input:focus { border-color: var(--accent); }
.login-card button[type="submit"] {
  width: 100%; padding: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #0a1720; font-weight: 600; font-size: 15px;
  border-radius: var(--radius-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.login-card button[type="submit"]:hover { transform: translateY(-1px); box-shadow: 0 8px 20px rgba(110,160,184,0.3); }
.login-card button[type="submit"]:disabled { opacity: 0.6; cursor: wait; }
.error {
  margin-top: 16px; padding: 10px 14px;
  background: rgba(224,109,109,0.1); border: 1px solid rgba(224,109,109,0.3);
  border-radius: var(--radius-sm); color: var(--danger); font-size: 13px;
}

/* ============================================================
   APP SHELL — CRM-matched layout
   ============================================================ */
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  overflow: hidden;
}

/* Top bar: identical to CRM .crm-topbar */
/* crm-topbar, crm-topbar-brand, crm-tag, crm-search-wrap,
   crm-search-input, crm-search-icon, crm-search-results,
   crm-topbar-user, crm-role-badge — all defined in crm.css import below */

/* Override: push app shell below fixed site header */
.app { height: calc(100vh - 80px); margin-top: 80px; }

.app-body { display: flex; flex: 1; overflow: hidden; }

/* Badge inside sidebar sub-links */
.nav-badge {
  min-width: 20px; padding: 2px 7px; margin-left: 6px;
  font-size: 11px; font-weight: 700; line-height: 1;
  background: #e06d6d; color: #fff;
  border-radius: 20px; text-align: center;
  display: inline-block;
}

/* ============ CONTENT ============ */
.content {
  flex: 1; overflow-y: auto;
  padding: 32px 40px;
}
.content-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.content-header h1 { font-size: 24px; font-weight: 600; }
.content-header .subtitle { color: var(--text-dim); font-size: 13px; margin-top: 4px; }

/* ============ FILTER BAR (shared across list pages) ============ */
.filter-bar {
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
}
.filter-bar-inner {
  display: flex; flex-wrap: wrap; gap: 14px 20px;
  align-items: center; justify-content: center;
}
.filter-bar label {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); font-weight: 600;
}
.filter-bar select {
  padding: 8px 12px; font-size: 13px;
  background: var(--bg-2); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  text-transform: none; letter-spacing: normal; font-weight: 400;
}
.filter-bar select:focus { border-color: var(--accent); outline: none; }
.filter-bar button { margin-left: 6px; font-size: 12px; }

/* ============ BUTTONS ============ */
.btn-primary {
  padding: 9px 18px; font-size: 13px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #0a1720; border-radius: var(--radius-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(110,160,184,0.3); }
.btn-ghost {
  padding: 8px 14px; font-size: 13px;
  color: var(--text-dim); border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: transparent;
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-hover); }
.btn-danger {
  padding: 8px 14px; font-size: 13px; color: var(--danger);
  border: 1px solid rgba(224,109,109,0.3); border-radius: var(--radius-sm);
  background: transparent;
}
.btn-danger:hover { background: rgba(224,109,109,0.1); }
.btn-icon {
  width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim); border-radius: var(--radius-sm); font-size: 16px;
}
.btn-icon:hover { background: var(--bg-2); color: var(--text); }

/* ============ DATA TABLE ============ */
.data-table {
  width: 100%; border-collapse: collapse;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden;
}
.data-table th {
  text-align: left; padding: 12px 16px;
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-muted); font-weight: 600;
  background: var(--bg-1); border-bottom: 1px solid var(--border);
}
.data-table td {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  font-size: 13.5px; vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: rgba(110,160,184,0.04); }
.data-table .cell-actions { text-align: right; white-space: nowrap; }

/* ── Users table sort + drag ── */
.data-table th[draggable] { cursor: grab; user-select: none; }
.data-table th[draggable]:active { cursor: grabbing; }
.data-table th .th-inner { display: flex; align-items: center; gap: 5px; }
.data-table th .drag-handle { opacity: 0.2; font-size: 13px; cursor: grab; flex-shrink: 0; }
.data-table th:hover .drag-handle { opacity: 0.6; }
.data-table th.dragging-over { background: rgba(110,160,184,0.12) !important; }
.data-table th.th-sorted { background: rgba(110,160,184,0.08) !important; }
.data-table th.th-sorted .u-col-label { color: var(--accent-bright, #6eb8d0); }
.data-table .cell-img {
  width: 60px; height: 40px;
  background: var(--bg-1); border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  overflow: hidden;
}
.data-table .cell-img img { max-width: 100%; max-height: 100%; object-fit: contain; }

.empty-state {
  padding: 64px 24px; text-align: center;
  border: 1px dashed var(--border); border-radius: var(--radius);
  color: var(--text-muted);
}

/* ============ FORM ============ */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid .full { grid-column: 1 / -1; }
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-dim); font-weight: 600;
}
.form-field input[type="text"],
.form-field input[type="email"],
.form-field input[type="tel"],
.form-field input[type="url"],
.form-field input[type="number"],
.form-field input[type="date"],
.form-field input[type="datetime-local"],
.form-field select,
.form-field textarea {
  padding: 10px 12px; font-size: 14px;
  background: var(--bg-1); color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  outline: none;
}
.form-field textarea { resize: vertical; min-height: 80px; font-family: inherit; }
.textarea-toolbar { display: flex; gap: 8px; margin-bottom: 6px; }
.textarea-toolbar .btn-ghost { font-size: 12px; padding: 6px 10px; }
.form-field input:focus, .form-field textarea:focus, .form-field select:focus {
  border-color: var(--accent);
}
.form-field .help { font-size: 11px; color: var(--text-muted); }

/* Image picker */
.image-picker {
  display: flex; gap: 12px; align-items: stretch;
  padding: 10px; background: var(--bg-1); border: 1px dashed var(--border);
  border-radius: var(--radius-sm); min-height: 80px;
}
.image-picker.dragging { border-color: var(--accent); background: rgba(110,160,184,0.08); }
.image-picker .preview {
  width: 80px; height: 80px; flex-shrink: 0;
  background: var(--bg-2); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; color: var(--text-muted); font-size: 11px;
}
.image-picker .preview img { max-width: 100%; max-height: 100%; object-fit: contain; }
.image-picker .picker-info { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.image-picker .picker-url {
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 11px;
  color: var(--text-muted); word-break: break-all;
}
.image-picker .picker-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Boolean switch */
.switch { display: inline-flex; align-items: center; gap: 10px; }
.switch input { accent-color: var(--accent); width: 16px; height: 16px; }

/* Brand checklist (multi-select) */
.brand-checklist {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
  padding: 12px;
  background: var(--bg-1); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  max-height: 320px; overflow-y: auto;
}
.brand-check {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 4px;
  cursor: pointer;
}
.brand-check:hover { background: var(--bg-2); }
.brand-check input { accent-color: var(--accent); width: 14px; height: 14px; }
.brand-check span:first-of-type { flex: 1; font-size: 13px; }
.brand-cat { font-size: 10px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }

/* ============ MODAL ============ */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: grid; place-items: center;
  padding: 24px;
}
.modal {
  width: min(980px, 100%); max-height: 90vh;
  display: flex; flex-direction: column;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 18px; font-weight: 600; }
.modal-body { padding: 24px; overflow-y: auto; }
.modal-footer {
  display: flex; gap: 10px; justify-content: flex-end;
  padding: 16px 24px; border-top: 1px solid var(--border);
}

#modal-close { font-size: 22px; line-height: 1; padding: 6px 10px; border: none; }
#picker-close { font-size: 22px; line-height: 1; padding: 6px 10px; border: none; background: transparent; color: var(--text-dim); cursor: pointer; }
#picker-close:hover { color: var(--text); background: var(--bg-2); border-radius: 6px; }
.picker-modal { width: min(860px, 100%); }
#picker-folders .btn-ghost.active {
  color: var(--accent-bright);
  border-color: rgba(110,160,184,0.4);
  background: rgba(110,160,184,0.1);
}

/* ============ MEDIA LIBRARY ============ */
.media-folders {
  display: flex; flex-wrap: wrap; gap: 8px;
  margin-bottom: 16px;
}
.media-folder-tab {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 20px;
  font-size: 13px; color: var(--text-dim); cursor: pointer;
  transition: all 0.15s ease;
}
.media-folder-tab:hover { color: var(--text); border-color: var(--border-hover); }
.media-folder-tab.active {
  background: rgba(110,160,184,0.18); color: var(--accent-bright);
  border-color: rgba(110,160,184,0.4);
}
.media-folder-name { text-transform: lowercase; font-weight: 500; }
.media-folder-count {
  font-size: 11px; font-weight: 600;
  padding: 1px 7px; border-radius: 10px;
  background: rgba(255,255,255,0.06); color: var(--text-muted);
}
.media-folder-tab.active .media-folder-count {
  background: rgba(110,160,184,0.25); color: var(--accent-bright);
}

.media-grid {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}
.media-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  display: flex; flex-direction: column;
  transition: border-color 0.15s ease, transform 0.15s ease;
}
.media-card:hover { border-color: var(--border-hover); transform: translateY(-2px); }
.media-card .thumb {
  aspect-ratio: 4/3; display: grid; place-items: center;
  background: var(--bg-0); overflow: hidden;
}
.media-card .thumb img { width: 100%; height: 100%; object-fit: contain; }
.media-card .meta { padding: 10px 12px; font-size: 12px; }
.media-card .name { color: var(--text); font-weight: 500; word-break: break-all; }
.media-card .path { color: var(--text-muted); font-size: 10px; margin-top: 3px; }
.media-card .actions { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 10px 10px; }
.media-card .actions button { flex: 1 1 0; min-width: 0; padding: 6px; font-size: 11px; }
.media-card .actions select[data-act="move"] {
  flex: 1 1 100%; min-width: 0; padding: 6px; font-size: 11px;
  border-radius: var(--radius-sm, 6px); border: 1px solid var(--border);
  background: var(--bg-1, var(--bg-2)); color: var(--text); cursor: pointer;
}

.upload-dropzone {
  margin-bottom: 24px; padding: 32px; text-align: center;
  border: 2px dashed var(--border); border-radius: var(--radius);
  color: var(--text-muted); transition: all 0.15s ease;
  cursor: pointer;
}
.upload-dropzone.dragging { border-color: var(--accent); background: rgba(110,160,184,0.06); color: var(--accent-bright); }
.upload-dropzone strong { color: var(--text); }

/* ============ TOASTS ============ */
.toasts {
  position: fixed; bottom: 20px; right: 20px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  padding: 12px 18px; background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow);
  font-size: 13px; max-width: 360px;
  animation: slidein 0.2s ease-out;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error { border-left: 3px solid var(--danger); }
.toast.info { border-left: 3px solid var(--accent); }
@keyframes slidein { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ============ STATUS PILLS ============ */
.pill {
  display: inline-block; padding: 2px 10px; font-size: 11px; font-weight: 600;
  border-radius: 20px; text-transform: uppercase; letter-spacing: 0.5px;
}
.pill-ok   { background: rgba(127,196,146,0.15); color: var(--success); }
.pill-warn { background: rgba(228,177,94,0.15);  color: var(--warning); }
.pill-err  { background: rgba(224,109,109,0.15); color: var(--danger); }
.pill-dim  { background: rgba(255,255,255,0.06); color: var(--text-muted); }

/* ============ UTIL ============ */
[hidden] { display: none !important; }
.row-gap { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.mono { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12px; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ ANALYTICS ============ */
.ana-summary { margin-bottom: 24px; }
.ana-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; }
.ana-card {
  padding: 18px 20px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
}
.ana-card-label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.ana-card-value { font-size: 28px; font-weight: 700; margin-top: 6px; color: var(--text); }
.ana-live {
  color: #7fc492; font-size: 10px; margin-left: 4px;
  animation: livepulse 1.6s ease-in-out infinite;
}
@keyframes livepulse { 0%, 100% { opacity: 1 } 50% { opacity: 0.3 } }

.ana-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 16px;
}
.ana-panel {
  padding: 18px 20px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 10px;
}
.ana-panel.ana-panel-wide { grid-column: 1 / -1; }
.ana-panel h3 {
  font-size: 13px; font-weight: 600; margin: 0 0 14px;
  text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-dim);
}

.ana-chart {
  display: flex; align-items: flex-end; gap: 6px;
  height: 160px; padding: 0 4px;
}
.ana-bar-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
  gap: 4px; height: 100%;
}
.ana-bar {
  width: 100%; min-height: 2px;
  background: linear-gradient(180deg, var(--accent-light), var(--accent));
  border-radius: 3px 3px 0 0;
}
.ana-bar-label {
  font-size: 10px; color: var(--text-muted);
  transform: rotate(-45deg); transform-origin: top center;
  white-space: nowrap;
}

.ana-list { list-style: none; padding: 0; margin: 0; }
.ana-list li {
  position: relative;
  display: grid; grid-template-columns: 1fr auto;
  gap: 10px; padding: 10px 12px;
  border-radius: 6px;
  align-items: center;
  font-size: 13px;
  margin-bottom: 4px;
}
.ana-list-bar {
  position: absolute; inset: 0;
  background: rgba(110,160,184,0.12);
  border-radius: 6px;
  z-index: 0;
}
.ana-list-k { position: relative; z-index: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text); }
.ana-list-v { position: relative; z-index: 1; font-weight: 600; color: var(--accent-light); }

@media (max-width: 720px) {
  .ana-grid { grid-template-columns: 1fr; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 720px) {
  .sidebar { width: 60px; padding: 12px 6px; }
  .nav-btn { font-size: 0; padding: 10px; text-align: center; }
  .nav-btn::before { content: '•'; font-size: 18px; }
  .content { padding: 20px 16px; }
  .form-grid { grid-template-columns: 1fr; }
}


/* Analytics diagnostic strips */
.ana-diag-ok,
.ana-diag-warn,
.ana-diag-err {
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 16px;
  line-height: 1.5;
}
.ana-diag-ok   { background: rgba(34,197,94,.12);  color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.ana-diag-warn { background: rgba(234,179, 8,.10);  color: #fbbf24; border: 1px solid rgba(234,179,8,.25); }
.ana-diag-err  { background: rgba(239, 68,68,.12);  color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ============================================================
   ADMIN PANEL — MOBILE IMPROVEMENTS
   ============================================================ */

@media (max-width: 640px) {
  /* Admin panel sidebar: same overlay drawer as CRM */
  .crm-sidebar {
    position: fixed !important;
    top: 0; left: 0; bottom: 0;
    width: 260px !important;
    z-index: 300;
    transform: translateX(-100%);
    transition: transform .25s ease;
    overflow-y: auto;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    padding-top: 64px;
  }
  .crm-sidebar.drawer-open { transform: translateX(0); }
  .content { margin-left: 0 !important; }

  /* Admin content header: stack on mobile */
  .content-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 12px;
  }
  .content-header .row-gap { flex-wrap: wrap; }

  /* Tables: horizontal scroll */
  .crm-table-wrap, table { overflow-x: auto; -webkit-overflow-scrolling: touch; display: block; }

  /* Analytics grid: single column */
  .ana-grid { grid-template-columns: 1fr !important; }

  /* Site settings inputs: full width */
  .site-settings-row { flex-direction: column; }

  /* Topbar: compact */
  .crm-topbar { padding: 0 10px; }
  .crm-topbar-user .user-name { display: none; }
  .crm-search-wrap { flex: 1; max-width: none; }

  /* Login card: full width */
  .login-card { width: 100% !important; max-width: none !important; margin: 0 16px; }

  /* Modal: full screen */
  .modal {
    width: 100vw !important; max-width: none !important;
    border-radius: 0 !important;
    height: 100dvh !important;
  }
  .modal-body { max-height: calc(100dvh - 120px) !important; }
}

@media (max-width: 420px) {
  .crm-role-badge { display: none; }
  .content { padding: 14px 12px !important; }
  h1 { font-size: 20px !important; }
}

/* ── Inquiry age flag (mirrors crm.css so admin + CRM modals match) ────── */
.inq-flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.4;
}
.inq-flag-green  { background: rgba(127,196,146,0.18); color: var(--success); }
.inq-flag-orange { background: rgba(228,177,94,0.20);  color: var(--warning); }
.inq-flag-red    { background: rgba(224,109,109,0.20); color: var(--danger); }
.inq-flag-none   { background: rgba(255,255,255,0.06); color: var(--text-muted); font-weight: 500; }

/* ── Site Branding previews ─────────────────────────────────────────────── */
.branding-preview {
  width: 160px;
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
  flex: 0 0 auto;
}
.branding-preview img { max-width: 100%; max-height: 120px; object-fit: contain; }
.branding-preview-favicon { width: 96px; min-height: 96px; }
.branding-preview-favicon img { max-height: 48px; max-width: 48px; image-rendering: -webkit-optimize-contrast; }
.branding-empty { color: var(--text-muted); font-size: 12px; }

/* ── News manager: category chips + per-category scroll ─────────────────── */
.news-cat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 22px;
}
.news-cat-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 8px 5px 12px;
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border, rgba(255,255,255,0.10));
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #e8eef0);
}
.news-cat-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #274D55;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
.news-cat-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.news-cat-del:hover { background: rgba(224,109,109,0.2); color: var(--danger, #e06d6d); }

/* Each category table scrolls vertically once it exceeds ~10 rows. The header
   stays pinned while the body scrolls. */
.news-group-scroll.scrolls {
  max-height: 460px;        /* ~10 rows + header */
  overflow-y: auto;
  border: 1px solid var(--border, rgba(255,255,255,0.08));
  border-radius: 8px;
}
.news-group-scroll.scrolls table.data-table thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--bg-2, #14222a);
}

/* ── News status badges (admin table) ───────────────────────────────────── */
.news-status-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.news-status-published {
  background: rgba(127,196,146,0.18);
  color: var(--success, #7fc492);
}
.news-status-draft {
  background: rgba(255,255,255,0.08);
  color: var(--text-muted, #8CA0AA);
}

/* Read-only (auto-filled) fields in the News editor */
.news-readonly {
  background: var(--bg-2, #1b2a30) !important;
  color: var(--text-muted) !important;
  cursor: not-allowed;
}

/* Locked banner when a published item is opened */
.news-locked-note {
  background: rgba(228,177,94,0.14);
  border: 1px solid rgba(228,177,94,0.35);
  color: var(--warning, #e4b15e);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* Per-category delete button in the News group header */
.news-cat-del-btn { font-size: 14px; }
.news-cat-del-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* Move-to-category dropdown sizing in the table */
.news-move-select {
  max-width: 160px;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--bg-1, #0f1c22);
  color: var(--text, #e8eef0);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius-sm, 6px);
  outline: none;
  cursor: pointer;
}
.news-move-select:focus { border-color: var(--accent, #6ea0b8); }

/* News tables: fixed layout so every category's columns line up identically */
.news-table { table-layout: fixed; width: 100%; }
/* Ellipsis only on the title column — never on the cover/status/actions cells,
   where text-overflow on a non-text box renders a stray "…". */
.news-table td:nth-child(2) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}
/* Guard: the cover cell must never show a text-overflow ellipsis. */
.news-table td:first-child {
  overflow: visible;
  text-overflow: clip;
}

/* News cover thumbnails keep the loaded photo's real aspect ratio.
   No background or letterboxing — just the image alone. */
.news-table .cell-img {
  width: 100%;
  height: auto;
  max-height: 64px;
  background: none;
  border-radius: var(--radius-sm);
  display: block;
  overflow: hidden;
  text-align: left;
}
.news-table .cell-img img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 64px;
  object-fit: contain;
  object-position: left center;
}

/* ─────────────────────────────────────────────────────────────
   Rich Text Editor (Body / HTML fields)
   ───────────────────────────────────────────────────────────── */
.rte {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 8px);
  background: var(--bg-2, #1b2a30);
  overflow: visible;
}
.rte.rte-disabled { opacity: .6; }

.rte-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 6px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-3, #16242a);
  border-radius: var(--radius-sm, 8px) var(--radius-sm, 8px) 0 0;
}

.rte-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 7px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--text, #e8eef0);
  cursor: pointer;
  font: inherit;
  line-height: 1;
}
.rte-btn:hover { background: var(--bg-1, #24383f); border-color: var(--border); }
.rte-btn:active { background: var(--accent, #274D55); }
.rte-btn.active { background: var(--accent, #274D55); border-color: var(--accent-bright, #506E78); color: #fff; }
.rte-btn svg { display: block; }

.rte-select {
  max-width: 160px;
  padding: 7px 10px;
  font-size: 13px;
  background: var(--bg-1, #0f1c22);
  color: var(--text, #e8eef0);
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  border-radius: var(--radius-sm, 6px);
  outline: none;
  cursor: pointer;
}
.rte-select:focus { border-color: var(--accent, #6ea0b8); }
/* Ensure dropdown list items are readable (dark-on-dark otherwise) */
.rte-select option {
  background: var(--bg-1, #24383f);
  color: var(--text, #e8eef0);
}

.rte-sep {
  width: 1px;
  height: 22px;
  margin: 0 4px;
  background: var(--border);
}

/* Color picker */
.rte-color-group { position: relative; display: inline-flex; }
.rte-color-btn { flex-direction: column; gap: 2px; padding-bottom: 4px; }
.rte-color-strip {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 2px;
  background: #c0392b;
}
.rte-color-pop {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 50;
  display: none;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  padding: 10px;
  background: var(--bg-1, #24383f);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: var(--shadow, 0 8px 24px rgba(0,0,0,.4));
  width: 232px;
}
.rte-color-pop.open { display: grid; }
.rte-swatch {
  width: 22px;
  height: 22px;
  border: 1px solid rgba(255,255,255,.25);
  border-radius: 5px;
  cursor: pointer;
  padding: 0;
}
.rte-swatch:hover { transform: scale(1.12); }
.rte-custom-color {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted, #9bb0b6);
  cursor: pointer;
}
.rte-custom-color input[type="color"] {
  width: 28px; height: 24px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: none;
  cursor: pointer;
  padding: 0;
}

/* Editable area */
.rte-area {
  min-height: 220px;
  max-height: 60vh;
  overflow-y: auto;
  padding: 14px 16px;
  color: var(--text, #e8eef0);
  font-family: var(--font, inherit);
  font-size: 16px;
  line-height: 1.6;
  outline: none;
}
.rte-area:focus { box-shadow: inset 0 0 0 2px var(--accent, #274D55); border-radius: 0 0 var(--radius-sm,8px) var(--radius-sm,8px); }
.rte-area img { max-width: 100%; height: auto; }
.rte-area a { color: var(--accent-light, #8CA0AA); }
.rte-area p:first-child { margin-top: 0; }
.rte-area:empty::before {
  content: attr(data-placeholder);
  color: var(--text-dim, #6b8088);
}

/* Source (raw HTML) textarea when toggled visible */
textarea.rte-source {
  width: 100%;
  min-height: 240px;
  border: none;
  border-radius: 0 0 var(--radius-sm, 8px) var(--radius-sm, 8px);
  background: var(--bg-0, #0f1a1f);
  color: var(--text, #e8eef0);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  padding: 14px 16px;
  resize: vertical;
}

/* ── Sales Support: manufacturer mosaic + brand file modal ───────────────── */
/* Dynamic mosaic: tiles auto-fill the available width and reflow with the
   window. Tiles are small squares with a logo, name, and file count. */
.ss-mosaic {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 14px;
  align-content: start;
}
@media (min-width: 600px)  { .ss-mosaic { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); } }
@media (min-width: 1100px) { .ss-mosaic { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); } }

.ss-tile {
  aspect-ratio: 1 / 1;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 8px; padding: 12px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  cursor: pointer; text-align: center;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s ease;
}
.ss-tile:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  box-shadow: 0 8px 20px rgba(0,0,0,0.28);
}
.ss-tile-logo {
  width: 100%; flex: 1 1 auto; min-height: 0;
  display: flex; align-items: center; justify-content: center;
}
.ss-tile-logo img {
  max-width: 88%; max-height: 100%;
  object-fit: contain;
  /* Most brand logos are dark-on-transparent; lift them onto the dark tile. */
  background: #fff; border-radius: 6px; padding: 6px;
}
.ss-tile-initial {
  width: 48px; height: 48px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 700; color: var(--accent-light);
  background: rgba(110,160,184,0.14);
}
.ss-tile-name {
  flex: 0 0 auto;
  font-size: 12px; font-weight: 600; color: var(--text);
  line-height: 1.2;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden;
}
.ss-tile-count { flex: 0 0 auto; font-size: 11px; color: var(--accent-light); }
.ss-tile-count.is-empty { color: var(--text-muted); }

/* Brand file modal */
.ss-modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  display: none; align-items: center; justify-content: center;
  padding: 18px;
  background: rgba(8,10,14,0.7); backdrop-filter: blur(3px);
}
.ss-modal-overlay.open { display: flex; }
.ss-modal {
  width: 100%; max-width: 560px; max-height: 85vh;
  display: flex; flex-direction: column;
  background: var(--bg-0, #11151b);
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 10px);
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
}
.ss-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.ss-modal-head h2 { font-size: 16px; font-weight: 600; margin: 0; }
.ss-modal-close {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-dim); cursor: pointer; font-size: 14px;
}
.ss-modal-close:hover { background: var(--bg-2); color: var(--text); }
.ss-modal-body { padding: 14px 18px 18px; overflow-y: auto; }
.ss-modal-actions {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}

.ss-add-btn {
  cursor: pointer; display: inline-flex; align-items: center;
  padding: 7px 14px; font-size: 12px; font-weight: 600;
  background: linear-gradient(135deg, var(--accent), var(--accent-light));
  color: #0a1720; border-radius: var(--radius-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.ss-add-btn:hover { transform: translateY(-1px); box-shadow: 0 6px 14px rgba(110,160,184,0.3); }
.ss-file-count { font-size: 12px; color: var(--text-muted); }

.ss-file-list { list-style: none; margin: 0; padding: 0; }
.ss-file-row {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px; border-radius: var(--radius-sm);
}
.ss-file-row + .ss-file-row { border-top: 1px solid var(--border); border-radius: 0; }
.ss-file-row:hover { background: var(--bg-2); }
.ss-file-name {
  flex: 1 1 auto; min-width: 0;
  color: var(--text); font-size: 13px; text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-file-name:hover { color: var(--accent-light); text-decoration: underline; }
.ss-file-meta { flex: 0 0 auto; font-size: 11px; color: var(--text-muted); white-space: nowrap; }
.ss-file-del {
  flex: 0 0 auto; width: 26px; height: 26px; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
  color: var(--text-muted); border: 1px solid transparent; border-radius: var(--radius-sm);
  cursor: pointer; font-size: 13px;
}
.ss-file-del:hover { color: var(--danger); border-color: rgba(224,109,109,0.3); background: rgba(224,109,109,0.08); }
.ss-file-del:disabled { opacity: 0.5; cursor: default; }
.ss-file-empty { padding: 8px 10px; font-size: 12px; color: var(--text-muted); font-style: italic; }

/* ── Sales Support: per-brand file history ───────────────────────────────── */
.ss-history { margin-top: 18px; border-top: 1px solid var(--border); padding-top: 14px; }
.ss-history-title { font-size: 13px; font-weight: 600; color: var(--text-dim); margin: 0 0 10px; text-transform: uppercase; letter-spacing: 0.04em; }
.ss-history-loading, .ss-history-empty { font-size: 12px; color: var(--text-muted); font-style: italic; padding: 4px 2px; }
.ss-history-list { list-style: none; margin: 0; padding: 0; }
.ss-history-row {
  display: flex; align-items: baseline; gap: 10px;
  padding: 7px 2px; font-size: 12px;
}
.ss-history-row + .ss-history-row { border-top: 1px solid var(--border); }
.ss-history-badge {
  flex: 0 0 auto;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
}
.ss-history-badge.is-add { background: rgba(110,184,130,0.15); color: var(--success, #6eb882); }
.ss-history-badge.is-del { background: rgba(224,109,109,0.15); color: var(--danger, #e06d6d); }
.ss-history-file {
  flex: 1 1 auto; min-width: 0; color: var(--text);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-history-meta { flex: 0 0 auto; color: var(--text-muted); white-space: nowrap; }

/* ── Campaign Layout Builder ── */
.lb-row { position:relative; }
.lb-row:hover .lb-row-actions { opacity:1; pointer-events:auto; }
.lb-row-actions { position:absolute; top:4px; right:6px; display:flex; gap:3px; opacity:0; pointer-events:none; transition:opacity .15s; z-index:20; background:#fff; border:1px solid #e2e8f0; border-radius:6px; padding:3px 4px; box-shadow:0 2px 8px rgba(0,0,0,.1); }
.lb-act-btn { padding:3px 7px; font-size:11px; border:1px solid #e2e8f0; border-radius:4px; background:#f8fafc; color:#64748b; cursor:pointer; line-height:1.4; transition:background .12s,color .12s; }
.lb-act-btn:hover { background:#f1f5f9; color:#374151; }
.lb-act-del:hover { background:#fef2f2; color:#dc2626; border-color:#fca5a5; }
.lb-act-spacer { display:inline-block; width:26px; }
.lb-cell { position:relative; }
.lb-cell:focus-within { background:#fafeff !important; }
.lb-text-ce:empty::before { content:"Click to type\2026"; color:#94a3b8; font-style:italic; pointer-events:none; }
.lb-resize-handle { width:6px; flex-shrink:0; background:rgba(110,160,184,.12); cursor:col-resize; position:relative; z-index:5; transition:background .15s; }
.lb-resize-handle::after { content:''; position:absolute; top:50%; left:50%; transform:translate(-50%,-50%); width:2px; height:24px; background:rgba(110,160,184,.35); border-radius:1px; }
.lb-resize-handle:hover, .lb-resize-handle.dragging { background:rgba(110,160,184,.45); }
.lb-resize-handle:hover::after, .lb-resize-handle.dragging::after { background:#6ea0b8; }
.lb-layout-opt { transition:border-color .15s,background .15s; }
.lb-layout-opt:hover { border-color:var(--accent) !important; background:rgba(110,160,184,.08) !important; }
