/* ═══════════════════════════════════════════════════════
   Secdrift — Refined Command
   Premium AI assistant + MSP operations center
   ═══════════════════════════════════════════════════════ */

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

/* ── Theme Variables ─────────────────────────────────── */
:root {
  --display: 'Syne', sans-serif;
  --body:    'Outfit', sans-serif;
  --mono:    'JetBrains Mono', monospace;
  --radius:  10px;
  --ease:    cubic-bezier(0.22, 1, 0.36, 1);
}

[data-theme="dark"] {
  --bg:         #09090b;
  --bg-raised:  #111114;
  --bg-overlay: #16161a;
  --surface:    #1c1c21;
  --surface-2:  #232329;
  --border:     #27272a;
  --border-2:   #303036;
  --text:       #fafaf9;
  --text-2:     #a1a1aa;
  --text-3:     #52525b;
  --amber:      #d4a04a;
  --amber-dim:  rgba(212, 160, 74, 0.12);
  --amber-glow: rgba(212, 160, 74, 0.06);
  --green:      #4ade80;
  --red:        #f87171;
  --orange:     #fb923c;
  --blue:       #60a5fa;
  --green-dim:  rgba(74, 222, 128, 0.1);
  --red-dim:    rgba(248, 113, 113, 0.1);
  --orange-dim: rgba(251, 146, 60, 0.1);
  --blue-dim:   rgba(96, 165, 250, 0.1);
  --canvas-alpha: 0.6;
  --toggle-bg: #27272a;
  --toggle-thumb: #3f3f46;
  --chart-grid: rgba(255,255,255,0.04);
  --chart-line: rgba(212, 160, 74, 0.8);
  --chart-fill: rgba(212, 160, 74, 0.08);
  --chart-bar:  rgba(96, 165, 250, 0.6);
}

[data-theme="light"] {
  --bg:         #fafaf9;
  --bg-raised:  #ffffff;
  --bg-overlay: #f5f5f4;
  --surface:    #f0f0ee;
  --surface-2:  #e7e5e4;
  --border:     #d6d3d1;
  --border-2:   #c0bcb8;
  --text:       #1c1917;
  --text-2:     #57534e;
  --text-3:     #a8a29e;
  --amber:      #b8860b;
  --amber-dim:  rgba(184, 134, 11, 0.08);
  --amber-glow: rgba(184, 134, 11, 0.04);
  --green:      #16a34a;
  --red:        #dc2626;
  --orange:     #ea580c;
  --blue:       #2563eb;
  --green-dim:  rgba(22, 163, 74, 0.08);
  --red-dim:    rgba(220, 38, 38, 0.08);
  --orange-dim: rgba(234, 88, 12, 0.08);
  --blue-dim:   rgba(37, 99, 235, 0.08);
  --canvas-alpha: 0.3;
  --toggle-bg: #e7e5e4;
  --toggle-thumb: #ffffff;
  --chart-grid: rgba(0,0,0,0.04);
  --chart-line: rgba(184, 134, 11, 0.8);
  --chart-fill: rgba(184, 134, 11, 0.06);
  --chart-bar:  rgba(37, 99, 235, 0.5);
}

html, body { height: 100%; overflow: hidden; }

body {
  font-family: var(--body);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background 0.4s var(--ease), color 0.4s var(--ease);
}

#ambient-canvas {
  position: fixed; inset: 0; z-index: 0;
  pointer-events: none;
  opacity: var(--canvas-alpha);
  transition: opacity 0.4s var(--ease);
}

/* ── Animations ──────────────────────────────────────── */
.anim-in {
  animation: fadeUp 0.7s var(--ease) both;
}
.anim-d2 { animation-delay: 0.15s; }
.anim-d3 { animation-delay: 0.3s; }
.anim-d4 { animation-delay: 0.45s; }

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Top Bar ─────────────────────────────────────────── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  display: flex; justify-content: space-between; align-items: center;
  padding: 0.75rem 1.25rem;
  background: transparent;
}

.topbar-left { display: flex; align-items: center; gap: 0.6rem; }

