/* Canban Modern amoCRM-Style Theme with Dark Mode & Responsive Layout */

:root,
:root[data-theme="light"] {
  color-scheme: light;

  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-surface-secondary: #f1f5f9;
  --bg-surface-hover: #e2e8f0;
  --bg-sidebar: #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-hover: #1e293b;
  --sidebar-width: 230px;
  --header-height: 64px;

  --color-primary: #0d9488;
  --color-primary-hover: #0f766e;
  --color-primary-light: #ccfbf1;
  --color-primary-text: #0f766e;
  --btn-primary-bg: #0f766e;
  --btn-primary-text: #ffffff;
  --btn-primary-border: #0f766e;
  --btn-primary-hover-bg: #115e59;
  --btn-primary-hover-text: #ffffff;
  --btn-primary-hover-border: #115e59;
  --color-text-main: #0f172a;
  --color-text-muted: #64748b;
  --color-border: #e2e8f0;
  --color-border-focus: #0d9488;
  --color-input-bg: #ffffff;
  --color-input-border: #cbd5e1;

  --bg-table: #ffffff;
  --bg-table-th: #f8fafc;
  --bg-table-hover: #f8fafc;
  --bg-modal: #ffffff;
  --bg-modal-overlay: rgba(15, 23, 42, 0.65);
  --bg-code: #0f172a;
  --color-code: #e2e8f0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);

  /* 7 Funnel Stage Accents (Light) */
  --stage-ideas: #64748b;
  --stage-ideas-bg: #f1f5f9;
  --stage-ideas-border: #cbd5e1;
  --stage-ideas-text: #334155;

  --stage-discussion: #2563eb;
  --stage-discussion-bg: #eff6ff;
  --stage-discussion-border: #bfdbfe;
  --stage-discussion-text: #1e3a8a;

  --stage-plan_review: #d97706;
  --stage-plan_review-bg: #fffbeb;
  --stage-plan_review-border: #fde68a;
  --stage-plan_review-text: #92400e;

  --stage-ready_for_dev: #7c3aed;
  --stage-ready_for_dev-bg: #f5f3ff;
  --stage-ready_for_dev-border: #ddd6fe;
  --stage-ready_for_dev-text: #5b21b6;

  --stage-development: #0d9488;
  --stage-development-bg: #f0fdfa;
  --stage-development-border: #99f6e4;
  --stage-development-text: #115e59;

  --stage-verification: #e11d48;
  --stage-verification-bg: #fff1f2;
  --stage-verification-border: #fecdd3;
  --stage-verification-text: #9f1239;

  --stage-done: #059669;
  --stage-done-bg: #ecfdf5;
  --stage-done-border: #a7f3d0;
  --stage-done-text: #065f46;

  /* Alerts & Badges */
  --alert-error-bg: #fef2f2;
  --alert-error-border: #fecaca;
  --alert-error-text: #991b1b;

  --alert-success-bg: #f0fdf4;
  --alert-success-border: #bbf7d0;
  --alert-success-text: #166534;

  --alert-warning-bg: #fffbeb;
  --alert-warning-border: #fde68a;
  --alert-warning-text: #b45309;
}

