/* ============================================================================
   WorkPages Design System
   AP11 - UX Redesign
   ============================================================================
   Pure CSS, no build tools, no framework dependencies.
   Uses CSS Custom Properties for theming and dark mode.
   ============================================================================ */


/* ============================================================================
   1. DESIGN TOKENS
   ============================================================================ */

:root {
    /* --- Colors: Neutrals --- */
    --c-gray-50:   #f9fafb;
    --c-gray-100:  #f3f4f6;
    --c-gray-200:  #e5e7eb;
    --c-gray-300:  #d1d5db;
    --c-gray-400:  #9ca3af;
    --c-gray-500:  #6b7280;
    --c-gray-600:  #4b5563;
    --c-gray-700:  #374151;
    --c-gray-800:  #1f2937;
    --c-gray-900:  #111827;
    --c-gray-950:  #030712;

    /* --- Colors: Primary (Blue) --- */
    --c-blue-50:   #eff6ff;
    --c-blue-100:  #dbeafe;
    --c-blue-200:  #bfdbfe;
    --c-blue-500:  #3b82f6;
    --c-blue-600:  #2563eb;
    --c-blue-700:  #1d4ed8;

    /* --- Colors: Semantic --- */
    --c-red-50:    #fef2f2;
    --c-red-500:   #ef4444;
    --c-red-600:   #dc2626;
    --c-red-700:   #b91c1c;
    --c-green-50:  #ecfdf5;
    --c-green-500: #22c55e;
    --c-green-600: #16a34a;
    --c-green-700: #15803d;
    --c-amber-50:  #fffbeb;
    --c-amber-500: #f59e0b;
    --c-amber-600: #d97706;
    --c-amber-700: #b45309;
    --c-violet-50: #f5f3ff;
    --c-violet-500:#8b5cf6;
    --c-violet-600:#7c3aed;
    --c-violet-700:#6d28d9;

    /* --- Semantic Mapping (Light Mode) --- */
    --color-bg:              var(--c-gray-50);
    --color-bg-sunken:       var(--c-gray-100);
    --color-surface:         #ffffff;
    --color-surface-hover:   var(--c-gray-50);
    --color-surface-active:  var(--c-gray-100);
    --color-sidebar:         var(--c-gray-900);
    --color-sidebar-hover:   var(--c-gray-800);
    --color-sidebar-active:  rgba(255, 255, 255, 0.12);
    --color-header:          #ffffff;
    --color-primary:         var(--wp-color-primary, var(--c-blue-600));
    --color-primary-hover:   var(--wp-color-accent, var(--c-blue-700));
    --color-primary-subtle:  var(--c-blue-50);
    --color-text:            var(--c-gray-900);
    --color-text-secondary:  var(--c-gray-500);
    --color-text-tertiary:   var(--c-gray-400);
    --color-text-inverse:    #ffffff;
    --color-border:          var(--c-gray-200);
    --color-border-strong:   var(--c-gray-300);
    --color-focus-ring:      rgba(37, 99, 235, 0.25);
    --color-error:           var(--c-red-600);
    --color-error-bg:        var(--c-red-50);
    --color-success:         var(--c-green-700);
    --color-success-bg:      var(--c-green-50);
    --color-warning:         var(--c-amber-700);
    --color-warning-bg:      var(--c-amber-50);
    --color-info:            var(--c-blue-600);
    --color-info-bg:         var(--c-blue-50);

    /* --- Typography --- */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
                 Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: "SF Mono", SFMono-Regular, ui-monospace, "Cascadia Mono",
                 "Segoe UI Mono", Menlo, Consolas, "Liberation Mono", monospace;
    --text-xs:   0.6875rem;
    --text-sm:   0.8125rem;
    --text-base: 0.875rem;
    --text-lg:   1rem;
    --text-xl:   1.25rem;
    --text-2xl:  1.5rem;
    --text-3xl:  1.875rem;
    --leading-tight:   1.25;
    --leading-normal:  1.5;
    --leading-relaxed: 1.7;
    --tracking-tight: -0.025em;
    --tracking-normal: 0;

    /* --- Spacing --- */
    --sp-0:  0;
    --sp-1:  0.25rem;
    --sp-2:  0.5rem;
    --sp-3:  0.75rem;
    --sp-4:  1rem;
    --sp-5:  1.25rem;
    --sp-6:  1.5rem;
    --sp-8:  2rem;
    --sp-10: 2.5rem;
    --sp-12: 3rem;

    /* --- Layout --- */
    --sidebar-width: 240px;
    --header-height: 52px;
    --content-max-width: 960px;

    /* --- Radius --- */
    --radius-sm:   4px;
    --radius-md:   6px;
    --radius-lg:   8px;
    --radius-xl:   12px;
    --radius-full: 9999px;

    /* --- Shadows --- */
    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.03);
    --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.04), 0 4px 6px rgba(0, 0, 0, 0.02);
    --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.05), 0 8px 10px rgba(0, 0, 0, 0.02);

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

    /* --- Touch / Mobile --- */
    --touch-target-min: 44px;
}


/* ============================================================================
   2. DARK MODE TOKENS
   ============================================================================ */

[data-theme="dark"] {
    --color-bg:              #0c0e14;
    --color-bg-sunken:       #080a0f;
    --color-surface:         #151821;
    --color-surface-hover:   #1c1f2a;
    --color-surface-active:  #232633;
    --color-sidebar:         #0a0c12;
    --color-sidebar-hover:   #151821;
    --color-sidebar-active:  rgba(255, 255, 255, 0.1);
    --color-header:          #151821;
    --color-primary:         var(--wp-color-primary, var(--c-blue-500));
    --color-primary-hover:   var(--wp-color-accent, var(--c-blue-600));
    --color-primary-subtle:  rgba(59, 130, 246, 0.12);
    --color-text:            var(--c-gray-200);
    --color-text-secondary:  var(--c-gray-400);
    --color-text-tertiary:   var(--c-gray-500);
    --color-text-inverse:    #ffffff;
    --color-border:          #232633;
    --color-border-strong:   #2d3039;
    --color-focus-ring:      rgba(59, 130, 246, 0.3);
    --color-error:           var(--c-red-500);
    --color-error-bg:        rgba(239, 68, 68, 0.1);
    --color-success:         var(--c-green-500);
    --color-success-bg:      rgba(34, 197, 94, 0.1);
    --color-warning:         var(--c-amber-500);
    --color-warning-bg:      rgba(245, 158, 11, 0.1);
    --color-info:            var(--c-blue-500);
    --color-info-bg:         rgba(59, 130, 246, 0.1);

    --shadow-xs:  0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-sm:  0 1px 3px rgba(0, 0, 0, 0.25), 0 1px 2px rgba(0, 0, 0, 0.15);
    --shadow-md:  0 4px 6px rgba(0, 0, 0, 0.2), 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-lg:  0 10px 15px rgba(0, 0, 0, 0.25), 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-xl:  0 20px 25px rgba(0, 0, 0, 0.3), 0 8px 10px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .status-backlog {
    background: rgba(107, 114, 128, 0.15);
    color: var(--c-gray-400);
}
[data-theme="dark"] .status-ready {
    background: rgba(37, 99, 235, 0.15);
    color: var(--c-blue-200);
}
[data-theme="dark"] .status-doing {
    background: rgba(217, 119, 6, 0.15);
    color: #fbbf24;
}
[data-theme="dark"] .status-review {
    background: rgba(109, 40, 217, 0.15);
    color: #c4b5fd;
}
[data-theme="dark"] .status-active {
    background: rgba(37, 99, 235, 0.15);
    color: var(--c-blue-200, #bfdbfe);
}
[data-theme="dark"] .status-done {
    background: rgba(22, 163, 74, 0.15);
    color: #86efac;
}

[data-theme="dark"] .role-admin {
    background: rgba(109, 40, 217, 0.15);
    color: #c4b5fd;
}
[data-theme="dark"] .role-member {
    background: rgba(37, 99, 235, 0.15);
    color: var(--c-blue-200);
}
[data-theme="dark"] .role-viewer {
    background: rgba(107, 114, 128, 0.15);
    color: var(--c-gray-400);
}

[data-theme="dark"] .tag-chip {
    background: rgba(99, 102, 241, 0.12);
    color: var(--c-gray-300);
}

[data-theme="dark"] .search-type-page {
    background: rgba(37, 99, 235, 0.15);
    color: var(--c-blue-200);
}
[data-theme="dark"] .search-type-task {
    background: rgba(217, 119, 6, 0.15);
    color: #fbbf24;
}

[data-theme="dark"] .search-result-snippet mark {
    background: rgba(251, 191, 36, 0.2);
    color: var(--c-gray-200);
}

[data-theme="dark"] .md-content pre {
    background: #080a0f;
    border: 1px solid var(--color-border);
}

[data-theme="dark"] .md-content code {
    background: var(--color-bg-sunken);
}

[data-theme="dark"] .kanban-card-owner {
    background: var(--c-blue-700);
}

/* --- EasyMDE Dark Mode --- */
[data-theme="dark"] .EasyMDEContainer .CodeMirror {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror-cursor {
    border-left-color: var(--color-text);
}
[data-theme="dark"] .EasyMDEContainer .editor-toolbar {
    background: var(--color-surface);
    border-color: var(--color-border);
}
[data-theme="dark"] .EasyMDEContainer .editor-toolbar button {
    color: var(--color-text-secondary);
}
[data-theme="dark"] .EasyMDEContainer .editor-toolbar button:hover,
[data-theme="dark"] .EasyMDEContainer .editor-toolbar button.active {
    background: var(--color-surface-hover);
    color: var(--color-text);
}
[data-theme="dark"] .EasyMDEContainer .editor-toolbar i.separator {
    border-left-color: var(--color-border);
    border-right-color: var(--color-border);
}
[data-theme="dark"] .EasyMDEContainer .editor-preview {
    background: var(--color-surface);
    color: var(--color-text);
}
[data-theme="dark"] .EasyMDEContainer .editor-preview-side {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .CodeMirror-selected {
    background: rgba(59, 130, 246, 0.3);
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-header {
    color: var(--color-text);
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-link {
    color: var(--c-blue-500);
}
[data-theme="dark"] .EasyMDEContainer .CodeMirror .cm-url {
    color: var(--color-text-secondary);
}


/* ============================================================================
   3. RESET & BASE
   ============================================================================ */

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

html {
    font-size: 16px;
    line-height: var(--leading-normal);
    -webkit-text-size-adjust: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

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

img {
    max-width: 100%;
    height: auto;
    display: block;
}

::selection {
    background: var(--color-primary);
    color: #ffffff;
}

/* Focus ring */
:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}


/* ============================================================================
   4. LAYOUT
   ============================================================================ */

/* --- 4.1 Header --- */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--color-header);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    padding: 0 var(--sp-4);
    z-index: 100;
}

.header-left {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-right: var(--sp-4);
}

.app-logo {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--color-text);
    letter-spacing: var(--tracking-tight);
}
.app-logo:hover {
    text-decoration: none;
    color: var(--color-primary);
}

.header-center {
    flex: 1 1 auto;
    max-width: 480px;
}

.search-form {
    width: 100%;
}

.search-input {
    width: 100%;
    padding: 6px var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    transition: border-color var(--transition-normal), background var(--transition-normal),
                box-shadow var(--transition-normal);
}
.search-input::placeholder {
    color: var(--color-text-tertiary);
}
.search-input:focus {
    outline: none;
    border-color: var(--color-primary);
    background: var(--color-surface);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}

.header-right {
    flex: 0 0 auto;
    margin-left: auto;
    padding-left: var(--sp-4);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.user-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--text-xs);
    font-weight: 600;
    padding: 3px var(--sp-3);
    border-radius: var(--radius-full);
    letter-spacing: 0.01em;
}

.user-role-label {
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 500;
}

.logout-link {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    padding: var(--sp-1) var(--sp-2);
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast);
}
.logout-link:hover {
    color: var(--color-error);
    background: var(--color-error-bg);
    text-decoration: none;
}

/* Theme toggle */
.theme-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: color var(--transition-fast), background var(--transition-fast),
                border-color var(--transition-fast);
}
.theme-toggle:hover {
    color: var(--color-text);
    background: var(--color-surface-hover);
    border-color: var(--color-border-strong);
}
.theme-toggle svg {
    width: 16px;
    height: 16px;
}
.theme-toggle .icon-moon { display: none; }
[data-theme="dark"] .theme-toggle .icon-sun { display: none; }
[data-theme="dark"] .theme-toggle .icon-moon { display: block; }

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.mobile-menu-btn:hover {
    background: var(--color-surface-hover);
}
.mobile-menu-btn svg {
    width: 20px;
    height: 20px;
}

