/* PowerHouse Modern UI - React Design Match */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ============================================
   CSS VARIABLES - DARKER THEME
   ============================================ */

:root {
  /* Much darker background */
  --background: 0 0% 6%;
  --foreground: 0 0% 98%;

  --card: 0 0% 8%;
  --card-foreground: 0 0% 98%;

  --popover: 0 0% 10%;
  --popover-foreground: 0 0% 98%;

  /* Cyan accent */
  --primary: 190 100% 50%;
  --primary-foreground: 0 0% 0%;

  --secondary: 0 0% 12%;
  --secondary-foreground: 0 0% 98%;

  --muted: 0 0% 12%;
  --muted-foreground: 0 0% 50%;

  --accent: 0 0% 12%;
  --accent-foreground: 0 0% 98%;

  --destructive: 0 72% 51%;
  --destructive-foreground: 0 0% 100%;

  --success: 142 71% 45%;
  --success-foreground: 0 0% 100%;

  --warning: 38 92% 50%;
  --warning-foreground: 0 0% 9%;

  --processing: 217 91% 60%;
  --processing-foreground: 0 0% 100%;

  --border: 0 0% 15%;
  --input: 0 0% 12%;
  --ring: 190 100% 50%;

  --radius: 0.5rem;

  /* Subtle shadows */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.6);
}

.dark {
  --background: 222 47% 11%;
  /* Deep rich blue/slate */
  --foreground: 210 40% 98%;

  --card: 217 33% 17%;
  --card-foreground: 210 40% 98%;

  --popover: 222 47% 11%;
  --popover-foreground: 210 40% 98%;

  --primary: 199 89% 60%;
  /* Vibrant Cyan/Blue */
  --primary-foreground: 0 0% 100%;

  --secondary: 217 19% 27%;
  --secondary-foreground: 210 40% 98%;

  --muted: 217 19% 27%;
  --muted-foreground: 215 20% 65%;

  --accent: 217 19% 27%;
  --accent-foreground: 210 40% 98%;

  --destructive: 0 62.8% 30.6%;
  --destructive-foreground: 210 40% 98%;

  --border: 217 33% 25%;
  /* Lighter border for glass effect */
  --input: 217 33% 17%;
  --ring: 199 89% 60%;

  --glass-border: 255 255% 255% / 0.15;
  --glass-bg: 217 33% 17% / 0.75;
  /* Increased opacity for better contrast */
}

/* Animated Gradient Background */
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: hsl(var(--background));
  background-image:
    radial-gradient(at 0% 0%, hsla(253, 16%, 7%, 1) 0, transparent 50%),
    radial-gradient(at 50% 0%, hsla(225, 39%, 30%, 1) 0, transparent 50%),
    radial-gradient(at 100% 0%, hsla(339, 49%, 30%, 1) 0, transparent 50%);
  background-attachment: fixed;
  background-size: cover;
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

/* Spinner & Loading */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid hsl(var(--primary-foreground) / 0.3);
  border-radius: 50%;
  border-top-color: hsl(var(--primary-foreground));
  animation: spin 1s linear infinite;
  vertical-align: middle;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 4px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: hsla(0, 0%, 0%, 0.85);
  backdrop-filter: blur(8px);
  z-index: 9999;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

/* Status Messages */
.status-message {
  margin-top: 20px;
  padding: 16px;
  border-radius: var(--radius);
  display: none;
  font-size: 14px;
  animation: fadeUp 0.3s ease-out;
}

.status-success {
  background: hsl(var(--success) / 0.1);
  color: hsl(var(--success));
  border: 1px solid hsl(var(--success) / 0.2);
}

.status-error {
  background: hsl(var(--destructive) / 0.1);
  color: hsl(var(--destructive));
  border: 1px solid hsl(var(--destructive) / 0.2);
}

.status-info {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

/* ============================================
   BASE STYLES
   ============================================ */

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  border-color: hsl(var(--border));
}

html {
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  line-height: 1.5;
  min-height: 100vh;
  font-size: 14px;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: hsl(var(--muted-foreground) / 0.2);
  border-radius: 100px;
}

::-webkit-scrollbar-thumb:hover {
  background: hsl(var(--muted-foreground) / 0.3);
}

/* ============================================
   LAYOUT
   ============================================ */

.app-container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0;
}