.logo {
  width: 28px; height: 28px; border-radius: 7px;
  background: linear-gradient(135deg, var(--amber), color-mix(in srgb, var(--amber), black 20%));
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-family: var(--display); font-weight: 700; font-size: 0.8rem;
}

.topbar-brand {
  font-family: var(--display); font-weight: 600; font-size: 0.9rem;
  color: var(--text); letter-spacing: -0.02em;
}

.topbar-center {
  display: flex; align-items: center; gap: 0.5rem;
  font-family: var(--mono); font-size: 0.7rem; color: var(--text-3);
}

.weather-temp { color: var(--text-2); font-weight: 500; }
.weather-desc { color: var(--text-3); }
.weather-sep { color: var(--border-2); }
.clock { font-variant-numeric: tabular-nums; }

.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg-raised);
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease);
}

.icon-btn:hover { color: var(--text-2); border-color: var(--border-2); }
.icon-btn.active { color: var(--amber); border-color: var(--amber-dim); }

/* ── Theme Toggle (pill pattern) ─────────────────────── */
.theme-toggle {
  width: 52px; height: 28px; border-radius: 14px;
  background: var(--toggle-bg); cursor: pointer;
  position: relative; transition: background 0.3s var(--ease);
  border: 1px solid var(--border);
}

.theme-toggle-thumb {
  width: 22px; height: 22px; border-radius: 11px;
  background: var(--toggle-thumb);
  position: absolute; top: 2px; left: 2px;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.35s var(--ease), background 0.3s var(--ease);
  box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

[data-theme="dark"] .theme-toggle-thumb { transform: translateX(24px); }
[data-theme="dark"] .icon-sun { display: none; }
[data-theme="light"] .icon-moon { display: none; }

.icon-sun, .icon-moon {
  width: 13px; height: 13px;
  stroke: var(--text-2);
  transition: stroke 0.3s var(--ease);
}

/* ── Spotify Inline Indicator ────────────────────────── */
.sp-inline {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 220px;
  overflow: hidden;
}

.sp-inline-art {
  width: 16px; height: 16px; border-radius: 3px;
  background: var(--border);
  background-size: cover; background-position: center;
  flex-shrink: 0;
}

.sp-inline-art.has-art {
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.sp-inline-track {
  color: var(--text-2);
  font-size: 0.65rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 120px;
}

.sp-inline-artist {
  color: var(--text-3);
  font-size: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 80px;
}

/* ── Metric Strip ────────────────────────────────────── */
.metric-strip {
  position: fixed; top: 52px; left: 0; right: 0; z-index: 90;
  display: flex; justify-content: center; gap: 0.35rem;
  padding: 0.4rem 1rem;
}

.metric {
  display: flex; align-items: center; gap: 0.3rem;
  padding: 0.2rem 0.6rem; border-radius: 999px;
  background: var(--bg-raised); border: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.6rem; color: var(--text-3);
  transition: all 0.2s var(--ease);
  cursor: pointer;
}

.metric:hover { border-color: var(--border-2); color: var(--text-2); }

.metric-dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--text-3); transition: background 0.3s;
}

.metric-dot.green { background: var(--green); }
.metric-dot.red { background: var(--red); }
.metric-dot.orange { background: var(--orange); }
.metric-dot.blue { background: var(--blue); }

/* ── Main AI Area ────────────────────────────────────── */
.ai-main {
  position: relative; z-index: 1;
  height: 100vh; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 5.5rem 1.25rem 2rem;
}

/* ── Greeting ────────────────────────────────────────── */
.greeting { text-align: center; }

.greeting h1 {
  font-family: var(--display); font-weight: 700;
  font-size: clamp(1.8rem, 4.5vw, 3rem);
  color: var(--text); letter-spacing: -0.03em; line-height: 1.1;
}

.greeting-sub {
  font-size: 0.9rem; color: var(--text-3);
  margin-top: 0.35rem; font-weight: 300;
}

/* ── Orb ─────────────────────────────────────────────── */
.orb-container {
  display: flex; flex-direction: column; align-items: center;
  gap: 0.75rem; margin: 1.5rem 0; cursor: pointer;
}

.orb {
  position: relative; width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
}

