/* =====================
   MKP WebHub — Main Styles
   Brand: Dark theme, Orange accent (#EA8623)
   ===================== */

/* V1.3.10: Self-host Material Symbols font · prevents broken icons when
   Google Fonts CDN is blocked by network/ad-blocker (renders as raw text
   like "dashboard" / "auto_awesome" instead of glyph). 1.8MB TTF served
   from /web/fonts/. CSS rules below apply globally. */
@font-face {
  font-family: 'Material Symbols Rounded';
  font-style: normal;
  font-weight: 400;
  font-display: block; /* hide text until font loads · avoids FOUT showing 'dashboard' literal */
  src: url('../fonts/material-symbols-rounded.ttf') format('truetype');
}
.material-symbols-rounded {
  font-family: 'Material Symbols Rounded';
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  -webkit-font-feature-settings: 'liga';
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'liga';
}

:root {
  --bg-primary: #0C0C0C;
  --bg-secondary: #161616;
  --bg-card: #1E1E1E;
  --bg-hover: #2A2A2A;
  --text-primary: #F0F0F0;
  --text-secondary: #888;
  --text-muted: #555;
  --accent: #EA8623;
  --accent-hover: #F5A040;
  --success: #4CAF50;
  --error: #F44336;
  --warning: #FFC107;
  --border: #333;
  --info: #2196F3;
  --grade-s: #FFD700;
  --grade-a: #4CAF50;
  --grade-b: #2196F3;
  --grade-c: #FFC107;
  --grade-d: #F44336;
  --tag-green: #81C784;
  --tag-blue: #64B5F6;
  --success-gradient: linear-gradient(90deg, #238636, #3fb950);
  --danger-gradient: linear-gradient(90deg, #da3633, #f85149);
  --sidebar-width: 220px;
  --radius: 8px;
  --font: 'Inter', -apple-system, sans-serif;

  /* 2026-05-09 · UX QW4 · Design tokens · single-source spacing/radius/shadow/transition
     Replaces ad-hoc inline `style="padding:14px;border-radius:6px;..."` across components.
     Use these vars instead of magic numbers · pages/orgs.js + approvals.js + campaigns.js
     gradually adopt as touched. */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 32px;

  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --radius-pill: 9999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.4);
  --shadow-accent: 0 4px 16px rgba(234, 134, 35, 0.25);

  --transition-fast: 0.12s ease;
  --transition-base: 0.18s ease;
  --transition-slow: 0.28s ease;

  --z-sidebar: 100;
  --z-banner: 9500;
  --z-modal: 10000;
  --z-toast: 10500;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

.hidden { display: none !important; }

/* Login */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-primary);
  padding: 16px;
  box-sizing: border-box;
}

.login-wrapper {
  display: flex;
  max-width: 900px;
  width: 100%;
  min-height: 480px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
  border: 1px solid var(--border);
}

/* Left branding panel */
.login-brand-side {
  flex: 1;
  background: linear-gradient(135deg, #0C0C0C 0%, #1a1200 50%, #2a1800 100%);
  padding: 40px 32px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--border);
}

.login-brand-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 16px;
}

.login-brand-name {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: 2px;
  line-height: 1.2;
  margin: 0 0 4px;
}

.login-brand-name span {
  font-size: 12px;
  color: var(--accent);
  letter-spacing: 5px;
  font-weight: 600;
}

.login-brand-tagline {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 24px;
}

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--text-secondary);
}

.login-feature .material-symbols-rounded {
  font-size: 18px;
  color: var(--accent);
}

.login-brand-footer {
  margin-top: 24px;
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

/* Right login form */
.login-card {
  flex: 1;
  background: var(--bg-card);
  padding: 40px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.login-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.login-logo-sm {
  width: 42px;
  height: 42px;
  background: var(--accent);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 800;
  color: #000;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

.login-subtitle-sm {
  font-size: 12px;
  color: var(--text-muted);
}

.login-form { flex: 1; }

.login-field { margin-bottom: 16px; }

.login-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.login-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 12px;
  transition: border-color 0.2s;
}

.login-input-wrap:focus-within { border-color: var(--accent); }

.login-input-wrap .material-symbols-rounded {
  font-size: 18px;
  color: var(--text-muted);
}

.login-input {
  width: 100%;
  padding: 12px 0;
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.login-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #000;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  margin-top: 4px;
}

.login-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

/* Chrome autofill dark theme fix */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-primary) inset !important;
  -webkit-text-fill-color: var(--text-primary) !important;
  caret-color: var(--text-primary);
  transition: background-color 5000s ease-in-out 0s;
}

.login-error {
  color: var(--error);
  margin-top: 12px;
  font-size: 13px;
  min-height: 20px;
  text-align: center;
}

