/* ================================================================
   HiSG Admin Panel — Complete Stylesheet
   Based on HiSG Admin High-Fidelity Prototype v2
   ================================================================ */

/* ---- CSS Variables ---- */
:root {
  --ink: #172033;
  --muted: #697586;
  --line: #dfe6ee;
  --bg: #f4f7fa;
  --panel: #ffffff;
  --navy: #0b2d4d;
  --gold: #f6c400;
  --gold-light: #fff8e1;
  --teal: #18b6a3;
  --teal-light: #e0f7f4;
  --red: #e84d43;
  --red-light: #fdecea;
  --blue: #3278ff;
  --blue-light: #e8f0fe;
  --shadow: 0 16px 44px rgba(15, 23, 42, 0.08);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.06);
  --radius: 8px;
  --radius-sm: 4px;
  --sidebar-w: 248px;
  --topbar-h: 72px;
  --transition: 0.2s ease;
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
input, select, textarea, button { font-family: inherit; font-size: inherit; }

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c4cdd5; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #a0aab4; }

/* ================================================================
   LOGIN PAGE
   ================================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #0a3d6b 50%, #0b2d4d 100%);
}
.login-card {
  background: var(--panel);
  border-radius: 12px;
  padding: 48px 40px;
  width: 420px;
  max-width: 94vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 36px; }
.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px; height: 56px;
  background: var(--navy);
  color: var(--gold);
  font-size: 24px;
  font-weight: 700;
  border-radius: 12px;
  margin-bottom: 16px;
}
.login-brand h1 { font-size: 22px; color: var(--ink); margin-bottom: 4px; }
.login-brand p { font-size: 14px; color: var(--muted); }
.login-form .form-group { margin-bottom: 20px; }
.login-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border-color var(--transition);
}
.login-form input:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(246,196,0,0.15);
}
.login-error {
  background: var(--red-light);
  color: var(--red);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}
.login-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 12px;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
}

/* ================================================================
   APP SHELL
   ================================================================ */
.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
  background: var(--navy);
  color: #fff;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-mark {
  width: 40px; height: 40px;
  background: var(--gold);
  color: var(--navy);
  font-size: 18px; font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 15px; font-weight: 600; line-height: 1.3; }
.brand-sub { font-size: 11px; color: rgba(255,255,255,0.5); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: rgba(255,255,255,0.65);
  cursor: pointer;
  transition: all var(--transition);
  border-left: 3px solid transparent;
  font-size: 14px;
  user-select: none;
}
.nav-item:hover { color: #fff; background: rgba(255,255,255,0.05); }
.nav-item.active {
  color: var(--gold);
  background: rgba(246,196,0,0.08);
  border-left-color: var(--gold);
}
.nav-icon { font-size: 18px; width: 24px; text-align: center; flex-shrink: 0; }
.nav-label { white-space: nowrap; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 10px;
}

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
}
.sidebar-version {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
}