/* Explicit Dark Theme */
:root[data-theme="dark"] {
  color-scheme: dark;

  --bg-page: #090d16;
  --bg-card: #111827;
  --bg-surface-secondary: #1e293b;
  --bg-surface-hover: #334155;
  --bg-sidebar: #090d16;
  --sidebar-border: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #f8fafc;
  --sidebar-hover: #1e293b;

  --color-primary: #14b8a6;
  --color-primary-hover: #2dd4bf;
  --color-primary-light: rgba(20, 184, 166, 0.18);
  --color-primary-text: #5eead4;
  --btn-primary-bg: #14b8a6;
  --btn-primary-text: #090d16;
  --btn-primary-border: #14b8a6;
  --btn-primary-hover-bg: #2dd4bf;
  --btn-primary-hover-text: #090d16;
  --btn-primary-hover-border: #2dd4bf;
  --color-text-main: #f1f5f9;
  --color-text-muted: #94a3b8;
  --color-border: #1e293b;
  --color-border-focus: #14b8a6;
  --color-input-bg: #1e293b;
  --color-input-border: #334155;

  --bg-table: #111827;
  --bg-table-th: #1e293b;
  --bg-table-hover: #1e293b;
  --bg-modal: #111827;
  --bg-modal-overlay: rgba(0, 0, 0, 0.8);
  --bg-code: #060910;
  --color-code: #e2e8f0;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55);

  /* 7 Funnel Stage Accents (Dark - Contrast Checked) */
  --stage-ideas: #94a3b8;
  --stage-ideas-bg: #1e293b;
  --stage-ideas-border: #334155;
  --stage-ideas-text: #cbd5e1;

  --stage-discussion: #60a5fa;
  --stage-discussion-bg: rgba(37, 99, 235, 0.16);
  --stage-discussion-border: rgba(96, 165, 250, 0.35);
  --stage-discussion-text: #bfdbfe;

  --stage-plan_review: #fbbf24;
  --stage-plan_review-bg: rgba(217, 119, 6, 0.16);
  --stage-plan_review-border: rgba(251, 191, 36, 0.35);
  --stage-plan_review-text: #fde68a;

  --stage-ready_for_dev: #a78bfa;
  --stage-ready_for_dev-bg: rgba(124, 58, 237, 0.16);
  --stage-ready_for_dev-border: rgba(167, 139, 250, 0.35);
  --stage-ready_for_dev-text: #ddd6fe;

  --stage-development: #2dd4bf;
  --stage-development-bg: rgba(13, 148, 136, 0.16);
  --stage-development-border: rgba(45, 212, 191, 0.35);
  --stage-development-text: #99f6e4;

  --stage-verification: #fb7185;
  --stage-verification-bg: rgba(225, 29, 72, 0.16);
  --stage-verification-border: rgba(251, 113, 133, 0.35);
  --stage-verification-text: #fecdd3;

  --stage-done: #34d399;
  --stage-done-bg: rgba(5, 150, 105, 0.16);
  --stage-done-border: rgba(52, 211, 153, 0.35);
  --stage-done-text: #a7f3d0;

  /* Alerts & Badges (Dark) */
  --alert-error-bg: rgba(239, 68, 68, 0.15);
  --alert-error-border: rgba(239, 68, 68, 0.35);
  --alert-error-text: #fca5a5;

  --alert-success-bg: rgba(16, 185, 129, 0.15);
  --alert-success-border: rgba(16, 185, 129, 0.35);
  --alert-success-text: #6ee7b7;

  --alert-warning-bg: rgba(245, 158, 11, 0.15);
  --alert-warning-border: rgba(245, 158, 11, 0.35);
  --alert-warning-text: #fcd34d;
}

/* System Preference (prefers-color-scheme: dark) fallback when not explicitly light */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg-page: #090d16;
    --bg-card: #111827;
    --bg-surface-secondary: #1e293b;
    --bg-surface-hover: #334155;
    --bg-sidebar: #090d16;
    --sidebar-border: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #f8fafc;
    --sidebar-hover: #1e293b;

    --color-primary: #14b8a6;
    --color-primary-hover: #2dd4bf;
    --color-primary-light: rgba(20, 184, 166, 0.18);
    --color-primary-text: #5eead4;
    --btn-primary-bg: #14b8a6;
    --btn-primary-text: #090d16;
    --btn-primary-border: #14b8a6;
    --btn-primary-hover-bg: #2dd4bf;
    --btn-primary-hover-text: #090d16;
    --btn-primary-hover-border: #2dd4bf;
    --color-text-main: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-border: #1e293b;
    --color-border-focus: #14b8a6;
    --color-input-bg: #1e293b;
    --color-input-border: #334155;

    --bg-table: #111827;
    --bg-table-th: #1e293b;
    --bg-table-hover: #1e293b;
    --bg-modal: #111827;
    --bg-modal-overlay: rgba(0, 0, 0, 0.8);
    --bg-code: #060910;
    --color-code: #e2e8f0;

    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.55);

    --stage-ideas: #94a3b8;
    --stage-ideas-bg: #1e293b;
    --stage-ideas-border: #334155;
    --stage-ideas-text: #cbd5e1;

    --stage-discussion: #60a5fa;
    --stage-discussion-bg: rgba(37, 99, 235, 0.16);
    --stage-discussion-border: rgba(96, 165, 250, 0.35);
    --stage-discussion-text: #bfdbfe;

    --stage-plan_review: #fbbf24;
    --stage-plan_review-bg: rgba(217, 119, 6, 0.16);
    --stage-plan_review-border: rgba(251, 191, 36, 0.35);
    --stage-plan_review-text: #fde68a;

    --stage-ready_for_dev: #a78bfa;
    --stage-ready_for_dev-bg: rgba(124, 58, 237, 0.16);
    --stage-ready_for_dev-border: rgba(167, 139, 250, 0.35);
    --stage-ready_for_dev-text: #ddd6fe;

    --stage-development: #2dd4bf;
    --stage-development-bg: rgba(13, 148, 136, 0.16);
    --stage-development-border: rgba(45, 212, 191, 0.35);
    --stage-development-text: #99f6e4;

    --stage-verification: #fb7185;
    --stage-verification-bg: rgba(225, 29, 72, 0.16);
    --stage-verification-border: rgba(251, 113, 133, 0.35);
    --stage-verification-text: #fecdd3;

    --stage-done: #34d399;
    --stage-done-bg: rgba(5, 150, 105, 0.16);
    --stage-done-border: rgba(52, 211, 153, 0.35);
    --stage-done-text: #a7f3d0;

    --alert-error-bg: rgba(239, 68, 68, 0.15);
    --alert-error-border: rgba(239, 68, 68, 0.35);
    --alert-error-text: #fca5a5;

    --alert-success-bg: rgba(16, 185, 129, 0.15);
    --alert-success-border: rgba(16, 185, 129, 0.35);
    --alert-success-text: #6ee7b7;

    --alert-warning-bg: rgba(245, 158, 11, 0.15);
    --alert-warning-border: rgba(245, 158, 11, 0.35);
    --alert-warning-text: #fcd34d;
  }
}