.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================
   HEADER - HORIZONTAL NAVIGATION
   ============================================ */

/* Glass Header */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  width: 100%;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(15, 23, 42, 0.85);
  /* Darker, less transparent header */
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
}

.header-container {
  display: flex;
  height: 56px;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  gap: 32px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  flex-shrink: 0;
}

.logo-icon {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: hsl(var(--primary));
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-title {
  font-size: 15px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 1;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-decoration: none;
  border-radius: 6px;
  transition: all 0.15s;
}

.nav-link:hover {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.nav-link.active {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 6px;
  background: hsl(var(--secondary));
}

.status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: hsl(var(--muted-foreground));
}

.status-idle .status-dot {
  background: hsl(var(--muted-foreground));
}

.status-processing .status-dot {
  background: hsl(var(--primary));
  animation: pulse-dot 2s infinite;
}

.status-success .status-dot {
  background: hsl(var(--success));
}

.status-error .status-dot {
  background: hsl(var(--destructive));
}

@keyframes pulse-dot {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: hsl(var(--secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  color: hsl(var(--foreground));
}

/* ============================================
   MAIN LAYOUT WITH SIDEBAR
   ============================================ */

.main-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 24px;
  padding: 24px;
}

.main-content-area {
  min-width: 0;
}

.sidebar-area {
  position: sticky;
  top: 80px;
  height: fit-content;
}

@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
  }

  .sidebar-area {
    display: none;
  }
}

/* ============================================
   CARDS - SMALLER & SUBTLE
   ============================================ */

/* Glass Cards - Higher Contrast */
.card {
  background: rgba(30, 41, 59, 0.65);
  /* Increased opacity from 0.4 */
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.card:hover {
  background: rgba(30, 41, 59, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-2px);
  box-shadow: 0 10px 40px -10px rgba(0, 0, 0, 0.3);
}

.card-elevated {
  box-shadow: var(--shadow-sm);
}

.card-interactive {
  cursor: pointer;
}

.card-interactive:hover {
  border-color: hsl(var(--border) / 1.5);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid hsl(var(--border));
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.card-description {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  line-height: 1.4;
}

.card-content {
  padding: 20px;
}

/* ============================================
   BUTTONS - CYAN PRIMARY
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 500;
  border-radius: 6px;
  transition: all 0.15s;
  cursor: pointer;
  border: none;
  outline: none;
  height: 36px;
  padding: 0 16px;
}

.btn:disabled {
  pointer-events: none;
  opacity: 0.5;
}

.btn-primary {
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.btn-primary:hover:not(:disabled) {
  background: hsl(var(--primary) / 0.9);
}

.btn-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
  border: 1px solid hsl(var(--border));
}

.btn-secondary:hover:not(:disabled) {
  background: hsl(var(--secondary) / 0.8);
}

.btn-outline {
  border: 1px solid hsl(var(--border));
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-outline:hover:not(:disabled) {
  background: hsl(var(--secondary));
}

.btn-ghost {
  background: transparent;
  color: hsl(var(--foreground));
}

.btn-ghost:hover:not(:disabled) {
  background: hsl(var(--secondary));
}

.btn-text {
  background: transparent;
  border: none;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  padding: 0;
  height: auto;
}

.btn-text:hover {
  color: hsl(var(--foreground));
}

.btn-sm {
  height: 32px;
  padding: 0 12px;
  font-size: 12px;
}

.btn-lg {
  height: 40px;
  padding: 0 20px;
  font-size: 14px;
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
  color: hsl(var(--foreground));
}

.form-input,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="url"],
textarea {
  width: 100%;
  height: 38px;
  border-radius: 6px;
  border: 1px solid hsl(var(--border));
  background: hsl(var(--input));
  padding: 0 12px;
  font-size: 13px;
  color: hsl(var(--foreground));
  transition: all 0.15s;
}

textarea {
  height: auto;
  padding: 10px 12px;
  min-height: 80px;
}

input::placeholder,
textarea::placeholder {
  color: hsl(var(--muted-foreground) / 0.6);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 3px hsl(var(--primary) / 0.1);
}

input:disabled,
textarea:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ============================================
   STAT CARDS - COMPACT
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 16px;
}

.stat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.stat-title {
  font-size: 11px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-icon {
  font-size: 16px;
  opacity: 0.5;
}

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: hsl(var(--foreground));
  margin-bottom: 2px;
  letter-spacing: -0.02em;
}

.stat-desc {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

.stat-trend {
  font-size: 11px;
  font-weight: 500;
  margin-top: 4px;
}

.stat-trend.positive {
  color: hsl(var(--success));
}

.stat-trend.negative {
  color: hsl(var(--destructive));
}

.error-text {
  color: hsl(var(--destructive));
}

/* ============================================
   ACTION CARDS - COMPACT
   ============================================ */

.actions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.action-card {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 20px;
  transition: all 0.2s;
}

.action-card:hover {
  border-color: hsl(var(--border) / 1.5);
}

.action-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-bottom: 12px;
}

.action-title {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
  color: hsl(var(--foreground));
}

.action-desc {
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  line-height: 1.4;
  margin-bottom: 16px;
}

/* ============================================
   TABLES
   ============================================ */

.activity-table {
  width: 100%;
  border-collapse: collapse;
}

.activity-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 500;
  color: hsl(var(--muted-foreground));
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-bottom: 1px solid hsl(var(--border));
}