/* ---- Topbar ---- */
.topbar {
  position: sticky;
  top: 0;
  height: var(--topbar-h);
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
  z-index: 50;
  gap: 16px;
}
.topbar-left { display: flex; align-items: center; gap: 16px; }
.sidebar-toggle {
  background: none; border: none;
  font-size: 20px; cursor: pointer;
  color: var(--muted); padding: 4px 8px;
  border-radius: var(--radius-sm);
}
.sidebar-toggle:hover { background: var(--bg); }
.topbar-project { font-size: 15px; font-weight: 600; color: var(--ink); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar-search input {
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 20px;
  width: 240px;
  font-size: 13px;
  background: var(--bg);
  transition: all var(--transition);
}
.topbar-search input:focus { outline: none; border-color: var(--gold); background: #fff; width: 300px; }
.env-pill {
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 12px;
  background: var(--teal-light);
  color: #0a6e62;
  font-weight: 500;
  white-space: nowrap;
}
.icon-btn {
  background: none; border: none;
  font-size: 18px; cursor: pointer;
  padding: 6px; border-radius: var(--radius-sm);
  position: relative; color: var(--muted);
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }
.icon-btn.has-badge .badge {
  position: absolute;
  top: 0; right: 0;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  min-width: 16px; height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--gold);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px; font-weight: 600;
}
.user-name { font-size: 13px; color: var(--ink); font-weight: 500; }

/* ---- Content Area ---- */
.content-area { padding: 28px; }

/* ---- Pages ---- */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ---- Page Header ---- */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}
.eyebrow { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.page-header h1 { font-size: 24px; font-weight: 700; color: var(--ink); margin-top: 2px; }
.header-actions { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.last-update { font-size: 12px; color: var(--muted); }

/* ================================================================
   BUTTONS
   ================================================================ */
.btn-primary, .btn-secondary, .btn-dark, .btn-outline, .btn-outline-gold, .btn-sm, .btn-block {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
  padding: 10px 20px;
  font-size: 14px;
}
.btn-primary { background: var(--gold); color: var(--navy); }
.btn-primary:hover { background: #e0b000; }
.btn-secondary { background: var(--panel); color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover { background: var(--bg); border-color: #c4cdd5; }
.btn-dark { background: var(--navy); color: #fff; }
.btn-dark:hover { background: #0a3d6b; }
.btn-outline { background: none; color: var(--muted); border: 1px solid var(--line); }
.btn-outline:hover { color: var(--ink); border-color: var(--muted); }
.btn-outline-gold { background: none; color: rgba(255,255,255,0.6); border: 1px solid rgba(255,255,255,0.2); font-size: 11px; padding: 4px 10px; }
.btn-outline-gold:hover { color: var(--gold); border-color: var(--gold); }
.btn-sm { font-size: 12px; padding: 4px 12px; }
.btn-block { width: 100%; }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-teal { background: var(--teal); color: #fff; }
.btn-teal:hover { background: #149d8c; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* ================================================================
   PANELS & CARDS
   ================================================================ */
.panel {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}
.panel h3 {
  font-size: 15px; font-weight: 600;
  color: var(--ink); margin-bottom: 16px;
}

/* ---- Sync Strip ---- */
.sync-strip {
  background: var(--teal-light);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  font-size: 14px;
}
.sync-strip .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--teal); flex-shrink: 0; }
.sync-strip.warning { background: var(--gold-light); }
.sync-strip.warning .dot { background: var(--gold); }
.sync-strip.error { background: var(--red-light); }
.sync-strip.error .dot { background: var(--red); }

/* ---- Metric Grid ---- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--teal);
}
.metric-card.warning { border-left-color: var(--gold); }
.metric-card.danger { border-left-color: var(--red); }
.metric-card .metric-value { font-size: 32px; font-weight: 700; color: var(--ink); line-height: 1.2; }
.metric-card .metric-label { font-size: 13px; color: var(--muted); margin-top: 4px; }
.metric-card .metric-sub { font-size: 12px; color: var(--muted); margin-top: 8px; }

/* ---- Dash Grids ---- */
.dash-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* ---- Risk Items ---- */
.risk-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.risk-item:last-child { border-bottom: none; }
.risk-icon { font-size: 18px; flex-shrink: 0; margin-top: 2px; }
.risk-body { flex: 1; }
.risk-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.risk-desc { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ---- Todo List ---- */
.todo-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.todo-item:last-child { border-bottom: none; }
.todo-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.todo-dot.yellow { background: var(--gold); }
.todo-dot.teal { background: var(--teal); }
.todo-dot.red { background: var(--red); }

/* ---- Phone Preview ---- */
.phone-preview {
  width: 280px;
  margin: 0 auto;
  background: #fff;
  border-radius: 20px;
  border: 3px solid #e0e0e0;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.phone-topbar {
  background: var(--gold);
  color: var(--navy);
  padding: 10px 16px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
}
.phone-body { padding: 12px; font-size: 11px; }
.phone-banner {
  background: var(--bg);
  height: 60px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  margin-bottom: 8px;
}
.phone-row {
  display: flex;
  gap: 6px;
  margin-bottom: 8px;
}
.phone-icon {
  flex: 1;
  background: var(--bg);
  height: 36px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.phone-text {
  background: var(--bg);
  height: 10px;
  border-radius: 3px;
  margin-bottom: 6px;
}
.phone-btn {
  background: var(--gold);
  color: var(--navy);
  text-align: center;
  padding: 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  margin: 8px 0;
}
.phone-tabbar {
  display: flex;
  border-top: 1px solid #f0f0f0;
  padding-top: 6px;
}
.phone-tab {
  flex: 1;
  text-align: center;
  font-size: 10px;
  color: var(--muted);
}

/* ---- Quick Actions ---- */
.quick-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.quick-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}
.quick-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.quick-card .qc-icon { font-size: 28px; margin-bottom: 8px; }
.quick-card .qc-title { font-size: 14px; font-weight: 500; color: var(--ink); }
.quick-card .qc-desc { font-size: 12px; color: var(--muted); margin-top: 4px; }

/* ---- Content Rank ---- */
.rank-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
}
.rank-item:last-child { border-bottom: none; }
.rank-num {
  width: 24px; height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px; font-weight: 700;
  flex-shrink: 0;
}
.rank-num.top { background: var(--gold); color: var(--navy); }
.rank-info { flex: 1; }
.rank-title { font-size: 13px; color: var(--ink); }
.rank-views { font-size: 11px; color: var(--muted); }

/* ================================================================
   FILTER BAR
   ================================================================ */
.filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px 20px;
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.filter-bar input, .filter-bar select {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.filter-bar input { width: 200px; }
.filter-bar input:focus, .filter-bar select:focus { outline: none; border-color: var(--gold); }

/* ================================================================
   TABLES
   ================================================================ */
.table-wrap {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
th {
  text-align: left;
  padding: 14px 16px;
  font-weight: 600;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--line);
  background: #fafbfc;
  white-space: nowrap;
}
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--bg); }
tr.selected td { background: var(--teal-light); }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.content-cell { display: flex; align-items: center; gap: 12px; }
.content-thumb {
  width: 48px; height: 36px;
  border-radius: 4px;
  background: var(--bg);
  object-fit: cover;
  flex-shrink: 0;
}

/* ---- Status Badges ---- */
.badge-pub {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}
.badge-pub.published { background: var(--teal-light); color: #0a6e62; }
.badge-pub.pending { background: var(--gold-light); color: #8a6d00; }
.badge-pub.draft { background: #f0f0f0; color: var(--muted); }
.badge-pub.archived { background: var(--red-light); color: var(--red); }
.badge-sync {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
}
.badge-sync.synced { color: var(--teal); }
.badge-sync.pending { color: var(--gold); }
.badge-sync.backend_only { color: var(--muted); }
.badge-sync::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
}
.badge-sync.synced::before { background: var(--teal); }
.badge-sync.pending::before { background: var(--gold); }
.badge-sync.backend_only::before { background: var(--muted); }

/* ---- Table Pagination ---- */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
  font-size: 13px;
  color: var(--muted);
}
.table-pagination .page-btns { display: flex; gap: 4px; }
.table-pagination button {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  cursor: pointer;
  font-size: 13px;
}
.table-pagination button:hover { background: var(--bg); }
.table-pagination button.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ================================================================
   SYNC INSPECTOR (bottom panel for selected content)
   ================================================================ */
.sync-inspector {
  background: var(--panel);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 24px;
  margin-top: 16px;
  border-top: 3px solid var(--teal);
}
.sync-inspector h3 { margin-bottom: 16px; }
.inspector-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 20px;
}
.inspector-col h4 {
  font-size: 12px;
  color: var(--muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.mini-map-chip {
  display: inline-block;
  padding: 4px 10px;
  background: var(--bg);
  border-radius: 12px;
  font-size: 12px;
  margin: 2px 4px 4px 0;
}
.api-path-code {
  background: #f0f2f5;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", "Consolas", monospace;
  color: var(--ink);
  margin-bottom: 6px;
  display: block;
}
.timeline-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.timeline-item:last-child { border-bottom: none; }
.timeline-time { color: var(--muted); }
.diff-item { padding: 6px 0; font-size: 12px; }
.diff-add { color: var(--teal); }
.diff-remove { color: var(--red); text-decoration: line-through; }

/* ================================================================
   EDITOR LAYOUT
   ================================================================ */
.editor-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
}
.editor-form {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}
.editor-form .form-group { margin-bottom: 20px; }
.editor-form label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 6px;
}
.editor-form input[type="text"],
.editor-form textarea,
.editor-form select {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color var(--transition);
}
.editor-form input:focus,
.editor-form textarea:focus,
.editor-form select:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(246,196,0,0.15);
}
.editor-form textarea { resize: vertical; min-height: 200px; }
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.upload-zone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  color: var(--muted);
  cursor: pointer;
  transition: all var(--transition);
}
.upload-zone:hover { border-color: var(--gold); background: var(--gold-light); }
.upload-preview { max-width: 200px; border-radius: var(--radius-sm); margin-top: 12px; }

/* Toggle Switch */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0;
}
.toggle {
  position: relative;
  width: 44px; height: 24px;
  cursor: pointer;
}
.toggle input { display: none; }
.toggle .track {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 12px;
  transition: background var(--transition);
}
.toggle .thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition);
  box-shadow: var(--shadow-sm);
}
.toggle input:checked + .track { background: var(--teal); }
.toggle input:checked + .track + .thumb { transform: translateX(20px); }

/* Editor Sidebar */
.editor-sidebar > div {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 16px;
}
.side-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.side-metric { text-align: center; }
.side-metric .val { font-size: 22px; font-weight: 700; color: var(--ink); }
.side-metric .lbl { font-size: 11px; color: var(--muted); }
.side-metric .delta { font-size: 11px; }
.side-metric .delta.up { color: var(--teal); }
.side-metric .delta.down { color: var(--red); }
.impact-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.biz-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}
.log-line {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
}
.log-line:last-child { border-bottom: none; }

