/* ============================================================
   CrimsonCore OS — Interactive Demo  (PcTechGuyOnline)
   Navy + Crimson brand theme. Zero external dependencies.
   ============================================================ */

:root {
  --navy: #0a1128;
  --navy2: #0e1633;
  --surface: #122046;
  --surface2: #16274f;
  --surface3: #1b2f5e;
  --crimson: #D10028;
  --crimson-hi: #ff3355;
  --crimson-soft: rgba(209, 0, 40, 0.14);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #eef2ff;
  --text-dim: #93a0c0;
  --text-faint: #64729a;
  --ok: #33d17a;
  --warn: #ffca3a;
  --bad: #ff6b6b;
  --info: #4cc9f0;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.30);
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Code", "Consolas", monospace;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font);
  background: var(--navy);
  color: var(--text);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--crimson-hi); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }

/* ---------- Demo banner ---------- */
.demo-banner {
  background: linear-gradient(90deg, #3a0012, #D10028);
  color: #fff;
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  border-bottom: 1px solid rgba(255,255,255,0.18);
}
.demo-badge {
  background: #fff;
  color: var(--crimson);
  font-weight: 800;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.06em;
}
.demo-banner-text { flex: 1; }
.demo-banner-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 2px 6px;
}

/* ---------- App shell ---------- */
.app-shell {
  display: grid;
  grid-template-columns: 264px 1fr;
  height: calc(100vh - 35px);
  overflow: hidden;
}

/* ---------- Sidebar ---------- */
.sidebar {
  background: var(--navy2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 18px 14px 14px;
  overflow-y: auto;
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 6px 18px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--crimson), #7a0017);
  display: grid; place-items: center;
  font-weight: 800; font-size: 22px; color: #fff;
  box-shadow: 0 6px 16px rgba(209,0,40,0.35);
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-weight: 700; font-size: 15px; letter-spacing: 0.01em; }
.brand-mode {
  font-size: 9px; font-weight: 800; letter-spacing: 0.18em;
  color: var(--crimson-hi); margin-top: 1px;
}
.sidebar-nav { flex: 1; margin-top: 16px; display: flex; flex-direction: column; gap: 3px; }
.nav-group {
  font-size: 10px; font-weight: 800; letter-spacing: 0.16em;
  color: var(--text-faint); padding: 14px 8px 5px;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  background: transparent; border: none; color: var(--text-dim);
  font-size: 14px; font-weight: 500; text-align: left;
  padding: 10px 10px; border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.nav-item.active {
  background: var(--crimson-soft); color: #fff;
  font-weight: 600;
  box-shadow: inset 3px 0 0 var(--crimson);
}
.nav-icon { width: 20px; text-align: center; font-size: 16px; }
.sidebar-foot {
  margin-top: 16px; padding: 12px 8px 0;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.foot-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--surface3); display: grid; place-items: center;
  font-size: 13px; font-weight: 700;
}
.foot-meta { display: flex; flex-direction: column; }
.foot-name { font-size: 13px; font-weight: 600; }
.foot-role { font-size: 11px; color: var(--text-faint); }

/* ---------- Main ---------- */
.main { display: flex; flex-direction: column; overflow: hidden; background: var(--navy); }
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 26px;
  background: var(--navy2);
  border-bottom: 1px solid var(--border);
  gap: 16px;
}
.page-title { font-size: 20px; font-weight: 700; }
.topbar-right { display: flex; align-items: center; gap: 10px; }

.icon-btn {
  position: relative;
  background: var(--surface); border: 1px solid var(--border);
  color: var(--text); border-radius: 10px; width: 40px; height: 40px;
  font-size: 17px; transition: background 0.15s;
}
.icon-btn:hover { background: var(--surface2); }
.notify-dot {
  position: absolute; top: -5px; right: -5px;
  background: var(--crimson); color: #fff; font-size: 10px; font-weight: 700;
  border-radius: 999px; min-width: 18px; height: 18px;
  display: grid; place-items: center; padding: 0 4px;
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: none; border-radius: 10px;
  padding: 9px 16px; font-size: 14px; font-weight: 600;
  transition: transform 0.08s, background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--crimson); color: #fff; box-shadow: 0 6px 18px rgba(209,0,40,0.30); }
