/* ============================================================
   OTTEngine Dashboard — Enterprise Dark Theme Design System
   Inspired by Cloudinary Console + Tesla Data Density
   ============================================================ */

/* --- CSS Custom Properties (Design Tokens) --- */
:root {
  /* Background layers */
  --oe-bg-base: #0D1117;
  --oe-bg-surface: #161B22;
  --oe-bg-surface-hover: #1C2128;
  --oe-bg-elevated: #21262D;
  --oe-bg-overlay: #30363D;

  /* Borders */
  --oe-border-default: #30363D;
  --oe-border-muted: #21262D;
  --oe-border-subtle: #1C2128;

  /* Text */
  --oe-text-primary: #E6EDF3;
  --oe-text-secondary: #8B949E;
  --oe-text-muted: #6E7681;
  --oe-text-placeholder: #484F58;

  /* Brand */
  --oe-brand-primary: #3B82F6;
  --oe-brand-primary-hover: #2563EB;
  --oe-brand-primary-muted: rgba(59, 130, 246, 0.15);
  --oe-brand-primary-subtle: rgba(59, 130, 246, 0.08);

  /* Accent colors */
  --oe-accent-green: #22C55E;
  --oe-accent-green-muted: rgba(34, 197, 94, 0.15);
  --oe-accent-red: #EF4444;
  --oe-accent-red-muted: rgba(239, 68, 68, 0.15);
  --oe-accent-yellow: #EAB308;
  --oe-accent-yellow-muted: rgba(234, 179, 8, 0.15);
  --oe-accent-purple: #A855F7;
  --oe-accent-purple-muted: rgba(168, 85, 247, 0.15);
  --oe-accent-cyan: #06B6D4;
  --oe-accent-cyan-muted: rgba(6, 182, 212, 0.15);
  --oe-accent-orange: #F97316;
  --oe-accent-orange-muted: rgba(249, 115, 22, 0.15);

  /* Spacing */
  --oe-sidebar-width-collapsed: 64px;
  --oe-sidebar-width-expanded: 240px;
  --oe-header-height: 56px;
  --oe-content-padding: 24px;

  /* Radius */
  --oe-radius-sm: 6px;
  --oe-radius-md: 8px;
  --oe-radius-lg: 12px;
  --oe-radius-xl: 16px;

  /* Shadows */
  --oe-shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --oe-shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --oe-shadow-lg: 0 8px 24px rgba(0,0,0,0.5);

  /* Transitions */
  --oe-transition-fast: 150ms ease;
  --oe-transition-normal: 250ms ease;
  --oe-transition-slow: 350ms ease;

  /* Typography */
  --oe-font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, Oxygen, Ubuntu, sans-serif;
  --oe-font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', Menlo, Consolas, monospace;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--oe-font-family);
  background-color: var(--oe-bg-base);
  color: var(--oe-text-primary);
  line-height: 1.5;
  overflow-x: hidden;
  min-height: 100vh;
}

a {
  color: var(--oe-brand-primary);
  text-decoration: none;
  transition: color var(--oe-transition-fast);
}
a:hover {
  color: var(--oe-brand-primary-hover);
}

/* --- Layout Shell --- */
.oe-app {
  display: flex;
  min-height: 100vh;
}

/* --- Zone 1: Primary Sidebar --- */
.oe-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--oe-sidebar-width-collapsed);
  background: var(--oe-bg-surface);
  border-right: 1px solid var(--oe-border-default);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: width var(--oe-transition-normal);
  overflow: hidden;
}

.oe-sidebar:hover,
.oe-sidebar.expanded {
  width: var(--oe-sidebar-width-expanded);
}

.oe-sidebar__logo {
  height: var(--oe-header-height);
  display: flex;
  align-items: center;
  padding: 0 12px;
  border-bottom: 1px solid var(--oe-border-default);
  flex-shrink: 0;
  overflow: hidden;
  gap: 10px;
}

.oe-sidebar__logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.oe-sidebar__logo-text {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--oe-text-primary);
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--oe-transition-fast);
  letter-spacing: -0.02em;
}

.oe-sidebar__logo-text-img {
  height: 22px;
  width: auto;
  opacity: 0;
  transition: opacity var(--oe-transition-fast);
  flex-shrink: 0;
}