/* ================================================================
   BUILDER (Home Page Config)
   ================================================================ */
.builder-layout {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 20px;
}
.builder-library {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.lib-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  cursor: grab;
  font-size: 13px;
  transition: all var(--transition);
  display: flex;
  align-items: center;
  gap: 8px;
}
.lib-item:hover { border-color: var(--gold); background: var(--gold-light); }
.lib-icon { font-size: 18px; }
.builder-canvas {
  background: #e8ecf1;
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-height: 600px;
}
.canvas-phone {
  width: 320px;
  margin: 0 auto;
  background: #fff;
  border-radius: 24px;
  border: 3px solid #333;
  overflow: hidden;
  min-height: 500px;
}
.canvas-status-bar {
  background: #f8f9fa;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  display: flex;
  justify-content: space-between;
}
.canvas-body { padding: 16px; }
.canvas-block {
  background: #fff;
  border: 2px dashed transparent;
  padding: 12px;
  margin-bottom: 8px;
  border-radius: 6px;
  position: relative;
  cursor: pointer;
  transition: all var(--transition);
}
.canvas-block:hover { border-color: var(--blue); background: var(--blue-light); }
.canvas-block.selected { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(246,196,0,0.15); }
.canvas-block .block-label {
  font-size: 11px;
  color: var(--muted);
  padding: 4px 8px;
  background: var(--bg);
  border-radius: 4px;
}
.builder-props {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
}
.builder-props .prop-row { margin-bottom: 16px; }
.builder-props label { font-size: 12px; font-weight: 600; color: var(--muted); display: block; margin-bottom: 4px; }
.builder-props input,
.builder-props select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}

