:root {
  --glass-bg: rgba(255, 255, 255, 0.84);
  --glass-border: rgba(255, 255, 255, 0.65);
  --glass-shadow: 0 18px 45px rgba(15, 23, 42, 0.22);
  --text-main: #0f172a;
  --text-muted: #475569;
  --accent: #0284c7;
  --accent-hover: #0369a1;
  --danger: #dc2626;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 14px;
  --mountain-img: url('https://images.unsplash.com/photo-1506744038136-46273834b3fb?auto=format&fit=crop&w=2000&q=80');
}

* { box-sizing: border-box; }
body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, sans-serif;
  color: var(--text-main);
  overflow: hidden;
  user-select: none;
}

.hidden { display: none !important; }

/* LANDING & LOGIN SCREEN */
.login-backdrop, .desktop-backdrop {
  width: 100vw;
  height: 100vh;
  background-image: linear-gradient(rgba(15, 23, 42, 0.35), rgba(15, 23, 42, 0.45)), var(--mountain-img);
  background-size: cover;
  background-position: center;
}

.login-backdrop {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-glass-card {
  width: 100%;
  max-width: 520px;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  padding: 32px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.35);
}

.brand-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}
.brand-emblem {
  font-size: 36px;
  background: #e0f2fe;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 14px;
}
.brand-title { font-size: 22px; font-weight: 800; letter-spacing: -0.4px; }
.os-tag {
  font-size: 12px;
  background: var(--accent);
  color: #fff;
  padding: 2px 8px;
  border-radius: 99px;
  vertical-align: middle;
}
.brand-sub { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

.cma-notice {
  background: rgba(254, 242, 242, 0.92);
  border-left: 4px solid var(--danger);
  color: #7f1d1d;
  font-size: 12px;
  line-height: 1.5;
  padding: 12px 14px;
  border-radius: 8px;
  margin-bottom: 20px;
}

label { display: block; font-size: 12px; font-weight: 600; color: var(--text-muted); margin-bottom: 5px; }
input, select, textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 9px;
  font-size: 14px;
  background: rgba(255, 255, 255, 0.95);
  color: var(--text-main);
  margin-bottom: 14px;
  font-family: inherit;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(2, 132, 199, 0.15);
}

