/* App chrome layouts: sidebar + topbar for PC web app */

.app-shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 42px);
  background: var(--bg);
}

.app-sidebar {
  background: var(--bg-elevated);
  border-right: 1px solid var(--surface-border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 42px;
  height: calc(100vh - 42px);
  overflow-y: auto;
}
.app-sidebar-brand {
  padding: 20px 22px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--surface-border);
}
.app-sidebar-org {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 0.82rem;
}
.app-sidebar-org-logo {
  width: 30px; height: 30px; border-radius: 7px;
  background: var(--gradient-brand);
  display: grid; place-items: center; color: #fff;
  font-family: var(--font-display); font-weight: 700; font-size: 0.82rem;
}
.app-sidebar-org-meta { display: flex; flex-direction: column; line-height: 1.2; }
.app-sidebar-org-name { color: var(--text-primary); font-weight: 600; font-size: 0.85rem; }
.app-sidebar-org-sub { color: var(--text-muted); font-size: 0.7rem; }

.nav-group { padding: 14px 12px 6px; }
.nav-group-label {
  font-family: var(--font-mono); font-size: 0.62rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); padding: 4px 10px; margin-bottom: 2px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--text-body);
  text-decoration: none;
  font-weight: 500;
  position: relative;
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item.active {
  background: color-mix(in srgb, var(--brand-500) 10%, transparent);
  color: var(--brand-600);
}
.nav-item.active::before {
  content: ''; position: absolute;
  left: -12px; top: 6px; bottom: 6px; width: 3px;
  background: var(--accent-500); border-radius: 0 3px 3px 0;
}
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }
.nav-item .nav-badge {
  margin-left: auto;
  font-family: var(--font-mono); font-size: 0.65rem;
  padding: 1px 6px; border-radius: 999px;
  background: var(--accent-500); color: #fff;
}

.app-sidebar-foot {
  margin-top: auto;
  padding: 14px 16px;
  border-top: 1px solid var(--surface-border);
  display: flex; align-items: center; gap: 10px;
  font-size: 0.8rem;
}
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--gradient-accent); color: #fff;
  font-family: var(--font-display); font-weight: 600; font-size: 0.82rem;
  flex-shrink: 0;
}

.app-main { display: flex; flex-direction: column; min-width: 0; }

.app-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 28px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--bg-elevated);
}
.app-toolbar h1 {
  font-size: 1.3rem;
  flex: 1 1 auto;
}
.search {
  flex: 0 1 320px;
  position: relative;
}
.search input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  font-size: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--surface-border);
  background: var(--surface-2);
  color: var(--text-primary);
}
.search svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 14px; height: 14px; color: var(--text-muted);
}

.app-content { padding: 24px 28px 60px; flex: 1; }

.page-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 20px; gap: 16px; flex-wrap: wrap;
}
.page-head h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
.page-head .muted { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}
.kpi {
  padding: 16px 18px;
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  position: relative;
  overflow: hidden;
}
.kpi-label {
  font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 8px;
}
.kpi-value {
  font-family: var(--font-display); font-size: 1.65rem;
  color: var(--text-primary); font-weight: 600;
  letter-spacing: -0.025em;
}
.kpi-delta {
  font-size: 0.74rem; margin-top: 4px;
  display: inline-flex; align-items: center; gap: 4px;
}
.kpi-delta.up { color: var(--success); }
.kpi-delta.down { color: var(--error); }
.kpi.accent::before {
  content: ''; position: absolute;
  right: -40px; top: -40px; width: 120px; height: 120px;
  background: radial-gradient(circle, var(--glow-orange-soft) 0%, transparent 70%);
  pointer-events: none;
}

.panel {
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  overflow: hidden;
}
.panel-head {
  padding: 14px 18px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid var(--surface-border);
  gap: 12px; flex-wrap: wrap;
}
.panel-head h3 { font-size: 1rem; letter-spacing: -0.015em; }
.panel-body { padding: 16px 18px; }
.panel-body.p-0 { padding: 0; }

.two-col { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .two-col, .three-col { grid-template-columns: 1fr; } }

.datatable {
  width: 100%; border-collapse: collapse;
  font-size: 0.84rem;
}
.datatable th {
  text-align: left;
  font-family: var(--font-mono); font-size: 0.68rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); font-weight: 500;
  padding: 10px 18px;
  border-bottom: 1px solid var(--surface-border);
  background: var(--surface-2);
}
.datatable td {
  padding: 12px 18px;
  border-bottom: 1px solid var(--surface-border);
  color: var(--text-body);
  vertical-align: middle;
}
.datatable tr:last-child td { border-bottom: none; }
.datatable tr:hover td { background: var(--surface-2); }
.datatable td strong { color: var(--text-primary); font-weight: 600; }