.orb-core {
  width: 44px; height: 44px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, var(--amber), color-mix(in srgb, var(--amber), black 35%));
  box-shadow: 0 0 30px var(--amber-glow), 0 0 60px var(--amber-glow);
  animation: orbIdle 4s ease-in-out infinite;
  transition: all 0.4s var(--ease);
}

.orb-ring {
  position: absolute; border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--amber), transparent 88%);
  transition: all 0.4s var(--ease);
}

.orb-ring.r1 { width: 66px; height: 66px; animation: ringRot 14s linear infinite; }
.orb-ring.r2 { width: 88px; height: 88px; animation: ringRot 20s linear infinite reverse; }
.orb-ring.r3 { width: 110px; height: 110px; animation: ringRot 28s linear infinite; }

@keyframes orbIdle {
  0%, 100% { transform: scale(1); }
  50%      { transform: scale(1.06); }
}

@keyframes ringRot { to { transform: rotate(360deg); } }

/* Orb states */
.orb-container.listening .orb-core {
  width: 52px; height: 52px;
  animation: orbListen 0.8s ease-in-out infinite;
  box-shadow: 0 0 50px color-mix(in srgb, var(--amber), transparent 60%);
}

.orb-container.listening .orb-ring { border-color: color-mix(in srgb, var(--amber), transparent 70%); }
.orb-container.listening .r1 { animation-duration: 3s; }
.orb-container.listening .r2 { animation-duration: 4s; }

@keyframes orbListen {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
}

.orb-container.speaking .orb-core {
  width: 48px; height: 48px;
  animation: orbSpeak 0.5s ease-in-out infinite;
  box-shadow: 0 0 40px color-mix(in srgb, var(--amber), transparent 65%);
}

@keyframes orbSpeak {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}

.orb-container.thinking .orb-core {
  animation: orbThink 1.5s ease-in-out infinite;
}

@keyframes orbThink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

.orb-label {
  font-family: var(--mono); font-size: 0.62rem;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.06em; min-height: 1em;
  transition: color 0.3s;
}

.orb-container.listening .orb-label,
.orb-container.speaking .orb-label { color: var(--amber); }

/* ── Conversation ────────────────────────────────────── */
.conversation {
  width: 100%; max-width: 580px; flex: 1; min-height: 0;
  overflow: hidden; display: flex; flex-direction: column;
}

.convo-messages {
  flex: 1; overflow-y: auto; display: flex; flex-direction: column;
  gap: 0.6rem; padding: 0.5rem 0;
  mask-image: linear-gradient(transparent, black 16px, black calc(100% - 16px), transparent);
  -webkit-mask-image: linear-gradient(transparent, black 16px, black calc(100% - 16px), transparent);
}

.convo-messages::-webkit-scrollbar { width: 2px; }
.convo-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.convo-msg {
  display: flex; flex-direction: column; max-width: 85%;
  animation: msgIn 0.25s var(--ease) both;
}

@keyframes msgIn { from { opacity: 0; transform: translateY(6px); } }

.convo-msg.user { align-self: flex-end; align-items: flex-end; }
.convo-msg.assistant { align-self: flex-start; }

.msg-role {
  font-family: var(--mono); font-size: 0.55rem;
  color: var(--text-3); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 0.15rem;
}

.msg-text {
  font-size: 0.85rem; line-height: 1.5; font-weight: 300;
}

.convo-msg.user .msg-text { color: var(--text); }
.convo-msg.assistant .msg-text { color: var(--text-2); }

/* ── Input Area ──────────────────────────────────────── */
.input-area { width: 100%; max-width: 580px; }

.input-row { display: flex; gap: 0.4rem; align-items: center; }

#chat-input {
  flex: 1; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 0.65rem 0.9rem;
  font-family: var(--body); font-size: 0.85rem; font-weight: 300;
  color: var(--text); outline: none;
  transition: all 0.2s var(--ease);
}

#chat-input::placeholder { color: var(--text-3); }
#chat-input:focus { border-color: var(--border-2); background: var(--surface); }

