/* Phase 2 — App shell: dark theme tokens + shared UI primitives (01-login, control tower, platform) */
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--app-bg);
  color: var(--app-text);
}

:root {
  /* Dark theme (01-login.md) */
  --app-bg: #0a0a0a;
  --app-card: #111;
  --app-border: #1e1e1e;
  --app-primary: #3b82f6;
  --app-primary-hover: #2563eb;
  --app-text: #e2e8f0;
  --app-text-bright: #f8fafc;
  --app-text-muted: #64748b;
  --app-text-muted2: #94a3b8;
  /* Semantic */
  --app-success: #22c55e;
  --app-warning: #f59e0b;
  --app-error: #ef4444;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 24px;
  border-bottom: 1px solid var(--app-border);
  background: rgba(10,10,10,0.95);
  flex-shrink: 0;
}
.app-header-left { display: flex; align-items: center; gap: 24px; }
.app-logo { font-weight: 300; font-size: 10px; color: var(--app-text-muted); text-transform: uppercase; letter-spacing: 0.15em; }
/* Reserve a fixed width for the title block so switching between
   "CONTROL TOWER" (13ch) and "PLATFORM MANAGEMENT" (19ch) doesn't
   shift the L1 pills, the tenant/project selectors and the KPIs to
   the right. Sized to fit the longer of the two with a small margin. */
.app-title { font-weight: 700; font-size: 20px; color: var(--app-text-bright); min-width: 22ch; white-space: nowrap; }

/* Project selector wrapper (Block 03) */
.project-selector-wrapper {
  position: relative;
}
.project-selector {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  font-family: inherit;
  font-size: inherit;
}
.project-selector:hover {
  border-color: #333;
}
.project-selector .label { font-size: 12px; color: var(--app-text-muted); }
.project-selector .value { font-size: 14px; font-weight: 600; color: var(--app-text-bright); }
.project-selector .chevron {
  color: var(--app-text-muted);
  font-size: 10px;
  margin-left: 8px;
  transition: transform 0.2s;
}
.project-selector-wrapper.open .project-selector .chevron {
  transform: rotate(180deg);
}
.project-dropdown-container {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 100;
  display: none;
}
.project-selector-wrapper.open .project-dropdown-container {
  display: block;
}