.oe-sidebar:hover .oe-sidebar__logo-text,
.oe-sidebar.expanded .oe-sidebar__logo-text,
.oe-sidebar:hover .oe-sidebar__logo-text-img,
.oe-sidebar.expanded .oe-sidebar__logo-text-img {
  opacity: 1;
}

.oe-sidebar__nav {
  flex: 1;
  padding: 8px 0;
  overflow-y: auto;
  overflow-x: hidden;
}

.oe-sidebar__nav::-webkit-scrollbar {
  width: 0;
}

.oe-nav-item {
  display: flex;
  align-items: center;
  padding: 10px 20px;
  color: var(--oe-text-secondary);
  cursor: pointer;
  transition: all var(--oe-transition-fast);
  white-space: nowrap;
  gap: 12px;
  position: relative;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 0.93rem;
}

.oe-nav-item:hover {
  background: var(--oe-bg-surface-hover);
  color: var(--oe-text-primary);
}

.oe-nav-item.active {
  color: var(--oe-brand-primary);
  background: var(--oe-brand-primary-subtle);
}

.oe-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--oe-brand-primary);
  border-radius: 0 3px 3px 0;
}

.oe-nav-item__icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.oe-nav-item__icon svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oe-nav-item__label {
  opacity: 0;
  transition: opacity var(--oe-transition-fast);
  font-weight: 500;
}

.oe-sidebar:hover .oe-nav-item__label,
.oe-sidebar.expanded .oe-nav-item__label {
  opacity: 1;
}

.oe-nav-divider {
  height: 1px;
  background: var(--oe-border-default);
  margin: 8px 16px;
}

.oe-sidebar__footer {
  padding: 12px;
  border-top: 1px solid var(--oe-border-default);
  flex-shrink: 0;
}

/* --- Main Content Wrapper --- */
.oe-main {
  margin-left: var(--oe-sidebar-width-collapsed);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--oe-transition-normal);
}

/* --- Header Bar --- */
.oe-header {
  position: sticky;
  top: 0;
  height: var(--oe-header-height);
  background: var(--oe-bg-surface);
  border-bottom: 1px solid var(--oe-border-default);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--oe-content-padding);
  z-index: 900;
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  background: rgba(22, 27, 34, 0.85);
}

.oe-header__left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.oe-header__breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.93rem;
  color: var(--oe-text-secondary);
}

.oe-header__breadcrumb-sep {
  color: var(--oe-text-muted);
}

.oe-header__breadcrumb-current {
  color: var(--oe-text-primary);
  font-weight: 600;
}

.oe-header__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.oe-header__icon-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--oe-radius-sm);
  border: none;
  background: transparent;
  color: var(--oe-text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--oe-transition-fast);
  position: relative;
}

.oe-header__icon-btn:hover {
  background: var(--oe-bg-elevated);
  color: var(--oe-text-primary);
}

.oe-header__icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.oe-header__notification-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--oe-accent-red);
  border-radius: 50%;
  border: 2px solid var(--oe-bg-surface);
}

.oe-header__user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 4px 4px;
  border-radius: var(--oe-radius-md);
  cursor: pointer;
  transition: background var(--oe-transition-fast);
  border: 1px solid transparent;
  background: none;
  color: var(--oe-text-primary);
}

.oe-header__user:hover {
  background: var(--oe-bg-elevated);
  border-color: var(--oe-border-default);
}

.oe-header__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--oe-brand-primary), var(--oe-accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 600;
  color: #fff;
  flex-shrink: 0;
}

.oe-header__user-name {
  font-weight: 500;
  font-size: 0.86rem;
}

.oe-header__user-plan {
  font-size: 0.72rem;
  color: var(--oe-text-muted);
}

/* --- Content Area ---
   Fills the full width of .oe-main at all viewport sizes. Grids, tables
   and charts inside scale with the container; individual cards can
   self-cap their inner max-width where text readability matters (e.g.
   the Notifications card caps its form body at 720px).
*/
.oe-content {
  flex: 1;
  padding: var(--oe-content-padding);
  width: 100%;
}

.oe-page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--oe-text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.oe-page-subtitle {
  font-size: 0.86rem;
  color: var(--oe-text-secondary);
  margin-bottom: 24px;
}

/* --- Metric Cards (Cloudinary-style) --- */
.oe-metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .oe-metrics-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .oe-metrics-grid { grid-template-columns: 1fr; }
}