.input-btn {
  width: 40px; height: 40px; border-radius: var(--radius);
  border: 1px solid var(--border); background: var(--bg-raised);
  color: var(--text-3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s var(--ease); flex-shrink: 0;
}

.input-btn:hover { color: var(--text-2); border-color: var(--border-2); }

.mic-btn { border-radius: 50%; }
.mic-btn:hover { color: var(--amber); border-color: color-mix(in srgb, var(--amber), transparent 60%); }
.mic-btn.listening {
  color: var(--amber); border-color: var(--amber);
  background: var(--amber-dim);
  animation: micPulse 1.5s ease-in-out infinite;
}

@keyframes micPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--amber), transparent 70%); }
  50% { box-shadow: 0 0 0 8px transparent; }
}

.input-meta {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 0.5rem; padding: 0 0.15rem;
}

#input-hint {
  font-family: var(--mono); font-size: 0.58rem; color: var(--text-3);
}

/* Typing dots animation */
.typing-dots {
  display: inline-block;
  letter-spacing: 2px;
  animation: dotPulse 1.2s ease-in-out infinite;
  color: var(--text-3);
}

@keyframes dotPulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Disabled input state */
#chat-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.input-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* Voice toggle active state */
.icon-btn.active {
  color: var(--amber);
}

/* ── Drawer ──────────────────────────────────────────── */
.drawer-overlay {
  position: fixed; inset: 0; z-index: 199;
  background: rgba(0,0,0,0.4); opacity: 0;
  pointer-events: none; transition: opacity 0.35s var(--ease);
}

.drawer-overlay.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  background: var(--bg-raised); border-top: 1px solid var(--border);
  border-radius: 16px 16px 0 0;
  transform: translateY(100%); transition: transform 0.4s var(--ease);
  max-height: 85vh; display: flex; flex-direction: column;
}

.drawer.open { transform: translateY(0); }

.drawer-handle {
  display: flex; justify-content: center; padding: 0.6rem; cursor: pointer;
}

.handle-bar {
  width: 32px; height: 3px; border-radius: 2px; background: var(--border-2);
}

.drawer-header {
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-right: 1rem;
}

.drawer-meta {
  margin-left: auto;
  flex-shrink: 0;
}

.drawer-updated {
  font-family: var(--mono);
  font-size: 0.52rem;
  color: var(--text-3);
}

/* Drawer Tabs */
.drawer-tabs {
  display: flex; gap: 0; padding: 0 1.25rem;
}

.drawer-tab {
  background: none; border: none; cursor: pointer;
  font-family: var(--mono); font-size: 0.65rem;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-3); padding: 0.6rem 0.8rem;
  border-bottom: 2px solid transparent;
  transition: all 0.2s var(--ease);
}

.drawer-tab:hover { color: var(--text-2); }
.drawer-tab.active { color: var(--amber); border-bottom-color: var(--amber); }

.drawer-panel {
  display: none; overflow-y: auto; padding: 1rem 1.25rem 1.5rem;
  max-height: calc(85vh - 100px);
}

.drawer-panel.active { display: block; }

.drawer-panel::-webkit-scrollbar { width: 3px; }
.drawer-panel::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

/* ── News List ───────────────────────────────────────── */
.news-item {
  display: flex; gap: 0.75rem; padding: 0.75rem 0;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s var(--ease);
  cursor: pointer;
}

.news-item:last-child { border-bottom: none; }
.news-item:hover { background: var(--surface); margin: 0 -0.5rem; padding-left: 0.5rem; padding-right: 0.5rem; border-radius: 8px; }

.news-tag {
  flex-shrink: 0; height: 20px; padding: 0 0.4rem;
  border-radius: 4px; font-family: var(--mono);
  font-size: 0.55rem; font-weight: 500;
  text-transform: uppercase; letter-spacing: 0.03em;
  display: flex; align-items: center;
  margin-top: 0.1rem;
}

.news-tag.cyber { background: var(--red-dim); color: var(--red); }
.news-tag.ai    { background: var(--blue-dim); color: var(--blue); }
.news-tag.msp   { background: var(--green-dim); color: var(--green); }
.news-tag.ms    { background: var(--orange-dim); color: var(--orange); }

.news-content { flex: 1; min-width: 0; }

.news-title {
  font-size: 0.82rem; font-weight: 500; color: var(--text);
  line-height: 1.35; margin-bottom: 0.2rem;
}