/* Base Reset & Box Sizing */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--bg-page);
  color: var(--color-text-main);
  line-height: 1.5;
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  min-height: 100dvh;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Screen Reader Only Utility */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* App Container Layout */
.app-container {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
}

/* Backdrop for Mobile Sidebar */
.sidebar-backdrop {
  display: none;
}

@media (max-width: 1023px) {
  .sidebar-backdrop {
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--bg-modal-overlay);
    z-index: 40;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
  }

  .sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
  }
}

/* Sidebar */
.app-sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-sidebar);
  color: #f8fafc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  z-index: 20;
}

.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, #0d9488 0%, #0284c7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: #ffffff;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-text {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  flex: 1;
}

.sidebar-close-btn {
  display: none;
  background: none;
  border: none;
  color: var(--sidebar-text);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  min-width: 44px;
  min-height: 44px;
  align-items: center;
  justify-content: center;
}

.sidebar-close-btn:hover {
  color: #ffffff;
}

.sidebar-nav {
  list-style: none;
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
  overflow-y: auto;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
  min-height: 44px;
}

.nav-link:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-active);
}

.nav-link.active {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-text-active);
  border-left: 3px solid var(--color-primary);
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  font-size: 12px;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Offcanvas Sidebar on Tablet / Mobile (< 1024px) */
@media (max-width: 1023px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    max-width: 86vw;
    height: 100vh;
    height: 100dvh;
    z-index: 50;
    transform: translateX(-100%);
    visibility: hidden; /* Fully hidden from accessibility tree when closed */
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0.25s;
    box-shadow: none;
  }

  .app-sidebar.sidebar-open {
    transform: translateX(0);
    visibility: visible;
    transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), visibility 0s;
    box-shadow: var(--shadow-lg);
  }

  .sidebar-close-btn {
    display: inline-flex;
  }
}

/* Main Area */
.app-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--bg-page);
}

/* Header */
.app-header {
  height: var(--header-height);
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 10;
  gap: 16px;
}

.header-row-top {
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1 1 auto;
  min-width: 0;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.header-theme-cell {
  display: inline-flex;
  align-items: center;
}

.header-row-bottom {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 0 0 auto;
}

.demo-badge-text-short {
  display: none;
}

.demo-badge-text-long {
  display: inline;
}

/* Mobile Nav Toggle (Hamburger Button) */
.mobile-nav-toggle {
  display: none;
  background: none;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  min-width: 44px;
  min-height: 44px;
  background-color: var(--bg-card);
  color: var(--color-text-main);
}

.mobile-nav-toggle:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

.hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--color-text-main);
  border-radius: 1px;
}

@media (max-width: 1023px) {
  .mobile-nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb-separator {
  color: var(--color-border);
}

.breadcrumb-current {
  color: var(--color-text-main);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* Segmented Theme Switch (UI-THEME-TOGGLE) */
.theme-control-wrapper {
  display: inline-flex;
  align-items: center;
}

.theme-segmented-switch {
  display: inline-flex;
  align-items: center;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
  box-sizing: border-box;
  max-width: 144px;
}

.theme-segment-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: calc(var(--radius-sm) - 2px);
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
  box-sizing: border-box;
  position: relative;
}

.theme-segment-btn:hover:not(:disabled) {
  color: var(--color-text-main);
  background-color: var(--bg-surface-hover);
}

.theme-segment-btn.active {
  background-color: var(--bg-card);
  color: var(--color-primary);
  border-color: var(--color-border);
  box-shadow: var(--shadow-sm);
}

.theme-segment-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
  z-index: 2;
}