.oe-metric-card {
  background: var(--oe-bg-surface);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-lg);
  padding: 20px;
  transition: all var(--oe-transition-fast);
  position: relative;
  overflow: hidden;
}

.oe-metric-card:hover {
  border-color: var(--oe-border-muted);
  background: var(--oe-bg-surface-hover);
}

.oe-metric-card__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.oe-metric-card__label {
  font-size: 0.8rem;
  color: var(--oe-text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.oe-metric-card__icon {
  width: 36px;
  height: 36px;
  border-radius: var(--oe-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.oe-metric-card__icon svg {
  width: 20px;
  height: 20px;
  stroke-width: 1.8;
}

.oe-metric-card__value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--oe-text-primary);
  line-height: 1.1;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
}

.oe-metric-card__trend {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.78rem;
  font-weight: 500;
}

.oe-metric-card__trend--up {
  color: var(--oe-accent-green);
}

.oe-metric-card__trend--down {
  color: var(--oe-accent-red);
}

.oe-metric-card__trend--neutral {
  color: var(--oe-text-muted);
}

.oe-metric-card__trend svg {
  width: 14px;
  height: 14px;
}

.oe-metric-card__sub {
  font-size: 0.75rem;
  color: var(--oe-text-muted);
  margin-top: 2px;
}

/* --- Cards (Generic) --- */
.oe-card {
  background: var(--oe-bg-surface);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-lg);
  overflow: hidden;
  transition: border-color var(--oe-transition-fast);
}

.oe-card:hover {
  border-color: var(--oe-bg-overlay);
}

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

.oe-card__title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--oe-text-primary);
}

.oe-card__action {
  font-size: 0.8rem;
  color: var(--oe-brand-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  font-weight: 500;
}

.oe-card__action:hover {
  color: var(--oe-brand-primary-hover);
}

.oe-card__body {
  padding: 20px;
}

/* --- Chart Cards --- */
.oe-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

@media (max-width: 900px) {
  .oe-charts-grid { grid-template-columns: 1fr; }
}

.oe-chart-wrapper {
  position: relative;
  height: 260px;
}

/* --- Quick Actions Grid --- */
.oe-quick-actions {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

@media (max-width: 1200px) {
  .oe-quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 640px) {
  .oe-quick-actions { grid-template-columns: repeat(2, 1fr); }
}

.oe-quick-action {
  background: var(--oe-bg-surface);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-lg);
  padding: 20px 16px;
  text-align: center;
  cursor: pointer;
  transition: all var(--oe-transition-fast);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.oe-quick-action:hover {
  border-color: var(--oe-brand-primary);
  background: var(--oe-brand-primary-subtle);
  transform: translateY(-2px);
}

.oe-quick-action__icon {
  width: 44px;
  height: 44px;
  border-radius: var(--oe-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
}

.oe-quick-action__icon svg {
  width: 22px;
  height: 22px;
  stroke-width: 1.8;
}

.oe-quick-action__title {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--oe-text-primary);
}

.oe-quick-action__desc {
  font-size: 0.72rem;
  color: var(--oe-text-muted);
  line-height: 1.4;
}

/* --- Account Environment Card --- */
.oe-env-card {
  background: var(--oe-bg-surface);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-lg);
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}

.oe-env-card__welcome {
  flex: 1;
  min-width: 200px;
}

.oe-env-card__greeting {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--oe-text-primary);
  margin-bottom: 4px;
}

.oe-env-card__detail {
  font-size: 0.82rem;
  color: var(--oe-text-secondary);
}

.oe-env-card__info {
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.oe-env-item {
  text-align: right;
}

.oe-env-item__label {
  font-size: 0.72rem;
  color: var(--oe-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 2px;
}

.oe-env-item__value {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--oe-text-primary);
}

/* --- Plan Usage Bar --- */
.oe-usage-bar {
  margin-top: 8px;
}

.oe-usage-bar__track {
  height: 6px;
  background: var(--oe-bg-elevated);
  border-radius: 3px;
  overflow: hidden;
}

.oe-usage-bar__fill {
  height: 100%;
  border-radius: 3px;
  transition: width var(--oe-transition-slow);
}

.oe-usage-bar__labels {
  display: flex;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 0.72rem;
  color: var(--oe-text-muted);
}

/* --- Data Tables --- */
.oe-table-wrapper {
  overflow-x: auto;
}

.oe-table {
  width: 100%;
  border-collapse: collapse;
}

.oe-table th {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--oe-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--oe-border-default);
  white-space: nowrap;
}