.news-meta {
  font-family: var(--mono); font-size: 0.6rem; color: var(--text-3);
}

.news-desc {
  font-size: 0.72rem; color: var(--text-3); line-height: 1.4;
  margin-top: 0.25rem;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

/* ── Filter Bar ──────────────────────────────────────── */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.filter-group {
  display: flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.filter-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-3);
  padding: 0.4rem 0.65rem;
  transition: all 0.15s var(--ease);
  border-right: 1px solid var(--border);
}

.filter-btn:last-child { border-right: none; }
.filter-btn:hover { color: var(--text-2); background: var(--bg-overlay); }
.filter-btn.active {
  color: var(--amber);
  background: var(--amber-dim);
}

.filter-label {
  font-family: var(--mono);
  font-size: 0.55rem;
  color: var(--text-3);
  margin-left: auto;
}

.filter-search {
  flex: 1;
  max-width: 200px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.4rem 0.6rem;
  font-family: var(--body);
  font-size: 0.72rem;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s var(--ease);
}

.filter-search::placeholder { color: var(--text-3); }
.filter-search:focus { border-color: var(--border-2); }

/* ── Weekday Grid ────────────────────────────────────── */
.weekday-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.35rem;
  margin-bottom: 1.25rem;
}

.weekday-cell {
  text-align: center;
  padding: 0.5rem 0.2rem;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: border-color 0.15s var(--ease);
}

.weekday-cell:hover { border-color: var(--border-2); }

.weekday-name {
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}

.weekday-value {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.1;
}

.weekday-sub {
  font-family: var(--mono);
  font-size: 0.48rem;
  color: var(--text-3);
  margin-top: 0.1rem;
}

.weekday-bar {
  height: 3px;
  border-radius: 2px;
  margin-top: 0.3rem;
  background: var(--amber-dim);
  overflow: hidden;
}

.weekday-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--amber);
  transition: width 0.4s var(--ease);
}

/* ── Device Row Expandable ───────────────────────────── */
.device-row { cursor: pointer; }

.device-detail {
  display: none;
  grid-column: 1 / -1;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.4rem;
}

.device-row.expanded .device-detail { display: block; }

.device-detail-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.35rem;
}

.device-detail-item {
  padding: 0.3rem 0;
}

.device-detail-label {
  font-family: var(--mono);
  font-size: 0.48rem;
  color: var(--text-3);
  text-transform: uppercase;
}

.device-detail-value {
  font-size: 0.68rem;
  color: var(--text);
  font-weight: 400;
}

/* ── Chart Containers ────────────────────────────────── */
.chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  margin-bottom: 1.25rem;
  position: relative;
  height: 220px;
}

.chart-container.chart-sm { height: 160px; }

.chart-container canvas {
  width: 100% !important;
  height: 100% !important;
}

/* ── Chart Stats Row ─────────────────────────────────── */
.chart-stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.chart-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.65rem 0.5rem;
  text-align: center;
  transition: border-color 0.2s var(--ease);
}

.chart-stat:hover { border-color: var(--border-2); }

.chart-stat-value {
  font-family: var(--display);
  font-size: 1.3rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}

.chart-stat-value.green { color: var(--green); }
.chart-stat-value.red { color: var(--red); }
.chart-stat-value.orange { color: var(--orange); }
.chart-stat-value.blue { color: var(--blue); }
.chart-stat-value.amber { color: var(--amber); }

.chart-stat-label {
  font-family: var(--mono);
  font-size: 0.52rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 0.2rem;
}

.chart-stat-diff {
  font-family: var(--mono);
  font-size: 0.5rem;
  margin-top: 0.1rem;
}

.chart-stat-diff.up { color: var(--green); }
.chart-stat-diff.down { color: var(--red); }

/* ── Monthly Comparison ──────────────────────────────── */
.compare-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.compare-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.7rem;
}

.compare-card-title {
  font-family: var(--mono);
  font-size: 0.55rem;
  color: var(--text-3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
}

.compare-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 0.2rem;
}

.compare-label {
  font-size: 0.7rem;
  color: var(--text-2);
}