.activity-table td {
  padding: 12px 16px;
  font-size: 13px;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
  color: hsl(var(--foreground));
}

.activity-table tr:last-child td {
  border-bottom: none;
}

.activity-table tr:hover td {
  background: hsl(var(--secondary) / 0.5);
}

/* Terminal & Logs */
.terminal-container {
  background-color: hsl(var(--background));
  border-radius: var(--radius);
  padding: 20px;
  font-family: 'JetBrains Mono', 'Consolas', monospace;
  color: hsl(var(--foreground) / 0.8);
  border: 1px solid hsl(var(--border));
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-terminal {
  flex: 1;
  background: transparent;
  padding: 12px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  color: hsl(var(--foreground) / 0.6);
}

.log-line {
  padding: 4px 0;
  border-bottom: 1px solid hsl(var(--border) / 0.3);
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-all;
}

.log-line:last-child {
  border-bottom: none;
}

.timestamp {
  color: hsl(var(--muted-foreground));
  margin-right: 12px;
  font-size: 11px;
  user-select: none;
  opacity: 0.7;
}

.fw-medium {
  font-weight: 500;
}

/* ============================================
   BADGES
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

.badge-success {
  background: hsl(var(--success) / 0.15);
  color: hsl(var(--success));
}

.badge-processing {
  background: hsl(var(--processing) / 0.15);
  color: hsl(var(--processing));
}

.badge-failed,
.badge-error {
  background: hsl(var(--destructive) / 0.15);
  color: hsl(var(--destructive));
}

.badge-secondary {
  background: hsl(var(--secondary));
  color: hsl(var(--foreground));
}

/* ============================================
   SIDEBAR PANEL
   ============================================ */

.system-status-panel {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  overflow: hidden;
}

.panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid hsl(var(--border));
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-title {
  font-size: 13px;
  font-weight: 600;
}

.panel-content {
  padding: 16px;
  font-size: 12px;
  color: hsl(var(--muted-foreground));
  min-height: 200px;
}

.status-item {
  padding: 10px 0;
  border-bottom: 1px solid hsl(var(--border) / 0.5);
}

.status-item:last-child {
  border-bottom: none;
}

.status-item-title {
  font-size: 12px;
  font-weight: 500;
  color: hsl(var(--foreground));
  margin-bottom: 2px;
}

.status-item-desc {
  font-size: 11px;
  color: hsl(var(--muted-foreground));
}

/* ============================================
   SECTION HEADERS
   ============================================ */

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.section-header h1 {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.section-header p {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  margin-top: 2px;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes fadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-fade-up {
  animation: fadeUp 0.4s ease-out;
}

.delay-100 {
  animation-delay: 100ms;
}

.delay-150 {
  animation-delay: 150ms;
}

.delay-200 {
  animation-delay: 200ms;
}

/* ============================================
   UTILITIES
   ============================================ */

.space-y-4>*+* {
  margin-top: 16px;
}

.space-y-6>*+* {
  margin-top: 24px;
}

.text-muted {
  color: hsl(var(--muted-foreground));
}

.text-xs {
  font-size: 11px;
}

.text-sm {
  font-size: 13px;
}

.mono {
  font-family: 'SF Mono', 'Menlo', 'Monaco', 'Consolas', monospace;
}

/* ============================================
   MODAL
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  padding: 24px;
  width: 450px;
  max-width: 90%;
  box-shadow: var(--shadow-lg);
  position: relative;
}

.modal-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-desc {
  font-size: 13px;
  color: hsl(var(--muted-foreground));
  margin-bottom: 20px;
}

.close-modal {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 20px;
}

.close-modal:hover {
  color: hsl(var(--foreground));
}

/* ============================================
   macOS TERMINAL WIDGET — Always Visible
   ============================================ */

/* Hide old sidebar markup (replaced by JS-injected terminal) */
.sidebar-pane,
.sidebar-toggle {
  display: none !important;
}

/* ── Terminal Panel — Always visible on right ── */
.mac-terminal {
  position: fixed;
  top: 80px;
  right: 16px;
  width: 340px;
  bottom: 16px;
  z-index: 10001;
  display: flex;
  flex-direction: column;
  border-radius: 12px;
  overflow: hidden;
  box-shadow:
    0 25px 60px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.08);
  font-family: 'JetBrains Mono', 'SF Mono', 'Consolas', 'Menlo', monospace;
  transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Minimized = titlebar only */
.mac-terminal.minimized {
  top: auto;
  bottom: 16px;
  height: 36px;
}

.mac-terminal.minimized .mac-terminal-body {
  display: none;
}

/* Closed = fully hidden */
.mac-terminal.closed {
  right: -400px;
  opacity: 0;
  pointer-events: none;
}

/* ── Restore Button (shows when closed) ─────── */
.mac-terminal-restore {
  position: fixed;
  bottom: 24px;
  right: 16px;
  z-index: 10001;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 10px 14px;
  background: rgba(30, 30, 32, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.7);
  font-family: 'Inter', -apple-system, sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  transition: all 0.3s ease;
}

.mac-terminal-restore:hover {
  background: rgba(45, 45, 48, 0.95);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
}

.restore-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #484f58;
  transition: all 0.3s;
}

.restore-dot.active {
  background: #3fb950;
  box-shadow: 0 0 8px rgba(63, 185, 80, 0.5);
}

.restore-dot.pulse {
  animation: dotPulse 1.5s ease infinite;
}

/* ── Titlebar ───────────────────────────────── */
.mac-terminal-titlebar {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 12px;
  background: linear-gradient(180deg, #3a3a3c, #2c2c2e);
  border-bottom: 1px solid rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
  user-select: none;
  -webkit-user-select: none;
}

.mac-dots {
  display: flex;
  gap: 7px;
  align-items: center;
}

.mac-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.mac-dot:hover {
  transform: scale(1.25);
}

.dot-red {
  background: #ff5f56;
  box-shadow: 0 0 4px rgba(255, 95, 86, 0.4);
}

.dot-yellow {
  background: #ffbd2e;
  box-shadow: 0 0 4px rgba(255, 189, 46, 0.4);
}

.dot-green {
  background: #27c93f;
  box-shadow: 0 0 4px rgba(39, 201, 63, 0.4);
}

.mac-terminal-title {
  flex: 1;
  text-align: center;
  font-size: 11px;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.55);
  letter-spacing: 0.02em;
}

/* Live status indicator in titlebar */
.mac-terminal-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.45);
}