.oe-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--oe-border-muted);
  font-size: 0.86rem;
  color: var(--oe-text-primary);
  vertical-align: middle;
}

.oe-table tbody tr:hover {
  background: var(--oe-bg-surface-hover);
}

.oe-table tbody tr:last-child td {
  border-bottom: none;
}

/* --- Badges --- */
.oe-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.oe-badge--green { background: var(--oe-accent-green-muted); color: var(--oe-accent-green); }
.oe-badge--red { background: var(--oe-accent-red-muted); color: var(--oe-accent-red); }
.oe-badge--yellow { background: var(--oe-accent-yellow-muted); color: var(--oe-accent-yellow); }
.oe-badge--blue { background: var(--oe-brand-primary-muted); color: var(--oe-brand-primary); }
.oe-badge--purple { background: var(--oe-accent-purple-muted); color: var(--oe-accent-purple); }
.oe-badge--orange { background: var(--oe-accent-orange-muted); color: var(--oe-accent-orange); }
.oe-badge--gray { background: var(--oe-bg-elevated); color: var(--oe-text-secondary); }

/* --- Buttons --- */
.oe-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--oe-radius-md);
  font-size: 0.86rem;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--oe-transition-fast);
  white-space: nowrap;
  font-family: var(--oe-font-family);
}

.oe-btn svg {
  width: 16px;
  height: 16px;
}

/* Anchors used as buttons (<a class="oe-btn oe-btn--primary"> etc.)
   inherit the global a:hover colour otherwise, which turns the label
   into the link-hover blue — invisible on a blue fill. Pin the text
   colour on every variant's hover so it stays readable regardless of
   element type. */
.oe-btn--primary {
  background: var(--oe-brand-primary);
  color: #fff;
  border-color: var(--oe-brand-primary);
}

.oe-btn--primary:hover,
a.oe-btn--primary:hover {
  background: var(--oe-brand-primary-hover);
  border-color: var(--oe-brand-primary-hover);
  color: #fff;
}

.oe-btn--secondary {
  background: var(--oe-bg-elevated);
  color: var(--oe-text-primary);
  border-color: var(--oe-border-default);
}

.oe-btn--secondary:hover,
a.oe-btn--secondary:hover {
  background: var(--oe-bg-overlay);
  color: var(--oe-text-primary);
}

.oe-btn--ghost {
  background: transparent;
  color: var(--oe-text-secondary);
}

.oe-btn--ghost:hover,
a.oe-btn--ghost:hover {
  background: var(--oe-bg-elevated);
  color: var(--oe-text-primary);
}

.oe-btn--sm {
  padding: 4px 10px;
  font-size: 0.78rem;
}

/* Muted brick-red for destructive actions (delete). Intentionally
   restrained so it doesn't draw the eye like primary CTAs. */
.oe-btn--danger-dull {
  background: rgba(185, 28, 28, 0.10);
  color: #b91c1c;
  border-color: rgba(185, 28, 28, 0.35);
}

.oe-btn--danger-dull:hover {
  background: rgba(185, 28, 28, 0.18);
  color: #991b1b;
  border-color: rgba(185, 28, 28, 0.55);
}

/* Shared AI Feature pill — one size everywhere so the treatment
   reads as a standard affordance wherever it appears. */
.oe-ai-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 6px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(147, 51, 234, 0.15), rgba(59, 130, 246, 0.15));
  border: 1px solid rgba(147, 51, 234, 0.35);
  color: #c4b5fd;
  font-size: 0.529rem; /* +15% from 0.46rem */
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

/* Subtle grey "kept quiet" button — used for destructive actions that
   sit next to a primary CTA and should read as a secondary option. */
.oe-btn--muted {
  background: transparent;
  color: var(--oe-text-muted);
  border: 1px solid var(--oe-border-default);
}

.oe-btn--muted:hover {
  background: var(--oe-bg-elevated);
  color: var(--oe-text-secondary);
  border-color: var(--oe-border-strong);
}

