:root {
  --navy: #0f1c3f;
  --navy-light: #16265a;
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --green: #16a34a;
  --amber: #d97706;
  --red: #dc2626;
  --border: #e5e7eb;
  --bg: #f6f7fb;
  --text: #111827;
  --muted: #6b7280;
  --radius: 10px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}
a { color: inherit; text-decoration: none; }

.app-shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.sidebar {
  width: 250px;
  background: var(--navy);
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
.sidebar-brand { padding: 22px 20px 10px; display: flex; align-items: center; gap: 10px; }
.sidebar-brand .logo-dot {
  width: 34px; height: 34px; border-radius: 8px; background: var(--blue);
  display: flex; align-items: center; justify-content: center; font-weight: 700; color: white;
}
.sidebar-brand .name { font-weight: 700; color: white; font-size: 15px; line-height: 1.2; }
.sidebar-brand .sub { font-size: 11px; color: #94a3b8; }

.sidebar-nav { padding: 10px 12px; flex: 1; }
.sidebar-nav a, .sidebar-nav .nav-disabled {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 8px; margin-bottom: 2px;
  color: #cbd5e1; font-size: 13.5px; font-weight: 500;
}
.sidebar-nav a:hover { background: var(--navy-light); color: white; }
.sidebar-nav a.active { background: var(--blue); color: white; }
.sidebar-nav .nav-disabled { color: #64748b; cursor: not-allowed; }
.sidebar-nav .badge-soon {
  margin-left: auto; font-size: 9.5px; padding: 2px 6px; border-radius: 20px;
  background: rgba(255,255,255,0.08); color: #94a3b8;
}

.sidebar-client-card {
  margin: 12px; padding: 14px; border-radius: var(--radius);
  background: var(--navy-light); border: 1px solid rgba(255,255,255,0.06);
}
.sidebar-client-card .client-name { color: white; font-weight: 700; margin-bottom: 6px; }
.sidebar-client-card .client-meta { font-size: 12px; color: #94a3b8; line-height: 1.6; }

/* ---------------- Topbar ---------------- */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: white; border-bottom: 1px solid var(--border);
  padding: 14px 24px;
}
.client-selector select, .date-input {
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 12px;
  font-size: 13.5px; background: white;
}
.topbar .page-title { font-size: 18px; font-weight: 700; margin: 0; }
.topbar .spacer { flex: 1; }
.status-pill {
  padding: 5px 12px; border-radius: 20px; font-size: 11.5px; font-weight: 700;
  letter-spacing: 0.04em;
}
.status-draft { background: #fef3c7; color: #92400e; }
.status-approved { background: #dcfce7; color: #166534; }
.status-sent { background: #dbeafe; color: #1e40af; }
.user-chip { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 34px; height: 34px; border-radius: 50%; background: var(--blue);
  color: white; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px;
}
.user-chip .role { font-size: 11px; color: var(--muted); }

/* ---------------- Content layout ---------------- */
.content { padding: 20px 24px; display: flex; gap: 20px; align-items: flex-start; }
.content-main { flex: 1; min-width: 0; }
.content-side { width: 300px; flex-shrink: 0; display: flex; flex-direction: column; gap: 16px; }

.card {
  background: white; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px 18px;
}
.card h3 { margin: 0 0 12px; font-size: 14px; font-weight: 700; }

.sections-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 16px; flex-wrap: wrap; }
.sections-bar .section-chip {
  display: flex; align-items: center; gap: 8px; padding: 9px 14px;
  border: 1px solid var(--border); border-radius: 8px; background: white; font-weight: 600; font-size: 13px;
}
.dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.btn {
  border: none; border-radius: 8px; padding: 9px 16px; font-weight: 600; font-size: 13px; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px;
}
.btn-primary { background: var(--blue); color: white; }
.btn-primary:hover { background: var(--blue-dark); }
.btn-outline { background: white; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #f3f4f6; }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.section-group { margin-bottom: 22px; }
.section-header {
  display: flex; align-items: center; gap: 10px; padding: 10px 4px; font-weight: 700; font-size: 14px;
}
.section-header .count-pill {
  background: #eef2ff; color: #3730a3; font-size: 11px; padding: 2px 9px; border-radius: 20px; font-weight: 700;
}

.story-card {
  display: flex; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--border);
}
.story-card:last-child { border-bottom: none; }
.story-thumb {
  width: 84px; height: 84px; border-radius: 8px; object-fit: cover; background: #e5e7eb; flex-shrink: 0;
}
.story-body { flex: 1; min-width: 0; }
.story-headline { font-weight: 700; font-size: 14.5px; margin: 0 0 6px; }
.story-meta { font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.tag {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 6px;
  background: #eef2ff; color: #3730a3;
}
.tag-positive { background: #dcfce7; color: #166534; }
.tag-negative { background: #fee2e2; color: #991b1b; }
.tag-neutral { background: #f3f4f6; color: #374151; }
.tag-review { background: #fef3c7; color: #92400e; }

.also-mentioned-btn {
  font-size: 12.5px; font-weight: 600; color: var(--blue); background: none; border: none; cursor: pointer;
  padding: 0;
}
.source-chips { display: flex; gap: 6px; margin-top: 8px; align-items: center; flex-wrap: wrap; }
.source-chip {
  font-size: 11px; font-weight: 700; padding: 4px 9px; border-radius: 6px; background: #f3f4f6; color: #374151;
}

.summary-row {
  display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid #f1f2f4; font-size: 13px;
}
.summary-row:last-child { border-bottom: none; }
.summary-row .value { font-weight: 700; }
.review-flag { color: var(--amber); }

.quick-action-btn {
  display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--border); background: white; font-weight: 600; font-size: 13px; cursor: pointer;
  width: 100%; text-align: left; margin-bottom: 8px;
}
.quick-action-btn:disabled { color: #9ca3af; cursor: not-allowed; }
.quick-action-btn.primary { background: var(--blue); color: white; border-color: var(--blue); }

textarea.notes-box {
  width: 100%; min-height: 90px; border: 1px solid var(--border); border-radius: 8px; padding: 10px;
  font-family: inherit; font-size: 13px; resize: vertical;
}

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); }

/* ---------------- Modal / drawer ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(15,28,63,0.45); display: none;
  align-items: center; justify-content: center; z-index: 50;
}
.overlay.open { display: flex; }
.drawer {
  background: white; border-radius: 14px; width: 560px; max-width: 92vw; max-height: 88vh; overflow: auto;
  padding: 22px 24px;
}
.drawer h2 { margin: 0 0 4px; font-size: 18px; }
.drawer .sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.tabs { display: flex; gap: 6px; margin-bottom: 16px; border-bottom: 1px solid var(--border); }
.tab {
  padding: 8px 14px; font-size: 13px; font-weight: 600; color: var(--muted); cursor: pointer;
  border-bottom: 2px solid transparent;
}
.tab.active { color: var(--blue); border-color: var(--blue); }
.tab.disabled { color: #cbd5e1; cursor: not-allowed; }
textarea.links-box {
  width: 100%; min-height: 160px; border: 1px solid var(--border); border-radius: 8px; padding: 12px;
  font-family: ui-monospace, monospace; font-size: 12.5px; resize: vertical;
}
.link-count { font-size: 12px; color: var(--muted); margin-top: 6px; }
.drawer-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }
.result-banner {
  background: #eef2ff; border: 1px solid #c7d2fe; color: #3730a3; padding: 12px 16px;
  border-radius: 8px; margin-bottom: 16px; font-size: 13.5px; font-weight: 600;
}

.mention-row {
  display: flex; justify-content: space-between; align-items: center; padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.mention-row:last-child { border-bottom: none; }
.mention-source { font-weight: 700; font-size: 13px; }
.mention-meta { font-size: 12px; color: var(--muted); }

/* ---------------- Login ---------------- */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center; background: var(--navy);
}
.login-card {
  background: white; border-radius: 14px; padding: 36px 34px; width: 380px; max-width: 90vw;
}
.login-card h1 { font-size: 20px; margin: 0 0 4px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 20px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 6px; }
.field input, .field select, .field textarea {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13.5px;
  font-family: inherit; box-sizing: border-box;
}
.error-box { background: #fee2e2; color: #991b1b; padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }

/* ---------------- Tables (admin) ---------------- */
table.data-table { width: 100%; border-collapse: collapse; }
table.data-table th, table.data-table td {
  text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); font-size: 13px;
}
table.data-table th { color: var(--muted); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
.form-inline { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.form-inline input, .form-inline select {
  padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px;
}
.page-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 18px; }
.page-header h1 { font-size: 20px; margin: 0; }
.container-padded { padding: 24px; }
.pill { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.pill-active { background: #dcfce7; color: #166534; }
.pill-disabled { background: #f3f4f6; color: #6b7280; }
.pill-needs-verification { background: #fef3c7; color: #92400e; }

/* ---------------- Dropdowns (client selector + user profile) ---------------- */
.dropdown { position: relative; }
.dropdown-trigger {
  display: flex; align-items: center; gap: 8px; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; padding: 6px 10px; cursor: pointer; font-size: 13.5px; font-family: inherit;
}
.client-dropdown-trigger { min-width: 170px; }
.client-badge {
  width: 26px; height: 26px; border-radius: 8px; background: #fef3c7; color: #92400e; font-weight: 700;
  font-size: 11px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.client-badge.small { width: 20px; height: 20px; font-size: 9px; }
.client-dropdown-name { font-weight: 600; flex: 1; text-align: left; }
.chevron { color: var(--muted); font-size: 10px; }
.dropdown-menu {
  display: none; position: absolute; top: calc(100% + 6px); left: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12); min-width: 220px; z-index: 50; overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-menu-right { left: auto; right: 0; }
.dropdown-item {
  display: flex; align-items: center; gap: 8px; padding: 10px 14px; font-size: 13px; color: #111827; text-decoration: none;
}
.dropdown-item:hover { background: #f9fafb; }
.dropdown-item.active { background: #eff6ff; font-weight: 600; }
.dropdown-item-static { padding: 10px 14px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); }
.user-dropdown-trigger { border: none; background: none; padding: 4px; }

/* ---------------- Section collapse / story cards (V1.3 UI alignment) ---------------- */
.section-group { padding: 0; overflow: hidden; }
.section-header { padding: 16px 18px; cursor: pointer; user-select: none; }
.section-header .drag-handle { color: #9ca3af; margin-right: 4px; cursor: grab; }
.section-toggle { color: var(--muted); transition: transform 0.15s; }
.section-toggle.collapsed { transform: rotate(-90deg); }
.section-body { padding: 0 18px 16px; }
.section-body.collapsed { display: none; }
.count-pill { background: #eef2ff; color: #4338ca; padding: 2px 9px; border-radius: 10px; font-size: 11px; font-weight: 700; margin-left: 8px; }

.story-card { display: flex; gap: 14px; padding: 14px 0; border-bottom: 1px solid #f1f5f9; align-items: flex-start; }
.story-card:last-of-type { border-bottom: none; }
.story-thumb {
  width: 72px; height: 56px; border-radius: 8px; background: #e5e7eb; flex-shrink: 0; object-fit: cover;
  display: flex; align-items: center; justify-content: center; color: #9ca3af; font-size: 11px;
}
.story-thumb.media-print { background: #fdf2f8; }
.story-thumb.media-video { background: #eff6ff; }
.story-body { flex: 1; min-width: 0; }
.story-headline { font-weight: 600; font-size: 14px; margin: 0 0 4px; }
.story-meta { font-size: 12px; color: var(--muted); margin-bottom: 6px; }
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.tag { background: #eff6ff; color: #1d4ed8; font-size: 11px; padding: 2px 9px; border-radius: 10px; font-weight: 600; }
.tag-review { background: #fef3c7; color: #92400e; }
.tag-sentiment-positive { background: #dcfce7; color: #166534; }
.tag-sentiment-neutral { background: #f3f4f6; color: #4b5563; }
.tag-sentiment-negative { background: #fee2e2; color: #991b1b; }
.also-mentioned-btn { background: none; border: none; color: #2563eb; font-size: 12px; font-weight: 600; cursor: pointer; padding: 0; margin-top: 2px; }
.source-logos { display: flex; align-items: center; gap: 4px; margin-top: 6px; }
.source-logo-circle {
  width: 24px; height: 24px; border-radius: 50%; background: #f3f4f6; color: #374151; font-size: 9px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff; box-shadow: 0 0 0 1px #e5e7eb;
  margin-left: -6px;
}
.source-logo-circle:first-child { margin-left: 0; }
.story-actions { display: flex; gap: 6px; align-items: center; flex-shrink: 0; }
.icon-btn {
  width: 28px; height: 28px; border-radius: 6px; border: 1px solid var(--border); background: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: #4b5563;
}
.icon-btn:hover { background: #f9fafb; }


/* ---------------- Client selector ---------------- */
.client-selector-page { margin:0; background:#f5f7fb; color:#10213f; min-height:100vh; }
.client-selector-shell { min-height:100vh; }
.client-selector-topbar { height:82px; background:#fff; border-bottom:1px solid #e4e9f1; display:flex; align-items:center; justify-content:space-between; padding:0 34px; }
.client-selector-brand { display:flex; align-items:center; gap:12px; }
.client-selector-brandmark { width:42px; height:42px; border-radius:11px; background:#2f6fec; color:#fff; display:flex; align-items:center; justify-content:center; font-weight:800; }
.client-selector-brand strong { display:block; font-size:18px; }
.client-selector-brand span { display:block; color:#71809a; font-size:12px; margin-top:2px; }
.client-selector-user { display:flex; align-items:center; gap:16px; font-size:14px; }
.client-selector-user a { color:#2f6fec; text-decoration:none; font-weight:600; }
.client-selector-main { max-width:1180px; margin:0 auto; padding:50px 28px 70px; }
.client-selector-heading { display:flex; justify-content:space-between; align-items:flex-end; gap:20px; margin-bottom:26px; }
.client-selector-heading h1 { margin:0 0 7px; font-size:30px; }
.client-selector-heading p { margin:0; color:#6d7b91; }
.client-selector-count { background:#eaf0ff; color:#2f5ec4; border-radius:999px; padding:7px 12px; font-size:12px; font-weight:700; }
.client-selector-grid { display:grid; grid-template-columns:repeat(auto-fill,minmax(240px,1fr)); gap:20px; }
.client-selector-card { background:#fff; border:1px solid #e1e6ee; border-radius:16px; padding:24px; min-height:220px; text-decoration:none; color:inherit; display:flex; flex-direction:column; align-items:center; justify-content:center; box-shadow:0 4px 14px rgba(23,45,82,.04); transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease; }
.client-selector-card:hover { transform:translateY(-3px); border-color:#b9c9ee; box-shadow:0 12px 28px rgba(23,45,82,.10); }
.client-selector-logo-wrap { width:170px; height:92px; display:flex; align-items:center; justify-content:center; margin-bottom:18px; }
.client-selector-logo-wrap img { max-width:100%; max-height:100%; object-fit:contain; }
.client-selector-logo-fallback { width:76px; height:76px; border-radius:18px; background:#eef3ff; color:#2f6fec; display:flex; align-items:center; justify-content:center; font-size:24px; font-weight:800; }
.client-selector-name { font-size:18px; font-weight:800; text-align:center; }
.client-selector-open { margin-top:8px; color:#71809a; font-size:12px; }
@media (max-width:640px) { .client-selector-topbar{padding:0 18px}.client-selector-user span{display:none}.client-selector-main{padding:34px 18px}.client-selector-heading{align-items:flex-start;flex-direction:column}.client-selector-grid{grid-template-columns:1fr} }