/* Mobile search button */
.mobile-search-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.mobile-search-btn:hover {
    background: var(--color-surface-hover);
}
.mobile-search-btn svg {
    width: 18px;
    height: 18px;
}

/* --- 4.2 Sidebar --- */
.app-body {
    display: flex;
    padding-top: var(--header-height);
    min-height: 100vh;
}

.sidebar {
    position: fixed;
    top: var(--header-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-sidebar);
    color: var(--color-text-inverse);
    display: flex;
    flex-direction: column;
    padding: var(--sp-3) 0;
    overflow-y: auto;
    z-index: 90;
    transition: transform var(--transition-slow);
}

.nav-list {
    list-style: none;
    padding: 0 var(--sp-2);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 7px var(--sp-3);
    color: rgba(255, 255, 255, 0.6);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background var(--transition-fast), color var(--transition-fast);
    margin-bottom: 1px;
    border-left: 2px solid transparent;
}
.nav-link:hover {
    background: var(--color-sidebar-hover);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}
.nav-link.active {
    background: var(--color-sidebar-active);
    color: #ffffff;
    border-left-color: var(--color-primary);
}

.nav-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.nav-icon svg {
    width: 18px;
    height: 18px;
    stroke-width: 1.75;
}

.nav-separator {
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin: var(--sp-2) var(--sp-3);
}

.sidebar-footer {
    margin-top: auto;
    padding: var(--sp-4) var(--sp-4) var(--sp-3);
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-label {
    display: block;
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: rgba(255, 255, 255, 0.35);
    margin-bottom: var(--sp-1);
    font-weight: 500;
}

.workspace-name {
    font-size: var(--text-sm);
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8);
}

/* Sidebar page tree */
.sidebar-pages {
    padding: var(--sp-3) var(--sp-3) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: var(--sp-3);
}

.sidebar-pages .sidebar-label {
    padding: 0 var(--sp-1);
    margin-bottom: var(--sp-2);
}

.page-tree {
    list-style: none;
    padding: 0;
    margin: 0;
}

.page-tree-link {
    display: block;
    padding: 3px 8px;
    color: rgba(255, 255, 255, 0.55);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}
.page-tree-link:hover {
    background: var(--color-sidebar-hover);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}
.page-tree-active {
    background: var(--color-sidebar-active);
    color: #ffffff;
}

/* --- 4.3 Main Content --- */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    padding: var(--sp-8) var(--sp-10);
    max-width: var(--content-max-width);
    min-width: 0;
}

.main-content-wide {
    max-width: none;
}


/* ============================================================================
   5. COMPONENTS
   ============================================================================ */

/* --- 5.1 Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--sp-2);
    padding: 8px var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-sans);
    line-height: var(--leading-tight);
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast), box-shadow var(--transition-fast),
                transform 60ms ease;
    text-decoration: none;
    white-space: nowrap;
    user-select: none;
}
.btn:hover {
    text-decoration: none;
}
.btn:active {
    transform: scale(0.98);
}
.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

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

.btn-secondary {
    background: var(--color-surface);
    color: var(--color-text);
    border-color: var(--color-border);
}
.btn-secondary:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-strong);
    color: var(--color-text);
}

.btn-danger {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: transparent;
}
.btn-danger:hover {
    background: var(--color-error);
    color: var(--color-text-inverse);
}

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

.btn-sm {
    display: inline-flex;
    align-items: center;
    padding: 3px var(--sp-2);
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-primary);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    text-decoration: none;
    cursor: pointer;
    border: none;
    background: transparent;
    font-family: var(--font-sans);
}
.btn-sm:hover {
    background: var(--color-primary-subtle);
    text-decoration: none;
}

.btn-sm-pad {
    padding: 6px var(--sp-3);
    font-size: var(--text-sm);
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-remove {
    color: var(--color-error);
}
.btn-remove:hover {
    background: var(--color-error-bg);
}


/* --- 5.2 Forms --- */
.form-group {
    margin-bottom: var(--sp-4);
}

.form-group label {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: var(--sp-1);
    color: var(--color-text);
}

.form-input {
    width: 100%;
    padding: 8px var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-family: var(--font-sans);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition-normal), box-shadow var(--transition-normal);
    line-height: var(--leading-normal);
}
.form-input::placeholder {
    color: var(--color-text-tertiary);
}
.form-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-focus-ring);
}
.form-input:disabled {
    background: var(--color-bg-sunken);
    color: var(--color-text-tertiary);
    cursor: not-allowed;
}

.form-input-sm {
    padding: 5px var(--sp-2);
    font-size: var(--text-sm);
}

select.form-input {
    cursor: pointer;
}

.form-textarea {
    resize: vertical;
    min-height: 200px;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
}

.form-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-5);
}

.form-row {
    display: flex;
    gap: var(--sp-4);
    margin-bottom: 0;
}

.form-group-half {
    flex: 1;
    min-width: 0;
}

.form-hint {
    display: block;
    margin-top: var(--sp-1);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.required {
    color: var(--color-error);
}

.inline-form {
    display: inline;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    cursor: pointer;
    font-size: var(--text-base);
}
.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--color-primary);
}


/* --- 5.3 Cards --- */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: var(--sp-4);
    margin-bottom: var(--sp-8);
}

.card {
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    transition: box-shadow var(--transition-normal), border-color var(--transition-normal),
                transform var(--transition-normal);
    color: var(--color-text);
}
.card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-strong);
    text-decoration: none;
    transform: translateY(-1px);
}

.card-icon {
    font-size: 1.5rem;
    margin-bottom: var(--sp-3);
    color: var(--color-primary);
    line-height: 1;
}

.card-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-1);
    letter-spacing: var(--tracking-tight);
}

.card-desc {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-normal);
}

.section-block {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-5);
    margin-bottom: var(--sp-5);
}

.section-block h2 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-3);
    letter-spacing: var(--tracking-tight);
}

.section-block h3 {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--sp-3);
}


/* --- 5.4 Tables --- */
.pages-table-wrap {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pages-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.pages-table thead {
    background: var(--color-bg-sunken);
}

.pages-table th {
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
    font-weight: 600;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--color-border);
}

.pages-table td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

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

.pages-table tbody tr {
    transition: background var(--transition-fast);
}
.pages-table tbody tr:hover {
    background: var(--color-surface-hover);
}


/* --- 5.5 Badges --- */
.status-badge {
    display: inline-block;
    padding: 2px 10px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    line-height: 1.5;
}

.status-backlog {
    background: var(--c-gray-100);
    color: var(--c-gray-500);
}
.status-ready {
    background: var(--c-blue-100);
    color: var(--c-blue-700);
}
.status-doing {
    background: var(--c-amber-50);
    color: var(--c-amber-700);
}
.status-review {
    background: var(--c-violet-50);
    color: var(--c-violet-700);
}
.status-active {
    background: var(--c-blue-50, #eff6ff);
    color: var(--c-blue-700, #1d4ed8);
}
.status-done {
    background: var(--c-green-50);
    color: var(--c-green-700);
}

.role-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.role-admin {
    background: var(--c-violet-50);
    color: var(--c-violet-700);
}
.role-member {
    background: var(--c-blue-50);
    color: var(--c-blue-700);
}
.role-viewer {
    background: var(--c-gray-100);
    color: var(--c-gray-600);
}

.tag-chip {
    display: inline-block;
    padding: 1px 8px;
    font-size: var(--text-xs);
    font-weight: 500;
    background: var(--c-gray-100);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    margin: 1px 2px;
    white-space: nowrap;
    line-height: 1.5;
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}


/* --- 5.6 Alerts --- */
.alert {
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--sp-4);
    border: 1px solid transparent;
    line-height: var(--leading-normal);
}

.alert-error {
    background: var(--color-error-bg);
    color: var(--color-error);
    border-color: rgba(220, 38, 38, 0.15);
}

.alert-success {
    background: var(--color-success-bg);
    color: var(--color-success);
    border-color: rgba(22, 163, 74, 0.15);
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-info);
    border-color: rgba(37, 99, 235, 0.15);
}


/* --- 5.7 Breadcrumbs --- */
.breadcrumb {
    margin-bottom: var(--sp-3);
}

.breadcrumb-list {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--text-sm);
}

.breadcrumb-item {
    display: flex;
    align-items: center;
}

.breadcrumb-item + .breadcrumb-item::before {
    content: "/";
    color: var(--color-text-tertiary);
    margin-right: var(--sp-1);
    font-size: var(--text-xs);
}

.breadcrumb-item a {
    color: var(--color-text-secondary);
    transition: color var(--transition-fast);
}
.breadcrumb-item a:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.breadcrumb-current span {
    color: var(--color-text);
    font-weight: 500;
}


/* --- 5.8 Empty States --- */
.placeholder-text {
    color: var(--color-text-secondary);
    font-size: var(--text-sm);
    font-style: italic;
}

.empty-state {
    text-align: center;
    padding: var(--sp-10) var(--sp-4);
    color: var(--color-text-secondary);
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: var(--sp-3);
    opacity: 0.4;
}

.empty-state-text {
    font-size: var(--text-sm);
    max-width: 320px;
    margin: 0 auto;
    line-height: var(--leading-relaxed);
}


/* ============================================================================
   6. FEATURE VIEWS
   ============================================================================ */

/* --- 6.1 Page Headers --- */
.page-header {
    margin-bottom: var(--sp-6);
}

.page-header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--sp-1);
    line-height: var(--leading-tight);
}

.subtitle {
    font-size: var(--text-base);
    color: var(--color-text-secondary);
    font-weight: 400;
}

.page-header-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--sp-4);
}

.page-actions {
    display: flex;
    gap: var(--sp-2);
    align-items: center;
    flex-shrink: 0;
}

/* Responsive button icon/label pattern */
.btn-icon {
    display: none;
    width: 16px;
    height: 16px;
    vertical-align: middle;
    flex-shrink: 0;
}
.btn-responsive {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
}

.page-link {
    font-weight: 500;
    color: var(--color-text);
    transition: color var(--transition-fast);
}
.page-link:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.text-muted {
    color: var(--color-text-secondary);
}

.text-overdue {
    color: var(--color-error);
    font-weight: 600;
}


/* --- 6.2 Login --- */
.login-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    min-height: 100vh;
    background: var(--color-bg);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: var(--sp-4);
    margin: auto 0;
}

.login-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-xl);
    padding: var(--sp-10) var(--sp-8);
    box-shadow: var(--shadow-lg);
    text-align: center;
    position: relative;
    overflow: hidden;
}
.login-card::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--color-primary), var(--c-violet-500));
}

.login-title {
    font-size: var(--text-xl);
    font-weight: 700;
    margin-bottom: var(--sp-1);
    letter-spacing: var(--tracking-tight);
}

.login-subtitle {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-8);
}

.login-form {
    text-align: left;
}

.login-footer-note {
    margin-top: var(--sp-5);
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
}


/* --- 6.3 Error Pages --- */
.error-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--color-bg);
}

.error-container {
    text-align: center;
    padding: var(--sp-8);
}

.error-code {
    font-size: 4.5rem;
    font-weight: 800;
    color: var(--color-text-tertiary);
    margin-bottom: var(--sp-2);
    letter-spacing: var(--tracking-tight);
    line-height: 1;
}