/* --- Modal (used by the global confirm dialog) --- */
.oe-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1200; /* above the chatbot panel (1100) */
}

.oe-modal.is-open {
  display: flex;
}

.oe-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(1px);
}

.oe-modal__dialog {
  position: relative;
  width: 100%;
  max-width: 440px;
  margin: 24px;
  background: var(--oe-bg-card);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-lg);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
  animation: oe-modal-in 0.16s ease-out;
}

@keyframes oe-modal-in {
  from { opacity: 0; transform: translateY(-8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.oe-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--oe-border-subtle);
}

.oe-modal__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--oe-text-primary);
}

.oe-modal__close {
  background: transparent;
  border: none;
  color: var(--oe-text-muted);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
}

.oe-modal__close:hover { color: var(--oe-text-primary); }

.oe-modal__body {
  padding: 18px;
  color: var(--oe-text-secondary);
  font-size: 0.9rem;
  line-height: 1.5;
}

.oe-modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--oe-border-subtle);
}

/* --- Tabs / Period Selector --- */
.oe-tabs {
  display: flex;
  gap: 2px;
  background: var(--oe-bg-elevated);
  border-radius: var(--oe-radius-md);
  padding: 3px;
  width: fit-content;
}

.oe-tab {
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--oe-text-muted);
  cursor: pointer;
  border-radius: var(--oe-radius-sm);
  transition: all var(--oe-transition-fast);
  border: none;
  background: none;
  font-family: var(--oe-font-family);
}

.oe-tab:hover {
  color: var(--oe-text-secondary);
}

.oe-tab.active {
  background: var(--oe-bg-surface);
  color: var(--oe-text-primary);
  box-shadow: var(--oe-shadow-sm);
}

/* --- Recent Videos Row --- */
.oe-recent-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 1200px) {
  .oe-recent-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
  .oe-recent-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Card + thumbnail sizing. Without an explicit aspect ratio + width
   clamp the <img> renders at the SVG's intrinsic 640x360, which
   overflows the grid cell and pushes the Watch Time Usage card
   out of alignment. */
.oe-recent-card {
  display: block;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}
.oe-recent-card__thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: var(--oe-bg-elevated);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-md);
  overflow: hidden;
}
.oe-recent-card__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.oe-recent-card__title {
  margin-top: 6px;
  font-size: 0.82rem;
  color: var(--oe-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oe-video-thumb {
  border-radius: var(--oe-radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: transform var(--oe-transition-fast);
}

.oe-video-thumb:hover {
  transform: scale(1.03);
}

.oe-video-thumb__img {
  width: 100%;
  aspect-ratio: 16/9;
  background: var(--oe-bg-elevated);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.oe-video-thumb__img svg {
  width: 32px;
  height: 32px;
  color: var(--oe-text-muted);
}

.oe-video-thumb__duration {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 0.68rem;
  padding: 1px 6px;
  border-radius: 3px;
  font-weight: 500;
}

.oe-video-thumb__title {
  padding: 8px 4px 4px;
  font-size: 0.78rem;
  color: var(--oe-text-primary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oe-video-thumb__meta {
  padding: 0 4px 4px;
  font-size: 0.68rem;
  color: var(--oe-text-muted);
}

/* --- Page: Placeholder / Empty States --- */
.oe-page-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 24px;
  text-align: center;
}

.oe-page-placeholder__icon {
  width: 64px;
  height: 64px;
  border-radius: var(--oe-radius-xl);
  background: var(--oe-brand-primary-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.oe-page-placeholder__icon svg {
  width: 32px;
  height: 32px;
  color: var(--oe-brand-primary);
}

.oe-page-placeholder__title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--oe-text-primary);
  margin-bottom: 8px;
}

.oe-page-placeholder__desc {
  font-size: 0.86rem;
  color: var(--oe-text-secondary);
  max-width: 400px;
  margin-bottom: 20px;
}

/* --- Section Title Row --- */
.oe-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.oe-section-title {
  font-size: 0.93rem;
  font-weight: 600;
  color: var(--oe-text-primary);
}

/* --- Dropdown Menu --- */
.oe-dropdown {
  position: relative;
  display: inline-block;
}

.oe-dropdown__menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 200px;
  background: var(--oe-bg-elevated);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-md);
  box-shadow: var(--oe-shadow-lg);
  z-index: 1100;
  padding: 4px;
  animation: oeDropdownIn 150ms ease;
}

.oe-dropdown__menu.show {
  display: block;
}

@keyframes oeDropdownIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

.oe-dropdown__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  font-size: 0.86rem;
  color: var(--oe-text-secondary);
  cursor: pointer;
  border-radius: var(--oe-radius-sm);
  transition: all var(--oe-transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--oe-font-family);
}

.oe-dropdown__item:hover {
  background: var(--oe-bg-overlay);
  color: var(--oe-text-primary);
}

.oe-dropdown__item svg {
  width: 16px;
  height: 16px;
}

.oe-dropdown__divider {
  height: 1px;
  background: var(--oe-border-default);
  margin: 4px 8px;
}

.oe-dropdown__item--danger {
  color: var(--oe-accent-red);
}
.oe-dropdown__item--danger:hover {
  background: var(--oe-accent-red-muted);
}

/* --- Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--oe-bg-overlay);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--oe-text-muted);
}

/* --- AI Chatbot Panel --- */
.oe-chat-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 380px;
  background: var(--oe-bg-surface);
  border-left: 1px solid var(--oe-border-default);
  z-index: 1050;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform var(--oe-transition-normal);
}

.oe-chat-panel.open {
  transform: translateX(0);
}

.oe-main.chat-open {
  margin-right: 380px;
}

.oe-chat-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--oe-border-default);
  flex-shrink: 0;
}

