:root {
  --bg: #f5f7fb;
  --ink: #0f172a;
  --muted: #64748b;
  --line: #e5e7eb;
  --nav: #111827;
  --accent: #2563eb;
  --good: #16a34a;
  --warn: #f59e0b;
  --bad: #dc2626;
}

body { background: var(--bg); color: var(--ink); }
a { text-decoration: none; }
.login-page { background: radial-gradient(circle at top left, #ffffff 0, #eef2f7 45%, #dfe7f2 100%); }

.app-shell { display: flex; min-height: 100vh; }
.sidebar { width: 260px; background: linear-gradient(180deg, #0f172a 0%, #111827 100%); color: #fff; padding: 22px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; color: #fff; font-weight: 800; font-size: 1.1rem; margin-bottom: 28px; }
.brand:hover { color: #fff; }
.brand-mark { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: #fff; color: #0f172a; }
.sidebar-nav { display: grid; gap: 6px; }
.sidebar-nav a { color: #cbd5e1; padding: 10px 12px; border-radius: 12px; font-weight: 600; }
.sidebar-nav a:hover { color: #fff; background: rgba(255,255,255,.08); }
.sidebar-user { margin-top: auto; border: 1px solid rgba(255,255,255,.12); border-radius: 18px; padding: 16px; background: rgba(255,255,255,.05); }
.role-pill { display: inline-flex; border-radius: 999px; padding: 4px 10px; background: rgba(255,255,255,.1); margin-top: 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.main-panel { min-width: 0; flex: 1; }
.content-wrap { padding: 28px; }
.mobile-topbar { display: none; }

.page-header { display: flex; justify-content: space-between; gap: 16px; align-items: flex-start; }
.page-header h1 { margin: 0; font-size: 1.9rem; font-weight: 850; letter-spacing: -.03em; }
.page-header p { margin: 4px 0 0; color: var(--muted); }
.eyebrow { text-transform: uppercase; color: var(--accent); font-size: 12px; font-weight: 800; letter-spacing: .08em; }

.app-card, .stat-card { border: 0; border-radius: 20px; box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08); }
.stat-label { color: var(--muted); font-size: 0.85rem; margin-bottom: 0.25rem; }
.stat-value { color: var(--ink); font-size: 1.9rem; font-weight: 850; letter-spacing: -.03em; }
.mini-kpi { background: #fff; border-radius: 18px; padding: 16px; box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08); }
.mini-kpi span { display: block; color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.mini-kpi strong { font-size: 1.1rem; }

.info-list > div { display: grid; grid-template-columns: 130px 1fr; gap: 12px; border-bottom: 1px solid #eef2f7; padding: 10px 0; }
.info-list span { color: var(--muted); }
.timeline-item { border-left: 3px solid var(--nav); padding-left: 14px; margin-bottom: 18px; }
.log-table pre { white-space: pre-wrap; font-size: 12px; margin: 0; max-width: 360px; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th { background: #0f172a; color: #fff; border-color: #0f172a; white-space: nowrap; }
.table-compact td, .table-compact th { font-size: 13px; }
.card-header { border-bottom: 1px solid #eef2f7; }
canvas { max-width: 100%; }
.dashboard-filter-pill { border-radius: 999px; background: #eef2f7; padding: 4px 10px; font-size: 12px; color: #334155; }
.status-badge { background: #eef2f7; color: #0f172a; border: 1px solid #dbe3ef; }
.priority-badge { border: 1px solid transparent; }
.priority-low { color: #475569 !important; background: #f1f5f9 !important; }
.priority-normal { color: #1d4ed8 !important; background: #dbeafe !important; }
.priority-high { color: #b45309 !important; background: #fef3c7 !important; }
.priority-urgent { color: #b91c1c !important; background: #fee2e2 !important; }
.flash-stack { position: sticky; top: 12px; z-index: 20; }

@media (max-width: 991.98px) {
  .app-shell { display: block; }
  .sidebar { display: none; }
  .mobile-topbar { display: block; }
  .content-wrap { padding: 18px; }
  .page-header { display: block; }
}

/* Phase 5 update: editor daily score widget */
.editor-score-card {
  background: linear-gradient(135deg, #ffffff 0%, #f7fbff 55%, #eef7ff 100%);
  border: 1px solid rgba(15, 23, 42, 0.08);
}
.score-face {
  font-size: 4.25rem;
  line-height: 1;
}
.score-stars {
  color: #f59e0b;
  font-size: 1.55rem;
  letter-spacing: 2px;
  margin-top: .35rem;
}
.score-number {
  font-size: 2rem;
  font-weight: 800;
  color: #111827;
}
.score-progress {
  height: 12px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}
.score-progress .progress-bar {
  background: linear-gradient(90deg, #0f172a, #2563eb);
}
.soft-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  background: rgba(255, 255, 255, .78);
  box-shadow: none;
}
.api-key-mask {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  letter-spacing: .04em;
}

/* Phase 5.1 branding + collapsible sidebar */
body { background: var(--bg); }
.login-page {
  background: radial-gradient(circle at top left, #ffffff 0, var(--bg) 52%, #dfe7f2 100%);
}
.sidebar {
  background: linear-gradient(180deg, var(--nav) 0%, #020617 100%);
  transition: width .18s ease, padding .18s ease;
}
.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 24px;
}
.sidebar-top .brand { margin-bottom: 0; min-width: 0; }
.brand-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-logo-wrap {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: rgba(255,255,255,.95);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  overflow: hidden;
}
.brand-logo {
  max-width: 34px;
  max-height: 34px;
  object-fit: contain;
}
.mobile-brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: 8px;
  background: #fff;
  padding: 2px;
  margin-right: 8px;
}
.sidebar-toggle {
  border: 1px solid rgba(255,255,255,.16);
  color: #fff;
  background: rgba(255,255,255,.08);
  border-radius: 12px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  font-weight: 800;
}
.sidebar-toggle:hover { background: rgba(255,255,255,.14); }
.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
}
.nav-icon {
  width: 24px;
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
}
.btn-dark {
  background-color: var(--button) !important;
  border-color: var(--button) !important;
}
.eyebrow { color: var(--accent); }
.score-progress .progress-bar { background: linear-gradient(90deg, var(--nav), var(--accent)); }
.login-logo {
  max-width: 180px;
  max-height: 90px;
  object-fit: contain;
}
.login-brand-mark {
  width: 66px;
  height: 66px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  background: var(--nav);
  color: #fff;
  font-size: 2rem;
  font-weight: 900;
}

body.sidebar-collapsed .sidebar {
  width: 88px;
  padding-left: 16px;
  padding-right: 16px;
}
body.sidebar-collapsed .brand-text,
body.sidebar-collapsed .menu-label,
body.sidebar-collapsed .sidebar-user-label,
body.sidebar-collapsed .sidebar-username,
body.sidebar-collapsed .role-pill,
body.sidebar-collapsed .sidebar-actions {
  display: none !important;
}
body.sidebar-collapsed .sidebar-top {
  justify-content: center;
  flex-direction: column;
}
body.sidebar-collapsed .brand,
body.sidebar-collapsed .sidebar-nav a {
  justify-content: center;
}
body.sidebar-collapsed .sidebar-nav a {
  padding-left: 8px;
  padding-right: 8px;
}
body.sidebar-collapsed .sidebar-user {
  padding: 12px;
  min-height: 54px;
}
body.sidebar-collapsed .sidebar-user::before {
  content: "👤";
  display: grid;
  place-items: center;
  font-size: 1.35rem;
}
.mobile-topbar { background: var(--nav) !important; }

.previous-state-box {
  background: rgba(0,0,0,0.035);
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 8px 10px;
}
.previous-state-box pre {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Dashboard centered KPI widgets fix */
.dashboard-widget-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
  justify-content: center;
  align-items: stretch;
  width: 100%;
}
.dashboard-widget-grid > .dashboard-widget {
  flex: 1 1 230px;
  max-width: 280px;
  min-width: 230px;
  display: flex;
}
.dashboard-widget-grid > .dashboard-widget > .card,
.dashboard-widget-grid > .dashboard-widget > .stat-card,
.dashboard-widget-grid > .dashboard-widget > .app-card {
  width: 100%;
  height: 100%;
}
.dashboard-widget-grid .stat-card .card-body {
  min-height: 126px;
}
@media (max-width: 575.98px) {
  .dashboard-widget-grid {
    gap: 14px;
  }
  .dashboard-widget-grid > .dashboard-widget {
    flex-basis: 100%;
    max-width: 100%;
    min-width: 0;
  }
}

/* Dashboard report cards grid helper for future widgets/charts */
.dashboard-report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(420px, 1fr));
  gap: 20px;
  align-items: stretch;
}
@media (max-width: 768px) {
  .dashboard-report-grid {
    grid-template-columns: 1fr;
  }
}

/* Editor daily progress: live mood states and hide/show support */
.editor-score-card-happy {
  background: linear-gradient(135deg, #ffffff 0%, #f0fff7 55%, #dcfce7 100%);
  border-color: rgba(34, 197, 94, 0.22);
}
.editor-score-card-serious {
  background: linear-gradient(135deg, #ffffff 0%, #fffaf0 55%, #fef3c7 100%);
  border-color: rgba(245, 158, 11, 0.25);
}
.editor-score-card-sad {
  background: linear-gradient(135deg, #ffffff 0%, #fff5f5 55%, #fee2e2 100%);
  border-color: rgba(239, 68, 68, 0.25);
}
.score-face-happy,
.score-face-ok {
  filter: drop-shadow(0 10px 16px rgba(34, 197, 94, 0.18));
}
.score-face-serious {
  filter: drop-shadow(0 10px 16px rgba(245, 158, 11, 0.18));
}
.score-face-sad {
  filter: drop-shadow(0 10px 16px rgba(239, 68, 68, 0.18));
}
.editor-momentum-alert {
  border-radius: 14px;
  border: 1px solid rgba(15, 23, 42, 0.08);
  font-size: .92rem;
}
.editor-momentum-happy,
.editor-momentum-ok {
  background: rgba(34, 197, 94, 0.10);
  color: #166534;
}
.editor-momentum-serious {
  background: rgba(245, 158, 11, 0.12);
  color: #92400e;
}
.editor-momentum-sad {
  background: rgba(239, 68, 68, 0.10);
  color: #991b1b;
}
#editorScoreWidgetShow .btn {
  border-radius: 999px;
  padding: .5rem .9rem;
}

/* Marketing page + Marketing detail widgets */
.business-widget-admin-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
}
.business-widget-admin-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 18px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
}
.business-widget-hidden {
  opacity: .68;
  background: #f8fafc;
}
.business-widget-preview,
.business-widget-text {
  white-space: pre-line;
  color: #334155;
  line-height: 1.55;
}
.widget-category-select {
  min-height: 160px;
}
.business-detail-category-widget {
  border-left: 4px solid var(--accent);
}
.business-detail-widget-stack .card-header span:first-child {
  overflow-wrap: anywhere;
}

/* Business Detail notes widget */
.business-note-widget textarea {
  resize: vertical;
}

.timeline-item .previous-state-box pre {
  white-space: pre-wrap;
}