button {
  cursor: pointer;
  border: none;
  border-radius: 9px;
  padding: 9px 15px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s ease;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-secondary { background: #e2e8f0; color: var(--text-main); }
.btn-secondary:hover { background: #cbd5e1; }
.full-width { width: 100%; padding: 12px; font-size: 14px; }

.error-msg {
  background: #fee2e2;
  color: #b91c1c;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 12px;
}
.login-footer {
  margin-top: 16px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* TOPBAR */
.topbar {
  height: 40px;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  font-size: 13px;
  position: relative;
  z-index: 900;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-logo { font-weight: 800; }
.topbar-sep { color: #94a3b8; }
.topbar-pill { font-weight: 600; }
.topbar-role-badge {
  text-transform: uppercase;
  font-size: 10px;
  font-weight: 800;
  background: #0f172a;
  color: #fff;
  padding: 2px 7px;
  border-radius: 6px;
}
.topbar-stat {
  background: rgba(241, 245, 249, 0.9);
  padding: 4px 10px;
  border-radius: 7px;
  font-weight: 600;
  font-size: 12px;
}
.btn-logout {
  background: rgba(220, 38, 38, 0.12);
  color: var(--danger);
  padding: 4px 10px;
  font-size: 12px;
}
.btn-logout:hover { background: var(--danger); color: #fff; }

/* WORKSPACE & WINDOWS */
.workspace {
  position: relative;
  width: 100%;
  height: calc(100vh - 116px);
  overflow: hidden;
}
.desktop-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  color: rgba(255, 255, 255, 0.85);
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.45);
  pointer-events: none;
}
.desktop-watermark h2 { margin: 0; font-size: 34px; letter-spacing: 2px; }
.desktop-watermark p { margin: 6px 0 0; font-size: 14px; }

.os-window {
  position: absolute;
  background: var(--glass-bg);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--glass-shadow);
  display: flex;
  flex-direction: column;
  min-width: 380px;
  min-height: 280px;
  resize: both;
  overflow: hidden;
}
.window-header {
  height: 38px;
  background: rgba(248, 250, 252, 0.92);
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  cursor: move;
}
.window-title { font-weight: 700; font-size: 13px; display: flex; align-items: center; gap: 7px; }
.window-controls { display: flex; gap: 6px; }
.win-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  background: #e2e8f0;
  color: #334155;
}
.win-btn.close:hover { background: var(--danger); color: #fff; }
.window-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  user-select: text;
  font-size: 13px;
}

/* DOCK */
.dock {
  position: fixed;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  border-radius: 18px;
  padding: 6px 12px;
  display: flex;
  gap: 8px;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.25);
  z-index: 950;
  max-width: 96vw;
  overflow-x: auto;
}
.dock-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 12px;
  background: transparent;
  color: var(--text-main);
  min-width: 66px;
}
.dock-item:hover { background: rgba(255, 255, 255, 0.9); transform: translateY(-3px); }
.dock-icon { font-size: 22px; margin-bottom: 2px; }
.dock-label { font-size: 10px; font-weight: 700; white-space: nowrap; }

/* UI COMPONENTS INSIDE APPS */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; border-bottom: 1px solid #cbd5e1; padding-bottom: 8px; flex-wrap: wrap; }
.tab-btn { background: #e2e8f0; color: #334155; padding: 6px 12px; font-size: 12px; }
.tab-btn.active { background: var(--accent); color: #fff; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.card {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}
table { width: 100%; border-collapse: collapse; font-size: 12px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid #e2e8f0; }
th { background: #f1f5f9; font-weight: 700; }
.pill { padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700; }
.pill-green { background: #dcfce7; color: #166534; }
.pill-red { background: #fee2e2; color: #991b1b; }
.pill-amber { background: #fef3c7; color: #92400e; }

/* ALERT BANNERS & FULL SHUTDOWN */
.alert-banner {
  position: fixed;
  top: 40px;
  left: 0;
  right: 0;
  z-index: 9990;
  padding: 10px 20px;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
  text-align: center;
  box-shadow: 0 4px 15px rgba(0,0,0,0.25);
}
.alert-LOW { background: #0284c7; }
.alert-MEDIUM { background: #d97706; }
.alert-HIGH { background: #dc2626; }
.alert-LOCKDOWN { background: #7f1d1d; animation: pulseBg 1s infinite alternate; }
@keyframes pulseBg { from { background: #7f1d1d; } to { background: #dc2626; } }

.shutdown-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 0, 0, 0.96);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  text-align: center;
  padding: 24px;
}
.shutdown-card {
  max-width: 580px;
  border: 2px solid #ef4444;
  background: #1a0505;
  padding: 36px;
  border-radius: 18px;
  box-shadow: 0 0 60px rgba(239, 68, 68, 0.45);
}
.shutdown-icon { font-size: 54px; margin-bottom: 10px; }
.shutdown-card h1 { color: #f87171; margin: 0 0 12px; font-size: 26px; letter-spacing: 1px; }
.shutdown-card p { font-size: 16px; line-height: 1.6; color: #fecaca; }
.shutdown-meta { margin: 18px 0; font-size: 11px; letter-spacing: 1.5px; color: #f87171; font-weight: 700; }
.btn-ghost-sm { background: transparent; border: 1px solid #7f1d1d; color: #fca5a5; font-size: 11px; margin-top: 10px; }

/* CALL TOAST */
.call-toast {
  position: fixed;
  top: 52px;
  right: 16px;
  background: #0f172a;
  color: #fff;
  padding: 14px 18px;
  border-radius: 14px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  gap: 16px;
  z-index: 9800;
}
.call-toast-actions { display: flex; gap: 8px; }