.theme-segment-btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.theme-icon {
  display: block;
  pointer-events: none;
  flex-shrink: 0;
}

@media (prefers-reduced-motion: reduce) {
  .theme-segment-btn {
    transition: none;
  }
}

/* Backward compatibility for any remaining select elements */
.theme-select {
  padding: 6px 10px;
  font-size: 13px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-input-border);
  background-color: var(--color-input-bg);
  color: var(--color-text-main);
  cursor: pointer;
  min-height: 36px;
  outline: none;
  transition: border-color 0.15s ease;
}

.theme-select:focus-visible {
  border-color: var(--color-border-focus);
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* Demo Badge */
.demo-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background-color: var(--color-primary-light);
  color: var(--color-primary-text);
  border: 1px solid rgba(13, 148, 136, 0.3);
  white-space: nowrap;
}

.demo-pulse {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background-color: var(--color-primary);
  animation: pulse 2s infinite;
  flex-shrink: 0;
}

.inline-pulse {
  display: inline-block;
  margin-left: 6px;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(13, 148, 136, 0.7); }
  70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(13, 148, 136, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(13, 148, 136, 0); }
}

/* Notification Pill */
.update-notify-pill {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  background-color: var(--alert-warning-bg);
  border: 1px solid var(--alert-warning-border);
  color: var(--alert-warning-text);
  cursor: pointer;
  white-space: nowrap;
}

.update-notify-pill.visible {
  display: inline-flex;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease-in-out;
  min-height: 38px;
  box-sizing: border-box;
}

.btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

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

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

.btn-secondary {
  background-color: var(--bg-card);
  color: var(--color-text-main);
  border-color: var(--color-border);
}

.btn-secondary:hover {
  background-color: var(--bg-surface-secondary);
}

.btn-success {
  background-color: #059669;
  color: #ffffff;
}

.btn-success:hover {
  background-color: #047857;
}

.btn-danger {
  background-color: #ef4444;
  color: #ffffff;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
  min-height: 32px;
}

.btn-block {
  width: 100%;
  margin-top: 10px;
  min-height: 44px;
}

.btn-rework {
  color: var(--alert-warning-text);
  border-color: var(--alert-warning-border);
  background-color: var(--bg-card);
}

.btn-chat-send {
  align-self: flex-end;
  min-height: 44px;
}

/* Alerts */
.alert {
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.alert-error {
  background-color: var(--alert-error-bg);
  border: 1px solid var(--alert-error-border);
  color: var(--alert-error-text);
}

.alert-success {
  background-color: var(--alert-success-bg);
  border: 1px solid var(--alert-success-border);
  color: var(--alert-success-text);
}

.alert-warning-box {
  font-size: 13px;
  color: var(--alert-warning-text);
  background-color: var(--alert-warning-bg);
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  border: 1px solid var(--alert-warning-border);
  line-height: 1.5;
}

/* Page Layout */
.page-content {
  padding: 24px;
  flex: 1;
  min-width: 0;
}

@media (max-width: 767px) {
  .page-content {
    padding: 16px 12px;
  }

  .app-header {
    padding: 10px 12px;
    min-height: 52px;
  }
}

/* Empty Board Banner */
.empty-board-banner {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.empty-board-title {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--color-text-main);
}

.empty-board-desc {
  margin-bottom: 1rem;
}

/* Board Header and Controls */
.board-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 16px;
}

.board-title-group h1 {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-main);
}

.board-subtitle {
  font-size: 14px;
  color: var(--color-text-muted);
}