.login-card-footer {
  text-align: center;
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

@media (max-width: 768px) {
  .login-screen { padding: 0; align-items: stretch; }
  .login-wrapper {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .login-brand-side {
    padding: 20px 24px;
    border-right: none;
    border-bottom: 1px solid var(--border);
    text-align: center;
  }
  .login-brand-logo { width: 48px; height: 48px; margin: 0 auto 8px; }
  .login-brand-name { font-size: 20px; }
  .login-brand-name br { display: none; }
  .login-brand-name span { display: inline; margin-left: 8px; }
  .login-brand-tagline { margin-bottom: 0; font-size: 11px; }
  .login-brand-features { display: none; }
  .login-brand-footer { display: none; }
  .login-card { padding: 24px 20px; }
  .login-card-header { margin-bottom: 20px; }
}

/* App Layout */
.app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 100;
}

.sidebar-logo {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo-img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.logo-text-group {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-text {
  font-size: 20px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
}

.logo-sub {
  font-size: 9px;
  color: var(--text-secondary);
  letter-spacing: 3px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 4px 0;
  min-height: 0; /* Allow flex shrink for scroll */
}

/* 2026-06-07 · Sprint 4 W1.4 · Org Switcher Dropdown */
.org-switcher {
  position: relative;
  margin: 0 12px 8px;
}
.org-switcher-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.org-switcher-btn:hover { background: rgba(255, 255, 255, 0.08); }
.org-switcher-name {
  flex: 1;
  text-align: left;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.org-switcher-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  z-index: 100;
  max-height: 360px;
  overflow-y: auto;
}
.org-switcher-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  background: transparent;
  border: 0;
  border-radius: 4px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
}
.org-switcher-item:hover { background: rgba(255, 255, 255, 0.06); }
.org-switcher-item.is-current { background: rgba(255, 200, 0, 0.08); }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  transition: all 0.15s;
  cursor: pointer;
  border-left: 3px solid transparent;
}

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

.nav-item.active {
  color: var(--accent);
  background: rgba(234, 134, 35, 0.08);
  border-left-color: var(--accent);
}

.nav-item .material-symbols-rounded { font-size: 20px; }

.nav-item.locked { opacity: 0.4; }
.nav-item.locked::after {
  content: '🔒';
  margin-left: auto;
  font-size: 12px;
}

/* 2026-05-07 Phase A.1 · Coming Soon items (Catalog · Channels · Inbox · Automations)
   Visible but disabled · click shows toast "กำลังพัฒนา · v2"
   Style is subtler than locked — not gated, just not yet built. */
.nav-item.coming-soon { opacity: 0.62; cursor: pointer; }
.nav-item.coming-soon:hover { opacity: 0.88; background: var(--bg-hover); }
.nav-cs-badge {
  margin-left: auto;
  font-size: 9px;
  font-weight: 700;
  background: rgba(234, 134, 35, 0.16);
  color: var(--accent);
  padding: 2px 7px;
  border-radius: 8px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}

/* 2026-05-09 · UX QW2 · Notification badges (Inbox · Approval · Campaigns) */
.nav-badge {
  margin-left: auto;
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  font-size: 10px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
  background: rgba(234, 134, 35, 0.18);
  color: var(--accent);
  border-radius: 9px;
  letter-spacing: 0;
  border: 1px solid rgba(234, 134, 35, 0.3);
  animation: nav-badge-pop 0.25s cubic-bezier(.34,1.56,.64,1);
}
.nav-badge.nav-badge-urgent {
  background: rgba(244, 67, 54, 0.18);
  color: var(--error);
  border-color: rgba(244, 67, 54, 0.4);
  animation: nav-badge-pop 0.25s cubic-bezier(.34,1.56,.64,1), nav-badge-pulse 2.4s ease-in-out infinite;
}
@keyframes nav-badge-pop {
  from { transform: scale(0); opacity: 0 }
  to { transform: scale(1); opacity: 1 }
}
@keyframes nav-badge-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.0) }
  50%      { box-shadow: 0 0 0 4px rgba(244, 67, 54, 0.18) }
}

/* ════════════════════════════════════════════════
   2026-05-09 · UX QW5 · A11y polish
   - Focus rings (visible only on keyboard nav · :focus-visible)
   - Skip-to-content link (hidden until tab-focus)
   - High-contrast outline for buttons + inputs + nav
   - Reduce motion preference
   ════════════════════════════════════════════════ */

/* Visible focus ring · 2px orange outline + 2px offset · WCAG 2.4.7 compliant */
*:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}
button:focus-visible,
.btn:focus-visible,
.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.mkp-modal-btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.mkp-modal-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
  border-color: transparent;
}
/* 2026-05-09 · boss caught double frame · login inputs sit inside .login-input-wrap
   which already has its own :focus-within border-color change. Don't add a 2nd
   outline · let the wrap handle the visual focus state. Same for ANY input
   wrapped by a container that uses :focus-within (catalog · org switcher · etc). */
.login-input-wrap input:focus-visible,
.org-switcher input:focus-visible,
[data-focus-ring="wrap"] input:focus-visible {
  outline: none;
  border-color: transparent;
}
.nav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  background: var(--bg-hover);
}

/* Skip-to-content · hidden until tab-focus · jumps screen reader past sidebar */
.skip-to-content {
  position: absolute;
  top: -100px;
  left: 8px;
  z-index: 99999;
  padding: 10px 16px;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border-radius: 6px;
  text-decoration: none;
  font-size: 13px;
}
.skip-to-content:focus { top: 8px; }

/* Reduced motion · respect OS preference */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Status badges with icon prefix · don't rely on color alone (WCAG 1.4.1) */
.status-icon { font-size: 11px; vertical-align: -1px; margin-right: 4px }
.status-success-bg { background: rgba(76, 175, 80, 0.15); color: var(--success) }
.status-warning-bg { background: rgba(255, 193, 7, 0.15); color: var(--warning) }
.status-error-bg   { background: rgba(244, 67, 54, 0.15); color: var(--error) }
.status-info-bg    { background: rgba(33, 150, 243, 0.15); color: var(--info) }
.status-neutral-bg { background: rgba(255, 255, 255, 0.06); color: var(--text-secondary) }

/* ════════════════════════════════════════════════
   2026-05-09 · UX QW10 · Brand polish + micro-animations
   - Hover lift on cards/buttons
   - Smooth transitions everywhere (respects prefers-reduced-motion)
   - Celebration burst (confetti-like) for first publish / approval / campaign
   - Subtle accent glow on primary actions
   ════════════════════════════════════════════════ */

/* Buttons get subtle lift on hover */
.btn,
.btn-primary,
.btn-secondary,
.mkp-modal-btn {
  transition: transform var(--transition-fast), box-shadow var(--transition-fast),
              background var(--transition-fast), filter var(--transition-fast);
}
.btn:hover:not(:disabled),
.btn-primary:hover:not(:disabled),
.btn-secondary:hover:not(:disabled),
.mkp-modal-btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active,
.btn-primary:active,
.btn-secondary:active {
  transform: translateY(0);
}

/* Primary CTA gets glow on hover */
.btn-primary:hover:not(:disabled),
.mkp-modal-btn-ok:hover:not(:disabled) {
  box-shadow: var(--shadow-accent);
}

/* Card hover lift */
.premium-card:hover {
  transform: translateY(-2px);
  transition: transform var(--transition-base), box-shadow var(--transition-base), border-color var(--transition-base);
}

/* Celebration burst · confetti-like 6-particle radial blast.
   Trigger via App.celebrate(x, y) · used on first publish · approve etc. */
.mkp-celebration {
  position: fixed;
  pointer-events: none;
  z-index: var(--z-toast);
  width: 0; height: 0;
}
.mkp-celebration::before,
.mkp-celebration::after {
  content: '';
  position: absolute;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow:
    20px -10px 0 -1px #FFC107,
   -20px -15px 0 -1px #4CAF50,
    25px  10px 0 -1px #2196F3,
   -22px  12px 0 -1px var(--accent),
     5px -28px 0 -1px #F44336,
    -8px  25px 0 -1px #9C27B0;
  animation: mkp-burst 0.7s cubic-bezier(.23, 1, .32, 1) forwards;
}
@keyframes mkp-burst {
  0%   { transform: scale(0)   rotate(0)   translate(0, 0);  opacity: 1; }
  100% { transform: scale(2.2) rotate(60deg) translate(0, -30px); opacity: 0; }
}