/* ================================================================
   KANBAN BOARD
   ================================================================ */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}
.kanban-col {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 16px;
}
.kanban-col h3 {
  font-size: 14px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.kanban-count {
  background: var(--panel);
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted);
}
.kanban-card {
  background: var(--panel);
  border-radius: var(--radius-sm);
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow-sm);
  border-left: 3px solid var(--teal);
}
.kanban-card.lead { border-left-color: var(--gold); }
.kanban-card.done { border-left-color: var(--blue); }
.kanban-card .kc-title { font-weight: 500; font-size: 13px; }
.kanban-card .kc-info { font-size: 12px; color: var(--muted); margin-top: 4px; }
.kanban-card .kc-meta { font-size: 11px; color: var(--muted); margin-top: 6px; display: flex; justify-content: space-between; }
.kanban-card .kc-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

/* ================================================================
   ANALYTICS / CHARTS
   ================================================================ */
.analytics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}
.chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  height: 160px;
  padding-top: 16px;
}
.chart-bar-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}
.chart-bar {
  width: 100%;
  max-width: 48px;
  border-radius: 4px 4px 0 0;
  background: linear-gradient(to top, var(--teal), var(--navy));
  transition: height 0.5s ease;
  min-height: 4px;
}
.chart-bar-label { font-size: 11px; color: var(--muted); }

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 24px;
  justify-content: center;
}
.donut-chart {
  width: 140px; height: 140px;
  border-radius: 50%;
}
.donut-legend { font-size: 12px; }
.donut-legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.donut-swatch {
  width: 10px; height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}