.board-stats {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.stat-pill {
  padding: 6px 12px;
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.board-filter-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.search-input, .select-input {
  padding: 8px 14px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background-color: var(--color-input-bg);
  color: var(--color-text-main);
  outline: none;
  transition: border-color 0.15s ease;
  min-height: 38px;
}

.search-input:focus, .select-input:focus {
  border-color: var(--color-border-focus);
}

.search-input {
  width: 280px;
  max-width: 100%;
}

/* Mobile Stage Selection Chips (Hidden on Desktop) */
.mobile-stages-bar {
  display: none;
}

.filter-search-group {
  display: contents;
}

.filter-select-group {
  display: contents;
}

@media (max-width: 1023px) {
  .mobile-stages-bar {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 2px 10px 2px;
    margin-bottom: 12px;
    scrollbar-width: none; /* Hide visual fat scrollbar on Firefox */
    -ms-overflow-style: none; /* Hide visual fat scrollbar on IE/Edge */
  }

  .mobile-stages-bar::-webkit-scrollbar {
    display: none; /* Hide visual fat scrollbar on Chrome/Safari/WebKit */
  }

  .stage-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: 9999px;
    font-size: 13px;
    font-weight: 500;
    background-color: var(--bg-card);
    border: 1px solid var(--color-border);
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
    min-height: 44px;
    transition: all 0.15s ease;
    flex-shrink: 0;
  }

  .stage-chip .chip-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
  }

  .stage-chip-ideas .chip-dot { background-color: var(--stage-ideas); }
  .stage-chip-discussion .chip-dot { background-color: var(--stage-discussion); }
  .stage-chip-plan_review .chip-dot { background-color: var(--stage-plan_review); }
  .stage-chip-ready_for_dev .chip-dot { background-color: var(--stage-ready_for_dev); }
  .stage-chip-development .chip-dot { background-color: var(--stage-development); }
  .stage-chip-verification .chip-dot { background-color: var(--stage-verification); }
  .stage-chip-done .chip-dot { background-color: var(--stage-done); }

  .stage-chip .chip-count {
    padding: 1px 6px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 700;
    background-color: var(--bg-surface-secondary);
    color: var(--color-text-main);
  }

  .stage-chip.active {
    background-color: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-text);
    font-weight: 700;
  }
}

/* 7 Columns Board Layout (Desktop default) */
.board-container {
  overflow-x: auto;
  overflow-y: hidden;
  padding-bottom: 16px;
  margin-top: 8px;
  min-width: 0;
}

.board-columns {
  display: flex;
  gap: 16px;
  min-width: 1720px;
  align-items: flex-start;
}

.board-column {
  width: 236px;
  flex-shrink: 0;
  background-color: var(--bg-surface-secondary);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 240px);
  border: 1px solid var(--color-border);
}

/* Mobile Stage View Behavior (< 1024px) */
@media (max-width: 1023px) {
  .board-container.mobile-stage-view {
    overflow-x: visible;
    padding-bottom: 0;
  }

  .board-container.mobile-stage-view .board-columns {
    min-width: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0;
  }

  .board-container.mobile-stage-view .board-column {
    display: none;
    width: 100%;
    max-height: none;
    flex-shrink: 1;
    min-width: 0;
  }

  .board-container.mobile-stage-view .board-column.mobile-selected {
    display: flex;
  }
}

.column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 10px;
  margin-bottom: 10px;
  border-bottom: 2px solid;
}

.column-header.stage-ideas { border-color: var(--stage-ideas); }
.column-header.stage-discussion { border-color: var(--stage-discussion); }
.column-header.stage-plan_review { border-color: var(--stage-plan_review); }
.column-header.stage-ready_for_dev { border-color: var(--stage-ready_for_dev); }
.column-header.stage-development { border-color: var(--stage-development); }
.column-header.stage-verification { border-color: var(--stage-verification); }
.column-header.stage-done { border-color: var(--stage-done); }

.column-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-main);
}

.column-badge {
  background-color: var(--bg-card);
  color: var(--color-text-main);
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 11px;
  font-weight: 700;
  border: 1px solid var(--color-border);
}

.column-cards {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  padding-right: 2px;
}

/* Card in Column */
.task-card {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  box-shadow: var(--shadow-sm);
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--color-border-focus);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

.project-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--bg-surface-secondary);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  flex: 1 1 auto;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-muted);
  flex: 0 0 auto;
  white-space: nowrap;
}

.card-num-lg {
  font-size: 14px;
}

.card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-main);
  line-height: 1.4;
  word-break: break-word;
}

.card-desc-clamp {
  font-size: 12px;
  color: var(--color-text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  word-break: break-word;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 4px;
  font-size: 11px;
  color: var(--color-text-muted);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  display: inline-block;
  flex-shrink: 0;
}

.status-dot.active-agent {
  background-color: var(--color-primary);
  animation: pulse 1.5s infinite;
}

.status-dot.waiting-decision {
  background-color: #f59e0b;
}

.status-dot.ready {
  background-color: #8b5cf6;
}

.status-dot.done {
  background-color: #10b981;
}

.status-dot.default {
  background-color: var(--color-text-muted);
}

.empty-column {
  padding: 24px 12px;
  text-align: center;
  color: var(--color-text-muted);
  font-size: 12px;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-secondary);
}