.error-message {
    font-size: var(--text-lg);
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-6);
}


/* --- 6.4 Page Content / Markdown --- */
.page-content {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-6);
    margin-bottom: var(--sp-5);
}

.md-content h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    margin: var(--sp-6) 0 var(--sp-3);
    letter-spacing: var(--tracking-tight);
    line-height: var(--leading-tight);
}
.md-content h1:first-child {
    margin-top: 0;
}

.md-content h2 {
    font-size: var(--text-xl);
    font-weight: 600;
    margin: var(--sp-6) 0 var(--sp-2);
    letter-spacing: var(--tracking-tight);
}

.md-content h3 {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: var(--sp-4) 0 var(--sp-2);
}

.md-content h4,
.md-content h5,
.md-content h6 {
    font-size: var(--text-base);
    font-weight: 600;
    margin: var(--sp-4) 0 var(--sp-2);
}

.md-content p {
    margin-bottom: var(--sp-4);
    line-height: var(--leading-relaxed);
}

.md-content ul,
.md-content ol {
    margin: 0 0 var(--sp-4) var(--sp-6);
    line-height: var(--leading-relaxed);
}

.md-content li {
    margin-bottom: var(--sp-1);
}

.md-content code {
    background: var(--color-bg-sunken);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    font-family: var(--font-mono);
}

.md-content pre {
    background: var(--c-gray-900);
    color: #e5e7eb;
    padding: var(--sp-4);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    margin-bottom: var(--sp-4);
    line-height: 1.6;
}
.md-content pre code {
    background: none;
    padding: 0;
    color: inherit;
    font-size: var(--text-sm);
}

.md-content blockquote {
    border-left: 3px solid var(--color-primary);
    padding: var(--sp-2) var(--sp-4);
    margin: 0 0 var(--sp-4);
    background: var(--color-primary-subtle);
    color: var(--color-text-secondary);
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
}
.md-content blockquote p {
    margin-bottom: 0;
}

.md-content hr {
    border: none;
    border-top: 1px solid var(--color-border);
    margin: var(--sp-6) 0;
}

.md-content a {
    color: var(--color-primary);
    text-decoration: underline;
    text-underline-offset: 2px;
}
.md-content a:hover {
    color: var(--color-primary-hover);
}

.md-content strong {
    font-weight: 600;
}

.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: var(--sp-4);
    font-size: var(--text-sm);
}
.md-content table th,
.md-content table td {
    border: 1px solid var(--color-border);
    padding: var(--sp-2) var(--sp-3);
    text-align: left;
}
.md-content table th {
    background: var(--color-bg-sunken);
    font-weight: 600;
}

/* --- GitHub Markdown CSS Integration --- */
.markdown-body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--color-text);
    background: transparent;
    line-height: var(--leading-relaxed);
}
.markdown-body pre {
    background: var(--c-gray-900);
    color: #e5e7eb;
}
.markdown-body blockquote {
    border-left-color: var(--color-primary);
}
.comment-body.markdown-body {
    font-size: var(--text-sm);
}
.comment-body.markdown-body p:last-child {
    margin-bottom: 0;
}
[data-theme="dark"] .markdown-body {
    color-scheme: dark;
    color: var(--color-text);
}
[data-theme="dark"] .markdown-body pre {
    background: #080a0f;
    border: 1px solid var(--color-border);
}
[data-theme="dark"] .markdown-body code {
    background: var(--color-bg-sunken);
}
[data-theme="dark"] .markdown-body table th,
[data-theme="dark"] .markdown-body table td {
    border-color: var(--color-border);
}
[data-theme="dark"] .markdown-body table th {
    background: var(--color-bg-sunken);
}
[data-theme="dark"] .markdown-body blockquote {
    color: var(--color-text-secondary);
}
[data-theme="dark"] .markdown-body hr {
    border-color: var(--color-border);
}

.page-meta {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    padding-top: var(--sp-3);
}


/* --- 6.5 Tasks --- */
.task-filters {
    margin-bottom: var(--sp-5);
}

.filter-form {
    width: 100%;
}

.filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 120px;
}

.filter-group label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filter-actions {
    flex-direction: row;
    align-items: center;
    gap: var(--sp-2);
    padding-bottom: 1px;
}

/* Task detail layout */
.task-detail-grid {
    display: grid;
    grid-template-columns: 260px 1fr;
    gap: var(--sp-5);
    margin-bottom: var(--sp-5);
}

.task-meta-card {
    margin-bottom: 0;
}

.task-meta-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
}

.task-meta-list dt {
    font-weight: 600;
    color: var(--color-text-secondary);
    white-space: nowrap;
}

.task-meta-list dd {
    margin: 0;
}

.task-description .page-content {
    margin-bottom: 0;
}

/* Tasks table tweaks */
.tasks-table td:nth-child(2),
.tasks-table td:nth-child(4) {
    white-space: nowrap;
}


/* --- 6.6 Page-Task Relations (AP5) --- */
.page-tasks-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}
.page-tasks-header h2 {
    margin-bottom: 0;
}

.reorder-cell {
    white-space: nowrap;
    text-align: center;
}

.btn-reorder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 20px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text-secondary);
    font-size: 10px;
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
                border-color var(--transition-fast);
    line-height: 1;
}
.btn-reorder:hover {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    border-color: var(--color-primary);
}

.status-select {
    display: inline-block;
    width: auto;
    min-width: 100px;
    padding: 2px 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    border: 1px solid var(--color-border);
    cursor: pointer;
    appearance: auto;
    background-color: var(--color-surface);
    font-family: var(--font-sans);
}

.status-select.status-backlog { background: var(--c-gray-100); color: var(--c-gray-500); }
.status-select.status-ready   { background: var(--c-blue-100); color: var(--c-blue-700); }
.status-select.status-doing   { background: var(--c-amber-50); color: var(--c-amber-700); }
.status-select.status-review  { background: var(--c-violet-50); color: var(--c-violet-700); }
.status-select.status-done    { background: var(--c-green-50); color: var(--c-green-700); }

.status-change-form {
    display: inline;
}

.linked-pages-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.linked-pages-list li {
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--color-border);
}
.linked-pages-list li:last-child {
    border-bottom: none;
}
.linked-pages-list .page-link {
    font-size: var(--text-sm);
}

.task-search-form {
    margin-bottom: var(--sp-3);
}

.page-tasks-table td {
    vertical-align: middle;
}


/* --- 6.7 Kanban Board (AP6) --- */
.board-header {
    margin-bottom: var(--sp-5);
}

.board-header h1 {
    font-size: var(--text-2xl);
    font-weight: 700;
    letter-spacing: var(--tracking-tight);
    margin-bottom: var(--sp-3);
}

.board-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--sp-3);
}

.board-filter-form {
    margin-bottom: var(--sp-2);
}
.board-filter-form .filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    align-items: flex-end;
}
.board-filter-form .filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 120px;
}
.board-filter-form .filter-group label {
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.kanban-board {
    display: flex;
    gap: var(--sp-3);
    overflow-x: auto;
    padding-bottom: var(--sp-4);
    min-height: 400px;
    align-items: flex-start;
}

.kanban-column {
    flex: 0 0 264px;
    min-width: 264px;
    max-width: 264px;
    background: var(--color-bg-sunken);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 220px);
    border: 1px solid var(--color-border);
}

.kanban-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--color-border);
    flex-shrink: 0;
}

.kanban-column-title {
    font-size: var(--text-xs);
}

.kanban-column-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.kanban-column-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--sp-2);
    min-height: 60px;
}

.kanban-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    margin-bottom: var(--sp-2);
    cursor: grab;
    transition: box-shadow var(--transition-fast), border-color var(--transition-fast),
                opacity var(--transition-normal);
    position: relative;
}
.kanban-card:hover {
    box-shadow: var(--shadow-sm);
    border-color: var(--color-border-strong);
}
.kanban-card:active {
    cursor: grabbing;
}

.kanban-card-dragging {
    opacity: 0.3;
}

.kanban-placeholder {
    background: var(--color-primary-subtle);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius-md);
    min-height: 48px;
    margin-bottom: var(--sp-2);
    cursor: default;
    padding: 0;
}

/* AP21: Quick Add in Board Columns */
.kanban-quick-add {
    padding: var(--sp-2) var(--sp-2) 0;
}
.kanban-quick-add-form {
    display: flex;
}
.kanban-quick-add-input {
    width: 100%;
    padding: var(--sp-2);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    background: transparent;
    font-size: var(--text-sm);
    color: var(--color-text);
    outline: none;
    transition: border-color 0.15s ease;
}
.kanban-quick-add-input::placeholder {
    color: var(--color-text-muted);
}
.kanban-quick-add-input:focus {
    border-color: var(--color-primary);
    border-style: solid;
    background: var(--color-surface);
}

/* AP21: Done card styling */
.kanban-card-done {
    opacity: 0.7;
}
.kanban-card-done .kanban-card-title {
    text-decoration: line-through;
    color: var(--color-text-muted);
}

.kanban-card-title {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: var(--sp-1);
    line-height: var(--leading-tight);
    word-wrap: break-word;
}
.kanban-card-title:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.kanban-card-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.kanban-card-owner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--color-primary);
    color: var(--color-text-inverse);
    border-radius: 50%;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.kanban-card-due {
    font-size: var(--text-xs);
}

.kanban-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
    margin-bottom: var(--sp-1);
}
.kanban-card-tags .tag-chip {
    font-size: 10px;
    padding: 1px 6px;
}

.kanban-card-actions {
    margin-top: var(--sp-1);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--color-border);
}
.kanban-card-actions .status-select {
    width: 100%;
    font-size: var(--text-xs);
    padding: 2px 6px;
}

.kanban-board-page .main-content {
    max-width: none;
}

/* Mobile Kanban Tabs (AP12) */
.kanban-tabs {
    display: none;
}

.kanban-tab {
    flex: 0 0 auto;
    padding: var(--sp-2) var(--sp-3);
    border: none;
    background: none;
    font-size: var(--text-sm);
    font-weight: 600;
    font-family: var(--font-sans);
    color: var(--color-text-secondary);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    white-space: nowrap;
    transition: color var(--transition-fast), border-color var(--transition-fast);
    min-height: var(--touch-target-min);
}
.kanban-tab:hover {
    color: var(--color-text);
}
.kanban-tab.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.kanban-tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    font-size: 10px;
    font-weight: 600;
    margin-left: var(--sp-1);
}
.kanban-tab.active .kanban-tab-count {
    background: var(--color-primary-subtle);
    color: var(--color-primary);
}


/* --- 6.8 Search (AP7) --- */
.search-page-form {
    margin-bottom: var(--sp-5);
}

.search-result-summary {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-5);
}

.search-section {
    margin-bottom: var(--sp-8);
}

.search-section-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    letter-spacing: var(--tracking-tight);
}

.search-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.search-results {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.search-result-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-4) var(--sp-5);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
.search-result-card:hover {
    border-color: var(--color-border-strong);
    box-shadow: var(--shadow-xs);
}

.search-result-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-1);
    flex-wrap: wrap;
}

.search-type-badge {
    display: inline-block;
    padding: 1px 8px;
    font-size: var(--text-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

.search-type-page {
    background: var(--c-blue-100);
    color: var(--c-blue-700);
}
.search-type-task {
    background: var(--c-amber-50);
    color: var(--c-amber-700);
}

.search-result-title {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text);
}
.search-result-title:hover {
    color: var(--color-primary);
    text-decoration: none;
}

.search-result-breadcrumb {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    margin-bottom: var(--sp-1);
}

.search-result-snippet {
    font-size: var(--text-sm);
    color: var(--color-text-secondary);
    line-height: var(--leading-normal);
    margin-bottom: var(--sp-2);
}

.search-result-snippet mark {
    background: #fef08a;
    color: var(--color-text);
    padding: 1px 3px;
    border-radius: 2px;
}

.search-result-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.search-meta-item {
    white-space: nowrap;
}

.search-meta-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 3px;
}