.status-indicator-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #484f58;
  transition: all 0.3s;
}

.status-indicator-dot.active {
  background: #3fb950;
  box-shadow: 0 0 6px rgba(63, 185, 80, 0.5);
}

.status-indicator-dot.pulse {
  animation: dotPulse 1.5s ease infinite;
}

.status-label {
  font-family: 'Inter', -apple-system, sans-serif;
  font-weight: 500;
}

@keyframes dotPulse {

  0%,
  100% {
    box-shadow: 0 0 4px rgba(63, 185, 80, 0.4);
  }

  50% {
    box-shadow: 0 0 14px rgba(63, 185, 80, 0.8);
  }
}

/* ── Terminal Body ──────────────────────────── */
.mac-terminal-body {
  flex: 1;
  background: #0d1117;
  padding: 14px 16px;
  overflow-y: auto;
  font-size: 12px;
  line-height: 1.7;
  color: #c9d1d9;
  scroll-behavior: smooth;
}

.mac-terminal-body::-webkit-scrollbar {
  width: 5px;
}

.mac-terminal-body::-webkit-scrollbar-track {
  background: transparent;
}

.mac-terminal-body::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

/* ── Log Lines ──────────────────────────────── */
.term-line {
  padding: 3px 0;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.term-line:last-of-type {
  border-bottom: none;
}

.term-time {
  color: #484f58;
  font-size: 10px;
  flex-shrink: 0;
  min-width: 56px;
  padding-top: 1px;
}

.term-prompt {
  color: #39d353;
  font-weight: 700;
  flex-shrink: 0;
}

.term-text {
  color: #c9d1d9;
  word-break: break-word;
}

/* Color-coded line types */
.term-error .term-prompt {
  color: #f85149;
}

.term-error .term-text {
  color: #ffa198;
}

.term-success .term-prompt {
  color: #3fb950;
}

.term-success .term-text {
  color: #7ee787;
}

.term-warn .term-prompt {
  color: #d29922;
}

.term-warn .term-text {
  color: #e3b341;
}

.term-active .term-prompt {
  color: #58a6ff;
}

.term-active .term-text {
  color: #79c0ff;
}

.term-idle .term-text {
  color: #484f58;
  font-style: italic;
}

/* Blinking cursor */
.term-cursor {
  color: #39d353;
  font-size: 13px;
  animation: termBlink 1s step-end infinite;
  margin-top: 4px;
}

@keyframes termBlink {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0;
  }
}