/* Card Detail Page */
.card-detail-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  max-width: 1440px;
  margin: 0 auto;
}

@media (max-width: 1023px) {
  .card-detail-layout {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

.card-main-col {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

@media (max-width: 767px) {
  .card-main-col {
    padding: 16px;
  }
}

.detail-header {
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.detail-nav-back {
  font-size: 13px;
  color: var(--color-text-muted);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
  min-height: 36px;
}

.detail-nav-back:hover {
  color: var(--color-primary);
}

.detail-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.detail-title-row h1 {
  font-size: 22px;
  font-weight: 700;
  word-break: break-word;
}

/* Stage Breadcrumb Banner */
.stage-breadcrumb-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
}

.stage-step {
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
}

.stage-step.active {
  background-color: var(--color-primary);
  color: #ffffff;
  font-weight: 600;
}

.stage-step.completed {
  color: #10b981;
}

.stage-arrow {
  color: var(--color-border);
  font-size: 11px;
}

/* Contextual Action Bar */
.contextual-action-bar {
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.action-bar-info {
  font-size: 13px;
  color: var(--color-text-main);
  flex: 1 1 280px;
}

.action-bar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-actions {
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}

.inline-form {
  display: inline-flex;
}

.stopping-text {
  font-size: 13px;
  color: var(--alert-warning-text);
  font-weight: 600;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: nowrap;
  scrollbar-width: thin;
}

.tab-btn {
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-muted);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  min-height: 44px;
}

.tab-btn:hover {
  color: var(--color-text-main);
}

.tab-btn.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: 600;
}

/* Tab Panels */
.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Form Styles */
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-main);
}