.btn-primary:hover { background: #e1002c; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--surface3); }
.btn-ghost { background: transparent; color: var(--text-dim); border: 1px solid var(--border); }
.btn-ghost:hover { background: rgba(255,255,255,0.05); color: var(--text); }
.btn-success { background: #1d7a4f; color: #fff; }
.btn-success:hover { background: #23945f; }
.btn-sm { padding: 6px 12px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Content ---------- */
.content { flex: 1; overflow-y: auto; padding: 26px; }

.view-head { margin-bottom: 20px; }
.view-head h2 { font-size: 22px; }
.view-head p { color: var(--text-dim); margin-top: 4px; max-width: 700px; }

/* ---------- Stats / cards ---------- */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
}
.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 18px 16px;
  box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12px; color: var(--text-dim); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .stat-value { font-size: 30px; font-weight: 800; margin-top: 6px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-faint); margin-top: 4px; }
.stat-card.good .stat-value { color: var(--ok); }
.stat-card.warn .stat-value { color: var(--warn); }
.stat-card.bad .stat-value { color: var(--bad); }
.stat-card.accent .stat-value { color: var(--crimson-hi); }

/* ---------- Card / panel ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.card-title {
  font-size: 15px; font-weight: 700; margin-bottom: 14px;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.card-title .sub { font-size: 12px; color: var(--text-dim); font-weight: 400; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.stack { display: flex; flex-direction: column; gap: 14px; }

@media (max-width: 1100px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--radius-sm); border: 1px solid var(--border); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 11px 14px; text-align: left; white-space: nowrap; }
thead th {
  background: var(--navy2); color: var(--text-dim);
  font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase;
  border-bottom: 1px solid var(--border);
}
tbody tr { border-bottom: 1px solid var(--border); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,0.03); }
td.mono, .mono { font-family: var(--mono); font-size: 13px; }

/* ---------- Badges ---------- */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
}
.pill.ok { background: rgba(51,209,122,0.14); color: var(--ok); }
.pill.warn { background: rgba(255,202,58,0.14); color: var(--warn); }
.pill.bad { background: rgba(255,107,107,0.14); color: var(--bad); }
.pill.info { background: rgba(76,201,240,0.14); color: var(--info); }
.pill.crimson { background: var(--crimson-soft); color: var(--crimson-hi); }
.pill.grey { background: rgba(255,255,255,0.07); color: var(--text-dim); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot.green { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.dot.amber { background: var(--warn); }
.dot.red { background: var(--bad); }
.dot.grey { background: var(--text-faint); }

/* ---------- Progress ---------- */
.progress-track { background: var(--navy2); border-radius: 999px; height: 10px; overflow: hidden; }
.progress-fill {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--crimson), var(--crimson-hi));
  border-radius: 999px;
  transition: width 0.25s ease;
}
.progress-fill.ok { background: linear-gradient(90deg, #1d7a4f, var(--ok)); }

/* ---------- Meter bars (fleet health etc.) ---------- */
.meter { display: flex; align-items: center; gap: 10px; }
.meter .track { flex: 1; background: var(--navy2); border-radius: 999px; height: 6px; overflow: hidden; }
.meter .fill { height: 100%; border-radius: 999px; }
.meter .val { font-family: var(--mono); font-size: 12px; min-width: 34px; text-align: right; color: var(--text-dim); }
.fill-green { background: var(--ok); }
.fill-amber { background: var(--warn); }
.fill-red { background: var(--bad); }
.fill-crimson { background: var(--crimson); }

/* ---------- Log console ---------- */
.console {
  background: #050a1c; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-family: var(--mono);
  font-size: 12.5px; padding: 14px; height: 220px; overflow-y: auto;
  line-height: 1.7;
}
.console .ln { color: #7be0a8; }
.console .ln.work { color: #ffd479; }
.console .ln.done { color: #4cc9f0; font-weight: 700; }

/* ---------- Toggle ---------- */
.toggle { position: relative; width: 44px; height: 24px; border-radius: 999px; background: var(--surface3); border: 1px solid var(--border-strong); transition: background 0.2s; flex-shrink: 0; }
.toggle::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: 50%; background: #fff;
  transition: transform 0.2s;
}
.toggle.on { background: var(--crimson); }
.toggle.on::after { transform: translateX(20px); }

/* ---------- Toast ---------- */
.toast-wrap {
  position: fixed; top: 60px; right: 22px; z-index: 2000;
  display: flex; flex-direction: column; gap: 10px;
}
.toast {
  background: var(--surface2); border: 1px solid var(--border-strong);
  border-left: 4px solid var(--crimson);
  border-radius: 10px; padding: 12px 16px; min-width: 260px; max-width: 380px;
  box-shadow: var(--shadow);
  animation: slidein 0.25s ease;
}
.toast.success { border-left-color: var(--ok); }
.toast.warn { border-left-color: var(--warn); }
.toast .t-title { font-weight: 700; font-size: 14px; }
.toast .t-msg { font-size: 13px; color: var(--text-dim); margin-top: 2px; }
@keyframes slidein { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }
.toast.out { opacity: 0; transform: translateX(20px); transition: all 0.3s; }

/* ---------- Notify panel ---------- */
.notify-panel {
  position: absolute; top: 64px; right: 24px; z-index: 1500;
  background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: 320px; padding: 8px;
}
.notify-item { padding: 10px 12px; border-radius: 8px; font-size: 13px; }
.notify-item:hover { background: rgba(255,255,255,0.04); }
.notify-item .n-title { font-weight: 600; }
.notify-item .n-time { font-size: 11px; color: var(--text-faint); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 3000;
  background: rgba(2, 6, 18, 0.72);
  display: grid; place-items: center;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 16px; width: min(560px, calc(100vw - 40px));
  max-height: 88vh; overflow-y: auto;
  box-shadow: 0 24px 60px rgba(0,0,0,0.5);
  padding: 24px;
  animation: modalpop 0.2s ease;
}
.modal.wide { width: min(760px, calc(100vw - 40px)); }
@keyframes modalpop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: none; } }
.modal h3 { font-size: 18px; margin-bottom: 8px; }
.modal .close-x {
  position: sticky; top: 0; float: right;
  background: var(--surface2); border: 1px solid var(--border-strong);
  color: var(--text); width: 30px; height: 30px; border-radius: 8px;
  font-size: 16px;
}

/* ---------- Forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; color: var(--text-dim); font-weight: 600; margin-bottom: 5px; letter-spacing: 0.02em; }
.field select, .field input {
  width: 100%; background: var(--navy2); border: 1px solid var(--border-strong);
  color: var(--text); padding: 10px 12px; border-radius: 10px; font-size: 14px; font-family: inherit;
}
.field select:focus, .field input:focus { outline: 2px solid var(--crimson); border-color: transparent; }
.hint { font-size: 12px; color: var(--text-faint); margin-top: 4px; }

/* ---------- Marketplace ---------- */
.product-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 16px; }
.product-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px;
  display: flex; flex-direction: column; gap: 10px;
  transition: border-color 0.15s, transform 0.1s;
}
.product-card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.product-cat { font-size: 10px; font-weight: 800; letter-spacing: 0.1em; color: var(--crimson-hi); text-transform: uppercase; }
.product-name { font-size: 15px; font-weight: 700; }
.product-desc { font-size: 13px; color: var(--text-dim); flex: 1; }
.product-price { font-size: 18px; font-weight: 800; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 18px; }
.chip {
  background: var(--surface); border: 1px solid var(--border-strong);
  color: var(--text-dim); font-size: 13px; border-radius: 999px; padding: 6px 14px;
}
.chip.active { background: var(--crimson); border-color: var(--crimson); color: #fff; }

/* ---------- CRM ---------- */
.client-list { display: flex; flex-direction: column; gap: 10px; }
.client-row {
  display: flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  cursor: pointer; transition: border-color 0.15s, background 0.15s;
}
.client-row:hover { border-color: var(--border-strong); background: var(--surface2); }
.client-avatar { width: 38px; height: 38px; border-radius: 10px; background: var(--surface3); display: grid; place-items: center; font-weight: 700; font-size: 14px; }
.client-info { flex: 1; }
.client-info .c-name { font-weight: 600; }
.client-info .c-meta { font-size: 12px; color: var(--text-dim); }
.client-right { text-align: right; }
.client-right .c-mrr { font-weight: 700; color: var(--ok); }
.client-right .c-devices { font-size: 12px; color: var(--text-faint); }

/* ---------- Tenant / licences ---------- */
.key-box {
  font-family: var(--mono); background: var(--navy2);
  border: 1px dashed var(--border-strong); border-radius: 10px;
  padding: 12px 14px; font-size: 15px; letter-spacing: 0.06em;
  color: var(--crimson-hi); user-select: all;
}

/* ---------- About / pricing ---------- */
.price-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.price-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; }
.price-card.featured { border-color: var(--crimson); box-shadow: 0 0 0 1px var(--crimson), var(--shadow); }
.price-card .plan { font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-dim); }
.price-card .amount { font-size: 32px; font-weight: 800; margin: 8px 0 4px; }
.price-card .per { font-size: 13px; color: var(--text-faint); }
.price-card ul { list-style: none; margin: 14px 0; display: flex; flex-direction: column; gap: 8px; font-size: 14px; }
.price-card li { color: var(--text-dim); }
.price-card li::before { content: "✓"; color: var(--ok); margin-right: 8px; font-weight: 700; }
.badge-popular {
  position: absolute; top: -10px; left: 16px;
  background: var(--crimson); color: #fff; font-size: 11px; font-weight: 800;
  padding: 3px 12px; border-radius: 999px;
}
.price-card { position: relative; }

/* ---------- Misc ---------- */
.divider { height: 1px; background: var(--border); margin: 16px 0; }
.muted { color: var(--text-dim); font-size: 13px; }
.faint { color: var(--text-faint); font-size: 12px; }
.mt { margin-top: 14px; }
.flex { display: flex; }
.between { justify-content: space-between; align-items: center; }
.gap { gap: 10px; }
.wrap { flex-wrap: wrap; }
.grid-placeholder {
  border: 2px dashed var(--border-strong); border-radius: var(--radius);
  padding: 40px; text-align: center; color: var(--text-dim);
}
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px,1fr)); gap: 14px; }
.kpi { background: var(--surface2); border-radius: 12px; padding: 14px 16px; }
.kpi .k-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-dim); font-weight: 700; }
.kpi .k-value { font-size: 22px; font-weight: 800; margin-top: 4px; }
.kpi .k-sub { font-size: 12px; color: var(--text-faint); margin-top: 2px; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}