.oe-chat-panel__title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 0.93rem;
  color: var(--oe-text-primary);
}

.oe-chat-panel__title-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--oe-radius-md);
  background: linear-gradient(135deg, var(--oe-brand-primary), var(--oe-accent-purple));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.oe-chat-panel__title-icon svg {
  width: 18px;
  height: 18px;
  stroke: #fff;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oe-chat-panel__close {
  width: 32px;
  height: 32px;
  border-radius: var(--oe-radius-sm);
  border: none;
  background: none;
  color: var(--oe-text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--oe-transition-fast);
}

.oe-chat-panel__close:hover {
  background: var(--oe-bg-elevated);
  color: var(--oe-text-primary);
}

.oe-chat-panel__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
}

.oe-chat-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.oe-chat-msg {
  display: flex;
  gap: 10px;
  max-width: 95%;
  animation: oeChatIn 250ms ease;
}

@keyframes oeChatIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.oe-chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.oe-chat-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.68rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.oe-chat-msg--ai .oe-chat-msg__avatar {
  background: linear-gradient(135deg, var(--oe-brand-primary), var(--oe-accent-purple));
}

.oe-chat-msg--user .oe-chat-msg__avatar {
  background: var(--oe-bg-overlay);
  color: var(--oe-text-secondary);
}

.oe-chat-msg__bubble {
  padding: 10px 14px;
  border-radius: var(--oe-radius-lg);
  font-size: 0.86rem;
  line-height: 1.55;
  color: var(--oe-text-primary);
}

.oe-chat-msg--ai .oe-chat-msg__bubble {
  background: var(--oe-bg-elevated);
  border-bottom-left-radius: 4px;
}

.oe-chat-msg--user .oe-chat-msg__bubble {
  background: var(--oe-brand-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.oe-chat-msg__time {
  font-size: 0.65rem;
  color: var(--oe-text-muted);
  margin-top: 4px;
}

.oe-chat-msg--user .oe-chat-msg__time {
  text-align: right;
}

.oe-chat-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 0;
}

.oe-chat-typing__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--oe-text-muted);
  animation: oeTypingBounce 1.2s ease-in-out infinite;
}

.oe-chat-typing__dot:nth-child(2) { animation-delay: 0.2s; }
.oe-chat-typing__dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes oeTypingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.oe-chat-panel__input {
  padding: 12px 16px;
  border-top: 1px solid var(--oe-border-default);
  flex-shrink: 0;
}

.oe-chat-panel__input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.oe-chat-panel__textarea {
  flex: 1;
  background: var(--oe-bg-elevated);
  border: 1px solid var(--oe-border-default);
  border-radius: var(--oe-radius-md);
  padding: 10px 14px;
  color: var(--oe-text-primary);
  font-size: 0.86rem;
  font-family: var(--oe-font-family);
  outline: none;
  resize: none;
  max-height: 100px;
  line-height: 1.4;
  transition: border-color var(--oe-transition-fast);
}