/* Subtle pulse on critical CTAs (when something needs attention) */
.cta-pulse {
  animation: cta-pulse 2.4s ease-in-out infinite;
}
@keyframes cta-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(234, 134, 35, 0.0) }
  50%      { box-shadow: 0 0 0 6px rgba(234, 134, 35, 0.15) }
}

/* Toast slide+fade smoother + role-driven color */
.toast {
  animation: toast-in 0.3s cubic-bezier(.23, 1, .32, 1);
}
@keyframes toast-in {
  from { transform: translateX(100%) scale(0.95); opacity: 0 }
  to   { transform: translateX(0)    scale(1);    opacity: 1 }
}

/* Tab transitions · smooth underline animation */
.tab-btn {
  transition: color var(--transition-fast), border-color var(--transition-base);
}

/* ════════════════════════════════════════════════════════════════════
   2026-05-09 · Issue #13 · Unified mode toggle (Live · Mockup pattern)
   Multiple legacy class names existed: .mock-toggle · .ch-mock-toggle ·
   .ana-mock-toggle. All now inherit identical styling via attribute selector
   so future pages use ONE pattern. Existing class names continue to work
   (legacy-friendly · zero regression).
   ════════════════════════════════════════════════════════════════════ */
.mock-toggle, .ch-mock-toggle, .ana-mock-toggle, .mkp-mode-toggle {
  display: inline-flex !important;
  background: var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-pill) !important;
  padding: 2px !important;
  gap: 0 !important;
}
.mock-toggle .mt-btn, .ch-mock-toggle .cmt-btn, .ana-mock-toggle .ana-mt-btn,
.mock-toggle button, .ch-mock-toggle button, .ana-mock-toggle button,
.mkp-mode-toggle button {
  background: transparent !important;
  border: 0 !important;
  color: var(--text-secondary) !important;
  padding: 6px 14px !important;
  font-size: 12px !important;
  border-radius: var(--radius-pill) !important;
  cursor: pointer !important;
  font: inherit;
  font-weight: 600 !important;
  transition: all var(--transition-fast);
}
.mock-toggle .mt-btn.on, .ch-mock-toggle .cmt-btn.on, .ana-mock-toggle .ana-mt-btn.on,
.mkp-mode-toggle button.on {
  background: linear-gradient(135deg, var(--accent), #FF9D3F) !important;
  color: #000 !important;
  font-weight: 700 !important;
  box-shadow: 0 1px 6px rgba(234, 134, 35, 0.3);
}
.mock-toggle .mt-btn:not(.on):hover, .ch-mock-toggle .cmt-btn:not(.on):hover,
.ana-mock-toggle .ana-mt-btn:not(.on):hover, .mkp-mode-toggle button:not(.on):hover {
  color: var(--text-primary) !important;
  background: rgba(255, 255, 255, 0.04) !important;
}

/* ════════════════════════════════════════════════════════════════════
   2026-05-09 · Issue #14 · Card class consolidation
   Legacy classes (.ch-card · .cmp-card · .recipe-card · .ib-card · .bk-card ·
   .ana-card · .ana-pf-card · .ana-kpi · .stat-card · .ac-card) get consistent
   card-v2 visual treatment via attribute selector. Adds:
   - subtle radial gradient backdrop (top-right orange wash)
   - hover: translateY -1px + accent border + shadow
   - smooth transitions
   No markup changes needed · existing classes inherit improved visuals.
   ════════════════════════════════════════════════════════════════════ */
.ch-card, .cmp-card, .recipe-card, .ib-card, .bk-card,
.ana-card, .ana-pf-card, .ana-kpi, .stat-card, .ac-card {
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(234, 134, 35, 0.04), transparent 50%),
    var(--bg-card) !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-lg, 12px) !important;
  transition: transform var(--transition-base), border-color var(--transition-base),
              box-shadow var(--transition-base);
}
.ch-card:hover, .cmp-card:hover, .recipe-card:hover, .ib-card:hover,
.bk-card:hover, .ana-card:hover, .ana-pf-card:hover, .ana-kpi:hover,
.stat-card:hover, .ac-card:hover {
  transform: translateY(-1px);
  border-color: rgba(234, 134, 35, 0.25) !important;
  box-shadow: var(--shadow-md);
}

/* Account rows (Channels) get hover treatment too */
.acct-row {
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
}
.acct-row:hover {
  background: rgba(255, 255, 255, 0.02);
}

/* ════════════════════════════════════════════════
   2026-05-09 · UX QW9 · Mobile responsive polish
   - Touch targets ≥ 44×44 (WCAG 2.5.5)
   - Tables stack as cards on small screens
   - Sticky banner adjusts to no-sidebar on mobile
   - Sidebar overlay full-width
   ════════════════════════════════════════════════ */
@media (max-width: 768px) {
  /* All buttons get min-height 44px touch target on mobile */
  button,
  .btn,
  .btn-primary,
  .btn-secondary,
  .mkp-modal-btn,
  .mkp-empty-btn-primary,
  .mkp-empty-btn-secondary,
  a.btn-secondary {
    min-height: 44px;
    padding-left: 16px !important;
    padding-right: 16px !important;
  }

  /* Sidebar overlays full screen when open */
  .sidebar.open { width: 90vw; max-width: 320px; }

  /* Modal padding adapts */
  .mkp-modal-card { padding: 18px 16px !important; }
  .mkp-modal-actions { flex-wrap: wrap; }
  .mkp-modal-btn { flex: 1; min-width: 100px; }

  /* Empty state more compact */
  .mkp-empty { padding: 36px 16px; }
  .mkp-empty-icon { width: 56px; height: 56px; margin-bottom: 12px }
  .mkp-empty-icon .material-symbols-rounded { font-size: 28px }

  /* Approval / Campaign cards · stack actions vertically */
  .approval-actions,
  .cmp-card .cmp-card-head { flex-wrap: wrap; gap: 8px; }
  .approval-card-head { flex-wrap: wrap; }

  /* Tables → become card-stacks below 600px (any .ana-table inside .ana-card) */
}

@media (max-width: 600px) {
  /* Convert tables to stacked cards · smooth fallback for narrow screens */
  table.ana-table,
  .approval-history table {
    display: block;
  }
  table.ana-table thead,
  .approval-history table thead { display: none; }
  table.ana-table tbody,
  .approval-history table tbody { display: block; }
  table.ana-table tr,
  .approval-history table tr {
    display: block;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-card);
  }
  table.ana-table td,
  .approval-history table td {
    display: flex;
    justify-content: space-between;
    border: 0 !important;
    padding: 4px 0 !important;
  }
  table.ana-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
  }
}

