* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --primary: #1A73E8;
  --primary-dark: #1557B0;
  --dark: #1B2631;
  --dark-lighter: #2C3E50;
  --accent: #E8710A;
  --accent-light: #FFF3E0;
  --success: #1E8E3E;
  --success-light: #E6F4EA;
  --error: #D93025;
  --error-light: #FCE8E6;
  --warning: #F9AB00;
  --warning-light: #FEF7E0;
  --light-bg: #F8F9FA;
  --border: #DADCE0;
  --white: #FFFFFF;
  --text: #3C4043;
  --text-secondary: #5F6368;
  --text-muted: #80868B;
  --sidebar-w: 240px;
}
body { font-family: 'Google Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--light-bg); color: var(--text); }

/* Sidebar */
.sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--dark); color: #fff; z-index: 100; display: flex; flex-direction: column;
  transition: width 0.2s;
}
.sidebar-header {
  padding: 20px 16px; border-bottom: 1px solid var(--dark-lighter);
  display: flex; align-items: center; gap: 12px;
}
.sidebar-logo {
  width: 36px; height: 36px; background: var(--primary); border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 16px;
}
.sidebar-brand { font-size: 18px; font-weight: 600; letter-spacing: -0.3px; }
.sidebar-brand span { color: var(--accent); }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-section { padding: 8px 16px 4px; font-size: 11px; text-transform: uppercase; color: var(--text-muted); letter-spacing: 0.5px; margin-top: 8px; }
.nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer;
  color: #B0BEC5; font-size: 14px; transition: all 0.15s; border-left: 3px solid transparent;
}
.nav-item:hover { background: var(--dark-lighter); color: #fff; }
.nav-item.active { background: rgba(26,115,232,0.15); color: #fff; border-left-color: var(--primary); }
.nav-item svg { width: 20px; height: 20px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto; background: var(--accent); color: #fff; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
}
.sidebar-footer { padding: 16px; border-top: 1px solid var(--dark-lighter); }
.license-badge {
  background: linear-gradient(135deg, var(--primary), #4285F4); border-radius: 8px;
  padding: 12px; font-size: 12px;
}
.license-badge .tier { font-weight: 700; font-size: 14px; }
.license-badge .expires { color: #90CAF9; margin-top: 4px; }

/* Main content */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.topbar {
  background: var(--white); border-bottom: 1px solid var(--border);
  padding: 12px 24px; display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.breadcrumb { font-size: 14px; color: var(--text-muted); }
.breadcrumb span { color: var(--text); font-weight: 500; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.site-selector {
  border: 1px solid var(--border); border-radius: 6px; padding: 6px 12px;
  font-size: 13px; background: var(--white); color: var(--text); cursor: pointer;
}
.topbar-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; background: transparent;
  color: var(--text-secondary); transition: background 0.15s;
}
.topbar-btn:hover { background: var(--light-bg); }
.content { padding: 24px; }

/* Pages */
.page { display: none; }
.page.active { display: block; }

/* Cards */
.card {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 20px; margin-bottom: 16px;
}
.card-title { font-size: 14px; color: var(--text-secondary); font-weight: 500; margin-bottom: 12px; display: flex; align-items: center; justify-content: space-between; }
.card-value { font-size: 32px; font-weight: 600; color: var(--text); }
.card-delta { font-size: 13px; margin-top: 4px; display: flex; align-items: center; gap: 4px; }
.card-delta.up { color: var(--success); }
.card-delta.down { color: var(--error); }

/* Grid */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 24px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 24px; }
.grid-2-1 { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; margin-bottom: 24px; }
.grid-1-2 { display: grid; grid-template-columns: 1fr 2fr; gap: 16px; margin-bottom: 24px; }

/* Health Score */
.health-ring {
  width: 120px; height: 120px; position: relative; margin: 0 auto 16px;
}
.health-ring svg { transform: rotate(-90deg); }
.health-ring .value {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 32px; font-weight: 700; color: var(--text);
}
.health-ring .label {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, calc(-50% + 20px));
  font-size: 11px; color: var(--text-muted); text-transform: uppercase;
}

/* Chart placeholder */
.chart-area {
  background: var(--light-bg); border-radius: 6px; height: 200px;
  display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden;
}
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 160px; padding: 0 20px; width: 100%; }
.chart-bar {
  flex: 1; background: var(--primary); border-radius: 3px 3px 0 0; transition: height 0.5s;
  position: relative; min-width: 0;
}
.chart-bar:hover { background: var(--primary-dark); }
.chart-bar.accent { background: var(--accent); }
.chart-bar.accent:hover { background: #C75F08; }

/* Link Graph Visualization */
.graph-container {
  background: var(--white); border-radius: 8px; height: 500px; position: relative;
  overflow: hidden; border: 1px solid var(--border);
}
.graph-canvas { width: 100%; height: 100%; }
.graph-node {
  position: absolute; border-radius: 50%; display: flex; align-items: center;
  justify-content: center; font-size: 10px; color: #fff; font-weight: 600;
  cursor: pointer; transition: transform 0.2s; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.graph-node:hover { transform: scale(1.15); z-index: 10; }
.graph-node .tooltip {
  display: none; position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%); background: var(--dark); color: #fff; padding: 8px 12px;
  border-radius: 6px; font-size: 12px; white-space: nowrap; font-weight: 400;
}
.graph-node:hover .tooltip { display: block; }
.graph-line { position: absolute; background: var(--border); transform-origin: left center; height: 1px; z-index: 0; }
.graph-legend { position: absolute; bottom: 16px; right: 16px; background: var(--white); border: 1px solid var(--border); border-radius: 8px; padding: 12px 16px; font-size: 12px; }
.graph-legend-item { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.graph-legend-dot { width: 12px; height: 12px; border-radius: 50%; }

/* Suggestions Table */
.suggestions-table { width: 100%; border-collapse: collapse; }
.suggestions-table th {
  text-align: left; padding: 10px 12px; font-size: 12px; color: var(--text-secondary);
  border-bottom: 2px solid var(--border); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px;
}
.suggestions-table td { padding: 12px; border-bottom: 1px solid var(--light-bg); font-size: 14px; }
.suggestions-table tr:hover td { background: var(--light-bg); }
.impact-bar { display: flex; gap: 2px; }
.impact-star { width: 14px; height: 14px; }
.impact-star.filled { color: var(--warning); }
.impact-star.empty { color: var(--border); }
.btn {
  padding: 6px 16px; border-radius: 4px; border: none; cursor: pointer;
  font-size: 13px; font-weight: 500; transition: all 0.15s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--border); }
.btn-outline:hover { background: var(--light-bg); }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: #C75F08; }
.btn-sm { padding: 4px 12px; font-size: 12px; }

/* Cluster Cards */
.cluster-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; transition: box-shadow 0.15s; cursor: pointer;
}
.cluster-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }
.cluster-header { display: flex; justify-content: space-between; align-items: start; margin-bottom: 12px; }
.cluster-name { font-weight: 600; font-size: 15px; }
.cluster-badge { font-size: 11px; padding: 3px 8px; border-radius: 12px; font-weight: 500; }
.cluster-badge.healthy { background: var(--success-light); color: var(--success); }
.cluster-badge.warning { background: var(--warning-light); color: #E37400; }
.cluster-badge.critical { background: var(--error-light); color: var(--error); }
.cluster-stat { display: flex; justify-content: space-between; font-size: 13px; padding: 4px 0; color: var(--text-secondary); }
.cluster-stat span:last-child { font-weight: 500; color: var(--text); }
.cluster-bar { height: 4px; background: var(--light-bg); border-radius: 2px; margin-top: 8px; overflow: hidden; }
.cluster-bar-fill { height: 100%; border-radius: 2px; transition: width 0.5s; }

/* AI Advisor */
.insight-card {
  background: var(--white); border: 1px solid var(--border); border-radius: 8px;
  padding: 16px; margin-bottom: 12px; border-left: 4px solid var(--primary);
}
.insight-card.high { border-left-color: var(--error); }
.insight-card.medium { border-left-color: var(--warning); }
.insight-card.low { border-left-color: var(--success); }
.insight-priority { font-size: 11px; text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px; margin-bottom: 6px; }
.insight-card.high .insight-priority { color: var(--error); }
.insight-card.medium .insight-priority { color: #E37400; }
.insight-card.low .insight-priority { color: var(--success); }
.insight-title { font-weight: 600; font-size: 15px; margin-bottom: 6px; }
.insight-desc { font-size: 13px; color: var(--text-secondary); line-height: 1.5; }
.insight-action { margin-top: 10px; }

/* SGE Score */
.sge-score-ring {
  width: 80px; height: 80px; position: relative;
}
.sge-score-ring .value {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  font-size: 22px; font-weight: 700;
}
.sge-factor { display: flex; align-items: center; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--light-bg); }
.sge-factor-name { font-size: 13px; color: var(--text-secondary); }
.sge-factor-bar { width: 120px; height: 6px; background: var(--light-bg); border-radius: 3px; overflow: hidden; }
.sge-factor-fill { height: 100%; border-radius: 3px; }

/* License Page */
.license-input-group { display: flex; gap: 8px; margin-bottom: 16px; }
.license-input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border); border-radius: 6px;
  font-size: 14px; font-family: 'Courier New', monospace; letter-spacing: 1px;
}
.license-input:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(26,115,232,0.1); }
.license-status {
  display: flex; align-items: center; gap: 12px; padding: 16px; border-radius: 8px; margin-bottom: 16px;
}
.license-status.active { background: var(--success-light); border: 1px solid #A8DAB5; }
.license-status.expired { background: var(--error-light); border: 1px solid #F5C6C2; }
.license-dot { width: 10px; height: 10px; border-radius: 50%; }
.license-dot.active { background: var(--success); }
.license-dot.expired { background: var(--error); }

/* Settings */
.setting-group { margin-bottom: 24px; }
.setting-group h3 { font-size: 16px; font-weight: 600; margin-bottom: 12px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.setting-row { display: flex; justify-content: space-between; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--light-bg); }
.setting-label { font-size: 14px; }
.setting-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.toggle { width: 44px; height: 24px; border-radius: 12px; background: var(--border); position: relative; cursor: pointer; transition: background 0.2s; }
.toggle.on { background: var(--primary); }
.toggle-dot { width: 20px; height: 20px; border-radius: 50%; background: #fff; position: absolute; top: 2px; left: 2px; transition: left 0.2s; box-shadow: 0 1px 3px rgba(0,0,0,0.2); }
.toggle.on .toggle-dot { left: 22px; }
.radio-group { display: flex; gap: 12px; }
.radio-option {
  border: 2px solid var(--border); border-radius: 8px; padding: 16px; cursor: pointer;
  flex: 1; transition: all 0.15s; text-align: center;
}
.radio-option.selected { border-color: var(--primary); background: rgba(26,115,232,0.04); }
.radio-option-title { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.radio-option-desc { font-size: 12px; color: var(--text-muted); }

/* Changelog */
.changelog-item {
  display: flex; gap: 16px; padding: 12px 0; border-bottom: 1px solid var(--light-bg);
  align-items: center;
}
.changelog-icon {
  width: 32px; height: 32px; border-radius: 6px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0; font-size: 14px;
}
.changelog-icon.added { background: var(--success-light); color: var(--success); }
.changelog-icon.removed { background: var(--error-light); color: var(--error); }
.changelog-icon.auto { background: var(--accent-light); color: var(--accent); }
.changelog-info { flex: 1; }
.changelog-action { font-size: 14px; }
.changelog-meta { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.changelog-undo { flex-shrink: 0; }

/* Page header */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 24px; font-weight: 600; color: var(--text); }
.page-subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* Tabs */
.tabs { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 24px; }
.tab {
  padding: 10px 20px; font-size: 14px; color: var(--text-secondary); cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: all 0.15s; font-weight: 500;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* Animations */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.card, .cluster-card, .insight-card { animation: fadeIn 0.3s ease; }

/* Responsive note */
.responsive-note { display: none; padding: 20px; text-align: center; color: var(--text-muted); font-size: 14px; }
@media (max-width: 900px) {
  .sidebar { width: 60px; }
  .sidebar .sidebar-brand, .sidebar .nav-item span, .sidebar .nav-badge, .sidebar .nav-section, .sidebar-footer { display: none; }
  .main { margin-left: 60px; }
  .grid-4, .grid-3 { grid-template-columns: 1fr 1fr; }
  .nav-item { justify-content: center; padding: 12px; }
}

/* Loading indicator */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.data-loading {
  opacity: 0.5;
  pointer-events: none;
  position: relative;
}
.data-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