/* --- 6.9 Comments (AP8) --- */
.comments-section {
    margin-bottom: var(--sp-5);
}

.comments-list {
    margin-bottom: var(--sp-5);
}

.comment-item {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
}
.comment-item:last-child {
    border-bottom: none;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    margin-bottom: var(--sp-2);
    font-size: var(--text-sm);
}

.comment-author {
    font-weight: 600;
    color: var(--color-text);
}

.comment-date {
    color: var(--color-text-tertiary);
    font-size: var(--text-xs);
}

.comment-delete-form {
    margin-left: auto;
}

.btn-comment-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-tertiary);
    font-size: var(--text-lg);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast);
    line-height: 1;
}
.btn-comment-delete:hover {
    background: var(--color-error-bg);
    color: var(--color-error);
}

.comment-body {
    font-size: var(--text-sm);
    line-height: 1.6;
}
.comment-body p {
    margin-bottom: var(--sp-2);
}
.comment-body p:last-child {
    margin-bottom: 0;
}

.comment-form {
    border-top: 1px solid var(--color-border);
    padding-top: var(--sp-4);
}

.comment-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    line-height: 1.6;
}


/* --- 6.10 Activity (AP8) --- */
.activity-section {
    margin-bottom: var(--sp-5);
}

.activity-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.activity-item {
    display: flex;
    gap: var(--sp-3);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--color-border);
    font-size: var(--text-sm);
    align-items: baseline;
}
.activity-item:last-child {
    border-bottom: none;
}

.activity-time {
    flex-shrink: 0;
    color: var(--color-text-tertiary);
    font-size: var(--text-xs);
    min-width: 110px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.activity-text {
    color: var(--color-text);
    line-height: 1.4;
}


/* --- 6.11 Share (AP9) --- */
.share-section {
    margin-top: var(--sp-5);
}

.share-link-box {
    margin-bottom: var(--sp-2);
}
.share-link-box .form-input {
    font-family: var(--font-mono);
    font-size: var(--text-sm);
    cursor: pointer;
    background: var(--color-bg-sunken);
}

.share-create-form .filter-row {
    align-items: flex-end;
}


/* ============================================================================
   7. UTILITIES
   ============================================================================ */

.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;
}

.truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}


/* ============================================================================
   8. RESPONSIVE - AP12 Mobile-First Optimization
   ============================================================================ */

/* --- Body scroll lock when sidebar is open on mobile --- */
body.sidebar-open {
    overflow: hidden;
}

/* --- 8.1 Tablet (max-width: 1024px) --- */
@media (max-width: 1024px) {
    .main-content {
        padding: var(--sp-6) var(--sp-6);
    }

    .kanban-column {
        flex: 0 0 240px;
        min-width: 240px;
        max-width: 240px;
    }

    .task-detail-grid {
        grid-template-columns: 220px 1fr;
    }
}

/* --- 8.2 Mobile (max-width: 768px) --- */
@media (max-width: 768px) {

    /* -- Header -- */
    .mobile-menu-btn {
        display: flex;
        width: var(--touch-target-min);
        height: var(--touch-target-min);
    }

    .mobile-search-btn {
        display: inline-flex;
        width: var(--touch-target-min);
        height: var(--touch-target-min);
    }

    .header-center {
        display: none;
    }

    .app-header.search-active .header-center {
        display: block;
        position: absolute;
        top: var(--header-height);
        left: 0;
        right: 0;
        padding: var(--sp-2) var(--sp-4);
        background: var(--color-header);
        border-bottom: 1px solid var(--color-border);
        max-width: none;
        z-index: 99;
        box-shadow: var(--shadow-md);
    }

    .user-role-label {
        display: none;
    }

    .logout-link {
        font-size: var(--text-xs);
        padding: var(--sp-1);
    }

    .user-badge {
        font-size: 10px;
        padding: 2px var(--sp-2);
    }

    /* -- Sidebar -- */
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }

    .nav-link {
        padding: var(--sp-3) var(--sp-3);
        min-height: var(--touch-target-min);
        font-size: var(--text-base);
    }

    .page-tree-link {
        padding: var(--sp-2) var(--sp-2);
        min-height: 36px;
        font-size: var(--text-sm);
        display: flex;
        align-items: center;
    }

    /* -- Main Content -- */
    .main-content {
        margin-left: 0;
        padding: var(--sp-4) var(--sp-4);
    }

    /* -- Page Headers -- */
    .page-header h1 {
        font-size: var(--text-xl);
    }

    .page-header-row {
        flex-direction: column;
        gap: var(--sp-3);
    }

    .page-actions {
        display: flex;
        flex-wrap: wrap;
        gap: var(--sp-2);
        width: 100%;
    }
    .page-actions .btn {
        min-width: 0;
        min-height: var(--touch-target-min);
    }

    /* -- Responsive icon-only buttons on mobile -- */
    .btn-responsive .btn-label {
        display: none;
    }
    .btn-responsive .btn-icon {
        display: inline-block;
    }
    .btn-responsive {
        flex: 0 0 auto;
        padding: var(--sp-2);
    }

    /* -- Mobile header: hide team label, compact layout -- */
    .team-switcher-label {
        display: none;
    }
    .user-menu-name {
        display: none;
    }
    .header-right {
        gap: var(--sp-1);
        padding-left: var(--sp-2);
    }

    /* -- Dashboard Cards -- */
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--sp-3);
    }
    .card {
        padding: var(--sp-4);
    }
    .card-title {
        font-size: var(--text-base);
    }
    .card-desc {
        font-size: var(--text-xs);
    }

    /* -- Task Detail -- */
    .task-detail-grid {
        grid-template-columns: 1fr;
    }
    .task-meta-card {
        order: -1;
    }

    /* -- Filters -- */
    .filter-row {
        flex-direction: column;
    }
    .filter-group {
        min-width: 100%;
    }
    .filter-actions {
        flex-direction: row;
        width: 100%;
    }
    .filter-actions .btn {
        flex: 1;
        min-height: var(--touch-target-min);
    }

    .board-filter-form .filter-row {
        flex-direction: column;
    }
    .board-filter-form .filter-group {
        min-width: 100%;
    }

    /* -- Forms -- */
    .form-row {
        flex-direction: column;
    }

    .form-input {
        padding: var(--sp-3);
        font-size: 16px;
        min-height: var(--touch-target-min);
    }
    .form-input-sm {
        padding: var(--sp-2) var(--sp-3);
        font-size: 16px;
        min-height: var(--touch-target-min);
    }
    select.form-input {
        min-height: var(--touch-target-min);
    }
    .form-textarea {
        min-height: 150px;
        font-size: 16px;
    }

    .form-actions {
        flex-direction: column;
    }
    .form-actions .btn {
        width: 100%;
        min-height: var(--touch-target-min);
        justify-content: center;
    }

    .checkbox-label {
        min-height: var(--touch-target-min);
        padding: var(--sp-1) 0;
    }
    .checkbox-label input[type="checkbox"] {
        width: 20px;
        height: 20px;
    }

    /* -- Buttons Global Touch Targets -- */
    .btn {
        min-height: var(--touch-target-min);
        padding: var(--sp-3) var(--sp-4);
    }
    .btn-sm {
        min-height: 36px;
        padding: var(--sp-2) var(--sp-3);
        font-size: var(--text-sm);
    }
    .btn-sm-pad {
        min-height: var(--touch-target-min);
        padding: var(--sp-3) var(--sp-4);
    }

    /* -- Kanban Board: Tab-Based Mobile -- */
    .kanban-tabs {
        display: flex;
        overflow-x: auto;
        gap: 0;
        border-bottom: 2px solid var(--color-border);
        margin-bottom: var(--sp-3);
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .kanban-tabs::-webkit-scrollbar {
        display: none;
    }

    .kanban-board {
        display: block;
        overflow-x: visible;
        min-height: auto;
        padding-bottom: var(--sp-4);
    }

    .kanban-column {
        display: none;
        flex: none;
        width: 100%;
        min-width: 100%;
        max-width: 100%;
        max-height: none;
    }
    .kanban-column.active {
        display: flex;
    }

    .kanban-card {
        padding: var(--sp-4);
        margin-bottom: var(--sp-3);
        cursor: default;
    }
    .kanban-card-title {
        font-size: var(--text-base);
        margin-bottom: var(--sp-2);
        padding: var(--sp-1) 0;
    }
    .kanban-card-meta {
        margin-bottom: var(--sp-2);
        font-size: var(--text-sm);
    }
    .kanban-card-owner {
        width: 28px;
        height: 28px;
        font-size: 11px;
    }
    .kanban-card-due {
        font-size: var(--text-sm);
    }
    .kanban-card-tags {
        margin-bottom: var(--sp-2);
    }
    .kanban-card-tags .tag-chip {
        font-size: var(--text-xs);
        padding: 2px 8px;
    }
    .kanban-card-actions {
        padding-top: var(--sp-3);
    }
    .kanban-card-actions .status-select {
        min-height: 36px;
        font-size: var(--text-sm);
        padding: var(--sp-1) var(--sp-2);
    }

    /* -- Table Card Transformation (AP12) -- */
    .responsive-cards {
        border: none;
        border-radius: 0;
        background: none;
        overflow: visible;
    }
    .responsive-cards .pages-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border-width: 0;
    }
    .responsive-cards .pages-table,
    .responsive-cards .pages-table tbody {
        display: block;
    }
    .responsive-cards .pages-table tr {
        display: block;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        border-radius: var(--radius-lg);
        padding: var(--sp-3) var(--sp-4);
        margin-bottom: var(--sp-3);
    }
    .responsive-cards .pages-table tr:hover {
        background: var(--color-surface);
    }
    .responsive-cards .pages-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-1) 0;
        border-bottom: none;
    }
    .responsive-cards .pages-table td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 90px;
        flex-shrink: 0;
        font-weight: 600;
        font-size: var(--text-xs);
        color: var(--color-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-right: var(--sp-3);
    }
    .responsive-cards .pages-table td:not([data-label])::before,
    .responsive-cards .pages-table td[data-label=""]::before {
        display: none;
    }
    /* Title cell: full width, prominent, no label */
    .responsive-cards .pages-table td.card-cell-title {
        display: block;
        padding-bottom: var(--sp-2);
        margin-bottom: var(--sp-2);
        border-bottom: 1px solid var(--color-border);
    }
    .responsive-cards .pages-table td.card-cell-title::before {
        display: none;
    }
    .responsive-cards .pages-table td.card-cell-title .page-link {
        font-size: var(--text-base);
        font-weight: 600;
    }
    /* Actions cell: right-aligned */
    .responsive-cards .pages-table td.card-cell-actions {
        display: flex;
        justify-content: flex-end;
        padding-top: var(--sp-2);
        margin-top: var(--sp-1);
        border-top: 1px solid var(--color-border);
    }
    .responsive-cards .pages-table td.card-cell-actions::before {
        display: none;
    }
    /* Hide reorder cells on mobile */
    .responsive-cards .pages-table td.reorder-cell {
        display: none;
    }

    /* -- Search Results -- */
    .search-result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .search-result-meta {
        flex-direction: column;
        align-items: flex-start;
    }
    .search-result-card {
        padding: var(--sp-3) var(--sp-4);
    }

    /* -- Page Tasks -- */
    .page-tasks-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--sp-2);
    }
    .page-tasks-header .btn {
        width: 100%;
    }

    /* -- Page Content -- */
    .page-content {
        padding: var(--sp-4);
        border-radius: var(--radius-md);
    }
    .md-content pre {
        padding: var(--sp-3);
        font-size: var(--text-xs);
    }
    .md-content table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* -- Comments -- */
    .comment-item {
        padding: var(--sp-3);
    }
    .comment-textarea {
        min-height: 80px;
    }
    .comment-header {
        flex-wrap: wrap;
    }
    .btn-comment-delete {
        width: 36px;
        height: 36px;
    }

    /* -- Activity -- */
    .activity-item {
        flex-direction: column;
        gap: var(--sp-1);
    }
    .activity-time {
        min-width: 0;
    }

    /* -- Share Section -- */
    .share-link-box .form-input {
        font-size: var(--text-xs);
    }
    .share-create-form .filter-row {
        flex-direction: column;
    }

    /* -- Status Select Mobile -- */
    .status-select {
        min-height: 32px;
        font-size: var(--text-sm);
        padding: var(--sp-1) var(--sp-2);
    }

    /* -- Breadcrumb -- */
    .breadcrumb-list {
        font-size: var(--text-xs);
    }

    /* -- Section Block -- */
    .section-block {
        padding: var(--sp-4);
    }
}