.form-control {
  padding: 8px 12px;
  border: 1px solid var(--color-input-border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background-color: var(--color-input-bg);
  color: var(--color-text-main);
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s ease;
  min-height: 38px;
}

.form-control:focus {
  border-color: var(--color-border-focus);
}

textarea.form-control {
  min-height: 100px;
  resize: vertical;
}

/* Touch friendly minimums & Compact Mobile Layout (< 768px) */
@media (max-width: 767px) {
  .app-header {
    height: auto;
    min-height: auto;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .header-row-top {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    min-width: 0;
  }

  .header-left {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1 1 auto;
  }

  .breadcrumb-prefix {
    display: none; /* Hides 'Canban / Рабочее пространство' on mobile */
  }

  .breadcrumb-current {
    font-size: 14px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .header-theme-cell {
    flex: 0 0 auto;
  }

  .header-theme-cell .theme-segmented-switch {
    padding: 2px;
    gap: 2px;
  }

  .header-theme-cell .theme-segment-btn {
    min-width: 42px;
    min-height: 44px;
  }

  .header-row-bottom {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    min-width: 0;
  }

  .demo-badge {
    padding: 2px 6px;
    font-size: 11px;
    gap: 4px;
    flex-shrink: 0;
  }

  .demo-badge-text-long {
    display: none;
  }

  .demo-badge-text-short {
    display: inline;
  }

  .user-pill {
    padding: 2px 6px;
    font-size: 12px;
    gap: 4px;
    min-width: 0;
    flex-shrink: 1;
  }

  .user-name {
    max-width: 65px;
    font-size: 11px;
  }

  .user-pill .btn {
    padding: 2px 6px;
    font-size: 11px;
    min-height: 26px;
  }

  .btn-new-task {
    padding: 4px 10px;
    font-size: 12px;
    min-height: 34px;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .update-notify-pill {
    padding: 2px 6px;
    font-size: 11px;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .board-header-bar {
    margin-bottom: 8px;
    gap: 6px;
  }

  .board-title-group h1 {
    font-size: 18px;
    line-height: 1.2;
    margin-bottom: 0;
  }

  .board-subtitle {
    display: none; /* Hide subtitle to preserve screen height */
  }

  .board-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    width: 100%;
    gap: 4px;
    margin-top: 4px;
  }

  .stat-pill {
    padding: 4px 4px;
    font-size: 10px;
    flex-direction: column;
    align-items: center;
    gap: 1px;
    text-align: center;
    line-height: 1.2;
  }

  .stat-pill strong {
    font-size: 12px;
  }

  .board-filter-bar {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
  }

  .filter-search-group {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .filter-search-group .search-input {
    flex: 1 1 auto;
    width: auto;
    font-size: 16px; /* Prevents auto-zoom on iOS */
    min-height: 44px;
  }

  .btn-filter-submit {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 14px;
  }

  .filter-select-group {
    display: flex;
    gap: 6px;
    width: 100%;
  }

  .filter-select-group .select-input {
    flex: 1 1 auto;
    width: auto;
    font-size: 16px; /* Prevents auto-zoom on iOS */
    min-height: 44px;
  }

  .btn-filter-reset {
    flex: 0 0 auto;
    min-height: 44px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
  }

  .form-control,
  .select-input,
  .theme-select {
    font-size: 16px; /* Prevents auto-zoom on iOS */
    min-height: 44px;
  }

  .btn {
    min-height: 44px;
    padding: 8px 14px;
  }
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
  flex-wrap: wrap;
}

/* Chat & Messages Tab */
.chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
  max-height: 480px;
  overflow-y: auto;
  padding-right: 6px;
}

.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.5;
  max-width: 85%;
}

.chat-bubble.user {
  align-self: flex-end;
  background-color: var(--stage-discussion-bg);
  border: 1px solid var(--stage-discussion-border);
  color: var(--stage-discussion-text);
}

.chat-bubble.assistant {
  align-self: flex-start;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  color: var(--color-text-main);
}

.chat-bubble-author {
  font-size: 11px;
  font-weight: 700;
  margin-bottom: 4px;
  text-transform: uppercase;
}

.chat-time {
  font-weight: normal;
  font-size: 10px;
  margin-left: 8px;
  opacity: 0.8;
}

.chat-text {
  white-space: pre-wrap;
  word-break: break-word;
}

.chat-empty {
  color: var(--color-text-muted);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.chat-input-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chat-input-row textarea {
  flex: 1 1 240px;
}

/* Plan Tab */
.plan-card {
  margin-bottom: 24px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background-color: var(--bg-card);
}

.plan-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 8px;
  flex-wrap: wrap;
  gap: 8px;
}

.badge-approved {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background-color: var(--alert-success-bg);
  color: var(--alert-success-text);
  border: 1px solid var(--alert-success-border);
}

.badge-draft {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background-color: var(--alert-warning-bg);
  color: var(--alert-warning-text);
  border: 1px solid var(--alert-warning-border);
}

.badge-superseded {
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  background-color: var(--bg-surface-secondary);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
}

.plan-container {
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 18px;
  font-family: monospace;
  font-size: 13px;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.6;
  color: var(--color-text-main);
  margin-bottom: 20px;
}

.plan-meta {
  font-size: 11px;
  color: var(--color-text-muted);
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.plan-empty {
  text-align: center;
  padding: 40px;
  color: var(--color-text-muted);
}

/* Agent Progress */
.agent-banner {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background-color: var(--stage-development-bg);
  border: 1px solid var(--stage-development-border);
}

.progress-log-container {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 12px;
  background-color: var(--bg-card);
  margin-bottom: 24px;
}

.progress-item {
  padding: 6px 10px;
  background-color: var(--bg-surface-secondary);
  border-radius: 6px;
  margin-bottom: 6px;
  font-size: 13px;
  word-break: break-word;
}

/* Result & Artifacts */
.result-banner {
  margin-bottom: 20px;
  padding: 16px;
  border-radius: var(--radius-sm);
  background-color: var(--alert-success-bg);
  border: 1px solid var(--alert-success-border);
}

.artifact-card {
  margin-bottom: 20px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background-color: var(--bg-card);
}

.artifact-header {
  background-color: var(--bg-surface-secondary);
  padding: 10px 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  flex-wrap: wrap;
  gap: 8px;
}

.rework-container {
  margin-top: 32px;
  border-top: 1px solid var(--color-border);
  padding-top: 20px;
}

/* Authentication & Setup Pages */
.auth-page-container {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-page);
  padding: 20px;
  position: relative;
}

.auth-top-bar {
  width: 100%;
  max-width: 440px;
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
}

@media (max-width: 480px) {
  .auth-card {
    padding: 20px;
  }
}

.auth-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.auth-brand .brand-logo {
  width: 40px;
  height: 40px;
  background-color: var(--color-primary);
  color: #ffffff;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
}

.auth-brand .brand-text {
  font-size: 22px;
  font-weight: 700;
  color: var(--color-text-main);
  letter-spacing: -0.5px;
}

.auth-title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 20px;
  color: var(--color-text-main);
}

.auth-description {
  font-size: 13px;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 20px;
  line-height: 1.5;
}

.auth-code-block {
  background-color: var(--bg-code);
  color: var(--color-code);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 13px;
  word-break: break-all;
  margin-bottom: 20px;
  user-select: all;
  border: 1px solid var(--color-border);
}

/* User pill & Logout in header */
.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px;
  background-color: var(--bg-surface-secondary);
  border: 1px solid var(--color-border);
  border-radius: 9999px;
  font-size: 13px;
}

.user-name {
  font-weight: 600;
  color: var(--color-text-main);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.logout-form {
  display: inline-flex;
  margin: 0;
  padding: 0;
}

/* Right Info Column in Card Detail */
.card-sidebar-col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.info-card {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-sm);
}

.info-card-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-muted);
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.info-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  font-size: 13px;
}

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