.compare-value {
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text);
}

.compare-value.green { color: var(--green); }
.compare-value.red { color: var(--red); }

/* ── Product Stats ───────────────────────────────────── */
.product-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.product-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.6rem 0.4rem;
  text-align: center;
}

.product-stat-value {
  font-family: var(--display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.product-stat-value.red { color: var(--red); }
.product-stat-value.orange { color: var(--orange); }
.product-stat-value.green { color: var(--green); }

.product-stat-label {
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 0.15rem;
}

/* ── Device Overview ─────────────────────────────────── */
.device-overview-row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.25rem;
  align-items: flex-start;
}

.device-chart-wrap {
  flex-shrink: 0;
  width: 140px;
  height: 140px;
  position: relative;
}

.device-chart-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
}

.device-chart-center .count {
  font-family: var(--display);
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.device-chart-center .label {
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--text-3);
  text-transform: uppercase;
}

.device-stats {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
}

.device-stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
}

.device-stat-val {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.device-stat-val.green { color: var(--green); }
.device-stat-val.red { color: var(--red); }
.device-stat-val.orange { color: var(--orange); }
.device-stat-val.blue { color: var(--blue); }

.device-stat-lbl {
  font-family: var(--mono);
  font-size: 0.5rem;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 0.15rem;
}

/* ── Patch Stats ─────────────────────────────────────── */
.patch-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.4rem;
  margin-bottom: 1.25rem;
}

.patch-stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem 0.4rem;
  text-align: center;
}

.patch-stat-val {
  font-family: var(--display);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.patch-stat-lbl {
  font-family: var(--mono);
  font-size: 0.48rem;
  color: var(--text-3);
  text-transform: uppercase;
  margin-top: 0.15rem;
}

/* ── Device List ─────────────────────────────────────── */
.device-list { display: flex; flex-direction: column; gap: 0.35rem; }

.device-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.5rem 0.65rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  transition: border-color 0.15s var(--ease);
}

.device-row:hover { border-color: var(--border-2); }

.device-status-dot {
  width: 7px; height: 7px; border-radius: 50%;
}

.device-status-dot.online { background: var(--green); box-shadow: 0 0 4px var(--green-dim); }
.device-status-dot.offline { background: var(--red); box-shadow: 0 0 4px var(--red-dim); }

.device-name {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.device-os {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--text-3);
  white-space: nowrap;
}

.device-uptime {
  font-family: var(--mono);
  font-size: 0.58rem;
  color: var(--text-3);
  white-space: nowrap;
}

.device-badges {
  display: flex;
  gap: 0.25rem;
  flex-shrink: 0;
}

.device-badge {
  font-family: var(--mono);
  font-size: 0.5rem;
  font-weight: 500;
  padding: 0.1rem 0.3rem;
  border-radius: 3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.device-badge.reboot { background: var(--orange-dim); color: var(--orange); }
.device-badge.threats { background: var(--red-dim); color: var(--red); }
.device-badge.patches { background: var(--blue-dim); color: var(--blue); }
.device-badge.healthy { background: var(--green-dim); color: var(--green); }

/* ── Forecast Row ────────────────────────────────────── */
.forecast-row {
  display: flex; gap: 0.5rem; margin-bottom: 1.25rem;
}

.forecast-day {
  flex: 1; text-align: center; padding: 0.6rem 0.4rem;
  background: var(--surface); border-radius: 8px;
  border: 1px solid var(--border);
}

.fd-name { font-family: var(--mono); font-size: 0.55rem; color: var(--text-3); text-transform: uppercase; }
.fd-temp { font-family: var(--display); font-size: 1.1rem; font-weight: 700; color: var(--text); margin: 0.15rem 0; }
.fd-desc { font-size: 0.6rem; color: var(--text-3); }
.fd-low  { font-family: var(--mono); font-size: 0.5rem; color: var(--text-3); margin-top: 0.1rem; }

/* ── Dashboard Grid ──────────────────────────────────── */
.section-label {
  font-family: var(--mono); font-size: 0.6rem;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-3); margin-bottom: 0.6rem;
}

.dash-grid {
  display: grid; grid-template-columns: repeat(3, 1fr);
  gap: 0.6rem;
}