/* --- 8.3 Small Mobile (max-width: 480px) --- */
@media (max-width: 480px) {
    .main-content {
        padding: var(--sp-3) var(--sp-3);
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .page-header h1 {
        font-size: var(--text-lg);
    }

    .login-card {
        padding: var(--sp-6) var(--sp-5);
    }

    .kanban-card {
        padding: var(--sp-3);
    }

    .responsive-cards .pages-table tr {
        padding: var(--sp-3);
    }

    .search-result-card {
        padding: var(--sp-3);
    }

    .app-logo {
        font-size: var(--text-base);
    }
}


/* ============================================================================
   9. ANIMATIONS
   ============================================================================ */

/* Alert auto-dismiss animation */
@keyframes alertSlideIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert {
    animation: alertSlideIn 200ms ease-out;
}

/* Sidebar overlay for mobile */
.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 85;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--transition-slow), visibility var(--transition-slow);
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Smooth scrollbar for sidebar */
.sidebar::-webkit-scrollbar {
    width: 4px;
}
.sidebar::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: var(--radius-full);
}

/* Smooth scrollbar for kanban columns */
.kanban-column-body::-webkit-scrollbar {
    width: 4px;
}
.kanban-column-body::-webkit-scrollbar-track {
    background: transparent;
}
.kanban-column-body::-webkit-scrollbar-thumb {
    background: var(--color-border);
    border-radius: var(--radius-full);
}

/* ============================================================================
   AP13 - Flexible Kanban Columns
   ============================================================================ */

/* WIP limit exceeded warning */
.kanban-column-wip-exceeded {
    background: rgba(239, 68, 68, 0.04);
}
.kanban-column-wip-exceeded .kanban-column-header {
    border-top-color: var(--color-danger, #ef4444) !important;
}
.kanban-wip-warning {
    color: var(--color-danger, #ef4444);
    font-weight: 600;
}

/* Column color swatch in management view */
.column-color-swatch {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: var(--radius-sm, 4px);
    border: 1px solid var(--color-border);
    vertical-align: middle;
}

/* Column management inline forms */
.column-edit-row td,
.column-delete-row td {
    background: var(--color-bg-alt, #f9fafb);
    border-top: 1px solid var(--color-border);
}
.column-inline-form {
    padding: var(--sp-2) 0;
}
.column-inline-form .filter-row {
    gap: var(--sp-3);
}

/* Reorder buttons */
.reorder-cell {
    white-space: nowrap;
    width: 60px;
}
.btn-reorder {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-bg);
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    color: var(--color-text);
    transition: background-color 0.15s ease;
}
.btn-reorder:hover {
    background: var(--color-primary-light, #dbeafe);
}

/* Section block heading with subtitle */
.section-block h2 {
    margin-bottom: var(--sp-3);
}

/* Form hint text */
.form-hint {
    display: block;
    font-size: 0.82rem;
    margin-top: var(--sp-1);
}

/* Board header row with manage button */
.board-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-3);
    flex-wrap: wrap;
}


/* ============================================================================
   AP14 - Smart Text Commands: Mentions, Tags, Autocomplete
   ============================================================================ */

/* --- Autocomplete Dropdown --- */
.mentions-dropdown {
    position: fixed;
    z-index: 1000;
    min-width: 200px;
    max-width: 360px;
    max-height: 240px;
    overflow-y: auto;
    background: var(--color-surface);
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--sp-1) 0;
}

.mentions-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    cursor: pointer;
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
}
.mentions-item:hover,
.mentions-item-active {
    background: var(--color-primary);
    color: #fff;
}
.mentions-item-active .mentions-item-email,
.mentions-item:hover .mentions-item-email {
    color: rgba(255, 255, 255, 0.8);
}