/* Project dropdown menu fragment (GET /api/projects/dropdown) */
/* Use a.project-dropdown-item + :visited so link UA / :visited colors never wash out on dark bg */
.project-dropdown-menu {
  display: flex;
  flex-direction: column;
  min-width: 220px;
  padding: 8px 0;
  background: var(--app-card, #171717);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  color-scheme: dark;
}
.project-dropdown-menu a.project-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: #e4e9ef;
  text-decoration: none;
  white-space: nowrap;
}
.project-dropdown-menu .project-dropdown-item-icon {
  flex-shrink: 0;
  display: flex;
  width: 18px;
  height: 18px;
  color: inherit;
  opacity: 0.9;
}
.project-dropdown-menu .project-dropdown-item-icon svg {
  width: 100%;
  height: 100%;
}
.project-dropdown-menu .project-dropdown-item-label {
  min-width: 0;
}
.project-dropdown-menu a.project-dropdown-item:visited {
  color: #e4e9ef;
}
.project-dropdown-menu a.project-dropdown-item:hover {
  background: rgba(59, 130, 246, 0.18);
  color: #f8fafc;
}
.project-dropdown-menu a.project-dropdown-item--active {
  font-weight: 600;
  color: var(--app-primary, #60a5fa);
}
.project-dropdown-menu a.project-dropdown-item--active:visited {
  color: var(--app-primary, #60a5fa);
}
.project-dropdown-menu a.project-dropdown-item--action {
  color: #acb6c9;
}
.project-dropdown-menu a.project-dropdown-item--action:visited {
  color: #acb6c9;
}
.project-dropdown-menu a.project-dropdown-item--action:hover {
  color: #f1f5f9;
}
.project-dropdown-sep {
  height: 1px;
  margin: 4px 0;
  background: var(--app-border);
}

/* KPIs row */
.app-kpis { display: flex; gap: 40px; }
.kpi-item { text-align: center; }
.kpi-item .label { font-size: 9px; color: var(--app-text-muted); text-transform: uppercase; letter-spacing: 0.1em; margin-bottom: 2px; }
.kpi-item .value { font-size: 18px; font-weight: 600; color: var(--app-text-bright); }
.kpi-item .value .unit { font-size: 12px; color: var(--app-text-muted); font-weight: 400; }
.kpi-item .value.warning { color: var(--app-warning); }

/* Tabs */
.tabs-bar {
  display: flex;
  justify-content: center;
  padding: 12px 0;
  background: rgba(10,10,10,0.9);
  border-bottom: 1px solid var(--app-border);
  flex-shrink: 0;
}
.tab-btn {
  padding: 10px 24px;
  font-size: 12px;
  font-weight: 500;
  color: var(--app-text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  text-decoration: none;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: inherit;
}
.tab-btn:hover { color: var(--app-text-muted2); }
.tab-btn.active { color: var(--app-text-bright); border-bottom-color: var(--app-primary); }

/* Buttons */
.btn {
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
}
.btn-primary { background: var(--app-primary); color: #fff; }
.btn-primary:hover { background: var(--app-primary-hover); }
.btn-secondary { background: transparent; border: 1px solid var(--app-border); color: var(--app-text-muted2); }
.btn-secondary:hover { border-color: #333; color: var(--app-text-bright); }

/* Form primitives */
.form-group { margin-bottom: 24px; }
.form-label { display: block; font-size: 12px; font-weight: 500; color: var(--app-text-muted2); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 8px; }
.form-input {
  width: 100%;
  padding: 12px 16px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  font-size: 14px;
  color: var(--app-text-bright);
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
}
.form-input:focus { border-color: var(--app-primary); }
.form-input::placeholder { color: #4a5568; }

/* Card */
.app-card {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 24px;
}

/* Table base */
.table-container { background: var(--app-card); border: 1px solid var(--app-border); border-radius: 12px; overflow: hidden; }
.table-header {
  display: grid;
  padding: 14px 24px;
  background: var(--app-bg);
  border-bottom: 1px solid var(--app-border);
  font-size: 10px;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.table-row {
  display: grid;
  padding: 16px 24px;
  border-bottom: 1px solid var(--app-border);
  align-items: center;
}
.table-row:last-child { border-bottom: none; }
.table-row:hover { background: rgba(59,130,246,0.03); }

/* Modal base */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.modal-box {
  background: var(--app-card);
  border: 1px solid var(--app-border);
  border-radius: 12px;
  padding: 24px;
  max-width: 90vw;
  max-height: 90vh;
  overflow: auto;
}

/* Drawer base */
.drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 400px;
  max-width: 90vw;
  background: var(--app-card);
  border: 1px solid var(--app-border);
  z-index: 100;
  overflow-y: auto;
}
.drawer-left { left: 0; border-right: 1px solid var(--app-border); }
.drawer-right { right: 0; border-left: 1px solid var(--app-border); }

/* Back link */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--app-text-muted);
  text-decoration: none;
  padding: 8px 16px;
  border: 1px solid var(--app-border);
  border-radius: 8px;
  transition: all 0.2s;
}
.back-link:hover { border-color: #333; color: var(--app-text-bright); }

/* Screen wrapper */
.screen {
  width: 100%;
  min-height: 100vh;
  background: var(--app-bg);
  display: flex;
  flex-direction: column;
}

.main-content { flex: 1; padding: 24px; }
.main-content--centered { display: flex; align-items: center; justify-content: center; }

/* Live Flow v1 — 3-column layout (Block 04) */
.live-flow-three-cols {
  display: grid;
  grid-template-columns: 280px 1fr 280px;
  gap: 0;
  height: 100%;
  min-height: 60vh;
  background: var(--app-bg);
}
.live-flow-panel {
  display: flex;
  flex-direction: column;
  background: var(--app-card);
  border-right: 1px solid var(--app-border);
  overflow: hidden;
}
.live-flow-panel:last-of-type {
  border-right: none;
  border-left: 1px solid var(--app-border);
}
.live-flow-panel-header {
  padding: 14px 16px;
  border-bottom: 1px solid var(--app-border);
  font-size: 10px;
  font-weight: 600;
  color: var(--app-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.live-flow-panel-header .count { color: var(--app-text); font-weight: 700; }
.live-flow-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.live-flow-center {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--app-bg);
  color: var(--app-text-muted);
  font-size: 13px;
  padding: 24px;
}
.live-flow-queue-card {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: border-color 0.2s;
}
.live-flow-queue-card:hover { border-color: #333; }
.live-flow-queue-card.critical { border-color: var(--app-warning); }
.live-flow-queue-card .name { font-weight: 600; font-size: 13px; color: var(--app-text-bright); }
.live-flow-queue-card .meta { font-size: 11px; color: var(--app-text-muted); margin-top: 4px; }
.live-flow-queue-card .backlog { font-size: 12px; color: var(--app-text-muted2); margin-top: 6px; }
.live-flow-worker-cell {
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}
.live-flow-worker-cell:hover { border-color: #333; }
.live-flow-worker-cell .status-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.live-flow-worker-cell .status-dot.online { background: var(--app-success); }
.live-flow-worker-cell .status-dot.offline { background: var(--app-text-muted); }
.live-flow-worker-cell .info { flex: 1; min-width: 0; }
.live-flow-worker-cell .hostname { font-weight: 600; font-size: 12px; color: var(--app-text-bright); }
.live-flow-worker-cell .gpus { font-size: 11px; color: var(--app-text-muted); margin-top: 2px; }
.live-flow-empty, .live-flow-error, .live-flow-loading {
  text-align: center;
  padding: 24px 16px;
  color: var(--app-text-muted);
  font-size: 13px;
}
.live-flow-error { color: var(--app-error); }
.live-flow-empty a, .live-flow-error a { color: var(--app-primary); text-decoration: none; }
.live-flow-empty a:hover, .live-flow-error a:hover { text-decoration: underline; }

/* Live Flow drawers (Block 05) */
.live-flow-drawer-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 200;
  opacity: 0; pointer-events: none; transition: opacity 0.2s;
}
.live-flow-drawer-overlay.open { opacity: 1; pointer-events: auto; }
.live-flow-drawer {
  position: fixed; top: 0; bottom: 0; width: 380px; max-width: 90vw;
  background: var(--app-card); border: 1px solid var(--app-border);
  z-index: 201; overflow-y: auto; transition: transform 0.2s;
}
.live-flow-drawer.drawer-left { left: 0; border-right: 1px solid var(--app-border); transform: translateX(-100%); }
.live-flow-drawer.drawer-left.open { transform: translateX(0); }
.live-flow-drawer.drawer-right { right: 0; border-left: 1px solid var(--app-border); transform: translateX(100%); }
.live-flow-drawer.drawer-right.open { transform: translateX(0); }
.live-flow-drawer-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--app-border);
}
.live-flow-drawer-header h2 { font-size: 16px; font-weight: 600; margin: 0; color: var(--app-text-bright); }
.live-flow-drawer-close {
  background: none; border: none; color: var(--app-text-muted); cursor: pointer;
  font-size: 24px; line-height: 1; padding: 0 4px;
}
.live-flow-drawer-close:hover { color: var(--app-text-bright); }
.live-flow-drawer-body { padding: 20px; }
.live-flow-drawer-section { margin-bottom: 20px; }
.live-flow-drawer-section h3 { font-size: 11px; color: var(--app-text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 10px; }
.live-flow-drawer-stats { display: grid; gap: 10px; }
.live-flow-drawer-stat { display: flex; justify-content: space-between; font-size: 13px; }
.live-flow-drawer-stat .label { color: var(--app-text-muted); }
.live-flow-drawer-list { list-style: none; padding: 0; margin: 0; }
.live-flow-drawer-list li { padding: 8px 0; border-bottom: 1px solid var(--app-border); font-size: 13px; }
.live-flow-drawer-list li:last-child { border-bottom: none; }
.live-flow-drawer-cta { margin-top: 24px; }
.live-flow-drawer-cta .btn { width: 100%; justify-content: center; }