/* ════════════════════════════════════════════════════════════════════
   2026-05-09 · UX Visual Identity Overhaul (V1-V7)
   Real visual change · not just hover polish · while staying inside
   dark+orange theme. Boss directive turn 21: "ทำให้เห็นต่าง · ไม่หมกเม็ด"
   ════════════════════════════════════════════════════════════════════ */

/* ───── V1 · SIDEBAR REFRESH ─────
   - Logo area: gradient bar at top, bigger logo, branded micro-tagline
   - Section divider: orange thin line + uppercase letterspaced label
   - Active state: orange left bar 4px + soft glow + subtle bg gradient
   - Hover: slide-in indicator instead of just bg change
   - All depth + identity · zero color outside theme */

/* 2026-05-09 · V1 sidebar refresh · DON'T override `position: fixed` from
   line 361 (above) · only add gradient bg + accent strip. Boss caught a real
   bug: my earlier V1 commit set `position: relative` which broke layout · the
   sidebar fell back into flex flow + content's `margin-left: 220px` doubled
   the visible gap. Now we keep position-fixed and only restyle bg/border. */
.sidebar {
  background: linear-gradient(180deg, #0E0A05 0%, var(--bg-primary) 280px) !important;
  border-right: 1px solid var(--border);
}
.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  opacity: 0.6;
  pointer-events: none;
}

.sidebar-logo {
  padding: 18px 16px 14px !important;
  border-bottom: 1px solid rgba(234, 134, 35, 0.12);
  background: radial-gradient(circle at top right, rgba(234, 134, 35, 0.08), transparent 60%);
}
.sidebar-logo-img {
  width: 36px !important;
  height: 36px !important;
  filter: drop-shadow(0 2px 8px rgba(234, 134, 35, 0.3));
}
.logo-text {
  font-size: 20px !important;
  font-weight: 800 !important;
  letter-spacing: 1px !important;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.logo-sub {
  font-size: 9px !important;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted) !important;
  font-weight: 600 !important;
}

.nav-section {
  font-size: 9px !important;
  font-weight: 800;
  letter-spacing: 1.6px;
  color: var(--accent) !important;
  text-transform: uppercase;
  padding: 16px 16px 6px !important;
  margin-top: 4px;
  position: relative;
  opacity: 0.85;
}
.nav-section::after {
  content: '';
  position: absolute;
  left: 16px; right: 16px; bottom: 2px;
  height: 1px;
  background: linear-gradient(90deg, rgba(234, 134, 35, 0.35), transparent);
}

/* 2026-05-12 · Big-Bang sidebar restructure · admin section collapsible.
 * Hia Gem CTO verdict #8: hide diagnostic items (Scanner · Radar · LIVE · Self-Healing · Image Bridge · etc.)
 * by default so SaaS customers don't see scary buttons. Click toggle to expand.
 */
.nav-section-admin-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  border-top: 1px solid var(--border);
  margin-top: 6px;
  padding-top: 4px;
  transition: opacity 0.15s;
}
.nav-section-admin-toggle:hover { opacity: 1; }
.nav-section-admin-toggle .nav-section {
  flex: 1;
  padding-top: 12px !important;
  margin-top: 0 !important;
  color: var(--text-muted) !important;
  opacity: 0.7;
}
.nav-section-admin-toggle .nav-section::after { display: none; }
.nav-section-admin-toggle:hover .nav-section { color: var(--text-secondary) !important; opacity: 1; }
.nav-admin-chevron {
  font-size: 16px !important;
  color: var(--text-muted);
  margin-right: 14px;
  transition: transform 0.2s;
}
.nav-section-admin-toggle[aria-expanded="true"] .nav-admin-chevron { color: var(--accent); }
.nav-admin-items .nav-item {
  font-size: 12px;
  padding-left: 26px;
  opacity: 0.78;
}
.nav-admin-items .nav-item:hover { opacity: 1; }

.nav-item {
  position: relative;
  margin: 1px 8px;
  border-radius: var(--radius-md);
  border-left: 3px solid transparent !important;
  padding: 9px 12px !important;
  transition: background var(--transition-fast), color var(--transition-fast),
              padding-left var(--transition-fast);
}
.nav-item:hover {
  background: rgba(234, 134, 35, 0.06) !important;
  padding-left: 14px !important;
}
.nav-item.active {
  background: linear-gradient(90deg, rgba(234, 134, 35, 0.18), rgba(234, 134, 35, 0.04)) !important;
  border-left-color: var(--accent) !important;
  box-shadow: inset 0 0 16px rgba(234, 134, 35, 0.06);
}
.nav-item.active .material-symbols-rounded {
  color: var(--accent);
  filter: drop-shadow(0 0 6px rgba(234, 134, 35, 0.5));
}

/* ───── V2 · PAGE HERO BAND ─────
   Top of every modern page: breadcrumb pill + XXL display title + action bar
   Subtle radial gradient backdrop · top-left corner orange wash */

.page-hero {
  position: relative;
  margin-bottom: var(--space-xl);
  padding: 22px 26px 22px;
  background:
    radial-gradient(ellipse 600px 180px at top left, rgba(234, 134, 35, 0.06), transparent 70%),
    linear-gradient(135deg, var(--bg-card), var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.page-hero::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: linear-gradient(180deg, var(--accent), transparent);
}
.page-hero-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(234, 134, 35, 0.1);
  border: 1px solid rgba(234, 134, 35, 0.25);
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-bottom: 12px;
}
.page-hero-breadcrumb a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
}
.page-hero-breadcrumb a:hover { color: var(--accent); }
.page-hero-breadcrumb .sep { color: var(--text-muted); }
.page-hero-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.page-hero-title {
  font-size: 26px !important;
  font-weight: 800 !important;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  margin: 0 !important;
  line-height: 1.15;
}
.page-hero-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
  font-weight: 400;
}
.page-hero-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

/* ───── V3 · KPI HERO NUMBERS ─────
   36-42px display number with gradient orange→amber text fill
   Trend arrow + delta + sparkline support */