.dash-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color 0.2s var(--ease);
}

.dash-card:hover { border-color: var(--border-2); }

.dc-head {
  display: flex; align-items: center; gap: 0.4rem;
  padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border);
  font-family: var(--mono); font-size: 0.58rem;
  text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-3);
}

.dc-head svg { flex-shrink: 0; }
.dc-head span:first-of-type { flex: 1; }

.dc-badge {
  font-family: var(--mono); font-size: 0.55rem; font-weight: 500;
}

.dc-badge.ok { color: var(--green); }
.dc-badge.warn { color: var(--orange); }
.dc-badge.error { color: var(--red); }

.dc-body {
  padding: 0.5rem 0.7rem; max-height: 200px; overflow-y: auto; font-size: 0.72rem;
}

.dc-body::-webkit-scrollbar { width: 2px; }
.dc-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Shared item styles ──────────────────────────────── */
.item {
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 0.35rem 0; border-bottom: 1px solid var(--border); gap: 0.4rem;
}
.item:last-child { border-bottom: none; }
.item-title { font-size: 0.72rem; font-weight: 500; color: var(--text); line-height: 1.3; }
.item-sub { font-size: 0.6rem; color: var(--text-3); font-family: var(--mono); }
.item-right { text-align: right; flex-shrink: 0; }
.item-time { font-size: 0.68rem; color: var(--amber); font-weight: 500; font-family: var(--mono); }
.item-countdown { font-size: 0.55rem; color: var(--text-3); font-family: var(--mono); }

.stat-row { display: flex; gap: 2px; margin-bottom: 0.4rem; }
.stat { flex: 1; text-align: center; padding: 0.35rem 0.2rem; background: var(--bg); border-radius: 5px; }
.stat-value { font-family: var(--display); font-size: 1.1rem; font-weight: 700; line-height: 1; }
.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.orange { color: var(--orange); }
.stat-value.blue { color: var(--blue); }
.stat-value.text { color: var(--text); }
.stat-label { font-family: var(--mono); font-size: 0.5rem; color: var(--text-3); text-transform: uppercase; margin-top: 0.15rem; }
.stat-diff { font-family: var(--mono); font-size: 0.5rem; margin-top: 0.1rem; }
.stat-diff.up { color: var(--green); }
.stat-diff.down { color: var(--red); }
.stat-diff.flat { color: var(--text-3); }

.sev-tag {
  display: inline-block; padding: 0.1rem 0.3rem; border-radius: 3px;
  font-family: var(--mono); font-size: 0.5rem; font-weight: 500; text-transform: uppercase;
}
.sev-critical { background: var(--red-dim); color: var(--red); }
.sev-major, .sev-warning { background: var(--orange-dim); color: var(--orange); }
.sev-minor, .sev-info { background: color-mix(in srgb, var(--text-3), transparent 85%); color: var(--text-3); }
.sev-failed { background: var(--red-dim); color: var(--red); }

.empty { color: var(--text-3); font-size: 0.72rem; text-align: center; padding: 1rem 0; font-style: italic; }
.error-msg { color: var(--red); font-size: 0.68rem; font-family: var(--mono); }

.count-badge { font-family: var(--mono); font-size: 0.55rem; font-weight: 500; }
.count-badge.alert { color: var(--red); }
.count-badge.warn { color: var(--orange); }
.count-badge.ok { color: var(--green); }

.skel { height: 8px; background: var(--border); border-radius: 4px; margin-bottom: 8px; animation: shimmer 1.5s ease-in-out infinite alternate; }
.skel.w60 { width: 60%; }
@keyframes shimmer { from { opacity: 0.3; } to { opacity: 0.5; } }