.oe-chat-panel__textarea:focus {
  border-color: var(--oe-brand-primary);
}

.oe-chat-panel__textarea::placeholder {
  color: var(--oe-text-placeholder);
}

.oe-chat-panel__send {
  width: 38px;
  height: 38px;
  border-radius: var(--oe-radius-md);
  border: none;
  background: var(--oe-brand-primary);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background var(--oe-transition-fast);
}

.oe-chat-panel__send:hover {
  background: var(--oe-brand-primary-hover);
}

.oe-chat-panel__send:disabled {
  background: var(--oe-bg-overlay);
  color: var(--oe-text-muted);
  cursor: not-allowed;
}

.oe-chat-panel__send svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.oe-chat-panel__suggestions {
  padding: 0 16px 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}

.oe-chat-panel__suggestion {
  padding: 6px 12px;
  background: var(--oe-bg-elevated);
  border: 1px solid var(--oe-border-default);
  border-radius: 20px;
  font-size: 0.75rem;
  color: var(--oe-text-secondary);
  cursor: pointer;
  transition: all var(--oe-transition-fast);
  font-family: var(--oe-font-family);
}

.oe-chat-panel__suggestion:hover {
  background: var(--oe-brand-primary-subtle);
  border-color: var(--oe-brand-primary);
  color: var(--oe-brand-primary);
}

/* Header AI button active state */
.oe-header__icon-btn.active {
  background: var(--oe-brand-primary-muted);
  color: var(--oe-brand-primary);
}

/* --- Animations --- */
@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.4; }
  100% { opacity: 1; }
}

/* --- Linear TV Schedule Slot --- */
.oe-schedule-slot {
  display: flex;
  align-items: center;
  padding: 12px 20px;
  border-bottom: 1px solid var(--oe-border-muted);
  gap: 16px;
  transition: background var(--oe-transition-fast);
}
.oe-schedule-slot:hover {
  background: var(--oe-bg-surface-hover);
}
.oe-schedule-slot:last-child {
  border-bottom: none;
}
.oe-schedule-slot__time {
  font-family: var(--oe-font-mono);
  font-size: 0.82rem;
  color: var(--oe-text-muted);
  min-width: 80px;
  flex-shrink: 0;
}
.oe-schedule-slot__bar {
  width: 4px;
  height: 36px;
  border-radius: 2px;
  flex-shrink: 0;
}
.oe-schedule-slot__info {
  flex: 1;
  min-width: 0;
}
.oe-schedule-slot__title {
  font-weight: 500;
  font-size: 0.86rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.oe-schedule-slot__meta {
  font-size: 0.72rem;
  color: var(--oe-text-muted);
}

/* --- Heatmap --- */
.oe-heatmap {
  display: grid;
  grid-template-columns: 60px repeat(24, 1fr);
  gap: 2px;
  font-size: 0.68rem;
}
.oe-heatmap__label {
  display: flex;
  align-items: center;
  color: var(--oe-text-muted);
  padding: 2px 4px;
}
.oe-heatmap__cell {
  aspect-ratio: 1;
  border-radius: 2px;
  min-height: 20px;
}
.oe-heatmap__hour {
  text-align: center;
  color: var(--oe-text-muted);
  padding: 2px 0;
}

/* --- Utility --- */
.oe-text-mono { font-family: var(--oe-font-mono); }
.oe-text-muted { color: var(--oe-text-muted); }
.oe-text-secondary { color: var(--oe-text-secondary); }
.oe-text-brand { color: var(--oe-brand-primary); }
.oe-text-green { color: var(--oe-accent-green); }
.oe-text-red { color: var(--oe-accent-red); }
.oe-mt-0 { margin-top: 0; }
.oe-mb-16 { margin-bottom: 16px; }
.oe-mb-24 { margin-bottom: 24px; }
.oe-gap-16 { gap: 16px; }
.oe-flex { display: flex; }
.oe-items-center { align-items: center; }
.oe-justify-between { justify-content: space-between; }

/* --- Footer --- */
.oe-footer {
  padding: 16px var(--oe-content-padding);
  border-top: 1px solid var(--oe-border-default);
  font-size: 0.72rem;
  color: var(--oe-text-muted);
  text-align: center;
  margin-top: auto;
}
