:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4d;
  --text: #e6edf3;
  --muted: #8b949e;
  --primary: #58a6ff;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 8px;
}

* { box-sizing: border-box; }
body { margin: 0; font-family: system-ui, -apple-system, sans-serif; background: var(--bg); color: var(--text); min-height: 100vh; position: relative; }
.bg-video { position: fixed; top: 0; left: 0; width: 100%; height: 100%; object-fit: cover; z-index: -2; }
.video-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(15, 20, 25, 0.82); z-index: -1; }
.layout { position: relative; z-index: 0; max-width: 1200px; margin: 0 auto; padding: 1rem 1.5rem; min-height: 100vh; display: flex; flex-direction: column; }

.header { margin-bottom: 1.5rem; position: relative; }
.header h1 { margin: 0 0 0.25rem 0; font-size: 1.5rem; font-weight: 600; }
.subtitle { margin: 0; color: var(--muted); font-size: 0.9rem; }
.auth-bar { position: absolute; top: 1rem; right: 1.5rem; display: flex; align-items: center; gap: 0.75rem; }
.auth-info { color: var(--muted); font-size: 0.85rem; }
.auth-info strong { color: var(--text); }
.header-actions { margin-top: 1rem; display: flex; gap: 0.5rem; flex-wrap: wrap; }
.login-form { display: flex; flex-direction: column; gap: 0.75rem; margin: 1rem 0; }
.login-form label { display: flex; flex-direction: column; gap: 0.25rem; }
.login-form input { padding: 0.5rem 0.6rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }
.login-form input:focus { outline: none; border-color: var(--primary); }
.session-name-field { display: flex; flex-direction: column; gap: 0.25rem; min-width: 16rem; }
.session-name-field span { color: var(--muted); font-size: 0.75rem; }
.session-name-field input {
  padding: 0.45rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.9rem;
}
.session-name-field input:focus {
  outline: none;
  border-color: var(--primary);
}