@keyframes termFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ── Responsive ─────────────────────────────── */

/* ====== Tablet (≤ 1024px) ====== */
@media (max-width: 1024px) {
  .main-layout {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .sidebar-area {
    display: none;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .actions-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .header-container {
    padding: 0 16px;
    gap: 16px;
  }

  .mac-terminal {
    width: 280px;
  }
}

/* ====== Mobile (≤ 768px) ====== */
@media (max-width: 768px) {
  /* Header: Stack and allow scroll */
  .header-container {
    height: auto;
    padding: 10px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-logo {
    order: 1;
  }

  .header-right {
    order: 2;
    margin-left: auto;
    gap: 8px;
  }

  .header-nav {
    order: 3;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 4px;
    flex: none;
    gap: 4px;
  }

  .header-nav::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    white-space: nowrap;
    font-size: 12px;
    padding: 0 10px;
    height: 30px;
    flex-shrink: 0;
  }

  .app-title {
    font-size: 13px;
  }

  .status-indicator {
    font-size: 11px;
    padding: 3px 8px;
  }

  .status-indicator span:last-child {
    display: none;
  }

  .user-avatar {
    width: 24px;
    height: 24px;
    font-size: 10px;
  }

  /* Main layout */
  .main-layout {
    padding: 12px;
    gap: 16px;
  }

  .container {
    padding: 0 12px;
  }

  /* Page header */
  .main-content-area h1 {
    font-size: 18px;
  }

  .main-content-area > div > p {
    font-size: 12px;
  }

  /* Stats grid: 2 columns on mobile */
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .stat-card {
    padding: 12px;
    border-radius: 8px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-title {
    font-size: 10px;
  }

  .stat-desc {
    font-size: 10px;
  }

  .stat-trend {
    font-size: 10px;
  }

  /* Action cards: Stack vertically */
  .actions-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-bottom: 16px;
  }

  .action-card {
    padding: 16px;
    border-radius: 10px;
  }

  .action-icon {
    width: 32px;
    height: 32px;
    font-size: 16px;
    margin-bottom: 8px;
  }

  .action-title {
    font-size: 14px;
    margin-bottom: 4px;
  }

  .action-desc {
    font-size: 12px;
    margin-bottom: 12px;
    line-height: 1.4;
  }

  /* Buttons */
  .btn {
    height: 34px;
    font-size: 12px;
    padding: 0 14px;
  }

  .btn-lg {
    height: 36px;
    font-size: 13px;
  }

  /* Section headers */
  .section-header {
    margin-bottom: 10px;
  }

  .section-header h2 {
    font-size: 14px;
  }

  .btn-text {
    font-size: 12px;
  }

  /* Tables: Horizontal scroll */
  .card {
    border-radius: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .activity-table {
    min-width: 500px;
  }

  .activity-table th {
    padding: 10px 12px;
    font-size: 10px;
  }

  .activity-table td {
    padding: 10px 12px;
    font-size: 12px;
  }

  .badge {
    font-size: 10px;
    padding: 2px 6px;
  }

  /* Charts */
  .charts-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .chart-container {
    height: 200px;
  }

  /* Cards general - more vibrant */
  .card-header {
    padding: 12px 16px;
  }

  .card-title {
    font-size: 14px;
    font-weight: 700;
  }

  .card-description {
    font-size: 12px;
  }

  .card-content {
    padding: 12px 16px;
  }

  /* Forms */
  .form-group {
    margin-bottom: 12px;
  }

  .form-label {
    font-size: 12px;
    margin-bottom: 4px;
  }

  .form-input,
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="url"],
  textarea {
    height: 40px;
    font-size: 14px;
    padding: 0 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
  }

  textarea {
    padding: 10px 12px;
    min-height: 80px;
  }

  /* Terminal: Full width bottom bar */
  .mac-terminal {
    top: auto;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 250px;
    border-radius: 20px 20px 0 0;
    z-index: 10001;
    border-top: 2px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  }

  .mac-terminal.minimized {
    height: 48px;
    bottom: 0;
  }

  .mac-terminal-titlebar {
    height: 48px;
  }

  .mac-terminal.closed {
    right: 0;
    bottom: -300px;
    opacity: 0;
  }

  .mac-terminal-body {
    padding: 12px 16px;
    font-size: 12px;
    line-height: 1.6;
  }

  /* Restore Terminal floating button */
  .mac-terminal-restore {
    bottom: 24px;
    right: 24px;
    font-size: 13px;
    padding: 12px 18px;
    border-radius: 99px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.9), rgba(139, 92, 246, 0.9));
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px rgba(59, 130, 246, 0.4);
    animation: floatButton 3s ease-in-out infinite;
  }

  @keyframes floatButton {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
  }

  .mac-terminal-restore:hover {
    background: linear-gradient(135deg, rgba(59, 130, 246, 1), rgba(139, 92, 246, 1));
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 20px rgba(59, 130, 246, 0.6);
  }

  .restore-label {
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 11px;
  }

  /* Add bottom padding to the page so content doesn't hide behind the terminal */
  body {
    padding-bottom: 250px;
  }

  /* Modal */
  .modal-content {
    width: 95%;
    max-width: 95%;
    padding: 24px;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.95), rgba(15, 23, 42, 0.98));
    border: 1px solid rgba(255, 255, 255, 0.15);
  }

  .modal-title {
    font-size: 18px;
    background: linear-gradient(to right, #60a5fa, #c084fc);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
  }

  .modal-desc {
    font-size: 13px;
    margin-bottom: 20px;
  }

  /* System status panel inline (shown where sidebar was) */
  .system-status-panel {
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.6), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(255, 255, 255, 0.1);
  }

  .panel-header {
    padding: 12px 16px;
  }

  .panel-title {
    font-size: 13px;
    font-weight: 600;
  }

  .panel-content {
    padding: 16px;
    min-height: auto;
  }
}

/* ====== Small Mobile (≤ 480px) ====== */
@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
  }

  .stat-card {
    padding: 12px;
    border-radius: 12px;
    background: linear-gradient(145deg, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.9));
  }

  .stat-value {
    font-size: 22px;
    font-weight: 800;
  }

  .stat-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }

  .main-layout {
    padding: 12px 8px;
  }

  .header-container {
    padding: 12px 12px;
  }

  .nav-link {
    font-size: 11px;
    padding: 0 12px;
    height: 32px;
    border-radius: 8px;
  }

  .action-card {
    padding: 16px;
    border-radius: 16px;
    background: linear-gradient(145deg, rgba(37, 99, 235, 0.1), rgba(15, 23, 42, 0.8));
    border: 1px solid rgba(59, 130, 246, 0.3);
  }

  .action-title {
    font-size:8px;
  }

  .action-card {
    padding: 12px;
  }

  .action-title {
    font-size: 13px;
  }

  .action-desc {
    font-size: 11px;
  }

  .btn {
    height: 32px;
    font-size: 11px;
  }

  .mac-terminal {
    height: 160px;
  }

  body {
    padding-bottom: 180px;
  }
}