
:root {
  --bg: #0F172A;
  --bg2: #1E293B;
  --bg3: #334155;
  --bg4: #475569;
  --border: #1E293B;
  --border2: #334155;
  --text: #F8FAFC;
  --muted: #94A3B8;
  --muted2: #CBD5E1;
  --green: #10B981;
  --green-bg: rgba(16, 185, 129, 0.1);
  --green-border: rgba(16, 185, 129, 0.2);
  --red: #EF4444;
  --red-bg: rgba(239, 68, 68, 0.1);
  --red-border: rgba(239, 68, 68, 0.2);
  --amber: #F59E0B;
  --amber-bg: rgba(245, 158, 11, 0.1);
  --amber-border: rgba(245, 158, 11, 0.2);
  --accent: #2563EB;
  --accent-bg: rgba(37, 99, 235, 0.15);
  --accent-border: rgba(37, 99, 235, 0.3);
  --mono: 'JetBrains Mono', monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --display: 'Poppins', sans-serif;
  --sidebar-w: 260px;
}

body.light {
  --bg: #F8FAFC;
  --bg2: #FFFFFF;
  --bg3: #F1F5F9;
  --bg4: #E2E8F0;
  --border: #E2E8F0;
  --border2: #CBD5E1;
  --text: #0F172A;
  --muted: #64748B;
  --muted2: #475569;
  --green: #059669;
  --green-bg: rgba(5, 150, 105, 0.1);
  --green-border: rgba(5, 150, 105, 0.2);
  --red: #DC2626;
  --red-bg: rgba(220, 38, 38, 0.1);
  --red-border: rgba(220, 38, 38, 0.2);
  --amber: #D97706;
  --amber-bg: rgba(217, 119, 6, 0.1);
  --amber-border: rgba(217, 119, 6, 0.2);
  --accent: #2563EB;
  --accent-bg: rgba(37, 99, 235, 0.1);
  --accent-border: rgba(37, 99, 235, 0.25);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { 
  background: var(--bg); 
  color: var(--text); 
  font-family: var(--sans); 
  height: 100vh; 
  overflow: hidden; 
  transition: background 0.2s ease, color 0.2s ease; 
}

h1, h2, h3, h4, h5, h6, .os-brand, .sec-title, .kl {
  font-family: var(--display);
}

.os-layout { display: flex; height: 100vh; width: 100vw; }

/* Sidebar */
.os-sidebar { 
  width: var(--sidebar-w); 
  background: var(--bg2); 
  border-right: 1px solid var(--border); 
  display: flex; 
  flex-direction: column; 
  padding: 32px 0; 
  overflow-y: auto; 
  flex-shrink: 0; 
}
.os-nav-bottom {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  position: sticky;
  bottom: 0;
  background: var(--bg2);
  z-index: 1;
}
.os-brand { 
  font-size: 16px; 
  font-weight: 600; 
  letter-spacing: .02em; 
  color: var(--text); 
  padding: 0 24px 24px; 
  margin-bottom: 12px; 
  border-bottom: 1px solid var(--border); 
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.os-nav-label { 
  font-family: var(--sans); 
  font-size: 11px; 
  font-weight: 600; 
  letter-spacing: .06em; 
  color: var(--muted); 
  text-transform: uppercase; 
  margin: 24px 24px 8px; 
  background: none;
  border: none;
  width: calc(100% - 48px);
  text-align: left;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0;
}
.os-nav-label.collapsible {
  cursor: pointer;
  transition: color .2s ease;
}
.os-nav-label.collapsible:hover {
  color: var(--text);
}
.os-nav-label-icon {
  font-size: 8px;
  transition: transform .2s ease;
}
.os-nav-label.collapsed .os-nav-label-icon {
  transform: rotate(-90deg);
}
.os-nav-group { display: flex; flex-direction: column; padding: 0 12px; transition: max-height .3s ease; }
.os-nav-main-group { flex: 1; }
.os-nav-sublabel { margin: 12px 12px 4px; font-size: 10px; width: calc(100% - 24px); }
.os-nav-subgroup { padding: 0 0 0 12px; }
.os-nav-muted { opacity: 0.5; }
.os-nav-link {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-decoration: none;
  padding: 10px 16px;
  margin-bottom: 4px;
  border-radius: 8px;
  transition: all .15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.os-nav-link:hover { color: var(--text); background: var(--bg3); }
.os-nav-link.active { color: var(--accent); background: var(--accent-bg); font-weight: 600; }

/* Main Area */
.os-main { flex: 1; position: relative; overflow: hidden; background: var(--bg); }
.os-view { position: absolute; inset: 0; display: none; }
.os-view.active { display: block; }
.full-iframe { width: 100%; height: 100%; border: none; display: block; background: var(--bg); }
.placeholder-msg { display: flex; align-items: center; justify-content: center; height: 100%; font-family: var(--sans); color: var(--muted); font-size: 14px; font-weight: 500; }

/* Nav dev badge */
.os-nav-dev-badge { font-size: 11px; opacity: .7; }

/* Operations always-open label */
.os-ops-label { cursor: default !important; }
.os-ops-label:hover { color: var(--muted) !important; }

/* Nav link flex row (for dev badge alignment) */
.os-nav-link { display: flex; align-items: center; justify-content: space-between; }

/* Dev / Under-development page message */
.dev-page-msg {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 60vh;
  gap: 16px;
  text-align: center;
}
.dev-page-emoji { font-size: 56px; line-height: 1; }
.dev-page-title {
  font-family: var(--display);
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
}
.dev-page-sub {
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
}

/* Home Controls */
.top-controls { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  margin-bottom: 48px; 
  background: var(--bg2); 
  padding: 16px 24px; 
  border-radius: 16px; 
  border: 1px solid var(--border); 
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}
.control-group { display: flex; align-items: center; gap: 16px; }
.control-label { font-family: var(--sans); font-weight: 600; font-size: 11px; letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.os-select { 
  font-family: var(--sans); 
  font-size: 14px; 
  font-weight: 500;
  background: var(--bg3); 
  border: 1px solid var(--border2); 
  border-radius: 8px; 
  color: var(--text); 
  padding: 8px 12px; 
  cursor: pointer; 
  outline: none; 
  transition: all 0.2s ease; 
}
.os-select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }
.os-btn { 
  font-family: var(--sans); 
  font-size: 14px; 
  font-weight: 600; 
  padding: 8px 16px; 
  background: var(--accent); 
  border: 1px solid transparent; 
  border-radius: 8px; 
  color: #ffffff; 
  cursor: pointer; 
  transition: all .2s ease; 
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.os-btn:hover { opacity: 0.9; transform: translateY(-1px); }
.os-btn.secondary { background: var(--bg3); border-color: var(--border2); color: var(--text); }
.os-btn.secondary:hover { background: var(--bg4); }
.fx-badge { 
  font-family: var(--mono); 
  font-size: 12px; 
  background: transparent; 
  border: 1px solid var(--border2); 
  border-radius: 8px; 
  padding: 8px 12px; 
  color: var(--muted); 
  display: flex; 
  align-items: center; 
  gap: 8px; 
  margin-left: 12px; 
  font-weight: 500;
}
.fx-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

/* Section Headers */
.sec-hdr { display: flex; align-items: center; gap: 16px; margin-bottom: 24px; }
.sec-title { font-size: 18px; font-weight: 600; color: var(--text); letter-spacing: 0; }
.sec-hdr::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* Portfolio Grid */
.portfolio-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 24px; }
.kc { 
  background: var(--bg2); 
  border: 1px solid var(--border); 
  border-radius: 16px; 
  padding: 24px; 
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.kc:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.kc.star { border-color: var(--accent); background: linear-gradient(180deg, var(--bg2) 0%, var(--accent-bg) 100%); }
.kc.profit { border-color: var(--green); background: linear-gradient(180deg, var(--bg2) 0%, var(--green-bg) 100%); }
.kc.loss { border-color: var(--red); background: linear-gradient(180deg, var(--bg2) 0%, var(--red-bg) 100%); }
.kl { font-size: 14px; font-weight: 500; color: var(--muted); margin-bottom: 16px; letter-spacing: 0; }
.kv { font-family: var(--mono); font-size: 28px; font-weight: 600; color: var(--text); line-height: 1; letter-spacing: -0.02em; }
.kc.star .kv { color: var(--accent); }
.kc.profit .kv { color: var(--green); }
.kc.loss .kv { color: var(--red); }
.ksub { font-family: var(--sans); font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 12px; }

/* Stores Grid */
.stores-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 24px; }
.store-card { 
  background: var(--bg2); 
  border: 1px solid var(--border); 
  border-radius: 16px; 
  padding: 24px; 
  display: flex; 
  flex-direction: column; 
  gap: 20px; 
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  transition: transform 0.2s ease;
}
.store-card:hover { transform: translateY(-2px); box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06); }
.store-card.muted { opacity: 0.6; }
.sc-top { display: flex; justify-content: space-between; align-items: flex-start; }
.sc-name { font-family: var(--display); font-size: 20px; font-weight: 600; color: var(--text); margin-bottom: 4px; }
.sc-badges { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.badge { font-family: var(--sans); font-size: 11px; font-weight: 600; padding: 4px 10px; border-radius: 20px; border: 1px solid var(--border); background: var(--bg3); color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.badge.green { background: var(--green-bg); color: var(--green); border-color: var(--green-border); }
.badge.amber { background: var(--amber-bg); color: var(--amber); border-color: var(--amber-border); }
.sc-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.sc-stat { display: flex; flex-direction: column; gap: 6px; }
.ss-l { font-family: var(--sans); font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; }
.ss-v { font-family: var(--mono); font-size: 15px; font-weight: 500; color: var(--text); }
.sc-actions { display: flex; gap: 12px; margin-top: auto; padding-top: 20px; border-top: 1px solid var(--border); }
.sc-btn { flex: 1; text-align: center; font-family: var(--sans); font-size: 13px; font-weight: 600; padding: 10px 0; background: var(--bg3); border: 1px solid var(--border); border-radius: 8px; color: var(--text); cursor: pointer; transition: all .2s ease; text-decoration: none; }
.sc-btn:hover { background: var(--bg4); border-color: var(--border2); color: var(--accent); }

/* Task Manager */
.tasks-container { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; padding: 24px; box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1); }
.tasks-filters { display: flex; gap: 16px; margin-bottom: 24px; }
.os-table { width: 100%; border-collapse: collapse; }
.os-table th { font-family: var(--sans); font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; padding: 16px; text-align: left; border-bottom: 1px solid var(--border); }
.os-table td { font-family: var(--sans); font-size: 14px; font-weight: 500; color: var(--text); padding: 16px; border-bottom: 1px solid var(--border); }
.os-table tr:last-child td { border-bottom: none; }
.os-table tr:hover td { background: var(--bg); }
.task-status { cursor: pointer; color: var(--muted); font-weight: 600; text-transform: capitalize; }

/* Modals & Forms */
.os-modal { display: none; position: fixed; inset: 0; background: rgba(15, 23, 42, 0.8); backdrop-filter: blur(8px); z-index: 1000; align-items: center; justify-content: center; }
.os-modal.open { display: flex; }
.os-modal-content { background: var(--bg2); border: 1px solid var(--border); border-radius: 16px; width: 800px; max-width: 90vw; max-height: 90vh; overflow-y: auto; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25); }
.os-modal-hdr { display: flex; align-items: center; justify-content: space-between; padding: 24px; border-bottom: 1px solid var(--border); }
.os-close-btn { background: transparent; border: none; color: var(--muted); font-size: 28px; line-height: 1; cursor: pointer; transition: color .2s; }
.os-close-btn:hover { color: var(--text); }
.os-modal-body { padding: 32px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 32px; }
.fg-col { display: flex; flex-direction: column; gap: 16px; }
.fg-col label { font-family: var(--sans); font-weight: 600; font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .02em; margin-bottom: -8px; }
.fg-col input, .fg-col select { font-family: var(--sans); font-size: 14px; font-weight: 500; background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text); padding: 12px 16px; outline: none; transition: all .2s; }
.fg-col input:focus, .fg-col select:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-bg); }