.mentions-item-name {
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mentions-item-email {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mentions-item-tag {
    font-weight: 500;
    color: var(--color-primary);
}
.mentions-item-active .mentions-item-tag,
.mentions-item:hover .mentions-item-tag {
    color: #fff;
}

/* --- Rendered Mention Inline --- */
.mention {
    display: inline;
    background: var(--c-blue-100, #dbeafe);
    color: var(--c-blue-700, #1d4ed8);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.92em;
    white-space: nowrap;
}

/* --- Rendered Tag Reference Inline --- */
a.tag-ref {
    display: inline;
    background: var(--c-amber-50, #fffbeb);
    color: var(--c-amber-700, #b45309);
    padding: 1px 4px;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.92em;
    text-decoration: none;
    white-space: nowrap;
}
a.tag-ref:hover {
    background: var(--c-amber-100, #fef3c7);
    text-decoration: none;
}

/* --- Dark mode adjustments --- */
[data-theme="dark"] .mention {
    background: rgba(59, 130, 246, 0.2);
    color: var(--c-blue-300, #93c5fd);
}
[data-theme="dark"] a.tag-ref {
    background: rgba(245, 158, 11, 0.15);
    color: var(--c-amber-300, #fcd34d);
}
[data-theme="dark"] a.tag-ref:hover {
    background: rgba(245, 158, 11, 0.25);
}
[data-theme="dark"] .mentions-dropdown {
    background: var(--color-surface);
    border-color: var(--color-border-strong);
}

/* --- Textarea hint for smart commands --- */
.textarea-hint {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    margin-top: var(--sp-1);
}

/* --- Mobile adjustments --- */
@media (max-width: 768px) {
    .mentions-dropdown {
        max-width: calc(100vw - 32px);
        min-width: 180px;
    }
    .mentions-item {
        padding: var(--sp-3) var(--sp-3);
        min-height: var(--touch-target-min);
    }
}


/* ============================================================================
   AP15 - NOTIFICATIONS, WATCHERS, EMAIL QUEUE
   ============================================================================ */

/* --- Notification Bell (header) --- */
.notif-bell-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.notif-bell-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--sp-1);
    color: var(--color-text-secondary);
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    transition: color 0.15s ease, background 0.15s ease;
}
.notif-bell-btn:hover {
    color: var(--color-text-primary);
    background: var(--color-bg-hover);
}
.notif-bell-btn svg {
    width: 20px;
    height: 20px;
}

.notif-badge {
    position: absolute;
    top: -2px;
    right: -4px;
    background: var(--c-red-500);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    border-radius: 99px;
    padding: 0 4px;
    pointer-events: none;
}

/* --- Notification Dropdown --- */
.notif-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 360px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--color-bg-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
}
.notif-dropdown.notif-dropdown-open {
    display: block;
}

.notif-dropdown-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    font-size: var(--text-sm);
}
.notif-dropdown-header a {
    font-weight: 400;
    font-size: var(--text-xs);
    color: var(--color-primary);
    text-decoration: none;
}
.notif-dropdown-header a:hover {
    text-decoration: underline;
}

.notif-dropdown-empty {
    padding: var(--sp-6) var(--sp-4);
    text-align: center;
    color: var(--color-text-tertiary);
    font-size: var(--text-sm);
}

.notif-dropdown-item {
    display: block;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border-subtle);
    text-decoration: none;
    color: var(--color-text-primary);
    transition: background 0.1s ease;
}
.notif-dropdown-item:hover {
    background: var(--color-bg-hover);
}
.notif-dropdown-item:last-child {
    border-bottom: none;
}
.notif-dropdown-item-unread {
    background: var(--c-blue-50);
}
[data-theme="dark"] .notif-dropdown-item-unread {
    background: rgba(59, 130, 246, 0.08);
}

.notif-dropdown-title {
    display: block;
    font-weight: 600;
    font-size: var(--text-sm);
    margin-bottom: 2px;
}
.notif-dropdown-body {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-bottom: 2px;
}
.notif-dropdown-meta {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

.notif-dropdown-footer {
    padding: var(--sp-2) var(--sp-4);
    text-align: center;
    border-top: 1px solid var(--color-border);
}
.notif-dropdown-footer a {
    font-size: var(--text-sm);
    color: var(--color-primary);
    text-decoration: none;
}
.notif-dropdown-footer a:hover {
    text-decoration: underline;
}

/* --- Notifications Page --- */
.notif-filter-tabs {
    display: flex;
    gap: var(--sp-1);
    margin-bottom: var(--sp-4);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
}
.notif-tab {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
}
.notif-tab:hover {
    color: var(--color-text-primary);
}
.notif-tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}
.notif-tab-badge {
    background: var(--c-red-500);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 99px;
    padding: 0 5px;
}

.notif-list {
    display: flex;
    flex-direction: column;
    gap: 0;
}

.notif-item {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border-subtle);
    transition: background 0.1s;
}
.notif-item:hover {
    background: var(--color-bg-hover);
}
.notif-item-unread {
    background: var(--c-blue-50);
    border-left: 3px solid var(--color-primary);
}
[data-theme="dark"] .notif-item-unread {
    background: rgba(59, 130, 246, 0.06);
}

.notif-item-content {
    flex: 1;
    min-width: 0;
}

.notif-item-link {
    display: block;
    text-decoration: none;
    color: var(--color-text-primary);
}
.notif-item-link:hover .notif-item-title {
    color: var(--color-primary);
}

.notif-item-title {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    margin-bottom: 2px;
    transition: color 0.15s;
}
.notif-item-body {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    margin-bottom: var(--sp-1);
}
.notif-item-meta {
    font-size: 11px;
    color: var(--color-text-tertiary);
}

.notif-item-actions {
    flex-shrink: 0;
    padding-top: 2px;
}

.notif-mark-read {
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: var(--sp-1);
    color: var(--color-text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.15s, border-color 0.15s;
}
.notif-mark-read:hover {
    color: var(--c-green-600, #16a34a);
    border-color: var(--c-green-600, #16a34a);
}

/* --- Watch Button --- */
.watch-form {
    display: inline-flex;
}
.watch-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-1);
    font-size: var(--text-sm);
}
.watch-btn svg {
    flex-shrink: 0;
}
.watch-btn.watch-active {
    color: var(--color-primary);
    border-color: var(--color-primary);
    background: var(--c-blue-50);
}
[data-theme="dark"] .watch-btn.watch-active {
    background: rgba(59, 130, 246, 0.1);
}
.watch-count {
    font-size: 11px;
    color: var(--color-text-tertiary);
    background: var(--color-bg-secondary);
    border-radius: 99px;
    padding: 0 5px;
    min-width: 16px;
    text-align: center;
    line-height: 16px;
}

/* --- Settings page: fieldset styling --- */
.fieldset-legend {
    font-size: var(--text-base);
    font-weight: 600;
    color: var(--color-text-primary);
    margin-bottom: var(--sp-3);
}
.form-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    cursor: pointer;
    padding: var(--sp-1) 0;
}
.form-checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

/* --- Email queue status badges --- */
.status-badge-pending {
    background: var(--c-amber-50, #fffbeb);
    color: var(--c-amber-700, #b45309);
    border: 1px solid var(--c-amber-200, #fde68a);
}
.status-badge-sent {
    background: var(--c-green-50, #f0fdf4);
    color: var(--c-green-700, #15803d);
    border: 1px solid var(--c-green-200, #bbf7d0);
}
.status-badge-failed {
    background: var(--c-red-50);
    color: var(--c-red-700);
    border: 1px solid var(--c-red-200, #fecaca);
}

/* --- Responsive: notification dropdown mobile --- */
@media (max-width: 768px) {
    .notif-dropdown {
        width: calc(100vw - 24px);
        right: -8px;
    }
    .notif-item {
        padding: var(--sp-3);
    }
}

/* ===================================================================
   AP16: Team Switcher
   =================================================================== */

.team-switcher-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.team-switcher-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius, 6px);
    background: var(--bg-card, #fff);
    color: var(--text);
    cursor: pointer;
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 150ms, border-color 150ms;
}
.team-switcher-btn:hover {
    background: var(--bg-hover, #f3f4f6);
    border-color: var(--primary, #3b82f6);
}
.team-switcher-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}
.team-switcher-label {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.team-switcher-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--bg-card, #fff);
    border: 1px solid var(--border);
    border-radius: var(--radius, 6px);
    box-shadow: var(--shadow-lg, 0 4px 16px rgba(0,0,0,0.12));
    z-index: 120;
    overflow: hidden;
    max-height: min(70vh, 420px);
    overflow-y: auto;
}
.team-switcher-dropdown.open {
    display: block;
}
.team-switcher-dropdown-header {
    padding: 8px 12px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
}
.team-switcher-item {
    display: block;
    width: 100%;
    padding: 8px 12px;
    border: none;
    background: none;
    color: var(--text);
    text-align: left;
    font-size: 0.88rem;
    cursor: pointer;
    transition: background 100ms;
}
.team-switcher-item:hover {
    background: var(--bg-hover, #f3f4f6);
}
.team-switcher-item.team-switcher-active {
    background: var(--primary-bg, #eff6ff);
    color: var(--primary, #3b82f6);
    font-weight: 600;
}

/* ===================================================================
   AP16: Team badge on lists
   =================================================================== */
.team-badge {
    display: inline-block;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 500;
    background: var(--bg-hover, #f3f4f6);
    color: var(--text-muted);
    white-space: nowrap;
    margin-left: 6px;
    vertical-align: middle;
}

/* ===================================================================
   AP16: Form row for inline forms (team edit page)
   =================================================================== */
.form-row {
    display: flex;
    gap: var(--sp-3, 12px);
    flex-wrap: wrap;
    align-items: flex-start;
}
.form-group-inline {
    flex: 1;
    min-width: 150px;
}
.form-control-inline {
    font-size: 0.85rem;
    padding: 4px 8px;
}

/* ===================================================================
   AP16: Team dropdown in create/edit forms
   =================================================================== */
.form-group .team-select {
    max-width: 300px;
}

/* ===================================================================
   AP16: Responsive team switcher
   =================================================================== */
@media (max-width: 768px) {
    .team-switcher-dropdown {
        width: min(320px, calc(100vw - 16px));
        right: 0;
        left: auto;
    }
    .team-switcher-label {
        max-width: 80px;
    }
}

/* ===================================================================
   AP17: File Attachments
   =================================================================== */

/* --- Attachments Section --- */
.attachments-section {
    margin-top: var(--sp-4);
}

/* --- Attachments Table --- */
.attachments-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}
.attachments-table th {
    text-align: left;
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-xs);
    font-weight: 600;
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 2px solid var(--color-border);
}
.attachments-table td {
    padding: var(--sp-2) var(--sp-3);
    border-bottom: 1px solid var(--color-border-subtle, var(--color-border));
    vertical-align: middle;
}
.attachments-table tbody tr:hover {
    background: var(--color-bg-hover, var(--color-bg-alt, #f9fafb));
}
[data-theme="dark"] .attachments-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

/* --- Attachment Name Cell --- */
.attachment-name-cell {
    max-width: 300px;
    word-break: break-all;
}
.attachment-icon {
    margin-right: var(--sp-1);
    font-size: 1rem;
    vertical-align: middle;
}
.attachment-link {
    font-weight: 500;
    color: var(--color-primary);
    text-decoration: none;
}
.attachment-link:hover {
    text-decoration: underline;
}
.attachment-preview-link {
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    text-decoration: none;
    margin-left: var(--sp-1);
}
.attachment-preview-link:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

/* --- Size, Uploader, Date Cells --- */
.attachment-size-cell {
    white-space: nowrap;
    color: var(--color-text-secondary);
}
.attachment-uploader-cell {
    white-space: nowrap;
}
.attachment-date-cell {
    white-space: nowrap;
    color: var(--color-text-secondary);
    font-size: var(--text-xs);
}

/* --- Actions Cell --- */
.attachment-actions-cell {
    white-space: nowrap;
    text-align: right;
}
.attachment-actions-cell .inline-form {
    display: inline;
    margin-left: var(--sp-1);
}
.btn-download {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-1) var(--sp-2);
    font-size: var(--text-xs);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm, 4px);
    background: var(--color-bg);
    color: var(--color-text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-download:hover {
    background: var(--color-bg-hover, var(--color-bg-alt));
}

/* --- Upload Form --- */
.attachment-upload-form {
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border-subtle, var(--color-border));
}
.attachment-upload-row {
    display: flex;
    align-items: flex-start;
    gap: var(--sp-3);
    flex-wrap: wrap;
}
.attachment-file-input {
    flex: 1;
    min-width: 200px;
}
.attachment-file-input .form-input {
    padding: var(--sp-2);
    font-size: var(--text-sm);
}
.attachment-upload-row .btn {
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0;
}

/* --- Responsive: Attachments Mobile --- */
@media (max-width: 768px) {
    .attachments-table thead {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border-width: 0;
    }
    .attachments-table,
    .attachments-table tbody {
        display: block;
    }
    .attachments-table tr {
        display: block;
        border: 1px solid var(--color-border);
        border-radius: var(--radius-md, 8px);
        padding: var(--sp-3);
        margin-bottom: var(--sp-2);
        background: var(--color-surface);
    }
    .attachments-table td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--sp-1) 0;
        border-bottom: none;
    }
    .attachments-table td::before {
        content: attr(data-label);
        display: inline-block;
        min-width: 80px;
        flex-shrink: 0;
        font-weight: 600;
        font-size: var(--text-xs);
        color: var(--color-text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        margin-right: var(--sp-2);
    }
    .attachments-table td:not([data-label])::before,
    .attachments-table td[data-label=""]::before {
        display: none;
    }
    .attachment-name-cell {
        max-width: none;
        display: block !important;
        padding-bottom: var(--sp-2) !important;
        border-bottom: 1px solid var(--color-border) !important;
        margin-bottom: var(--sp-1);
    }
    .attachment-name-cell::before {
        display: none !important;
    }
    .attachment-actions-cell {
        display: flex !important;
        justify-content: flex-end;
        padding-top: var(--sp-2) !important;
        margin-top: var(--sp-1);
        border-top: 1px solid var(--color-border) !important;
    }
    .attachment-actions-cell::before {
        display: none !important;
    }
    .attachment-upload-row {
        flex-direction: column;
    }
    .attachment-upload-row .btn {
        width: 100%;
        min-height: var(--touch-target-min);
    }
}

/* ================================================================
   AP18: Reports & Flow Metrics
   ================================================================ */

/* Report header with navigation tabs */
.report-header {
    margin-bottom: var(--sp-4);
}

.report-header h1 {
    margin-bottom: var(--sp-2);
}

.report-nav {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
    border-bottom: 2px solid var(--color-border);
    padding-bottom: var(--sp-1);
}

.report-nav-link {
    display: inline-block;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--radius) var(--radius) 0 0;
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background-color 150ms ease, color 150ms ease;
}

.report-nav-link:hover {
    background-color: var(--color-bg-hover);
    color: var(--color-text);
}

.report-nav-link.active {
    background-color: var(--color-primary);
    color: #fff;
}

.report-export-link {
    margin-left: auto;
    background-color: var(--color-bg-hover);
    border-radius: var(--radius);
}

.report-export-link:hover {
    background-color: var(--color-border);
}

/* Filter bar */
.report-filters {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.report-filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2) var(--sp-3);
    align-items: flex-end;
}

.report-filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
    min-width: 120px;
}

.report-filter-dates {
    display: flex;
    flex-direction: row;
    align-items: flex-end;
    gap: var(--sp-1);
}

.report-filter-dates .form-input-sm {
    width: 140px;
}

.report-filter-actions {
    display: flex;
    flex-direction: row;
    gap: var(--sp-1);
    align-items: flex-end;
    margin-left: auto;
}

/* KPI Grid */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.kpi-grid-sm {
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
}

.kpi-card {
    background: var(--color-bg-card);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: var(--sp-4);
    text-align: center;
}

.kpi-card-warning {
    border-color: var(--c-orange-400, #fb923c);
    background: var(--c-orange-50, #fff7ed);
}

[data-theme="dark"] .kpi-card-warning {
    background: rgba(251, 146, 60, 0.1);
    border-color: var(--c-orange-600, #ea580c);
}

.kpi-value {
    font-size: var(--text-3xl);
    font-weight: 700;
    color: var(--color-primary);
    line-height: 1.2;
    word-break: break-word;
}

.kpi-card-warning .kpi-value {
    color: var(--c-orange-600, #ea580c);
}

.kpi-label {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    margin-top: var(--sp-1);
}

.kpi-hint {
    font-size: var(--text-xs);
    color: var(--color-text-muted);
    margin-top: var(--sp-1);
}

/* Report sections */
.report-section {
    margin-bottom: var(--sp-4);
}

.report-section-title {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--sp-2);
    padding-bottom: var(--sp-1);
    border-bottom: 1px solid var(--color-border);
}

/* Two-column grid for side-by-side sections */
.report-grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-4);
    margin-bottom: var(--sp-4);
}

/* Report tables */
.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-sm);
}

.report-table th {
    text-align: left;
    padding: var(--sp-2) var(--sp-2);
    border-bottom: 2px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: var(--text-xs);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.report-table td {
    padding: var(--sp-2) var(--sp-2);
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.report-table tbody tr:hover {
    background-color: var(--color-bg-hover);
}

.report-table a {
    color: var(--color-primary);
    text-decoration: none;
}

.report-table a:hover {
    text-decoration: underline;
}

.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Text helpers */
.text-warning {
    color: var(--c-orange-600, #ea580c);
    font-weight: 600;
}

.text-sm {
    font-size: var(--text-sm);
}

/* Tag chips for report */
.tag-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-1);
}

.tag-count {
    font-weight: 400;
    color: var(--color-text-muted);
}

.tag-sm {
    font-size: var(--text-xs);
    padding: 1px var(--sp-1);
}

/* Bar chart (CSS only) */
.chart-bar-container {
    display: flex;
    flex-direction: column;
    gap: var(--sp-1);
}

.chart-bar-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.chart-bar-label {
    min-width: 100px;
    font-size: var(--text-sm);
    color: var(--color-text-muted);
    text-align: right;
    flex-shrink: 0;
}

.chart-bar-track {
    flex: 1;
    background: var(--color-bg-hover);
    border-radius: var(--radius);
    height: 24px;
    overflow: hidden;
}

.chart-bar-fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: var(--sp-2);
    min-width: fit-content;
    transition: width 300ms ease;
}

.chart-bar-fill-backlog {
    background: var(--c-gray-400, #9ca3af);
}

.chart-bar-fill-active {
    background: var(--color-primary);
}

.chart-bar-fill-done {
    background: var(--c-green-500, #22c55e);
}

.chart-bar-fill-warning {
    background: var(--c-orange-500, #f97316);
}

.chart-bar-value {
    font-size: var(--text-xs);
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
}

/* Form label sm */
.form-label-sm {
    font-size: var(--text-xs);
    margin-bottom: 0;
}

/* Responsive: report grid */
@media (max-width: 768px) {
    .report-grid-2 {
        grid-template-columns: 1fr;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .report-filter-form {
        flex-direction: column;
    }

    .report-filter-group {
        width: 100%;
    }

    .report-filter-actions {
        margin-left: 0;
        width: 100%;
    }

    .report-filter-actions .btn {
        flex: 1;
    }

    .chart-bar-label {
        min-width: 70px;
        font-size: var(--text-xs);
    }

    .report-nav {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .report-export-link {
        margin-left: 0;
    }
}


/* ============================================================================
   AP20 - Finalization, Branding, Personalization
   ============================================================================ */

/* --- Logo in header --- */
.app-logo-img {
    height: 28px;
    width: auto;
    max-width: 160px;
    object-fit: contain;
    vertical-align: middle;
}

/* --- Logo on login page --- */
.login-logo {
    display: block;
    max-height: 56px;
    max-width: 200px;
    width: auto;
    margin: 0 auto var(--sp-4);
    object-fit: contain;
}

/* --- Maintenance banner --- */
.maintenance-banner {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    width: 100%;
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 500;
    text-align: center;
    line-height: var(--leading-normal);
    z-index: 140;
}

body.has-maintenance .app-header {
    top: var(--maintenance-banner-height, 40px);
}

body.has-maintenance .app-body {
    padding-top: calc(var(--header-height) + var(--maintenance-banner-height, 40px));
}

body.has-maintenance .sidebar {
    top: calc(var(--header-height) + var(--maintenance-banner-height, 40px));
}

body.login-body.has-maintenance {
    min-height: calc(100vh - var(--maintenance-banner-height, 40px));
}

.maintenance-info {
    background: var(--c-blue-50, #eff6ff);
    color: var(--c-blue-700, #1d4ed8);
    border-bottom: 1px solid var(--c-blue-200, #bfdbfe);
}

.maintenance-warning {
    background: var(--c-amber-50, #fffbeb);
    color: var(--c-amber-700, #b45309);
    border-bottom: 1px solid var(--c-amber-200, #fde68a);
}

.maintenance-critical {
    background: var(--c-red-50, #fef2f2);
    color: var(--c-red-700, #b91c1c);
    border-bottom: 1px solid var(--c-red-200, #fecaca);
}

[data-theme="dark"] .maintenance-info {
    background: rgba(59, 130, 246, 0.1);
    color: var(--c-blue-200, #bfdbfe);
    border-bottom-color: rgba(59, 130, 246, 0.2);
}

[data-theme="dark"] .maintenance-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #fcd34d;
    border-bottom-color: rgba(245, 158, 11, 0.2);
}

[data-theme="dark"] .maintenance-critical {
    background: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border-bottom-color: rgba(239, 68, 68, 0.2);
}

/* --- App Footer --- */
.app-footer {
    padding: var(--sp-3) var(--sp-6);
    margin-left: var(--sidebar-width);
    font-size: var(--text-xs);
    color: var(--color-text-tertiary);
    text-align: center;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.app-footer a {
    color: var(--color-text-secondary);
    text-decoration: none;
}

.app-footer a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.app-footer-sep {
    margin: 0 var(--sp-2);
    color: var(--color-border-strong);
}

@media (max-width: 768px) {
    .app-footer {
        margin-left: 0;
        padding: var(--sp-3);
    }
}

/* --- Admin Settings Tabs --- */
.admin-settings-tabs {
    display: flex;
    gap: var(--sp-1);
    margin-bottom: var(--sp-4);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: 0;
    overflow-x: auto;
}

.admin-settings-tab {
    display: inline-flex;
    align-items: center;
    padding: var(--sp-2) var(--sp-4);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text-secondary);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: color 0.15s, border-color 0.15s;
    white-space: nowrap;
}

.admin-settings-tab:hover {
    color: var(--color-text);
}

.admin-settings-tab-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

/* --- Preset Grid --- */
.preset-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: var(--sp-3);
}

.preset-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-3);
    border: 2px solid var(--color-border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    background: var(--color-surface);
}

.preset-card:hover {
    border-color: var(--color-primary);
}

.preset-card-active {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.preset-radio {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.preset-colors {
    display: flex;
    gap: var(--sp-1);
}

.preset-swatch {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full);
    border: 2px solid var(--color-surface);
    box-shadow: var(--shadow-xs);
}

.preset-name {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--color-text);
}

/* --- Radio Group --- */
.radio-group {
    display: flex;
    gap: var(--sp-4);
    margin-bottom: var(--sp-2);
}

.radio-label {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-sm);
    cursor: pointer;
}

/* --- Color Input --- */
.color-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--sp-3);
}

.color-input-wrap {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.color-input-wrap input[type="color"] {
    width: 40px;
    height: 36px;
    padding: 2px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    background: var(--color-surface);
}

/* --- Color Preview --- */
.color-preview {
    margin-top: var(--sp-4);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.color-preview-header {
    padding: var(--sp-3) var(--sp-4);
}

.color-preview-body {
    padding: var(--sp-4);
    display: flex;
    gap: var(--sp-2);
    background: var(--color-surface);
}

/* --- Logo Preview --- */
.logo-preview {
    margin-bottom: var(--sp-3);
    padding: var(--sp-3);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-bg-sunken);
    display: inline-block;
}

.logo-preview-img {
    max-height: 48px;
    max-width: 200px;
    width: auto;
    object-fit: contain;
}

/* --- Form Actions --- */
.form-actions {
    display: flex;
    gap: var(--sp-2);
    margin-top: var(--sp-4);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
}

@media (max-width: 768px) {
    .preset-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .color-fields {
        grid-template-columns: 1fr;
    }

    .radio-group {
        flex-direction: column;
        gap: var(--sp-2);
    }

    .admin-settings-tabs {
        gap: 0;
    }

    .admin-settings-tab {
        padding: var(--sp-2) var(--sp-3);
        font-size: var(--text-xs);
    }
}


/* ============================================================================
   AP22: Home Dashboard - Meine Arbeit
   ============================================================================ */

.home-section {
    margin-bottom: var(--sp-5);
}

.home-section-title {
    font-size: var(--text-base);
    font-weight: 600;
    margin-bottom: var(--sp-3);
    display: flex;
    align-items: center;
    gap: var(--sp-2);
}

.home-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    background: var(--color-border);
    color: var(--color-text-secondary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
}

.home-section-overdue {
    border-left: 3px solid var(--color-error);
    padding-left: var(--sp-3);
}

.home-section-title-overdue {
    color: var(--color-error);
}

.home-section-icon-overdue {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    background: var(--color-error);
    color: #fff;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.home-section-title-today {
    color: var(--color-warning);
}

.home-section-today {
    border-left: 3px solid var(--color-warning);
    padding-left: var(--sp-3);
}

.home-task-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.home-task-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-2) var(--sp-3);
    gap: var(--sp-3);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition-fast);
}
.home-task-row:last-child {
    border-bottom: none;
}
.home-task-row:hover {
    background: var(--color-surface-hover);
}

.home-task-main {
    flex: 1;
    min-width: 0;
}

.home-task-title {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
    text-decoration: none;
    margin-bottom: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.home-task-title:hover {
    color: var(--color-primary);
}

.home-task-meta {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
}

.home-task-column {
    font-weight: 500;
}

.home-task-due {
    font-weight: 400;
}

.home-task-board {
    color: var(--color-text-tertiary);
}

.home-task-owner {
    color: var(--color-text-tertiary);
}

.home-task-actions {
    display: flex;
    gap: var(--sp-1);
    flex-shrink: 0;
}

.home-btn-done {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--color-text-secondary);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition-fast);
}
.home-btn-done:hover {
    background: var(--color-success-bg);
    border-color: var(--color-success);
    color: var(--color-success);
}

.home-empty-state {
    text-align: center;
    padding: var(--sp-10) var(--sp-4);
    color: var(--color-text-secondary);
}

.home-empty-links {
    display: flex;
    gap: var(--sp-2);
    justify-content: center;
    margin-top: var(--sp-4);
}


/* ============================================================================
   AP22: Page Content Primary - dominant content area
   ============================================================================ */

.page-content-primary {
    margin-bottom: var(--sp-5);
    padding: var(--sp-4) 0;
    font-size: var(--text-lg);
    line-height: var(--leading-relaxed);
}

.page-content-primary h1 {
    font-size: var(--text-3xl);
    margin-bottom: var(--sp-4);
}
.page-content-primary h2 {
    font-size: var(--text-2xl);
    margin-bottom: var(--sp-3);
}
.page-content-primary h3 {
    font-size: var(--text-xl);
    margin-bottom: var(--sp-3);
}


/* ============================================================================
   AP22: Task Detail - information hierarchy
   ============================================================================ */

.task-description-primary {
    grid-column: 1;
}

.task-detail-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
    align-items: start;
}

.task-meta-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    padding: var(--sp-4);
    position: sticky;
    top: calc(var(--header-height) + var(--sp-3));
}

.task-meta-move {
    margin-top: var(--sp-3);
    padding-top: var(--sp-3);
    border-top: 1px solid var(--color-border);
}

.section-secondary {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    background: var(--color-surface);
    padding: var(--sp-4);
    margin-bottom: var(--sp-4);
}

@media (max-width: 768px) {
    .task-detail-grid {
        grid-template-columns: 1fr;
    }
    .task-description-primary {
        order: 1;
    }
    .task-meta-card {
        order: 2;
        position: static;
    }
}


/* ============================================================================
   AP22: Activity collapsible
   ============================================================================ */

.activity-collapsible {
    margin-bottom: var(--sp-5);
}

.activity-collapsible-summary {
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-bg-sunken);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    user-select: none;
    transition: background var(--transition-fast);
    list-style: none;
}
.activity-collapsible-summary::-webkit-details-marker {
    display: none;
}
.activity-collapsible-summary::before {
    content: '\25B6';
    display: inline-block;
    margin-right: var(--sp-2);
    font-size: 10px;
    transition: transform var(--transition-fast);
}
.activity-collapsible[open] .activity-collapsible-summary::before {
    transform: rotate(90deg);
}
.activity-collapsible-summary:hover {
    background: var(--color-surface-hover);
}

.activity-collapsible .activity-section {
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    background: var(--color-surface);
    padding: var(--sp-3);
    margin-bottom: 0;
}

.activity-collapsible .activity-section h2 {
    display: none;
}


/* ============================================================================
   AP22: Share panel collapsible
   ============================================================================ */

.share-panel-collapsible {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--sp-3);
    margin-bottom: var(--sp-4);
}


/* ============================================================================
   AP22: Board UI polishing - column colors, card dropdown
   ============================================================================ */

/* Column dot indicator */
.kanban-column-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    margin-right: 4px;
    vertical-align: middle;
}

/* Column color left bar on cards */
.kanban-card-color-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
}

.kanban-card {
    position: relative;
}

/* AP22: Card dropdown - themed properly for darkmode */
.kanban-card-select {
    width: 100%;
    font-size: var(--text-xs);
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    outline: none;
    appearance: auto;
    transition: border-color var(--transition-fast);
}
.kanban-card-select:hover {
    border-color: var(--color-border-strong);
}
.kanban-card-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.kanban-card-select-board {
    margin-top: var(--sp-1);
    font-style: italic;
    color: var(--color-text-secondary);
}

/* Override old status-select used in cards */
.kanban-card-actions .status-select {
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
}
.kanban-card-actions .status-select:focus {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

/* Move board form */
.kanban-move-board-form {
    margin-top: 0;
}


/* ============================================================================
   AP22: Tag autocomplete input
   ============================================================================ */

.tag-input-wrap {
    position: relative;
}

.tag-input-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    padding: 4px 8px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-surface);
    min-height: 38px;
    align-items: center;
    cursor: text;
    transition: border-color var(--transition-fast);
}
.tag-input-chips:focus-within {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px var(--color-focus-ring);
}

.tag-input-chip {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px 8px;
    background: var(--color-primary-subtle);
    color: var(--color-primary);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 500;
    white-space: nowrap;
}

.tag-input-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: none;
    color: inherit;
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0 2px;
    opacity: 0.6;
}
.tag-input-chip-remove:hover {
    opacity: 1;
}

.tag-input-field {
    border: none;
    outline: none;
    background: transparent;
    color: var(--color-text);
    font-size: var(--text-sm);
    flex: 1;
    min-width: 80px;
    padding: 2px 0;
}
.tag-input-field::placeholder {
    color: var(--color-text-tertiary);
}

.tag-input-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    margin-top: 2px;
}

.tag-input-option {
    padding: var(--sp-2) var(--sp-3);
    font-size: var(--text-sm);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.tag-input-option:hover {
    background: var(--color-surface-hover);
}

.tag-input-option-new {
    color: var(--color-primary);
    font-style: italic;
}


/* ============================================================================
   AP22: Mobile overrides
   ============================================================================ */

@media (max-width: 768px) {
    .home-task-meta {
        flex-wrap: wrap;
    }

    .home-task-row {
        flex-direction: column;
        align-items: stretch;
    }

    .home-task-actions {
        justify-content: flex-end;
    }

    .page-content-primary {
        font-size: var(--text-base);
    }
}


/* ============================================================================
   AP23: User Dropdown Menu
   ============================================================================ */

.user-menu-wrap {
    position: relative;
}

.user-menu-btn {
    display: inline-flex;
    align-items: center;
    gap: var(--sp-2);
    padding: 3px var(--sp-2) 3px 3px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    transition: background var(--transition-fast), border-color var(--transition-fast);
}

.user-menu-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border-strong);
}

.user-menu-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: var(--radius-full);
    background: var(--color-primary);
    color: var(--color-text-inverse);
    font-size: var(--text-xs);
    font-weight: 600;
    flex-shrink: 0;
}

.user-menu-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-menu-chevron {
    width: 14px;
    height: 14px;
    color: var(--color-text-tertiary);
    transition: transform var(--transition-fast);
    flex-shrink: 0;
}

.user-menu-dropdown.open + .user-menu-btn .user-menu-chevron,
.user-menu-wrap .user-menu-dropdown.open ~ .user-menu-btn .user-menu-chevron {
    transform: rotate(180deg);
}

.user-menu-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 220px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    z-index: 200;
    overflow: hidden;
}

.user-menu-dropdown.open {
    display: block;
}

.user-menu-dropdown-header {
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--color-border);
}

.user-menu-dropdown-name {
    display: block;
    font-size: var(--text-sm);
    font-weight: 600;
    color: var(--color-text);
}

.user-menu-dropdown-role {
    display: block;
    font-size: var(--text-xs);
    color: var(--color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-top: 2px;
}

.user-menu-item {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    padding: var(--sp-2) var(--sp-4);
    color: var(--color-text);
    font-size: var(--text-sm);
    transition: background var(--transition-fast);
    text-decoration: none;
}

.user-menu-item:hover {
    background: var(--color-surface-hover);
    text-decoration: none;
}

.user-menu-item svg {
    width: 16px;
    height: 16px;
    color: var(--color-text-secondary);
    flex-shrink: 0;
}

.user-menu-item-danger {
    color: var(--color-error);
}

.user-menu-item-danger svg {
    color: var(--color-error);
}

.user-menu-item-danger:hover {
    background: var(--color-error-bg);
}

.user-menu-separator {
    height: 1px;
    background: var(--color-border);
    margin: var(--sp-1) 0;
}


/* ============================================================================
   AP23: Collapsible Page Tree
   ============================================================================ */

.page-tree-scroll {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
}

.page-tree-scroll::-webkit-scrollbar {
    width: 4px;
}

.page-tree-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.page-tree-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
}

.page-tree-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.page-tree-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    padding: 0;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    transition: color var(--transition-fast), background var(--transition-fast), transform var(--transition-fast);
}