.btn { padding: 0.5rem 1rem; border-radius: var(--radius); border: 1px solid var(--border); cursor: pointer; font-size: 0.9rem; background: var(--surface); color: var(--text); }
.btn:hover { background: var(--border); }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { filter: brightness(1.1); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-small { padding: 0.35rem 0.65rem; font-size: 0.8rem; }

.tabs { display: flex; gap: 0.25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab { padding: 0.6rem 1rem; border: none; border-radius: var(--radius) var(--radius) 0 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 0.9rem; }
.tab:hover { color: var(--text); }
.tab.active { background: var(--surface); color: var(--text); }

.content { flex: 1; }
.panel { display: none; }
.panel.active { display: block; }

.filters { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label { display: flex; align-items: center; gap: 0.5rem; }
.filters select { padding: 0.4rem 0.6rem; border-radius: 6px; border: 1px solid var(--border); background: var(--surface); color: var(--text); }

.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { color: var(--muted); font-weight: 500; }
.data-table tr:hover td { background: rgba(255,255,255,0.03); }
.data-table .actions { min-width: 20rem; padding: 0.75rem 0.85rem; }
.data-table .actions button { padding: 0.36rem 0.6rem; font-size: 0.82rem; font-weight: 500; }
.data-table .actions .action-stack { display: flex; flex-direction: column; gap: 0.55rem; }
.data-table .actions .action-row { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.data-table .actions .action-links .btn { color: var(--text); text-decoration: none; }
.data-table .actions .action-row .btn,
.data-table .actions .deploy-actions-grid .btn {
  border-color: #3a4a62;
}
.data-table .actions .deploy-actions-panel {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: rgba(255,255,255,0.02);
  padding: 0.4rem 0.5rem;
}
.data-table .actions .deploy-actions-panel summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 600;
  user-select: none;
}
.data-table .actions .deploy-actions-panel[open] summary { margin-bottom: 0.4rem; }
.data-table .actions .deploy-actions-grid { display: flex; gap: 0.55rem; flex-wrap: wrap; }
.data-table .actions .deploy-result {
  width: 100%;
  margin-top: 0.35rem;
  padding: 0.35rem 0.45rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
}
.deploy-result-ok { background: rgba(63,185,80,0.15); border: 1px solid rgba(63,185,80,0.45); }
.deploy-result-fail { background: rgba(248,81,73,0.15); border: 1px solid rgba(248,81,73,0.45); }
.data-table .actions .deploy-result code { display: inline-block; margin-top: 0.2rem; white-space: pre-wrap; word-break: break-word; }
.data-table .actions .deploy-meta { margin-top: 0.2rem; color: var(--muted); font-size: 0.75rem; }
.sessions-cards { display: flex; flex-direction: column; gap: 1rem; }
.sessions-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: rgba(255,255,255,0.02);
  padding: 0.75rem;
}
.sessions-card h3 {
  margin: 0 0 0.6rem 0;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}
.empty-sessions { color: var(--muted); font-style: italic; }

.message { padding: 0.75rem; border-radius: var(--radius); margin-bottom: 1rem; }
.message.error { background: rgba(248,81,73,0.15); color: var(--danger); }
.status { font-size: 0.85rem; color: var(--muted); }
.status.ok { color: var(--success); }
.status.fail { color: var(--danger); }

.usage-output { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; overflow: auto; max-height: 60vh; font-size: 0.85rem; white-space: pre-wrap; word-break: break-all; }
.placeholder { color: var(--muted); padding: 1rem; }
.placeholder code { background: var(--surface); padding: 0.2rem 0.4rem; border-radius: 4px; }

/* System overview (public, below "Log in to view sessions") */
.sessions-login-required { margin-bottom: 1rem; }
.system-overview { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.system-overview-title { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 600; color: var(--text); }
.system-metrics { display: flex; gap: 2rem; flex-wrap: wrap; margin-bottom: 1.5rem; justify-content: center; }
.system-metrics .metric { display: flex; flex-direction: column; gap: 0.25rem; align-items: center; }
.system-metrics .metric-value { font-size: 1.5rem; font-weight: 600; color: var(--primary); }
.system-metrics .metric-value.ok { color: var(--success); }
.system-metrics .metric-value.fail { color: var(--danger); }
.system-metrics .metric-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.system-flowchart-wrap { margin: 1rem 0; overflow: auto; display: flex; justify-content: center; }
.system-flowchart { width: 100%; max-width: 520px; height: auto; display: block; margin: 0 auto; }
.system-flowchart .flow-node { fill: var(--surface); stroke: var(--border); stroke-width: 1.5; transition: fill 0.2s, stroke 0.2s; }
.system-flowchart .flow-node:hover { fill: rgba(88, 166, 255, 0.12); stroke: var(--primary); }
.system-flowchart .flow-node-db { fill: rgba(63, 185, 80, 0.08); stroke: var(--success); }
.system-flowchart .flow-node-db:hover { fill: rgba(63, 185, 80, 0.18); }
.system-flowchart text { font-size: 11px; fill: var(--text); font-family: system-ui, -apple-system, sans-serif; text-anchor: middle; dominant-baseline: middle; pointer-events: none; }
.system-overview-hint { margin: 0.75rem 0 0 0; font-size: 0.85rem; color: var(--muted); }

/* System info card (below Platform status) */
.system-info { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.system-info-title { margin: 0 0 1rem 0; font-size: 1rem; font-weight: 600; color: var(--text); }
.system-info-metrics { display: flex; gap: 2rem; flex-wrap: wrap; justify-content: center; }
.system-info-metrics .info-metric { display: flex; flex-direction: column; gap: 0.25rem; align-items: center; }
.system-info-metrics .info-metric-value { font-size: 1.1rem; font-weight: 500; color: var(--primary); }
.system-info-metrics .info-metric-value.ok { color: var(--success); }
.system-info-metrics .info-metric-value.fail { color: var(--danger); }
.system-info-metrics .info-metric-label { font-size: 0.8rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }

/* Quick links card ("From Glenn De Gelas") */
.quick-links-card { margin-top: 1.5rem; padding: 1.25rem; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); text-align: center; }
.quick-links-title { margin: 0 0 0.5rem 0; font-size: 1rem; font-weight: 600; color: var(--text); }
.quick-links-intro { margin: 0 0 1rem 0; font-size: 0.9rem; color: var(--muted); line-height: 1.45; }
.quick-links-buttons { display: flex; gap: 1rem; flex-wrap: wrap; justify-content: center; }
.quick-links-buttons .quick-link-btn { text-decoration: none; display: inline-block; }

.footer { margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 0.5rem; font-size: 0.85rem; }
.footer a { color: var(--primary); }

.link-session { color: var(--primary); text-decoration: none; }
.link-session:hover { text-decoration: underline; }
.data-table .vnc-password { white-space: nowrap; }
.data-table .vnc-password code.vnc-pw { font-size: 0.85em; margin-right: 0.5rem; }
.data-table .client-login { white-space: nowrap; }
.data-table .client-login code.client-password { font-size: 0.85em; margin-right: 0.35rem; }
.data-table .client-login .btn-copy-password { margin-left: 0.25rem; }
.payments-tenant-hint { margin-bottom: 1rem; }
.payments-tenant-hint h3 { margin-top: 0; }
.hint { font-size: 0.85rem; color: var(--muted); margin-bottom: 1rem; }
.container-info {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  min-width: 16rem;
  padding: 0.2rem 0;
}
.container-info .container-meta {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  flex-direction: column;
}
.container-info .container-meta span { color: var(--muted); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; min-width: 4.9rem; }
.container-info .container-meta code {
  font-size: 0.8rem;
  word-break: break-all;
  display: inline-block;
  padding: 0.12rem 0;
}
.container-info .container-meta + .container-meta {
  border-top: 1px dashed rgba(139, 148, 158, 0.25);
  padding-top: 0.55rem;
}
.container-info .role-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  border-top: 1px dashed rgba(139, 148, 158, 0.25);
  padding-top: 0.6rem;
}
.container-info .role-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.15rem 0.35rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 0.74rem;
  background: rgba(255,255,255,0.02);
}
.container-info .role-chip code { font-size: 0.72rem; }

.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.7); }
.modal-content { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem; max-width: 28rem; box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.modal-content-wide { max-width: min(52rem, 96vw); width: min(52rem, 96vw); }
.modal-title { margin: 0 0 0.75rem 0; font-size: 1.15rem; }
.modal-message { margin: 0 0 1.25rem 0; color: var(--muted); font-size: 0.95rem; line-height: 1.5; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; }
.fulfill-form { margin: 1rem 0; }
.fulfill-form .form-row { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; align-items: center; }
.fulfill-form .form-row label { display: flex; flex-direction: column; gap: 0.25rem; font-size: 0.9rem; }
.fulfill-form .form-row input { padding: 0.5rem 0.6rem; border-radius: 6px; border: 1px solid var(--border); background: var(--bg); color: var(--text); min-width: 12rem; }
.fulfill-form .form-row input:focus { outline: none; border-color: var(--primary); }
.history-log {
  margin: 0 0 1rem 0;
  max-height: 60vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.82rem;
  line-height: 1.4;
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.75rem;
}

@media (max-width: 960px) {
  .layout { padding: 0.85rem; }
  .data-table.sessions-list-table thead { display: none; }
  .data-table.sessions-list-table,
  .data-table.sessions-list-table tbody,
  .data-table.sessions-list-table tr,
  .data-table.sessions-list-table td {
    display: block;
    width: 100%;
  }
  .data-table.sessions-list-table tr.session-row {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 0.9rem;
    background: rgba(255,255,255,0.02);
    overflow: hidden;
  }
  .data-table.sessions-list-table td {
    border-bottom: 1px solid rgba(255,255,255,0.06);
    padding: 0.5rem 0.65rem;
  }
  .data-table.sessions-list-table td:last-child { border-bottom: none; }
  .data-table.sessions-list-table td::before {
    content: attr(data-label);
    display: block;
    color: var(--muted);
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.2rem;
  }
  .data-table.sessions-list-table .actions {
    min-width: 0;
    padding: 0.65rem;
  }
  .data-table.sessions-list-table .actions .action-row .btn,
  .data-table.sessions-list-table .actions .action-row a.btn,
  .data-table.sessions-list-table .actions .deploy-actions-grid .btn {
    flex: 1 1 calc(50% - 0.35rem);
    text-align: center;
  }
  .data-table.sessions-list-table .actions .deploy-actions-panel {
    padding: 0.35rem 0.45rem;
  }
  .container-info { min-width: 0; }
}

/* Specialized Templates Modal */
.specialized-templates-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.specialized-templates-filters label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.85rem;
}
.specialized-templates-filters select {
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
}
.specialized-templates-filters select:focus {
  outline: none;
  border-color: var(--primary);
}