.kpi-card {
  background:
    radial-gradient(circle at top right, rgba(234, 134, 35, 0.05), transparent 60%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition-base), border-color var(--transition-base),
              box-shadow var(--transition-base);
}
.kpi-card:hover {
  transform: translateY(-2px);
  border-color: rgba(234, 134, 35, 0.4);
  box-shadow: var(--shadow-md), inset 0 0 0 1px rgba(234, 134, 35, 0.1);
}
.kpi-card.kpi-accent {
  background:
    radial-gradient(circle at top right, rgba(234, 134, 35, 0.15), transparent 65%),
    linear-gradient(135deg, var(--bg-card), rgba(234, 134, 35, 0.03));
  border-color: rgba(234, 134, 35, 0.25);
}
.kpi-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-label .material-symbols-rounded { font-size: 14px; opacity: 0.8 }
.kpi-hero-number {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -1px;
  line-height: 1;
  background: linear-gradient(135deg, #FFD180 0%, var(--accent) 60%, #C76A0F 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: inline-block;
}
.kpi-hero-number.kpi-success {
  background: linear-gradient(135deg, #A5D6A7, var(--success));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
.kpi-sub {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
}
.kpi-delta.up   { background: rgba(76, 175, 80, 0.16); color: var(--success) }
.kpi-delta.down { background: rgba(244, 67, 54, 0.16); color: var(--error) }
.kpi-delta.flat { background: rgba(136, 136, 136, 0.12); color: var(--text-secondary) }

/* ───── V4 · PREMIUM CARD VARIANTS ─────
   Subtle radial gradient backdrop + multi-layer shadow + accent corner */

.card-v2 {
  position: relative;
  background:
    radial-gradient(circle at top right, rgba(234, 134, 35, 0.04), transparent 50%),
    var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  transition: all var(--transition-base);
}
.card-v2:hover {
  transform: translateY(-1px);
  border-color: rgba(234, 134, 35, 0.25);
  box-shadow: var(--shadow-md);
}
.card-v2-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px dashed rgba(234, 134, 35, 0.15);
}
.card-v2-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}
.card-v2-title .material-symbols-rounded {
  color: var(--accent);
  font-size: 18px;
}

/* ───── V5 · PER-PLATFORM COLORS ─────
   Subtle tint on platform-specific elements · still under dark theme */

.platform-fb     { color: #4F8EF7 }
.platform-fb-bg  { background: rgba(79, 142, 247, 0.12); border-color: rgba(79, 142, 247, 0.25); color: #6FA5F8 }
.platform-yt     { color: #FF6B6B }
.platform-yt-bg  { background: rgba(255, 107, 107, 0.12); border-color: rgba(255, 107, 107, 0.25); color: #FF8585 }
.platform-tt     { color: #EC407A }
.platform-tt-bg  { background: rgba(236, 64, 122, 0.12); border-color: rgba(236, 64, 122, 0.25); color: #F06292 }
.platform-ig     { color: #E1306C }
.platform-ig-bg  { background: rgba(225, 48, 108, 0.12); border-color: rgba(225, 48, 108, 0.25); color: #EC4F89 }
.platform-shopee { color: #EE6123 }
.platform-shopee-bg { background: rgba(238, 97, 35, 0.12); border-color: rgba(238, 97, 35, 0.25); color: #F5824A }
.platform-lemon8 { color: #F9B026 }
.platform-lemon8-bg { background: rgba(249, 176, 38, 0.12); border-color: rgba(249, 176, 38, 0.25); color: #FBC766 }

.platform-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border: 1px solid;
}

/* ───── V6 · EMPTY STATE ILLUSTRATIONS ─────
   Multi-ring halo + dotted background pattern (the boss-eye-catcher version) */

.mkp-empty {
  position: relative;
  background:
    radial-gradient(circle at center top, rgba(234, 134, 35, 0.05), transparent 50%),
    var(--bg-card);
  overflow: hidden;
}
.mkp-empty::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 18px 18px;
  opacity: 0.5;
  pointer-events: none;
}
.mkp-empty > * { position: relative; }
.mkp-empty-icon {
  position: relative;
  width: 88px !important;
  height: 88px !important;
  margin-bottom: 20px !important;
  background:
    radial-gradient(circle, rgba(234, 134, 35, 0.25) 0%, rgba(234, 134, 35, 0.06) 60%, transparent 100%) !important;
  border: 1px solid rgba(234, 134, 35, 0.3) !important;
  box-shadow:
    0 0 0 6px rgba(234, 134, 35, 0.06),
    0 0 0 12px rgba(234, 134, 35, 0.03),
    0 4px 24px rgba(234, 134, 35, 0.15);
  animation: mkp-empty-glow 3s ease-in-out infinite;
}
.mkp-empty-icon .material-symbols-rounded {
  font-size: 42px !important;
  filter: drop-shadow(0 0 8px rgba(234, 134, 35, 0.4));
}
@keyframes mkp-empty-glow {
  0%, 100% { box-shadow: 0 0 0 6px rgba(234, 134, 35, 0.06), 0 0 0 12px rgba(234, 134, 35, 0.03), 0 4px 24px rgba(234, 134, 35, 0.15) }
  50%      { box-shadow: 0 0 0 8px rgba(234, 134, 35, 0.10), 0 0 0 16px rgba(234, 134, 35, 0.05), 0 4px 32px rgba(234, 134, 35, 0.25) }
}

/* ───── V7 · STATUS PILLS ─────
   Pill radius · subtle gradient · icon-first · hover gleam · hidden by default
   on legacy `.approval-status` etc · we add new `.status-pill` class on top. */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border: 1px solid transparent;
  transition: all var(--transition-fast);
  position: relative;
  overflow: hidden;
}
.status-pill::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(105deg, transparent 30%, rgba(255, 255, 255, 0.06) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.6s;
}
.status-pill:hover::before { transform: translateX(100%); }

.status-pill-pending  { background: linear-gradient(135deg, rgba(255, 193, 7, 0.18), rgba(255, 193, 7, 0.06)); color: #FFCA28; border-color: rgba(255, 193, 7, 0.3) }
.status-pill-approved { background: linear-gradient(135deg, rgba(76, 175, 80, 0.18), rgba(76, 175, 80, 0.06)); color: #66BB6A; border-color: rgba(76, 175, 80, 0.3) }
.status-pill-rejected { background: linear-gradient(135deg, rgba(244, 67, 54, 0.18), rgba(244, 67, 54, 0.06)); color: #EF5350; border-color: rgba(244, 67, 54, 0.3) }
.status-pill-draft    { background: linear-gradient(135deg, rgba(136, 136, 136, 0.18), rgba(136, 136, 136, 0.06)); color: #B0B0B0; border-color: rgba(136, 136, 136, 0.3) }
.status-pill-active   { background: linear-gradient(135deg, rgba(76, 175, 80, 0.18), rgba(76, 175, 80, 0.06)); color: #66BB6A; border-color: rgba(76, 175, 80, 0.3) }
.status-pill-paused   { background: linear-gradient(135deg, rgba(136, 136, 136, 0.18), rgba(136, 136, 136, 0.06)); color: #B0B0B0; border-color: rgba(136, 136, 136, 0.3) }
.status-pill-completed{ background: linear-gradient(135deg, rgba(33, 150, 243, 0.18), rgba(33, 150, 243, 0.06)); color: #42A5F5; border-color: rgba(33, 150, 243, 0.3) }
.status-pill-failed   { background: linear-gradient(135deg, rgba(244, 67, 54, 0.18), rgba(244, 67, 54, 0.06)); color: #EF5350; border-color: rgba(244, 67, 54, 0.3) }
.status-pill-stub     { background: linear-gradient(135deg, rgba(234, 134, 35, 0.18), rgba(234, 134, 35, 0.06)); color: var(--accent); border-color: rgba(234, 134, 35, 0.3) }
.status-pill-live     { background: linear-gradient(135deg, rgba(76, 175, 80, 0.25), rgba(76, 175, 80, 0.08)); color: #81C784; border-color: rgba(76, 175, 80, 0.4); box-shadow: 0 0 12px rgba(76, 175, 80, 0.2) }

/* Refresh existing approval-status / cmp-status to also benefit visually
   without touching markup that uses those classes */
.approval-status, .cmp-status {
  border-radius: var(--radius-pill) !important;
  padding: 4px 10px !important;
  letter-spacing: 0.5px;
  border: 1px solid currentColor;
  background-blend-mode: overlay;
}

/* Buttons get gradient treatment */
.btn-primary,
.mkp-modal-btn-ok,
.mkp-empty-btn-primary {
  background: linear-gradient(135deg, var(--accent), #FF9D3F) !important;
  border-radius: var(--radius-md) !important;
  font-weight: 700 !important;
  letter-spacing: 0.2px;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.1) inset, 0 2px 8px rgba(234, 134, 35, 0.2);
}
.btn-primary:hover,
.mkp-modal-btn-ok:hover,
.mkp-empty-btn-primary:hover {
  background: linear-gradient(135deg, var(--accent-hover), #FFB266) !important;
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.15) inset, 0 4px 14px rgba(234, 134, 35, 0.35);
}

/* Page title (legacy h1.page-title) gets a subtle accent underline */
h1.page-title {
  position: relative;
  display: inline-block;
  padding-bottom: 4px;
}
h1.page-title::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0;
  width: 32px; height: 3px;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--accent), transparent);
}

/* V1.3.20: Lite-tier locked elements (Live Activity card, Upgrade button)
   match the same gray-out style as nav-item.locked · pointer-events:none
   prevents accidental clicks */
.lite-locked {
  opacity: 0.4;
  pointer-events: none;
  filter: grayscale(0.5);
}
button.lite-locked {
  background: var(--bg-card, #1E1E1E) !important;
  color: var(--text-muted, #666) !important;
  border: 1px solid var(--border, #333) !important;
}

.nav-section {
  padding: 12px 16px 2px;
  font-size: 10px;
  text-transform: uppercase;
  color: var(--text-muted);
  letter-spacing: 1px;
}

.sidebar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 12px;
  padding: 6px 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 12px;
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 0.15s;
}

.sidebar-search:hover { border-color: var(--accent); }
.sidebar-search .kbd { margin-left: auto; }

.sidebar-footer {
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

/* 2026-05-22 · Lite Premium Utility Widget · Vercel/Linear vibe · muted grays
   No flashy buttons · no sales copy · pure utility (Usage + Recent + Status).
   2026-05-22 v2 · font sizes bumped per boss UX feedback · Thai chars need
   ≥12-13px to read comfortably (was 9-11px). Heading kept uppercase compact. */
.sidebar-premium-widget {
  padding: 14px 16px 6px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  font-size: 13px;
  color: var(--text-muted);
  overflow: hidden;
}
.spw-section {
  margin-bottom: 16px;
}
.spw-section:last-child { margin-bottom: 10px; }
.spw-heading {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  opacity: 0.85;
  margin-bottom: 10px;
}
.spw-meter-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
  font-size: 13px;
}
.spw-meter-row .spw-meter-label {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  min-width: 56px;
  font-weight: 500;
}
.spw-meter-bar {
  flex: 1;
  height: 5px;
  background: var(--bg-elevated, #1a1a1a);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.spw-meter-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 999px;
  transition: width 0.4s ease;
}
.spw-meter-fill.warn { background: #f59e0b; }
.spw-meter-fill.danger { background: #ef4444; }
.spw-meter-text {
  flex: 0 0 auto;
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-muted);
  min-width: 44px;
  text-align: right;
}
.spw-recent-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
  cursor: pointer;
}
.spw-recent-item:hover { color: var(--text); background: var(--bg-elevated, #1a1a1a); padding-left: 4px; padding-right: 4px; }
.spw-recent-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.spw-recent-dot.ok { background: #10b981; }
.spw-recent-dot.run { background: #3b82f6; animation: spw-pulse 1.6s ease-in-out infinite; }
.spw-recent-dot.fail { background: #ef4444; }
@keyframes spw-pulse { 0%,100% { opacity: 1 } 50% { opacity: 0.35 } }
.spw-recent-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.spw-recent-time {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-size: 11px;
}
.spw-recent-empty {
  font-size: 12px;
  color: var(--text-muted);
  opacity: 0.7;
  padding: 6px 0;
  font-style: italic;
}
.spw-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
  color: var(--text-secondary);
}
.spw-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.spw-status-dot.ok { background: #10b981; }
.spw-status-dot.warn { background: #f59e0b; }
.spw-status-dot.fail { background: #ef4444; }
.spw-status-label { flex: 1; font-weight: 500; }
.spw-status-value { color: var(--text-muted); font-size: 11px; }
.spw-version {
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.7;
  text-align: center;
  padding-top: 6px;
  border-top: 1px solid var(--border);
  margin-top: 10px;
  font-variant-numeric: tabular-nums;
}

.package-badge {
  background: var(--accent);
  color: #000;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 600;
}

/* V1.3.6: Larger + labeled Logout button — easier to find, harder to misclick */
.btn-logout {
  background: var(--bg-elevated, #1a1a1a);
  border: 1px solid var(--border, #333);
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn-logout .material-symbols-rounded { font-size: 18px; }
.btn-logout-label { font-size: 12px; }
.btn-logout:hover {
  color: var(--error);
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.08);
}

/* Content Area — THIS div owns the scroll */
.content {
  margin-left: var(--sidebar-width);
  flex: 1;
  padding: 24px;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  overflow-x: hidden;
}

.page-title {
  font-size: 24px;
  font-weight: 600;
  margin-bottom: 24px;
}

.page-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 400px;
  color: var(--text-secondary);
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* Grid */
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

/* Stats Card */
.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--accent);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Buttons */
.btn {
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary { background: var(--accent); color: #000; font-weight: 600; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); }
.btn-secondary:hover { background: #333; }
.btn-danger { background: var(--error); color: #fff; }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* Toast */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 280px;
  animation: slideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--error); }
.toast.info { border-left: 4px solid var(--accent); }
/* S3.4 polish 2026-04-30: warning variant + icon prefix + softer entry */
.toast.warning { border-left: 4px solid #f59e0b; }
.toast::before {
  content: '';
  width: 18px; height: 18px; flex-shrink: 0;
  background: currentColor; border-radius: 50%;
  mask-position: center; mask-repeat: no-repeat; mask-size: 14px;
  opacity: 0.85;
}
.toast.success::before { color: var(--success); mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23fff' d='M9 16.2l-3.5-3.5-1.4 1.4L9 19l11-11-1.4-1.4z'/></svg>"); }
.toast.error::before   { color: var(--error);   mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23fff' d='M19 6.4L17.6 5 12 10.6 6.4 5 5 6.4 10.6 12 5 17.6 6.4 19 12 13.4 17.6 19 19 17.6 13.4 12z'/></svg>"); }
.toast.warning::before { color: #f59e0b;        mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23fff' d='M1 21h22L12 2 1 21zm12-3h-2v-2h2v2zm0-4h-2v-4h2v4z'/></svg>"); }
.toast.info::before    { color: var(--accent);  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path fill='%23fff' d='M11 17h2v-6h-2v6zm1-15a10 10 0 100 20 10 10 0 000-20zm0 18a8 8 0 110-16 8 8 0 010 16zm-1-11h2V7h-2v2z'/></svg>"); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* Status Dots */
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.dot-green { background: var(--success); }
.dot-red { background: var(--error); }
.dot-yellow { background: var(--warning); }

/* Tables */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--border); font-size: 14px; }
th { color: var(--text-secondary); font-weight: 500; font-size: 12px; text-transform: uppercase; }
tr:hover { background: var(--bg-hover); }

/* Warning tag */
.btn-warning { background: var(--warning); color: #000; font-weight: 600; }
.btn-warning:hover { background: #e6ac00; }

/* Mobile menu toggle */
.mobile-menu-btn {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px;
  color: var(--text-primary);
  cursor: pointer;
}

.mobile-menu-btn .material-symbols-rounded { font-size: 24px; }

/* Sidebar overlay for mobile */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 99;
}

/* Responsive: Tablet */
@media (max-width: 1024px) {
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .content { padding: 16px; }
}

/* Responsive: Mobile */
@media (max-width: 768px) {
  .mobile-menu-btn { display: flex; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 101;
  }

  .sidebar.open { transform: translateX(0); }
  .sidebar.open ~ .sidebar-overlay { display: block; }

  .content {
    margin-left: 0;
    padding: 52px 8px 16px;
    max-width: 100vw;
    overflow-x: hidden;
    overflow-y: auto;
    height: 100vh;
    height: 100dvh;
    box-sizing: border-box;
  }

  .page-title { font-size: 18px; margin-bottom: 12px; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }

  .quick-stats {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px !important;
    overflow: hidden !important;
  }

  .premium-stat { padding: 8px 6px; overflow: hidden; }
  .premium-stat .value { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .premium-stat .label { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .premium-stat .sub { font-size: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

  .tab-bar {
    flex-wrap: wrap; gap: 2px;
    border-bottom: none;
  }
  .tab-btn {
    flex: 0 0 auto; padding: 6px 10px; font-size: 11px;
    border: 1px solid var(--border); border-radius: 6px;
    border-bottom: none;
    white-space: nowrap;
  }
  .tab-btn.active { border-color: var(--accent); }

  table { font-size: 11px; }
  th, td { padding: 5px 6px; }
  th { font-size: 9px; }

  .card { padding: 10px; margin-bottom: 8px; overflow: hidden; }
  .premium-card { padding: 12px; overflow: hidden; }
  .card-header { flex-direction: column; gap: 6px; }
  .card-title { font-size: 14px; margin-bottom: 8px; }
  .section-title { font-size: 14px; }

  .toast { min-width: 180px; font-size: 12px; }

  .chart-bar-group { height: 100px; }

  /* Dashboard mobile fixes */
  .dash-welcome { padding: 10px; flex-direction: column !important; text-align: center; overflow: hidden; }
  .dash-welcome p { font-size: 10px !important; white-space: normal; word-break: break-word; }
  .dash-greeting { font-size: 15px !important; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .dash-welcome-actions { justify-content: center; display: flex !important; flex-direction: row !important; gap: 6px; }
  .dash-welcome-actions .btn { font-size: 11px; padding: 6px 10px; flex: 1; text-align: center; }

  /* Force grids on mobile */
  .grid.grid-3 { grid-template-columns: repeat(3, 1fr) !important; gap: 4px !important; }
  .grid.grid-4 { grid-template-columns: repeat(2, 1fr) !important; gap: 4px !important; }

  .dash-health-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
  .dash-health-item { padding: 6px 8px; }
  .dash-health-item div:first-of-type { font-size: 11px !important; }

  .quick-actions-grid { grid-template-columns: repeat(4, 1fr) !important; gap: 4px; }
  .action-btn { padding: 8px 2px; font-size: 9px; min-width: 0; min-height: 56px; }
  .action-btn .material-symbols-rounded { font-size: 20px; }
  .action-btn span:last-child { font-size: 9px; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Mini stats */
  .mini-stat { padding: 6px; }
  .mini-stat-val { font-size: 16px; }
  .mini-stat-label { font-size: 9px; }

  /* Modals */
  .modal { width: 92vw !important; max-width: 92vw !important; max-height: 85vh; overflow-y: auto; margin: 0 auto; left: 0; right: 0; box-sizing: border-box; }

  /* Forms · 2026-05-09 Mobile-W1+W2 · iOS anti-zoom + 44px touch targets
     iOS Safari auto-zooms when input font-size < 16px on focus · we lock to 16px.
     Touch targets follow Apple HIG/Material 44dp rule on btn + btn-sm. */
  .form-input, .form-input-sm,
  input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], input[type="search"], input[type="tel"], input[type="url"],
  textarea, select { font-size: 16px !important; }
  .btn { font-size: 13px; padding: 10px 16px; min-height: 44px; min-width: 44px; }
  .btn-sm { font-size: 12px; padding: 8px 12px; min-height: 40px; min-width: 40px; }
  .btn-xs { font-size: 11px; padding: 6px 10px; min-height: 36px; min-width: 36px; }
  /* Modal close ✕ buttons · explicit 44x44 hit area regardless of class */
  .btn-close, [aria-label="ปิด"], [aria-label="Close"], [aria-label="close"] {
    min-width: 44px; min-height: 44px; display: inline-flex;
    align-items: center; justify-content: center;
  }

  /* Tooltips disabled on mobile (touch) */
  [data-tooltip]::before, [data-tooltip]::after { display: none !important; }

  /* Package badge */
  .package-badge { font-size: 10px; padding: 3px 8px; }

  /* Tags */
  .tag { font-size: 10px; padding: 1px 6px; }
  .mini-tag { font-size: 9px; }

  /* Status badges */
  .status-badge { font-size: 10px; }

  /* Progress bars */
  .premium-progress { height: 6px; }

  /* Tables: card layout on mobile */
  table { white-space: normal; min-width: unset; }
  thead { display: none; }
  tbody { display: flex; flex-direction: column; gap: 6px; }
  tr {
    display: flex; flex-wrap: wrap; gap: 4px 8px;
    padding: 10px; background: var(--bg-primary); border-radius: 8px;
    border: 1px solid var(--border); align-items: center;
  }
  td { border: none !important; padding: 2px 0 !important; font-size: 12px; }
  td:first-child { font-weight: 600; }
  .cell-truncate { max-width: 100% !important; }

  /* Cell truncation */
  .cell-truncate { max-width: 80px !important; }

  /* Form layouts — left-aligned labels */
  .form-row { flex-direction: column; gap: 4px; align-items: stretch !important; }
  .form-row label { min-width: auto !important; text-align: left !important; font-size: 12px; }
  .form-input, select.form-input { width: 100% !important; font-size: 16px !important; }

  /* Grid inside cards on mobile */
  .grid.grid-3 { grid-template-columns: repeat(3, 1fr) !important; gap: 4px; }

  /* Section headers */
  .section-header { flex-direction: column; gap: 6px; }
  .card-header .btn, .card-header .btn-sm { font-size: 10px; }

  /* Sidebar: hide search + Ctrl+K hint on mobile */
  .sidebar-search { display: none; }
  .kbd { display: none !important; }

  /* X-Ray filter collapse on mobile */
  .xray-filter-bar { flex-direction: column; gap: 6px; }
  .xray-filter-bar .filter-group { width: 100%; }
  .xray-filter-bar input, .xray-filter-bar select { min-height: 44px; font-size: 16px !important; }
  .filter-presets { flex-wrap: wrap; }

  /* Platform/device cards */
  .platform-card, .device-card, .room-card { font-size: 12px; }
  .device-card { padding: 8px; gap: 6px; }

  /* Settings page */
  .provider-card { padding: 10px; }
  .code-editor { font-size: 11px !important; }

  /* Studio canvas — show banner, hide toolbar on mobile */
  .studio-mobile-notice { display: block !important; }
  .section-header > div:last-child { display: none !important; }
  #fabricCanvas { max-height: 200px; }
}

/* Responsive: Small mobile */
@media (max-width: 380px) {
  .content { padding: 52px 6px 12px; }
  .quick-stats { grid-template-columns: 1fr 1fr; gap: 4px; }
  .premium-stat .value { font-size: 16px; }
  .quick-actions-grid { grid-template-columns: repeat(2, 1fr) !important; }
  .dash-welcome-actions { flex-direction: column; }
  .dash-welcome-actions .btn { width: 100%; }
  .grid.grid-3 { grid-template-columns: 1fr !important; }
}

/* ═══════════════════════════════════════════════════════════════
 * 2026-05-09 · Mobile UX Upgrade (Hia Gem CTO directive)
 * M-W3 Scrollable tabs · M-W4 Desktop-required gate · M-W5 Bottom nav
 * ═══════════════════════════════════════════════════════════════ */

/* M-W3 · Scrollable tabs · prevent overflow, swipe horizontally */
@media (max-width: 768px) {
  .tab-bar {
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;            /* Firefox */
    scroll-snap-type: x proximity;
    padding-bottom: 2px;
  }
  .tab-bar::-webkit-scrollbar { display: none; }  /* Chrome/Safari */
  .tab-bar .tab-btn {
    flex-shrink: 0;
    scroll-snap-align: start;
    min-height: 44px;
    padding: 12px 16px;
  }
}

/* M-W4 · Desktop-required gate · for canvas/editor pages
 * Pages that require precision (Studio canvas, Headline editor) opt-in by
 * adding `data-desktop-required="1"` on their root element. On mobile we
 * show a friendly notice + hide the actual editor content. */
.desktop-required-notice { display: none; }

@media (max-width: 768px) {
  [data-desktop-required="1"] > *:not(.desktop-required-notice) { display: none !important; }
  [data-desktop-required="1"] .desktop-required-notice {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 48px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin: 16px 0;
  }
  .desktop-required-notice .material-symbols-rounded {
    font-size: 64px;
    color: var(--accent);
    margin-bottom: 16px;
  }
  .desktop-required-notice h3 {
    margin: 0 0 8px;
    font-size: 18px;
    color: var(--text-primary);
  }
  .desktop-required-notice p {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.5;
    max-width: 320px;
  }
}

/* M-W5 · Bottom nav bar · 5 sticky tabs on mobile only */
.mobile-bottom-nav { display: none; }

@media (max-width: 768px) {
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    z-index: 150;
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom);  /* iPhone notch */
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.3);
  }
  .mobile-bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: var(--text-muted);
    text-decoration: none;
    font-size: 10px;
    font-weight: 500;
    padding: 8px 4px;
    border: none;
    background: transparent;
    cursor: pointer;
    min-height: 44px;
    transition: color 0.15s;
  }
  .mobile-bottom-nav-item:active { background: rgba(255, 255, 255, 0.05); }
  .mobile-bottom-nav-item .material-symbols-rounded { font-size: 22px; }
  .mobile-bottom-nav-item.active {
    color: var(--accent);
  }
  .mobile-bottom-nav-item.active .material-symbols-rounded {
    font-variation-settings: 'FILL' 1;
  }
  /* Make room above bottom nav so content isn't hidden */
  .content { padding-bottom: 76px !important; }
}