/* Timeline */
.timeline-slot {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 10px 14px;
  border-radius: 10px;
}
.timeline-slot.now { background: color-mix(in srgb, var(--accent-500) 8%, transparent); }
.timeline-time {
  font-family: var(--font-mono); font-size: 0.76rem;
  color: var(--text-muted); width: 50px; flex-shrink: 0;
  padding-top: 3px;
}
.timeline-slot.now .timeline-time { color: var(--accent-600); font-weight: 600; }
.timeline-slot-body { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.timeline-slot-name { color: var(--text-primary); font-weight: 600; font-size: 0.9rem; }
.timeline-slot-meta { color: var(--text-muted); font-size: 0.78rem; }

.chart-sparkline { width: 100%; height: 120px; }
.chart-bar { width: 100%; height: 160px; }

/* Mobile frame */
.device-wrap {
  padding: 32px 20px;
  min-height: calc(100vh - 42px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 32px;
  flex-wrap: wrap;
  background:
    radial-gradient(ellipse 50% 30% at 20% 10%, var(--glow-orange-soft) 0%, transparent 55%),
    radial-gradient(ellipse 40% 30% at 80% 90%, var(--glow-blue-soft) 0%, transparent 55%),
    var(--bg);
}
.iphone {
  width: 390px;
  height: 844px;
  border-radius: 50px;
  background: #0a0a1a;
  padding: 12px;
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(255,255,255,0.04);
  position: relative;
  flex-shrink: 0;
}
.iphone-screen {
  width: 100%; height: 100%;
  border-radius: 40px;
  overflow: hidden;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  position: relative;
}
.iphone-notch {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 30px; background: #0a0a1a;
  border-radius: 0 0 16px 16px; z-index: 10;
}
.ios-statusbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 32px 8px;
  font-family: var(--font-body);
  font-size: 0.82rem; font-weight: 600;
  color: var(--text-primary);
  flex-shrink: 0;
}
.ios-statusbar-icons { display: flex; align-items: center; gap: 5px; font-size: 0.78rem; }

.device-label {
  font-family: var(--font-mono); font-size: 0.7rem;
  letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--text-muted); margin-bottom: 14px;
  text-align: center;
}

/* Kiosk portrait */
.kiosk-wrap {
  padding: 24px;
  min-height: calc(100vh - 42px);
  display: flex; justify-content: center; align-items: flex-start;
  background: #0a0a1a;
}
.kiosk {
  width: 480px;
  max-width: 100%;
  aspect-ratio: 9/16;
  border-radius: 18px;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--surface-border);
}

/* Tablet landscape */
.tablet-wrap {
  padding: 24px;
  min-height: calc(100vh - 42px);
  display: flex; justify-content: center; align-items: flex-start;
  background: #05081a;
}
.tablet {
  width: 1024px;
  max-width: 100%;
  aspect-ratio: 4/3;
  border-radius: 20px;
  background: #0a0a1a;
  padding: 18px;
  box-shadow: var(--shadow-xl);
}
.tablet-screen {
  width: 100%; height: 100%;
  border-radius: 10px;
  background: var(--bg);
  overflow: hidden;
  display: flex; flex-direction: column;
}

/* Flow navigation */
.flow-nav {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--surface-border);
  font-size: 0.82rem;
}
.flow-step {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 999px;
  background: var(--surface-1); border: 1px solid var(--surface-border);
  color: var(--text-muted); font-size: 0.78rem; font-weight: 500;
  text-decoration: none;
}
.flow-step .num {
  display: inline-grid; place-items: center;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--surface-muted); color: var(--text-muted);
  font-family: var(--font-mono); font-size: 0.64rem;
}
.flow-step.active { background: var(--brand-500); color: #fff; border-color: var(--brand-500); }
.flow-step.active .num { background: rgba(255,255,255,0.25); color: #fff; }
.flow-step.done { color: var(--success); border-color: color-mix(in srgb, var(--success) 30%, transparent); }
.flow-step.done .num { background: var(--success); color: #fff; }
.flow-step-arrow { color: var(--text-muted); font-family: var(--font-mono); }
.flow-nav-actions { margin-left: auto; display: flex; gap: 8px; }

/* Glow accent card */
.glow-card {
  position: relative;
  background: var(--surface-1);
  border: 1px solid var(--surface-border);
  border-radius: 14px;
  padding: 20px;
  overflow: hidden;
}
.glow-card::after {
  content: ''; position: absolute;
  right: -60px; bottom: -60px; width: 200px; height: 200px;
  background: radial-gradient(circle, var(--glow-orange-soft) 0%, transparent 65%);
  pointer-events: none;
}
.glow-card > * { position: relative; z-index: 1; }

/* Status chips */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-live { background: var(--success); box-shadow: 0 0 8px var(--success); animation: pulse 2s infinite; }
.status-wait { background: var(--warning); }
.status-done { background: var(--text-muted); }
@keyframes pulse { 0%,100% {opacity: 1;} 50% {opacity: 0.5;} }

/* AI pill */
.ai-pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-family: var(--font-mono); font-size: 0.66rem;
  letter-spacing: 0.08em; text-transform: uppercase;
  background: linear-gradient(135deg, color-mix(in srgb, var(--accent-500) 15%, transparent), color-mix(in srgb, var(--brand-500) 15%, transparent));
  border: 1px solid color-mix(in srgb, var(--accent-500) 25%, transparent);
  color: var(--accent-700);
}
.ai-pill::before {
  content: ''; width: 6px; height: 6px;
  background: var(--accent-500); border-radius: 50%;
  box-shadow: 0 0 8px var(--accent-500);
  animation: pulse 2s infinite;
}
[data-theme="dark"] .ai-pill { color: var(--accent-300); }

/* Icons */
.icon-btn {
  width: 32px; height: 32px; display: inline-grid; place-items: center;
  border-radius: 8px; border: 1px solid var(--surface-border);
  background: var(--surface-1); color: var(--text-body); cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn svg { width: 16px; height: 16px; }