.health-row {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.health-row:last-child { border-bottom: none; }
.health-label { width: 160px; font-size: 13px; font-weight: 500; }
.health-bar-wrap { flex: 1; background: var(--bg); border-radius: 6px; height: 12px; overflow: hidden; }
.health-bar {
  height: 100%;
  border-radius: 6px;
  transition: width 0.6s ease;
}
.health-bar.good { background: var(--teal); }
.health-bar.warn { background: var(--gold); }
.health-bar.bad { background: var(--red); }
.health-val { width: 80px; text-align: right; font-size: 13px; font-weight: 500; }

/* ================================================================
   SYNC CENTER
   =============================================================== */
.sync-hero {
  background: linear-gradient(135deg, var(--navy), #0a3d6b);
  border-radius: var(--radius);
  padding: 28px;
  color: #fff;
  margin-bottom: 20px;
}
.sync-pipeline {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: 12px;
}
.pipeline-stage {
  text-align: center;
  font-size: 13px;
}
.pipeline-stage .stage-icon {
  width: 48px; height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 8px;
  font-size: 22px;
  background: rgba(255,255,255,0.12);
}
.pipeline-arrow { font-size: 24px; color: rgba(255,255,255,0.4); }

.sync-status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.sync-status-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.sync-status-card .ssc-icon { font-size: 28px; margin-bottom: 8px; }
.sync-status-card .ssc-count { font-size: 28px; font-weight: 700; color: var(--ink); }
.sync-status-card .ssc-label { font-size: 12px; color: var(--muted); margin-top: 4px; }

.sync-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.version-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}
.version-card {
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border-top: 3px solid var(--line);
}
.version-card.live { border-top-color: var(--teal); }
.version-card.draft { border-top-color: var(--gold); }
.version-card.prev { border-top-color: var(--blue); }
.version-card .vc-title { font-size: 14px; font-weight: 600; }
.version-card .vc-version { font-size: 11px; color: var(--muted); margin-bottom: 8px; }
.version-card .vc-meta { font-size: 12px; color: var(--muted); }
.version-card .vc-actions { margin-top: 12px; display: flex; gap: 6px; }

/* ================================================================
   MODAL / DIALOG
   ================================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  background: var(--panel);
  border-radius: 12px;
  padding: 28px;
  width: 480px;
  max-width: 94vw;
  box-shadow: 0 24px 80px rgba(0,0,0,0.2);
}
.modal-box h2 { font-size: 18px; margin-bottom: 12px; }
.modal-box .modal-body { font-size: 14px; color: var(--muted); margin-bottom: 24px; line-height: 1.6; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

/* ================================================================
   TOAST / NOTIFICATIONS
   ================================================================ */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}
.toast.success { background: var(--teal); }
.toast.error { background: var(--red); }
.toast.info { background: var(--blue); }
.toast.warning { background: var(--gold); color: var(--navy); }
@keyframes slideIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

/* ---- Loading ---- */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--muted);
  font-size: 14px;
}
.spinner {
  width: 28px; height: 28px;
  border: 3px solid var(--line);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Empty State ---- */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--muted);
}
.empty-state .empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state h4 { color: var(--ink); margin-bottom: 4px; }

/* ================================================================
   RESPONSIVE
   ================================================================ */
@media (max-width: 1320px) {
  .metric-grid { grid-template-columns: repeat(2, 1fr); }
  .sync-status-grid { grid-template-columns: repeat(2, 1fr); }
  .version-cards { grid-template-columns: 1fr; }
  .builder-layout { grid-template-columns: 1fr; }
  .kanban-board { grid-template-columns: 1fr; }
}
@media (max-width: 980px) {
  .app-shell { grid-template-columns: 64px 1fr; }
  .sidebar { width: 64px; }
  .brand-text, .nav-label, .nav-badge, .sidebar-version span, .sidebar-version button { display: none; }
  .sidebar-brand { padding: 16px 12px; justify-content: center; }
  .nav-item { padding: 12px; justify-content: center; }
  .dash-grid-2col, .analytics-grid, .sync-grid-2col { grid-template-columns: 1fr; }
  .editor-layout { grid-template-columns: 1fr; }
  .inspector-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 760px) {
  .content-area { padding: 16px; }
  .metric-grid { grid-template-columns: 1fr; }
  .filter-bar { flex-direction: column; }
  .page-header { flex-direction: column; }
  .header-actions { width: 100%; }
}