/* Pill Filters */
.pill-group {
  display: flex;
  gap: 8px;
  background: var(--bg2);
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--border);
}

.pill {
  padding: 8px 16px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover {
  color: var(--text);
  background: var(--bg3);
}

.pill.active {
  background: var(--accent);
  color: #fff;
}

/* Metric Cards Row */
.metrics-row {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 20px;
  margin-bottom: 32px;
}

.metric-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.metric-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.metric-value {
  font-family: var(--mono);
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
}

.metric-sub {
  font-size: 12px;
  font-weight: 600;
}

.metric-sub.positive { color: var(--green); }
.metric-sub.negative { color: var(--red); }

/* Kanban Board */
#pipeline-viewport {
  margin-top: 32px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

#swimlane-container {
  display: flex;
  gap: 1.5rem;
  overflow-x: auto;
  padding: 8px 0 24px;
  align-items: flex-start;
}

.swimlane {
  flex: 0 0 320px;
  min-height: 500px;
  background: var(--bg3);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
}

/* Task Manager Badges */
.badge.status-todo { background: var(--bg4); color: var(--muted2); }
.badge.status-in-progress { background: var(--accent-bg); color: var(--accent); }

.badge.priority-low { background: var(--bg4); color: var(--muted2); }
.badge.priority-medium { background: rgba(245, 158, 11, 0.2); color: #f59e0b; }
.badge.priority-high { background: var(--red-bg); color: var(--red); }

.task-manager-section { margin-top: 48px; }
.task-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.task-filters { display: flex; gap: 12px; align-items: center; }

.action-btn { 
  background: var(--bg3); 
  border: 1px solid var(--border); 
  border-radius: 6px; 
  padding: 4px 8px; 
  cursor: pointer; 
  font-size: 12px; 
  transition: all 0.2s; 
  color: var(--text);
}
.action-btn:hover { background: var(--bg4); }
.action-btn.done:hover { color: var(--green); border-color: var(--green); }
.action-btn.delete:hover { color: var(--red); border-color: var(--red); }

.swimlane.optimizing {
  background: rgba(245, 158, 11, 0.05);
  border-color: rgba(245, 158, 11, 0.2);
}

.swimlane.scaling {
  background: rgba(16, 185, 129, 0.05);
  border-color: rgba(16, 185, 129, 0.2);
}

.swimlane.muted {
  opacity: 0.6;
  filter: grayscale(1);
}

.lane-header {
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.lane-title {
  font-family: var(--display);
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lane-count {
  background: var(--bg4);
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
}

.lane-cards {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
}

/* Home Mini Card */
.home-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
}

.home-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.card-title {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.card-badges {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.card-pl-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 10px;
  border-top: 1px dotted var(--border);
}

.card-pl-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
}

.card-pl-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
}

.card-date {
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

/* Expanded Store Card */
.store-card-expanded {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.expanded-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  font-size: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.stat-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

.stat-value {
  font-family: var(--mono);
  font-weight: 600;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.icon-btn {
  flex: 1;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.icon-btn:hover {
  background: var(--bg4);
}

/* Task Manager Section */
.task-manager-section {
  margin-top: 48px;
}

.task-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.inline-form {
  display: flex;
  gap: 12px;
  background: var(--bg2);
  padding: 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  margin-bottom: 24px;
  align-items: flex-end;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-group label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
}

/* Highlight for deep linking */
.highlighted-card {
  border-color: var(--accent) !important;
  box-shadow: 0 0 0 4px var(--accent-bg) !important;
  transform: scale(1.02);
  z-index: 10;
}

#view-analytics, #view-scaling, #view-exit { padding: 0; overflow: hidden; }