.hidden { display: none !important; }

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 1024px) {
  .dash-grid { grid-template-columns: repeat(2, 1fr); }
  .chart-stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .ai-main { padding: 5rem 1rem 1.5rem; }
  .greeting h1 { font-size: 1.6rem; }
  .topbar-center { display: none; }
  .orb { width: 90px; height: 90px; }
  .orb-core { width: 36px; height: 36px; }
  .orb-ring.r1 { width: 54px; height: 54px; }
  .orb-ring.r2 { width: 72px; height: 72px; }
  .orb-ring.r3 { width: 90px; height: 90px; }
  .conversation, .input-area { max-width: 100%; }
  .dash-grid { grid-template-columns: 1fr; }
  .metric-strip { flex-wrap: wrap; }
  .metric { font-size: 0.55rem; }
  .chart-stats-row { grid-template-columns: repeat(2, 1fr); }
  .product-stats { grid-template-columns: repeat(2, 1fr); }
  .device-overview-row { flex-direction: column; align-items: center; }
  .device-row { grid-template-columns: auto 1fr auto; }
  .device-os, .device-uptime { display: none; }
  .patch-stats { grid-template-columns: repeat(2, 1fr); }
  .filter-bar { flex-wrap: wrap; }
  .filter-search { max-width: 100%; }
  .weekday-grid { grid-template-columns: repeat(4, 1fr); }
  .device-detail-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ── Analyses Panel ─────────────────────────────────── */
.analyses-header {
  padding: 0 0 12px;
}

.analyses-info {
  font-size: 0.75rem;
  color: var(--text-3);
  font-family: 'Outfit', sans-serif;
  line-height: 1.5;
}

.analyses-info em {
  color: var(--amber);
  font-style: italic;
}

.analyses-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.analysis-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.analysis-card:hover {
  border-color: var(--amber);
}

.analysis-card-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  cursor: pointer;
  user-select: none;
}

.analysis-cat {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
  margin-top: 2px;
}

.analysis-cat.market { background: rgba(59,130,246,0.15); color: var(--blue); }
.analysis-cat.sales { background: rgba(34,197,94,0.15); color: var(--green); }
.analysis-cat.operations { background: rgba(249,115,22,0.15); color: var(--orange); }
.analysis-cat.security { background: rgba(239,68,68,0.15); color: var(--red); }
.analysis-cat.general { background: rgba(212,160,74,0.15); color: var(--amber); }

.analysis-info {
  flex: 1;
  min-width: 0;
}

.analysis-title {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-1);
  margin-bottom: 3px;
}

.analysis-summary {
  font-size: 0.72rem;
  color: var(--text-3);
  line-height: 1.4;
}

.analysis-date {
  font-size: 0.6rem;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 3px;
}

.analysis-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 2px;
}

.analysis-actions button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-3);
  padding: 3px 6px;
  cursor: pointer;
  font-size: 0.6rem;
  transition: all 0.2s;
}

.analysis-actions button:hover {
  border-color: var(--red);
  color: var(--red);
}

.analysis-expand {
  color: var(--text-3);
  font-size: 0.7rem;
  transition: transform 0.2s;
  flex-shrink: 0;
  margin-top: 4px;
}

.analysis-card.open .analysis-expand {
  transform: rotate(180deg);
}

.analysis-body {
  display: none;
  padding: 0 14px 14px;
  border-top: 1px solid var(--border);
}

.analysis-card.open .analysis-body {
  display: block;
}

.analysis-content {
  font-size: 0.75rem;
  line-height: 1.7;
  color: var(--text-2);
  font-family: 'Outfit', sans-serif;
}

.analysis-content h1,
.analysis-content h2,
.analysis-content h3 {
  font-family: 'Syne', sans-serif;
  color: var(--text-1);
  margin: 16px 0 8px;
}

.analysis-content h1 { font-size: 1rem; }
.analysis-content h2 { font-size: 0.88rem; }
.analysis-content h3 { font-size: 0.8rem; }

.analysis-content p {
  margin: 6px 0;
}

.analysis-content ul,
.analysis-content ol {
  padding-left: 20px;
  margin: 6px 0;
}

.analysis-content li {
  margin: 3px 0;
}

.analysis-content strong {
  color: var(--amber);
}

.analysis-content code {
  background: var(--bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.7rem;
}

.analysis-sources {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.analysis-source-tag {
  font-size: 0.55rem;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg);
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

.analyses-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-3);
  font-size: 0.8rem;
}

.analyses-empty-icon {
  font-size: 2rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

@media (max-height: 600px) {
  .drawer { max-height: 95vh; }
}