.specialized-templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
  margin: 1rem 0;
  max-height: 60vh;
  overflow-y: auto;
  padding: 0.5rem;
}

.template-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: border-color 0.2s, background 0.2s;
}
.template-card:hover {
  border-color: var(--primary);
  background: rgba(255,255,255,0.05);
}

.template-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.template-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
}

.template-badge {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.template-badge-category {
  background: rgba(88, 166, 255, 0.2);
  color: var(--primary);
  border: 1px solid rgba(88, 166, 255, 0.3);
}
.template-badge-category.template-badge-trading {
  background: rgba(63, 185, 80, 0.2);
  color: var(--success);
  border-color: rgba(63, 185, 80, 0.3);
}
.template-badge-category.template-badge-ml {
  background: rgba(255, 123, 172, 0.2);
  color: #ff7bac;
  border-color: rgba(255, 123, 172, 0.3);
}
.template-badge-category.template-badge-data {
  background: rgba(255, 184, 0, 0.2);
  color: #ffb800;
  border-color: rgba(255, 184, 0, 0.3);
}
.template-badge-category.template-badge-architecture {
  background: rgba(138, 180, 248, 0.2);
  color: #8ab4f8;
  border-color: rgba(138, 180, 248, 0.3);
}

.template-badge-tier {
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  border: 1px solid var(--border);
}
.template-badge-tier.template-badge-free {
  background: rgba(63, 185, 80, 0.15);
  color: var(--success);
  border-color: rgba(63, 185, 80, 0.3);
}
.template-badge-tier.template-badge-pro {
  background: rgba(88, 166, 255, 0.15);
  color: var(--primary);
  border-color: rgba(88, 166, 255, 0.3);
}
.template-badge-tier.template-badge-enterprise {
  background: rgba(255, 123, 172, 0.15);
  color: #ff7bac;
  border-color: rgba(255, 123, 172, 0.3);
}

.template-description {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.template-features,
.template-use-cases {
  font-size: 0.85rem;
  color: var(--text);
}
.template-features strong,
.template-use-cases strong {
  color: var(--text);
  font-size: 0.9rem;
}
.template-features ul,
.template-use-cases ul {
  margin: 0.5rem 0 0 0;
  padding-left: 1.25rem;
  color: var(--muted);
}
.template-features li,
.template-use-cases li {
  margin: 0.25rem 0;
  line-height: 1.4;
}

.template-pricing {
  font-size: 0.85rem;
  color: var(--primary);
  font-weight: 600;
  padding: 0.5rem;
  background: rgba(88, 166, 255, 0.1);
  border-radius: 4px;
  border: 1px solid rgba(88, 166, 255, 0.2);
}

.template-setup-time {
  font-size: 0.8rem;
  color: var(--muted);
  font-style: italic;
}

.template-create-btn {
  margin-top: auto;
  width: 100%;
}

@media (max-width: 960px) {
  .specialized-templates-grid {
    grid-template-columns: 1fr;
  }
  .specialized-templates-filters {
    flex-direction: column;
  }
}