.page-tree-toggle:hover {
    color: rgba(255, 255, 255, 0.7);
    background: rgba(255, 255, 255, 0.08);
}

.page-tree-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform var(--transition-fast);
}

.page-tree-item.expanded > .page-tree-row > .page-tree-toggle svg {
    transform: rotate(90deg);
}

.page-tree-item.has-children > ul {
    display: none;
}

.page-tree-item.has-children.expanded > ul {
    display: block;
}

.page-tree-spacer {
    display: inline-block;
    width: 18px;
    flex-shrink: 0;
}

.page-tree-link {
    display: block;
    flex: 1;
    min-width: 0;
    padding: 3px 8px;
    color: rgba(255, 255, 255, 0.55);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast), color var(--transition-fast);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-decoration: none;
}

.page-tree-link:hover {
    background: var(--color-sidebar-hover);
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
}

.page-tree-active {
    background: var(--color-sidebar-active);
    color: #ffffff;
}


/* ============================================================================
   AP23: Admin Sidebar Section
   ============================================================================ */

.sidebar-admin {
    padding: var(--sp-3) var(--sp-3) 0;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    margin-top: var(--sp-2);
}

.sidebar-admin .sidebar-label {
    padding: 0 var(--sp-2);
    margin-bottom: var(--sp-1);
}