.info-label {
  font-size: 11px;
  color: var(--color-text-muted);
}

.info-value {
  font-weight: 500;
  color: var(--color-text-main);
  word-break: break-all;
}

/* Layout for Projects, Runs, Settings, Error */
.projects-layout, .runs-layout {
  max-width: 1100px;
  margin: 0 auto;
}

.projects-header, .runs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.projects-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 24px;
  align-items: flex-start;
}

@media (max-width: 860px) {
  .projects-grid {
    grid-template-columns: 1fr;
  }
}

.projects-card, .runs-card {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.settings-layout {
  max-width: 900px;
  margin: 0 auto;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 20px;
  margin-bottom: 24px;
}

@media (max-width: 767px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

.settings-form {
  max-width: 440px;
}

.error-box {
  max-width: 600px;
  margin: 40px auto;
  text-align: center;
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 40px 24px;
  box-shadow: var(--shadow-sm);
}

.error-code {
  font-size: 48px;
  font-weight: 700;
  color: #dc2626;
  margin-bottom: 12px;
}

.error-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 12px;
}

.error-desc {
  font-size: 14px;
  color: var(--color-text-muted);
  margin-bottom: 24px;
  line-height: 1.5;
}

/* Modal Dialog */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background-color: var(--bg-modal-overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(2px);
  padding: 16px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background-color: var(--bg-modal);
  color: var(--color-text-main);
  border-radius: var(--radius-md);
  width: min(100% - 24px, 560px);
  max-height: min(90vh, 90dvh);
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--color-border);
  position: relative;
}

@media (max-width: 480px) {
  .modal-box {
    padding: 16px;
    width: 100%;
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--color-text-muted);
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.modal-close:hover {
  color: var(--color-text-main);
}

/* Responsive Table Wrapper */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}

/* Tables */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background-color: var(--bg-table);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.data-table th, .data-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.data-table th {
  background-color: var(--bg-table-th);
  font-weight: 600;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.data-table tr:hover td {
  background-color: var(--bg-table-hover);
}

.table-empty-cell {
  padding: 2rem;
  text-align: center;
}

.cell-nowrap {
  white-space: nowrap;
}

.audit-details {
  font-size: 12px;
  color: var(--color-text-muted);
  max-width: 360px;
  word-break: break-word;
}

/* Code Preview */
.code-preview {
  background-color: var(--bg-code);
  color: var(--color-code);
  padding: 16px;
  border-radius: var(--radius-sm);
  font-family: monospace;
  font-size: 12px;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 400px;
  border: 1px solid var(--color-border);
}

.settings-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  background-color: var(--bg-surface-secondary);
  color: var(--color-text-muted);
  border: 1px solid var(--color-border);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 12px;
}

.settings-card {
  background-color: var(--bg-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 24px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
}

.section-heading { font-size: 14px; font-weight: 700; margin-bottom: 10px; }
.section-subheading { font-size: 16px; font-weight: 700; margin-bottom: 12px; }
.banner-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; flex-wrap: wrap; gap: 8px; }
.meta-caption { font-size: 10px; }
.empty-text { font-size: 13px; color: var(--color-text-muted); }
.empty-box { font-size: 13px; color: var(--color-text-muted); padding: 20px; text-align: center; }

.card-heading { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 13px; }
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 12px; }
.mb-4 { margin-bottom: 16px; }
.ml-2 { margin-left: 8px; }
.ml-3 { margin-left: 12px; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.font-mono { font-family: monospace; }
.space-between-center { display: flex; justify-content: space-between; align-items: center; }

/* Utility Classes */
.text-primary { color: var(--color-primary); }
.text-warning { color: #d97706; }
.text-success { color: #059669; }
.text-danger { color: #ef4444; }
.text-quarantine { color: #dc2626; font-weight: 600; }
.text-muted { color: var(--color-text-muted); }
.text-center { text-align: center; }

.status-text-active { color: var(--color-primary); font-weight: 600; }
.status-text-waiting { color: #d97706; font-weight: 500; }
.status-text-done { color: #059669; }