.sidebar-admin .nav-list {
    padding: 0;
}

.sidebar-admin .nav-link {
    font-size: var(--text-xs);
    padding: 5px var(--sp-3);
    color: rgba(255, 255, 255, 0.45);
}

.sidebar-admin .nav-link:hover {
    color: rgba(255, 255, 255, 0.8);
}

.sidebar-admin .nav-link.active {
    color: #ffffff;
}

.sidebar-admin .nav-icon svg {
    width: 15px;
    height: 15px;
}


/* ============================================================================
   AP23: Mobile overrides for user menu
   ============================================================================ */

@media (max-width: 768px) {
    .user-menu-name {
        display: none;
    }

    .user-menu-chevron {
        display: none;
    }

    .user-menu-btn {
        padding: 2px;
        border: none;
        background: transparent;
    }

    .user-menu-dropdown {
        right: -8px;
    }
}

/* ── AP24: Language Switcher Styles ──────────────────────────────── */

/* Login screen language switch */
.login-lang-switch {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    margin-top: var(--sp-4, 16px);
    font-size: 0.8rem;
    color: var(--color-text-secondary, #64748b);
}

.login-lang-active {
    font-weight: 600;
    color: var(--color-text, #1e293b);
}

.login-lang-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.8rem;
    color: var(--color-primary, #2563eb);
    text-decoration: underline;
    font-family: inherit;
}

.login-lang-btn:hover {
    color: var(--color-primary-hover, #1d4ed8);
}

.login-lang-sep {
    color: var(--color-border, #e2e8f0);
}

/* User menu language selector */
.user-menu-lang {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 12px;
    gap: 8px;
}

.user-menu-lang-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    color: var(--color-text-secondary, #64748b);
    white-space: nowrap;
}

.user-menu-lang-label svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.user-menu-lang-form {
    display: inline;
}

.user-menu-lang-select {
    font-size: 0.8rem;
    padding: 2px 6px;
    min-width: 0;
    width: auto;
}

/* ── AP26: Sprint UI ─────────────────────────────────────────── */

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

.card-body {
    flex: 1;
}

.content-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-bottom: var(--sp-4);
}

.btn-success {
    background-color: var(--color-success, #22c55e);
    color: #fff;
    border: none;
}
.btn-success:hover {
    background-color: #16a34a;
    color: #fff;
}

.btn-warning {
    background-color: #f59e0b;
    color: #000;
    border: none;
}
.btn-warning:hover {
    background-color: #d97706;
    color: #000;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    color: var(--color-text-muted);
    font-size: inherit;
}
.btn-link:hover {
    color: var(--color-text);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--color-border);
    border-radius: var(--radius-full, 9999px);
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    background: var(--color-success, #22c55e);
    border-radius: var(--radius-full, 9999px);
    transition: width 0.3s ease;
}

.alert-error {
    padding: var(--sp-3) var(--sp-4);
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-md);
    color: #991b1b;
    margin-bottom: var(--sp-4);
}
[data-theme="dark"] .alert-error {
    background: #451a1a;
    border-color: #7f1d1d;
    color: #fca5a5;
}


/* ============================================================================
   AP27: Saved Views
   ============================================================================ */

/* Views bar – sits below the filter form */
.views-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
    margin-top: var(--sp-3);
    padding-top: var(--sp-2);
    border-top: 1px solid var(--color-border);
}

.views-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
}

/* Chip list for quick-switch */
.views-quick-switch {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.views-chips {
    display: flex;
    gap: var(--sp-1);
    flex-wrap: wrap;
}

.views-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 3px 10px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full, 9999px);
    font-size: 0.8rem;
    color: var(--color-text);
    text-decoration: none;
    background: var(--color-surface);
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}

.views-chip:hover {
    border-color: var(--color-primary);
    background: var(--c-blue-50, #eff6ff);
    color: var(--color-primary);
}

[data-theme="dark"] .views-chip:hover {
    background: rgba(59, 130, 246, 0.1);
}

.views-chip--default {
    border-color: var(--color-primary);
    background: var(--c-blue-50, #eff6ff);
}

[data-theme="dark"] .views-chip--default {
    background: rgba(59, 130, 246, 0.1);
}

.views-chip-star {
    color: var(--c-yellow-500, #f59e0b);
    font-size: 0.85em;
}

/* Save button */
.views-save-btn {
    margin-left: auto;
    font-size: 0.82rem;
}

/* Save form (inline, hidden by default) */
.views-save-form {
    width: 100%;
    margin-top: var(--sp-2);
    padding: var(--sp-2) var(--sp-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.views-save-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.views-name-input {
    flex: 1;
    min-width: 180px;
}

.views-default-label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.82rem;
    color: var(--color-text-muted);
    white-space: nowrap;
    cursor: pointer;
}

.views-hint {
    font-size: 0.78rem;
    color: var(--color-text-muted);
    margin: var(--sp-1) 0 0 0;
}

/* Manage panel (details/summary) */
.views-manage {
    margin-top: var(--sp-2);
}

.views-manage-details {
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}

.views-manage-summary {
    padding: var(--sp-2) var(--sp-3);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    user-select: none;
}

.views-manage-summary:hover {
    color: var(--color-text);
}

.views-manage-list {
    padding: 0 var(--sp-3) var(--sp-2);
}

.views-manage-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp-2);
    padding: var(--sp-2) 0;
    border-bottom: 1px solid var(--color-border);
}

.views-manage-item:last-child {
    border-bottom: none;
}

.views-manage-item-header {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex: 1;
    min-width: 0;
}

.views-manage-name {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.views-manage-type {
    font-size: 0.72rem;
    padding: 1px 6px;
    border-radius: 3px;
    background: var(--color-border);
    color: var(--color-text-muted);
    white-space: nowrap;
}

.views-manage-actions {
    display: flex;
    align-items: center;
    gap: var(--sp-1);
    flex-shrink: 0;
}

/* Extra-small button variant */
.btn-xs {
    padding: 2px 8px;
    font-size: 0.75rem;
    line-height: 1.4;
    border-radius: 3px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text-muted);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

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

.btn-danger.btn-xs {
    color: var(--c-red-600, #dc2626);
    border-color: var(--c-red-600, #dc2626);
}

.btn-danger.btn-xs:hover {
    background: var(--c-red-600, #dc2626);
    color: #fff;
}

/* Home dashboard: saved views */
.home-views-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
}

.home-views-group {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    flex-wrap: wrap;
}

.home-views-group-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--color-text-muted);
    min-width: 100px;
}

.home-views-link {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    padding: 4px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-full, 9999px);
    font-size: 0.82rem;
    color: var(--color-text);
    text-decoration: none;
    background: var(--color-surface);
    transition: border-color 0.15s, background 0.15s;
}

.home-views-link:hover {
    border-color: var(--color-primary);
    background: var(--c-blue-50, #eff6ff);
    color: var(--color-primary);
}

[data-theme="dark"] .home-views-link:hover {
    background: rgba(59, 130, 246, 0.1);
}

.home-views-link--default {
    border-color: var(--color-primary);
    font-weight: 600;
}

/* Responsive: stack views-bar vertically on small screens */
@media (max-width: 768px) {
    .views-bar {
        flex-direction: column;
        align-items: stretch;
    }
    .views-save-btn {
        margin-left: 0;
    }
    .views-save-row {
        flex-direction: column;
    }
    .views-name-input {
        min-width: 0;
        width: 100%;
    }
    .views-manage-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .home-views-group {
        flex-direction: column;
        align-items: flex-start;
    }
}
