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

:root {
    --bg: #0f1117;
    --bg-elevated: #1a1d27;
    --bg-surface: #232736;
    --surface: var(--bg-surface);
    --bg-hover: #2d3148;
    --border: #363b54;
    --text: #e4e7f1;
    --text-secondary: #9197b3;
    --text-muted: #6b7194;
    --primary: #6366f1;
    --primary-hover: #5457e5;
    --primary-soft: rgba(99, 102, 241, 0.15);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --transition: 150ms ease;
    --header-height: 56px;

    --color-default: #64748b;
    --color-red: #ef4444;
    --color-orange: #f97316;
    --color-amber: #f59e0b;
    --color-yellow: #eab308;
    --color-lime: #84cc16;
    --color-green: #22c55e;
    --color-emerald: #10b981;
    --color-teal: #14b8a6;
    --color-cyan: #06b6d4;
    --color-sky: #0ea5e9;
    --color-blue: #3b82f6;
    --color-indigo: #6366f1;
    --color-violet: #8b5cf6;
    --color-purple: #a855f7;
    --color-fuchsia: #d946ef;
    --color-pink: #ec4899;
    --color-rose: #f43f5e;
}

/* Brand logo squares - derive shades from primary */
.logo-sq-1 { fill: var(--primary); }
.logo-sq-2 { fill: var(--primary); opacity: 0.65; }
.logo-sq-3 { fill: var(--primary); opacity: 0.4; }

html, body { height: 100%; }

body {
    font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow: hidden;
}

.screen { display: none; height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ── Auth ── */
.auth-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 2rem;
}
.auth-brand { text-align: center; margin-bottom: 2rem; }
.auth-brand h1 { font-size: 2rem; margin-top: 0.75rem; letter-spacing: -0.02em; }
.auth-subtitle { color: var(--text-secondary); margin-top: 0.25rem; }
.auth-form {
    width: 100%;
    max-width: 400px;
    background: var(--bg-elevated);
    padding: 2rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.auth-form h2 { margin-bottom: 1.5rem; font-size: 1.25rem; }
.auth-switch { text-align: center; margin-top: 1rem; font-size: 0.875rem; color: var(--text-secondary); }
.auth-switch a { color: var(--primary); text-decoration: none; }
.auth-switch a:hover { text-decoration: underline; }

/* ── Forms ── */
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.375rem; }
.form-row { display: flex; gap: 1rem; }
.flex-1 { flex: 1; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], textarea, select {
    width: 100%;
    padding: 0.625rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.875rem;
    font-family: inherit;
    transition: border-color var(--transition);
    outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--primary); }
textarea { resize: vertical; }
.form-error { color: var(--danger); font-size: 0.8125rem; margin-top: 0.5rem; min-height: 1.25rem; }
.form-success {
    color: #2ecc40;
    font-size: 0.9rem;
    margin-top: 0.5rem;
    text-align: center;
}

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; font-size: 0.875rem; }
.checkbox-label input[type="checkbox"] { width: auto; accent-color: var(--primary); }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    padding: 0.625rem 1.125rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-outline { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Header ── */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: var(--header-height);
    padding: 0 1rem;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    gap: 0.75rem;
}
.header-left, .header-right { display: flex; align-items: center; gap: 0.75rem; }
.header-brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; font-size: 1rem; }

.board-select {
    max-width: 200px;
    padding: 0.375rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.8125rem;
}

.view-switcher { display: flex; gap: 2px; background: var(--bg-surface); border-radius: var(--radius); padding: 2px; }
.view-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition);
}
.view-btn:hover { color: var(--text); }
.view-btn.active { background: var(--primary-soft); color: var(--primary); }

.search-input {
    width: 180px;
    padding: 0.375rem 0.75rem;
    font-size: 0.8125rem;
}

/* ── User Menu ── */
.user-menu { position: relative; }
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
}
.dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    min-width: 200px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    z-index: 100;
    padding: 0.375rem;
}
.dropdown-header { padding: 0.75rem; }
.dropdown-header strong { display: block; font-size: 0.875rem; }
.dropdown-header small { color: var(--text-secondary); font-size: 0.75rem; }
.dropdown-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-radius: 6px;
    color: var(--text);
    font-size: 0.8125rem;
    font-family: inherit;
    cursor: pointer;
}
.dropdown-item:hover { background: var(--bg-hover); }
.dropdown hr { border: none; border-top: 1px solid var(--border); margin: 0.375rem 0; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted); }

/* ── Main Content ── */
.app-main { flex: 1; overflow: auto; padding: 1rem; }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    gap: 1rem;
}
.empty-state h2 { font-size: 1.5rem; }
.empty-state p { color: var(--text-secondary); max-width: 400px; }

/* ── Grid View ── */
.grid-container { display: flex; flex-direction: column; height: 100%; }
.column-headers {
    display: grid;
    gap: 1px;
    padding-left: 60px;
    margin-bottom: 1px;
}
.column-header {
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    padding: 0.375rem;
    background: var(--bg-elevated);
    border-radius: 6px 6px 0 0;
}
.grid-body { display: flex; flex: 1; overflow: auto; }
.row-headers { display: flex; flex-direction: column; gap: 1px; width: 60px; flex-shrink: 0; }
.row-header {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-elevated);
    border-radius: 6px 0 0 6px;
    min-height: 80px;
}

.task-grid { display: grid; gap: 1px; flex: 1; align-content: start; }
.shape-pill .task-grid, .shape-pill .column-headers, .shape-pill .row-headers { gap: 3px; }
.shape-circle .task-grid, .shape-circle .column-headers, .shape-circle .row-headers { gap: 4px; }
.shape-rounded .task-grid, .shape-rounded .column-headers, .shape-rounded .row-headers { gap: 2px; }

.grid-cell {
    min-height: 80px;
    background: var(--bg-elevated);
    border-radius: 4px;
    padding: 0.5rem;
    cursor: pointer;
    transition: all var(--transition);
    position: relative;
    overflow: hidden;
    border: 1px solid transparent;
}
.grid-cell:hover { background: var(--bg-hover); border-color: var(--border); }
.grid-cell.has-task { border-left: 3px solid var(--cell-color, var(--color-default)); }
.grid-cell.dragging { opacity: 0.4; }
.grid-cell.drag-over { border-color: var(--primary); background: var(--primary-soft); }

.cell-title {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cell-meta { display: flex; align-items: center; gap: 0.375rem; margin-top: 0.375rem; flex-wrap: wrap; }
.cell-tag {
    font-size: 0.625rem;
    padding: 1px 6px;
    background: var(--primary-soft);
    color: var(--primary);
    border-radius: 100px;
    font-weight: 500;
}
.cell-due {
    font-size: 0.625rem;
    color: var(--text-muted);
}
.cell-due.overdue { color: var(--danger); }
.cell-check {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 16px;
    height: 16px;
    color: var(--success);
}
.cell-completed .cell-title { text-decoration: line-through; opacity: 0.6; }

/* ── List View ── */
.list-container { max-width: 700px; margin: 0 auto; width: 100%; }
.task-list { display: flex; flex-direction: column; gap: 2px; }
.task-list-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--bg-elevated);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition);
    border-left: 3px solid var(--cell-color, var(--color-default));
}
.task-list-item:hover { background: var(--bg-hover); }
.task-list-item .list-title { flex: 1; font-size: 0.875rem; }
.task-list-item .list-context { font-size: 0.75rem; color: var(--text-muted); }
.task-list-item .list-due { font-size: 0.75rem; color: var(--text-muted); }
.task-list-item.completed .list-title { text-decoration: line-through; opacity: 0.6; }

/* ── Kanban View ── */
.kanban-container { height: 100%; overflow-x: auto; }
.kanban-board { display: flex; gap: 1rem; height: 100%; padding-bottom: 1rem; }
.kanban-column {
    flex: 0 0 280px;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    max-height: 100%;
}
.kanban-column-header {
    padding: 0.75rem 1rem;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.kanban-column-header .count {
    background: var(--bg-surface);
    padding: 1px 8px;
    border-radius: 100px;
    font-size: 0.6875rem;
}
.kanban-cards { flex: 1; overflow-y: auto; padding: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.kanban-card {
    padding: 0.75rem;
    background: var(--bg-surface);
    border-radius: var(--radius);
    cursor: pointer;
    transition: all var(--transition);
    border-left: 3px solid var(--cell-color, var(--color-default));
}
.kanban-card:hover { background: var(--bg-hover); }
.kanban-card-title { font-size: 0.8125rem; font-weight: 500; margin-bottom: 0.375rem; }
.kanban-card-meta { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ── Color Picker ── */
.color-picker { display: flex; gap: 0.375rem; flex-wrap: wrap; }
.color-swatch {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.selected { border-color: white; box-shadow: 0 0 0 2px var(--primary); }

/* ── Modals ── */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.6); }
.modal-content {
    position: relative;
    width: 90%;
    max-width: 480px;
    max-height: 90vh;
    background: var(--bg-elevated);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modalIn 200ms ease;
}
.modal-lg { max-width: 640px; }
.modal-xl { max-width: 720px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 1.125rem; }
.modal-close {
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    border-radius: 6px;
}
.modal-close:hover { background: var(--bg-hover); color: var(--text); }
.modal-body { padding: 1.25rem; overflow-y: auto; }
.modal-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
}
.modal-footer-right { display: flex; gap: 0.5rem; margin-left: auto; }

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(10px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* ── Settings Tabs ── */
.settings-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    padding: 0 1.25rem;
    background: var(--bg-elevated);
}
.settings-tab {
    padding: 0.625rem 1rem;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition);
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

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

.form-hint { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; margin-top: -0.25rem; }

/* Title inputs */
.title-inputs { display: flex; flex-direction: column; gap: 0.375rem; max-height: 240px; overflow-y: auto; }
.title-input-row { display: flex; align-items: center; gap: 0.5rem; }
.title-input-row .title-label {
    width: 28px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}
.title-input-row input {
    flex: 1;
    padding: 0.375rem 0.625rem;
    font-size: 0.8125rem;
}

/* Border toggles */
.border-toggles { display: flex; flex-direction: column; gap: 0.25rem; max-height: 280px; overflow-y: auto; }
.border-toggle-row {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    transition: background var(--transition);
    user-select: none;
}
.border-toggle-row:hover { background: var(--bg-hover); }
.border-toggle-row input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; }
.border-toggle-label {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    flex: 1;
}
.border-preview {
    width: 40px;
    height: 0;
    border-top: 2px solid var(--primary);
    flex-shrink: 0;
}
.border-preview.solid { border-top-style: solid; }
.border-preview.dashed { border-top-style: dashed; }
.border-preview.dotted { border-top-style: dotted; }
.border-preview.double { border-top-style: double; border-top-width: 3px; }
.border-preview.thick { border-top-style: solid; border-top-width: 3px; }

/* Stripe color pickers */
.stripe-color-list { display: flex; flex-direction: column; gap: 0.375rem; max-height: 240px; overflow-y: auto; }
.stripe-color-row { display: flex; align-items: center; gap: 0.625rem; }
.stripe-color-row .stripe-label {
    width: 28px;
    text-align: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-shrink: 0;
}
.stripe-color-row input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    cursor: pointer;
}
.stripe-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.stripe-color-row input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.stripe-color-row .stripe-name { font-size: 0.8125rem; color: var(--text-secondary); flex: 1; }
.stripe-color-row .stripe-clear {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
}
.stripe-color-row .stripe-clear:hover { background: var(--bg-hover); color: var(--danger); }
.stripe-color-row input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; flex-shrink: 0; }

.bulk-color-bar {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.625rem;
    background: var(--bg-surface);
    border-radius: var(--radius);
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}
.bulk-color-bar input[type="color"] {
    width: 32px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    cursor: pointer;
    flex-shrink: 0;
}
.bulk-color-bar input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.bulk-color-bar input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.bulk-apply-btn { margin-top: 0.375rem; align-self: flex-start; }

/* Grid border rendering */
.grid-cell.border-right { border-right-width: 3px !important; border-right-style: solid !important; }
.grid-cell.border-bottom { border-bottom-width: 3px !important; border-bottom-style: solid !important; }
.grid-cell.border-dashed.border-right { border-right-style: dashed !important; }
.grid-cell.border-dashed.border-bottom { border-bottom-style: dashed !important; }
.grid-cell.border-dotted.border-right { border-right-style: dotted !important; }
.grid-cell.border-dotted.border-bottom { border-bottom-style: dotted !important; }
.grid-cell.border-double.border-right { border-right-style: double !important; border-right-width: 4px !important; }
.grid-cell.border-double.border-bottom { border-bottom-style: double !important; border-bottom-width: 4px !important; }
.grid-cell.border-thick.border-right { border-right-width: 5px !important; }
.grid-cell.border-thick.border-bottom { border-bottom-width: 5px !important; }

/* Font settings */
.font-preview {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
    line-height: 1.6;
    color: var(--text);
}
.font-color-row { display: flex; align-items: center; gap: 0.75rem; }
.font-color-row input[type="color"] {
    width: 40px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-surface);
    cursor: pointer;
}
.font-color-row input[type="color"]::-webkit-color-swatch-wrapper { padding: 2px; }
.font-color-row input[type="color"]::-webkit-color-swatch { border-radius: 4px; border: none; }
.font-color-hex { font-size: 0.8125rem; color: var(--text-secondary); font-family: 'JetBrains Mono', monospace; }

/* ── Analytics ── */
.analytics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
    background: var(--bg-surface);
    border-radius: var(--radius);
    padding: 1rem;
    text-align: center;
}
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); margin-top: 0.25rem; }
.analytics-section { margin-bottom: 1.5rem; }
.analytics-section h4 { font-size: 0.875rem; color: var(--text-secondary); margin-bottom: 0.75rem; }
.analytics-bar { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 0.5rem; }
.analytics-bar-label { width: 80px; font-size: 0.8125rem; text-align: right; color: var(--text-secondary); }
.analytics-bar-fill { height: 24px; border-radius: 4px; background: var(--primary); min-width: 2px; transition: width 300ms ease; }
.analytics-bar-value { font-size: 0.8125rem; color: var(--text-muted); }

/* ── Permissions ── */
.invite-row { display: flex; gap: 0.5rem; align-items: center; }
.invite-error { color: var(--danger); font-size: 0.8rem; margin-top: 0.375rem; }
.invite-row input[type="text"] { flex: 1 1 0; min-width: 0; width: auto; }
.invite-row select { flex: 0 0 auto; width: auto; }
.invite-results { margin-top: 0.5rem; }
.invite-result {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    background: var(--bg-surface);
    border-radius: var(--radius);
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
    cursor: pointer;
}
.invite-result:hover { background: var(--bg-hover); }
.permissions-list .perm-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.perm-item:last-child { border-bottom: none; }
.perm-user { font-size: 0.8125rem; }
.perm-user small { color: var(--text-muted); display: block; }
.perm-actions { display: flex; gap: 0.5rem; align-items: center; }
.perm-badge {
    font-size: 0.6875rem;
    padding: 2px 8px;
    border-radius: 100px;
    background: var(--primary-soft);
    color: var(--primary);
    font-weight: 500;
}
.perm-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    padding: 0 4px;
}
.perm-remove:hover { color: var(--danger); }

/* ── Templates ── */
.modal-lg { max-width: 760px; }
.modal-xl { max-width: 960px; }
.tmpl-search-wrap {
    display: flex; align-items: center; gap: 0.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 8px;
    padding: 0.375rem 0.75rem; flex: 1; max-width: 340px; margin: 0 1rem;
}
.tmpl-search-wrap svg { flex-shrink: 0; opacity: 0.5; }
.tmpl-search-wrap input {
    border: none !important; background: none !important; outline: none;
    font-size: 0.85rem; color: var(--text); width: 100%; padding: 0 !important;
}
.tmpl-search-wrap input::placeholder { color: var(--text-muted); opacity: 0.6; }
.tmpl-layout {
    display: flex; min-height: 480px; max-height: 72vh;
}
.tmpl-tabs {
    width: 200px; flex-shrink: 0; border-right: 1px solid var(--border);
    display: flex; flex-direction: column; padding: 0.5rem 0;
    overflow-y: auto; background: var(--bg);
}
.tmpl-tab {
    padding: 0.625rem 1rem; cursor: pointer; border: none; background: none;
    text-align: left; color: var(--text-muted); font-size: 0.85rem;
    font-weight: 500; border-left: 3px solid transparent;
    transition: all 0.15s; white-space: nowrap;
}
.tmpl-tab:hover { color: var(--text); background: var(--surface); }
.tmpl-tab.active {
    color: var(--primary); border-left-color: var(--primary);
    background: var(--surface);
}
.tmpl-tab .tmpl-tab-count {
    font-size: 0.7rem; color: var(--text-muted); margin-left: 0.25rem;
    opacity: 0.7;
}
.tmpl-content {
    flex: 1; overflow-y: auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 0.625rem;
}
.template-card {
    display: flex; align-items: flex-start; gap: 0.875rem;
    padding: 1rem 1.125rem; background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; transition: border-color 0.15s, box-shadow 0.15s;
}
.template-card:hover { border-color: var(--primary); box-shadow: 0 2px 12px rgba(99,102,241,0.08); }
.tmpl-card-left { flex-shrink: 0; }
.template-info { flex: 1; min-width: 0; }
.template-name-row { display: flex; align-items: center; gap: 0.5rem; margin-bottom: 2px; }
.template-name { font-weight: 600; color: var(--text); font-size: 0.95rem; }
.template-desc {
    font-size: 0.8rem; color: var(--text-muted); line-height: 1.4;
    margin-bottom: 6px;
}
.template-meta { font-size: 0.75rem; color: var(--text-muted); opacity: 0.7; }
.template-badges { display: flex; flex-wrap: wrap; align-items: center; gap: 0.375rem; margin-top: 0.375rem; }
.tmpl-badge {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 2px 8px; border-radius: 4px; font-size: 0.65rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.tmpl-badge-icon { font-size: 0.6rem; }
.badge-blue { background: rgba(99,102,241,0.15); color: #818cf8; }
.badge-green { background: rgba(52,211,153,0.15); color: #34d399; }
.badge-amber { background: rgba(251,191,36,0.15); color: #fbbf24; }
.badge-purple { background: rgba(168,85,247,0.15); color: #a855f7; }
.tmpl-cat-pill {
    display: inline-block; padding: 2px 8px; border-radius: 4px;
    font-size: 0.65rem; font-weight: 500; color: var(--text-muted);
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.08);
}
.tmpl-grid-size {
    font-size: 0.7rem; color: var(--text-muted); opacity: 0.7;
}
.tmpl-size-label { font-size: 0.6rem; opacity: 0.6; margin-left: 2px; }
.tmpl-tab-icon { margin-right: 0.375rem; font-size: 0.8rem; opacity: 0.7; }
.template-actions { display: flex; flex-direction: column; gap: 0.375rem; align-items: flex-end; flex-shrink: 0; }
.template-actions .btn-primary {
    font-size: 0.75rem; padding: 0.375rem 0.875rem; border-radius: 6px; white-space: nowrap;
}
.template-preview {
    width: 84px; height: 60px; flex-shrink: 0; border-radius: 6px;
    border: 1px solid var(--border); overflow: hidden;
    display: grid; gap: 1px; background: var(--border);
}
.template-preview-cell {
    background: var(--surface); min-width: 0; min-height: 0;
}
.template-actions { display: flex; gap: 0.375rem; flex-shrink: 0; align-self: center; }
.btn-outline {
    background: transparent; border: 1px solid var(--border); color: var(--text);
    padding: 0.375rem 0.75rem; border-radius: 6px; cursor: pointer;
    font-size: 0.8rem; transition: all 0.15s;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.templates-empty { text-align: center; padding: 2rem 1rem; color: var(--text-muted); }
.templates-empty p { margin: 0.5rem 0; }
.template-section-label {
    font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.06em; color: var(--text-muted); padding: 0.25rem 0;
}

/* ── Custom Fields ── */
.std-field-toggles {
    display: flex; flex-wrap: wrap; gap: 0.75rem 1.25rem; padding: 0.25rem 0;
}
.std-field-toggles .checkbox-label { font-size: 0.85rem; }
.custom-field-row {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.5rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    margin-bottom: 0.375rem;
}
.custom-field-row input[type="text"],
.custom-field-row select {
    padding: 0.3rem 0.5rem; font-size: 0.8rem; flex-shrink: 0;
}
.custom-field-row input[type="text"] { flex: 1; min-width: 80px; }
.custom-field-row select { width: 100px; }
.cf-options-input { flex: 2 !important; min-width: 120px; }
.cf-grid-toggle { flex-shrink: 0; display: flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; color: var(--text-muted); }
.cf-remove {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 1.1rem; padding: 0 4px; flex-shrink: 0;
}
.cf-remove:hover { color: var(--danger); }
.cell-custom { font-size: 0.65rem; color: var(--text-muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── Cell Mode Toggle ── */
.cell-mode-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.cell-mode-btn {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.5rem 1rem; font-size: 0.8rem; font-weight: 500;
    background: var(--surface); color: var(--text-muted);
    border: none; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.cell-mode-btn + .cell-mode-btn { border-left: 1px solid var(--border); }
.cell-mode-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.cell-mode-btn:hover:not(.active) { background: var(--bg); }

/* ── Spreadsheet Mode Cells ── */
.ss-cell { cursor: text; }
.ss-cell .ss-value {
    font-size: inherit; line-height: 1.3;
    display: block; width: 100%;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ss-input {
    width: 100% !important; height: 100%; min-height: 24px;
    padding: 2px 4px !important; margin: 0;
    font-size: inherit; font-family: inherit; color: var(--text);
    background: var(--bg-elevated); border: 2px solid var(--primary) !important;
    border-radius: 3px; outline: none;
    position: absolute; inset: 0; z-index: 5;
}
.ss-cell { position: relative; }

/* ── Multi-entry Mode ── */
.me-cell { cursor: pointer; position: relative; overflow: visible; }
.me-cell:not(.has-task)::after {
    content: '+ add entries';
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.72rem; color: var(--text-muted); opacity: 0;
    transition: opacity 0.15s;
}
.me-cell:not(.has-task):hover::after { opacity: 0.6; }
.me-chips {
    display: flex; flex-wrap: wrap; gap: 4px;
    align-items: flex-start; padding: 3px;
    width: 100%; overflow-y: auto; max-height: 100%;
}
.me-chip {
    display: inline-flex; align-items: center; gap: 3px;
    padding: 3px 8px; font-size: 0.74rem; line-height: 1.35;
    font-weight: 500;
    background: var(--primary-soft, rgba(99,102,241,0.15));
    border: 1px solid rgba(99,102,241,0.25);
    border-radius: 6px; color: var(--text);
    max-width: 100%; cursor: pointer;
    transition: background 0.12s, border-color 0.12s, transform 0.1s;
}
.me-chip:hover {
    background: rgba(99,102,241,0.25);
    border-color: rgba(99,102,241,0.4);
    transform: translateY(-1px);
}
.me-chip-count {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    font-size: 0.65rem; font-weight: 700;
    background: var(--primary); color: #fff;
    border-radius: 9px; margin-left: auto; flex-shrink: 0;
}
.me-chip-edit {
    background: rgba(99,102,241,0.18);
    border-color: rgba(99,102,241,0.35);
}
.me-chip-edit .me-chip-text { cursor: pointer; }
.me-chip-edit .me-chip-text:hover { text-decoration: underline; }
.me-chip-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-chip-x {
    background: none; border: none; color: inherit; opacity: 0.4;
    cursor: pointer; padding: 0 2px; font-size: 0.95rem; line-height: 1;
    flex-shrink: 0; transition: opacity 0.1s, color 0.1s;
}
.me-chip-x:hover { opacity: 1; color: #ff6b6b; }

.me-editor {
    position: absolute; inset: 0; z-index: 10;
    background: var(--bg-elevated); border: 2px solid var(--primary);
    border-radius: 6px; padding: 6px;
    display: flex; flex-direction: column; gap: 5px;
    overflow-y: auto; min-height: 100%;
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}
.me-edit-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.me-add-input {
    width: 100% !important; padding: 5px 8px !important;
    font-size: 0.78rem; font-family: inherit;
    background: rgba(255,255,255,0.06); border: 1px solid var(--border) !important;
    border-radius: 5px; color: var(--text); outline: none;
    margin-top: auto;
}
.me-add-input::placeholder { color: var(--text-muted); opacity: 0.6; }
.me-add-input:focus { border-color: var(--primary) !important; background: rgba(255,255,255,0.1); }
.me-open-form-btn {
    width: 100%; padding: 4px 8px;
    font-size: 0.7rem; font-family: inherit; font-weight: 500;
    background: rgba(99,102,241,0.12); color: var(--primary);
    border: 1px dashed rgba(99,102,241,0.35); border-radius: 5px;
    cursor: pointer; transition: background 0.12s, border-color 0.12s;
    margin-top: 2px;
}
.me-open-form-btn:hover { background: rgba(99,102,241,0.22); border-color: var(--primary); }

/* ── Cell Style Toggles (Board Settings) ── */
.cell-style-toggle { display: flex; gap: 0; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; width: fit-content; }
.cs-btn {
    display: flex; align-items: center; gap: 0.375rem;
    padding: 0.45rem 0.75rem; font-size: 0.75rem; font-weight: 500;
    background: var(--surface); color: var(--text-muted);
    border: none; cursor: pointer; transition: background 0.15s, color 0.15s;
}
.cs-btn + .cs-btn { border-left: 1px solid var(--border); }
.cs-btn.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.cs-btn:hover:not(.active) { background: var(--bg); }

/* ── Cell Ratio ── */
.ratio-square .grid-cell, .ratio-square .row-header { min-height: 80px; }
.ratio-square .col-header, .ratio-square .column-header { min-height: auto; }
.ratio-wide .grid-cell, .ratio-wide .row-header { min-height: 48px; }
.ratio-wide .col-header, .ratio-wide .column-header { padding-top: 0.25rem; padding-bottom: 0.25rem; }
.ratio-tall .grid-cell, .ratio-tall .row-header { min-height: 120px; }
.ratio-compact .grid-cell, .ratio-compact .row-header { min-height: 36px; padding: 0.25rem 0.375rem; font-size: 0.7rem; }
.ratio-compact .col-header, .ratio-compact .column-header { padding: 0.25rem 0.375rem; font-size: 0.65rem; }
.ratio-compact .cell-title { font-size: 0.7rem; }
.ratio-compact .cell-meta { font-size: 0.55rem; }
.ratio-compact .me-chip { font-size: 0.62rem; padding: 2px 5px; }
.ratio-compact .me-chips { gap: 3px; padding: 2px; }

/* ── Cell Shape ── */
.shape-sharp .grid-cell, .shape-sharp .col-header, .shape-sharp .column-header, .shape-sharp .row-header { border-radius: 0; }
.shape-rounded .grid-cell { border-radius: 8px; }
.shape-rounded .col-header, .shape-rounded .column-header { border-radius: 8px 8px 0 0; }
.shape-rounded .row-header { border-radius: 8px 0 0 8px; }
.shape-pill .grid-cell { border-radius: 50px; padding-left: 0.75rem; padding-right: 0.75rem; }
.shape-pill .col-header, .shape-pill .column-header { border-radius: 50px; }
.shape-pill .row-header { border-radius: 50px; }
.shape-circle .grid-cell {
    border-radius: 50%; aspect-ratio: 1;
    display: flex; align-items: center; justify-content: center;
    text-align: center; overflow: hidden; padding: 0.375rem;
}
.shape-circle .col-header, .shape-circle .column-header { border-radius: 50%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 0.25rem; }
.shape-circle .row-header { border-radius: 50%; aspect-ratio: 1; display: flex; align-items: center; justify-content: center; padding: 0.25rem; }
.shape-circle .grid-cell .cell-title,
.shape-circle .grid-cell .ss-value,
.shape-circle .grid-cell .me-chips { font-size: 0.65rem; line-height: 1.2; }

/* ── Cell Character ── */
.char-flat .grid-cell { background: var(--bg-elevated); }
.char-card .grid-cell, .char-card .col-header, .char-card .column-header, .char-card .row-header {
    box-shadow: 0 2px 6px rgba(0,0,0,0.25), 0 1px 2px rgba(0,0,0,0.15);
    border: 1px solid rgba(255,255,255,0.04);
}
.char-card .grid-cell { background: var(--bg-elevated); }
.char-card .grid-cell:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.35), 0 2px 4px rgba(0,0,0,0.2);
    transform: translateY(-1px);
}
.char-outlined .grid-cell, .char-outlined .col-header, .char-outlined .column-header, .char-outlined .row-header {
    background: transparent;
    border: 1.5px solid var(--border);
}
.char-outlined .grid-cell:hover { border-color: var(--primary); }
.char-glass .grid-cell, .char-glass .col-header, .char-glass .column-header, .char-glass .row-header {
    background: rgba(255,255,255,0.04);
    backdrop-filter: blur(8px);
    border: 1px solid rgba(255,255,255,0.08);
}
.char-glass .grid-cell:hover { background: rgba(255,255,255,0.07); }

/* ── Board Dashboard View ── */
.dashboard-container { padding: 1.5rem; overflow-y: auto; }
.board-dashboard { max-width: 1100px; margin: 0 auto; }
.dash-title { font-size: 1.35rem; font-weight: 700; color: var(--text); margin: 0 0 1.25rem; }
.dash-stats {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 0.75rem; margin-bottom: 1.5rem;
}
.dash-stat {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem;
    display: flex; flex-direction: column; gap: 0.2rem;
}
.dash-stat .ds-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.dash-stat .ds-label { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; font-weight: 600; }
.dash-stat.ds-primary .ds-value { color: var(--primary); }
.dash-stat.ds-success .ds-value { color: #22c55e; }
.dash-stat.ds-warn .ds-value { color: #f59e0b; }
.dash-stat.ds-danger .ds-value { color: #ef4444; }

.dash-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 1rem; }
.dash-panel {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1rem;
}
.dash-panel-full { grid-column: 1 / -1; }
.dash-panel h4 { font-size: 0.85rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.03em; margin: 0 0 0.75rem; }
.dash-bar-list { display: flex; flex-direction: column; gap: 0.5rem; }
.dash-bar-item { display: flex; align-items: center; gap: 0.5rem; }
.dash-bar-label { width: 90px; font-size: 0.8rem; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex-shrink: 0; }
.dash-bar-track { flex: 1; height: 20px; background: var(--bg); border-radius: 6px; overflow: hidden; position: relative; }
.dash-bar-fill { height: 100%; border-radius: 6px; transition: width 0.3s ease; min-width: 2px; }
.dash-bar-count { width: 32px; text-align: right; font-size: 0.8rem; font-weight: 600; color: var(--text-muted); flex-shrink: 0; }
.dash-progress-ring { display: flex; align-items: center; justify-content: center; gap: 1rem; padding: 0.5rem 0; }
.dash-progress-ring svg { flex-shrink: 0; }
.dash-progress-label { font-size: 0.9rem; color: var(--text); }
.dash-progress-pct { font-size: 2rem; font-weight: 700; color: var(--primary); }

.dash-heatmap { display: grid; gap: 2px; }
.dash-heat-cell {
    aspect-ratio: 1; border-radius: 3px;
    background: var(--bg); position: relative;
}
.dash-heat-cell[title]:hover { outline: 2px solid var(--primary); z-index: 1; }

.dash-recent { max-height: 220px; overflow-y: auto; }
.dash-recent-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.375rem 0; border-bottom: 1px solid var(--border);
    font-size: 0.8rem;
}
.dash-recent-item:last-child { border-bottom: none; }
.dash-recent-date { color: var(--text-muted); font-size: 0.75rem; }

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

/* ── Reports Modal ── */
.modal-reports { max-width: 640px; }
.report-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.report-card {
    display: flex; gap: 1rem; padding: 1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.report-card:hover { border-color: var(--primary); background: var(--primary-soft); }
.report-card-icon {
    flex-shrink: 0; width: 48px; height: 48px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); border-radius: 10px; color: var(--primary);
}
.report-card-body h4 { margin: 0 0 0.25rem; font-size: 0.9rem; font-weight: 600; color: var(--text); }
.report-card-body p { margin: 0; font-size: 0.78rem; color: var(--text-muted); line-height: 1.4; }
.report-cards-sm { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 0.75rem; }
.report-cards-sm .report-card { flex-direction: column; gap: 0.625rem; padding: 0.875rem; }
.report-cards-sm .report-card-icon { width: 40px; height: 40px; border-radius: 8px; }
.report-cards-sm .report-card-body h4 { font-size: 0.82rem; }
.report-cards-sm .report-card-body p { font-size: 0.72rem; }

/* ── Messages ── */
.modal-messages { max-width: 560px; }
.msg-body { display: flex; flex-direction: column; padding: 0 !important; height: 460px; max-height: 65vh; }
.messages-feed {
    flex: 1; overflow-y: auto; padding: 1rem;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.msg-item {
    display: flex; gap: 0.625rem; padding: 0.5rem 0;
    border-bottom: 1px solid var(--border);
}
.msg-item:last-child { border-bottom: none; }
.msg-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    background: var(--primary-soft); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 0.8rem;
}
.msg-content { flex: 1; min-width: 0; }
.msg-header { display: flex; align-items: baseline; gap: 0.5rem; margin-bottom: 2px; }
.msg-author { font-weight: 600; font-size: 0.85rem; color: var(--text); }
.msg-time { font-size: 0.7rem; color: var(--text-muted); }
.msg-text { font-size: 0.85rem; color: var(--text); line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.msg-delete {
    background: none; border: none; color: var(--text-muted); cursor: pointer;
    font-size: 0.8rem; padding: 0; opacity: 0; transition: opacity 0.15s;
    align-self: flex-start;
}
.msg-item:hover .msg-delete { opacity: 1; }
.msg-delete:hover { color: var(--danger); }
.msg-compose {
    display: flex; gap: 0.5rem; padding: 0.75rem 1rem;
    border-top: 1px solid var(--border); background: var(--bg); flex-shrink: 0;
    align-items: flex-end;
}
.msg-compose textarea {
    flex: 1; resize: none; min-height: 36px; max-height: 100px;
    padding: 0.5rem 0.75rem; font-size: 0.85rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text);
    font-family: inherit;
}
.msg-compose textarea:focus { border-color: var(--primary); outline: none; }
.msg-empty { text-align: center; padding: 3rem 1rem; color: var(--text-muted); }
.msg-empty p { margin: 0.375rem 0; }
.msg-load-more {
    text-align: center; padding: 0.5rem;
}
.msg-load-more button {
    background: none; border: none; color: var(--primary); cursor: pointer;
    font-size: 0.8rem; text-decoration: underline;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Responsive ── */
@media (max-width: 768px) {
    .search-input { width: 120px; }
    .header-brand span { display: none; }
    .board-select { max-width: 140px; }
    .grid-cell { min-height: 64px; padding: 0.375rem; }
    .cell-title { font-size: 0.75rem; }
}

/* ── Toast Notifications ── */
.toast-container {
    position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 9999;
    display: flex; flex-direction: column-reverse; gap: 0.5rem; pointer-events: none;
}
.toast {
    pointer-events: all; display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem; border-radius: 10px; font-size: 0.85rem;
    color: #fff; min-width: 280px; max-width: 420px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25); animation: toastIn 0.3s ease;
    cursor: pointer;
}
.toast.removing { animation: toastOut 0.3s ease forwards; }
.toast-success { background: #059669; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #6366f1; }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.toast-msg { flex: 1; line-height: 1.4; }
@keyframes toastIn { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateX(40px); } }

/* ══════════════════════════════════
   ADMIN AREA
   ══════════════════════════════════ */
.admin-layout { display: flex; height: 100vh; background: var(--bg); }

.admin-sidebar {
    width: 230px; flex-shrink: 0; background: var(--bg-elevated);
    border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.admin-brand {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 1.25rem 1rem; font-weight: 700; font-size: 1.1rem;
    color: var(--primary); border-bottom: 1px solid var(--border);
}
.admin-nav { flex: 1; padding: 0.5rem 0.5rem; display: flex; flex-direction: column; gap: 2px; }
.admin-nav-item {
    display: flex; align-items: center; gap: 0.625rem;
    padding: 0.6rem 0.875rem; font-size: 0.85rem; font-weight: 500;
    color: var(--text-secondary); background: none; border: none;
    cursor: pointer; width: 100%; text-align: left;
    transition: background 0.15s, color 0.15s; border-radius: 8px;
}
.admin-nav-item:hover { background: var(--surface); color: var(--text); }
.admin-nav-item.active { background: var(--primary-soft); color: var(--primary); font-weight: 600; }
.admin-back {
    border-top: 1px solid var(--border); margin-top: auto;
    padding: 1rem; border-radius: 0; color: var(--text-muted);
}
.admin-back:hover { color: var(--primary); }

.admin-content { flex: 1; overflow-y: auto; padding: 2rem; min-width: 0; }
.admin-section { display: none; }
.admin-section.active { display: block; }
.admin-section h2 { margin: 0; font-size: 1.5rem; font-weight: 700; color: var(--text); }
.admin-section-header {
    display: flex; align-items: center; justify-content: space-between;
    flex-wrap: wrap; gap: 0.75rem; margin-bottom: 1.5rem;
}
.admin-section-header h2 { margin: 0; }
.admin-subtitle { font-size: 0.85rem; color: var(--text-muted); }
.admin-search {
    width: 240px; padding: 0.5rem 0.75rem;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--surface); color: var(--text); font-size: 0.85rem;
}
.admin-search:focus { border-color: var(--primary); outline: none; }
.admin-filter-row { display: flex; gap: 0.5rem; align-items: center; }
.admin-filter-select {
    padding: 0.5rem 0.625rem; font-size: 0.82rem; border: 1px solid var(--border);
    border-radius: 8px; background: var(--surface); color: var(--text);
}

/* Stat cards */
.admin-stats {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem; margin-bottom: 1.5rem;
}
.admin-stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 12px; padding: 1.25rem; display: flex; flex-direction: column; gap: 0.25rem;
    cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s;
}
.admin-stat-card:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(99,102,241,0.12); }
.stat-card-top { display: flex; align-items: center; justify-content: space-between; }
.stat-value { font-size: 2rem; font-weight: 700; color: var(--primary); line-height: 1; }
.stat-icon {
    width: 40px; height: 40px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
}
.stat-icon-users { background: rgba(99,102,241,0.12); color: var(--primary); }
.stat-icon-boards { background: rgba(16,185,129,0.12); color: #10b981; }
.stat-icon-tasks { background: rgba(245,158,11,0.12); color: #f59e0b; }
.stat-icon-templates { background: rgba(139,92,246,0.12); color: #8b5cf6; }
.stat-label {
    font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase;
    letter-spacing: 0.05em; font-weight: 600;
}
.stat-sub { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.125rem; }

/* Quick actions */
.admin-quick-actions { display: flex; gap: 0.75rem; margin-bottom: 2rem; flex-wrap: wrap; }
.admin-qa-btn {
    display: flex; align-items: center; gap: 0.5rem; padding: 0.625rem 1rem;
    border-radius: 8px; border: 1px solid var(--border); background: var(--surface);
    color: var(--text); font-size: 0.82rem; font-weight: 500; cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.admin-qa-btn:hover { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* Activity feed */
.admin-feed-title { font-size: 1rem; font-weight: 600; color: var(--text); margin: 0 0 0.75rem; }
.admin-activity-feed {
    display: flex; flex-direction: column; gap: 0; border: 1px solid var(--border);
    border-radius: 10px; overflow: hidden; max-height: 400px; overflow-y: auto;
}
.af-item {
    display: flex; align-items: flex-start; gap: 0.75rem; padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border); font-size: 0.82rem;
    transition: background 0.1s;
}
.af-item:last-child { border-bottom: none; }
.af-item:hover { background: var(--surface); }
.af-icon {
    width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem; flex-shrink: 0; margin-top: 2px;
}
.af-icon-created { background: rgba(16,185,129,0.12); color: #10b981; }
.af-icon-updated { background: rgba(99,102,241,0.12); color: var(--primary); }
.af-icon-deleted { background: rgba(220,38,38,0.12); color: #dc2626; }
.af-body { flex: 1; line-height: 1.5; color: var(--text); }
.af-user { font-weight: 600; }
.af-entity { font-weight: 500; color: var(--primary); }
.af-board { color: var(--text-muted); font-size: 0.75rem; }
.af-time { font-size: 0.72rem; color: var(--text-muted); white-space: nowrap; margin-top: 2px; }

/* Data tables */
.admin-table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.admin-table th {
    text-align: left; padding: 0.75rem 0.875rem;
    background: var(--bg-elevated); color: var(--text-muted);
    font-weight: 600; font-size: 0.72rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border);
    white-space: nowrap; position: sticky; top: 0; z-index: 1;
    cursor: pointer; user-select: none; transition: color 0.15s;
}
.admin-table th:hover { color: var(--primary); }
.admin-table th .sort-arrow { font-size: 0.65rem; margin-left: 3px; opacity: 0.5; }
.admin-table th .sort-arrow.active { opacity: 1; color: var(--primary); }
.admin-table td {
    padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border);
    color: var(--text); vertical-align: middle;
}
.admin-table tr:hover td { background: rgba(99,102,241,0.03); }
.admin-table .col-actions { white-space: nowrap; text-align: right; }
.admin-table select {
    width: auto; padding: 0.25rem 0.5rem; font-size: 0.8rem; border-radius: 6px;
}
.admin-table .btn-sm { padding: 0.25rem 0.625rem; font-size: 0.75rem; }

/* User avatar */
.admin-avatar {
    width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.8rem; color: #fff; flex-shrink: 0; text-transform: uppercase;
}

/* Inline edit */
.inline-edit {
    cursor: pointer; border-bottom: 1px dashed var(--border); padding-bottom: 1px;
    transition: border-color 0.15s;
}
.inline-edit:hover { border-color: var(--primary); }
.inline-edit-input {
    padding: 0.25rem 0.375rem; font-size: inherit; border: 1px solid var(--primary);
    border-radius: 4px; background: var(--surface); color: var(--text); width: 100%; min-width: 80px;
}

/* Admin badges */
.admin-badge {
    display: inline-flex; align-items: center; padding: 0.15rem 0.5rem;
    border-radius: 999px; font-size: 0.7rem; font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.admin-badge-admin { background: var(--primary-soft); color: var(--primary); }
.admin-badge-user { background: var(--surface); color: var(--text-muted); border: 1px solid var(--border); }

/* Status dot */
.status-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.status-dot-active { background: #10b981; }
.status-dot-stale { background: #f59e0b; }
.status-dot-inactive { background: var(--text-muted); opacity: 0.4; }

/* Clickable link in table */
.admin-link { color: var(--primary); cursor: pointer; text-decoration: none; }
.admin-link:hover { text-decoration: underline; }

/* Open board button */
.admin-open-btn {
    display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.2rem 0.5rem;
    font-size: 0.72rem; border-radius: 5px; border: 1px solid var(--border);
    background: none; color: var(--text-muted); cursor: pointer; transition: all 0.15s;
}
.admin-open-btn:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-soft); }

/* Pagination */
.admin-pagination {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.75rem 0; font-size: 0.8rem; color: var(--text-muted);
}
.admin-pagination-btns { display: flex; gap: 0.25rem; }
.admin-pagination-btns button {
    padding: 0.3rem 0.75rem; border: 1px solid var(--border); border-radius: 6px;
    background: var(--surface); color: var(--text); font-size: 0.78rem;
    cursor: pointer; transition: border-color 0.15s;
}
.admin-pagination-btns button:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.admin-pagination-btns button:disabled { opacity: 0.4; cursor: default; }
.admin-pagination-btns button.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* Permissions matrix */
.admin-perm-controls { display: flex; gap: 0.75rem; align-items: center; flex-wrap: wrap; }
.admin-perm-bulk { display: flex; gap: 0.5rem; align-items: center; }
.admin-perm-bulk select { width: auto; padding: 0.375rem 0.5rem; font-size: 0.8rem; }
.admin-matrix-wrap { overflow: auto; max-height: calc(100vh - 220px); border: 1px solid var(--border); border-radius: 10px; }
.perm-matrix { border-collapse: collapse; font-size: 0.8rem; min-width: 100%; }
.perm-matrix th, .perm-matrix td {
    padding: 0.375rem 0.5rem; border: 1px solid var(--border);
    text-align: center; white-space: nowrap;
}
.perm-matrix thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--bg-elevated); font-weight: 600;
    font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase;
}
.perm-matrix thead th.perm-board-col {
    max-width: 100px; overflow: hidden; text-overflow: ellipsis;
    writing-mode: vertical-rl; text-orientation: mixed;
    height: 100px; vertical-align: bottom;
}
.perm-matrix tbody th {
    position: sticky; left: 0; z-index: 1;
    background: var(--bg-elevated); text-align: left;
    font-weight: 500; color: var(--text); min-width: 180px;
}
.perm-matrix tbody tr:hover td { background: rgba(99,102,241,0.04); }
.perm-matrix td { background: var(--surface); }
.perm-matrix td.perm-owner { background: var(--primary-soft); color: var(--primary); font-weight: 700; font-size: 0.7rem; }

/* Permission pills (replacing dropdowns) */
.perm-pill {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 22px; border-radius: 5px; font-size: 0.65rem; font-weight: 700;
    cursor: pointer; transition: all 0.15s; border: 1px solid transparent; user-select: none;
}
.perm-pill:hover { transform: scale(1.15); }
.perm-pill-none { background: var(--bg); color: var(--text-muted); border-color: var(--border); }
.perm-pill-read { background: rgba(107,114,128,0.15); color: #6b7280; }
.perm-pill-write { background: rgba(59,130,246,0.15); color: #3b82f6; }
.perm-pill-admin { background: rgba(16,185,129,0.15); color: #10b981; }

.perm-matrix select {
    width: 70px; padding: 0.15rem 0.25rem; font-size: 0.75rem;
    border-radius: 4px; text-align: center;
}
.perm-matrix input[type="checkbox"] { width: auto; accent-color: var(--primary); cursor: pointer; }
.perm-check-col { width: 32px; }
.perm-matrix .perm-user-check { text-align: center; }

/* Template system toggle */
.tmpl-system-toggle {
    padding: 0.2rem 0.5rem; font-size: 0.72rem; border-radius: 5px;
    cursor: pointer; border: 1px solid var(--border); background: none; color: var(--text-muted);
    transition: all 0.15s;
}
.tmpl-system-toggle:hover { border-color: var(--primary); color: var(--primary); }
.tmpl-system-toggle.is-system { background: var(--primary-soft); color: var(--primary); border-color: var(--primary); }

/* Batch controls */
.admin-batch-bar {
    display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.75rem;
    background: var(--primary-soft); border-radius: 8px; margin-bottom: 0.75rem;
    font-size: 0.82rem; color: var(--primary);
}

/* ══════════════════════════════════
   STATUS BADGES
   ══════════════════════════════════ */

.status-badge {
    display: inline-flex; align-items: center; gap: 0.375rem;
    padding: 0.125rem 0.5rem;
    border-radius: 999px; font-size: 0.7rem; font-weight: 600;
    background: color-mix(in srgb, var(--status-color) 15%, transparent);
    color: var(--status-color);
    white-space: nowrap;
}
.status-dot {
    width: 7px; height: 7px; border-radius: 50%;
    background: var(--status-color);
    display: inline-block; flex-shrink: 0;
}

/* ══════════════════════════════════
   SPREADSHEET VIEW
   ══════════════════════════════════ */

.spreadsheet-container { padding: 0; overflow: auto; height: 100%; }
.spreadsheet-table-wrap { overflow: auto; height: 100%; }
.ss-table {
    width: 100%; border-collapse: collapse; font-size: 0.82rem;
    min-width: 800px;
}
.ss-table thead { position: sticky; top: 0; z-index: 2; }
.ss-table th {
    text-align: left; padding: 0.5rem 0.75rem;
    background: var(--bg-elevated); color: var(--text-muted);
    font-weight: 600; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.04em;
    border-bottom: 2px solid var(--border);
    white-space: nowrap; user-select: none;
}
.ss-table td {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    color: var(--text); vertical-align: middle;
}
.ss-row { cursor: pointer; transition: background 0.1s; }
.ss-row:hover td { background: var(--bg-hover); }
.ss-col-color { width: 28px; padding-right: 0; text-align: center; }
.ss-color-dot {
    width: 10px; height: 10px; border-radius: 50%;
    display: inline-block;
}
.ss-col-title { min-width: 180px; }
.ss-col-title strong { font-weight: 600; }
.ss-col-status { width: 120px; }
.ss-col-loc { width: 100px; color: var(--text-secondary); font-size: 0.78rem; }
.ss-col-context { color: var(--text-secondary); max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-col-tags { max-width: 180px; }
.ss-col-tags .cell-tag { font-size: 0.65rem; }
.ss-col-due { width: 90px; white-space: nowrap; }
.ss-due { font-size: 0.78rem; color: var(--text-secondary); }
.ss-due.overdue { color: var(--danger); font-weight: 600; }
.ss-col-assignee { width: 100px; color: var(--text-secondary); }

@media (max-width: 768px) {
    .ss-col-context, .ss-col-assignee { display: none; }
}

/* ══════════════════════════════════
   ORGANISATION SETTINGS
   ══════════════════════════════════ */

.org-settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1.25rem;
}
.org-card {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
}
.org-card-wide { grid-column: 1 / -1; }
.org-card-title {
    display: flex; align-items: center; gap: 0.5rem;
    font-size: 1rem; font-weight: 600; color: var(--text);
    margin: 0 0 1.25rem; padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.org-card-title svg { color: var(--primary); flex-shrink: 0; }
.org-field { margin-bottom: 1rem; }
.org-field:last-child { margin-bottom: 0; }
.org-field label {
    display: block; font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 0.375rem;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.org-field input[type="text"],
.org-select {
    width: 100%; padding: 0.5rem 0.75rem;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: var(--radius); color: var(--text);
    font-size: 0.875rem; font-family: inherit;
    transition: border-color var(--transition);
}
.org-field input[type="text"]:focus,
.org-select:focus {
    border-color: var(--primary); outline: none;
}
.org-select {
    appearance: none; cursor: pointer;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 12 12' fill='none' stroke='%239197b3' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M3 5l3 3 3-3'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 0.625rem center;
    padding-right: 2rem;
}
.org-hint {
    font-size: 0.75rem; color: var(--text-muted); margin-top: 0.25rem;
}

/* Logo upload */
.org-logo-upload {
    display: flex; align-items: center; gap: 1rem;
}
.org-logo-preview {
    width: 72px; height: 72px;
    border-radius: var(--radius-lg);
    background: var(--bg-surface);
    border: 2px dashed var(--border);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden; flex-shrink: 0;
    transition: border-color var(--transition);
}
.org-logo-preview:hover { border-color: var(--primary); }
.org-logo-preview img {
    width: 100%; height: 100%; object-fit: contain;
}
.org-logo-preview.has-logo {
    border-style: solid; border-color: var(--border);
}
.org-logo-actions {
    display: flex; flex-direction: column; gap: 0.375rem;
}

/* Theme presets */
.org-theme-presets {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 0.625rem;
}
.org-preset {
    position: relative;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0.625rem;
    cursor: pointer;
    transition: border-color var(--transition), transform 0.1s;
    background: none;
    text-align: left;
    width: 100%;
}
.org-preset:hover { border-color: var(--text-muted); transform: translateY(-1px); }
.org-preset.active { border-color: var(--primary); }
.org-preset.active::after {
    content: '✓';
    position: absolute; top: 4px; right: 6px;
    color: var(--primary); font-size: 0.75rem; font-weight: 700;
}
.org-preset-swatches {
    display: flex; gap: 3px; margin-bottom: 0.375rem;
}
.org-preset-swatch {
    width: 100%; height: 20px;
    border-radius: 3px;
}
.org-preset-name {
    font-size: 0.75rem; font-weight: 600;
    color: var(--text-secondary);
}

/* Color pickers */
.org-colors-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.875rem;
}
.org-color-field label {
    display: block; font-size: 0.75rem; font-weight: 600;
    color: var(--text-secondary); margin-bottom: 0.25rem;
}
.org-color-input-wrap {
    display: flex; align-items: center; gap: 0.5rem;
}
.org-color-picker {
    width: 36px; height: 36px; padding: 2px;
    border: 2px solid var(--border); border-radius: 8px;
    cursor: pointer; background: none;
    flex-shrink: 0;
}
.org-color-picker::-webkit-color-swatch-wrapper { padding: 0; }
.org-color-picker::-webkit-color-swatch { border: none; border-radius: 5px; }
.org-color-picker::-moz-color-swatch { border: none; border-radius: 5px; }
.org-color-hex {
    width: 80px; padding: 0.375rem 0.5rem;
    background: var(--bg-surface); border: 1px solid var(--border);
    border-radius: 6px; color: var(--text);
    font-size: 0.8rem; font-family: 'JetBrains Mono', monospace;
}
.org-color-hex:focus { border-color: var(--primary); outline: none; }

/* Slider */
.org-slider-wrap {
    display: flex; align-items: center; gap: 0.75rem;
}
.org-slider {
    flex: 1; -webkit-appearance: none; appearance: none;
    height: 6px; border-radius: 3px;
    background: var(--bg-surface); outline: none;
}
.org-slider::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary); cursor: pointer;
    border: 2px solid var(--bg-elevated);
    box-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.org-slider::-moz-range-thumb {
    width: 18px; height: 18px; border-radius: 50%;
    background: var(--primary); cursor: pointer;
    border: 2px solid var(--bg-elevated);
}
.org-slider-value {
    font-size: 0.8rem; font-weight: 600;
    color: var(--text-secondary); min-width: 32px;
    font-family: 'JetBrains Mono', monospace;
}

/* Live preview */
.org-theme-preview {
    border-radius: var(--radius-lg); overflow: hidden;
    border: 1px solid var(--border);
    background: var(--preview-bg, #0f1117);
    min-height: 180px;
}
.preview-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.625rem 0.875rem;
    background: var(--preview-elevated, #1a1d27);
    border-bottom: 1px solid var(--preview-border, #363b54);
}
.preview-logo {
    width: 24px; height: 24px; border-radius: 4px;
    background: var(--preview-primary, #6366f1);
}
.preview-nav { display: flex; gap: 6px; }
.preview-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--preview-border, #363b54);
}
.preview-body {
    display: flex; min-height: 120px;
}
.preview-sidebar {
    width: 48px; flex-shrink: 0;
    background: var(--preview-elevated, #1a1d27);
    border-right: 1px solid var(--preview-border, #363b54);
    padding: 0.5rem 0.375rem;
    display: flex; flex-direction: column; gap: 4px;
}
.preview-menu-item {
    height: 8px; border-radius: 3px;
    background: var(--preview-surface, #232736);
}
.preview-menu-item.active {
    background: var(--preview-primary, #6366f1);
    opacity: 0.7;
}
.preview-content {
    flex: 1; padding: 0.75rem;
    display: flex; flex-direction: column; gap: 0.5rem;
}
.preview-card {
    height: 36px; border-radius: 6px;
    background: var(--preview-surface, #232736);
    border: 1px solid var(--preview-border, #363b54);
}
.preview-card.sm { height: 24px; width: 60%; }
.preview-btn {
    width: 60px; height: 22px; border-radius: 4px;
    background: var(--preview-primary, #6366f1);
    margin-top: auto;
}

/* Save status */
.org-save-status {
    margin-top: 1rem; font-size: 0.85rem;
    min-height: 1.5em;
}
.org-save-status.success { color: var(--success); }
.org-save-status.error { color: var(--danger); }

/* Responsive admin (updated) */
@media (max-width: 1024px) {
    .org-settings-grid { grid-template-columns: 1fr; }
    .org-colors-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    .admin-sidebar { width: 56px; }
    .admin-brand span, .admin-nav-item span { display: none; }
    .admin-nav-item { justify-content: center; padding: 0.75rem; }
    .admin-content { padding: 1rem; }
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
    .org-colors-grid { grid-template-columns: repeat(2, 1fr); }
    .org-theme-presets { grid-template-columns: repeat(2, 1fr); }
    .org-logo-upload { flex-direction: column; align-items: flex-start; }
}

/* ── Assignee Picker ── */
.assignee-picker { position: relative; }
.assignee-results {
    position: absolute; top: 100%; left: 0; right: 0; z-index: 20;
    background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 6px;
    max-height: 160px; overflow-y: auto; box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.assignee-option {
    padding: 0.5rem 0.75rem; cursor: pointer; font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
}
.assignee-option:hover { background: var(--surface); }
.assignee-option.disabled { color: var(--text-muted); cursor: default; }
.assigned-user {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.375rem 0.625rem; background: var(--primary-soft);
    border-radius: 6px; font-size: 0.85rem; color: var(--primary);
}
.assigned-user button { font-size: 1.1rem; opacity: 0.6; }
.assigned-user button:hover { opacity: 1; }

/* ── Archive Toggle ── */
.archive-toggle {
    display: flex; align-items: center; gap: 0.25rem; cursor: pointer;
    color: var(--text-muted); font-size: 0.75rem; padding: 0.25rem 0.5rem;
    border-radius: 4px; transition: color 0.15s;
}
.archive-toggle:hover { color: var(--text); }
.archive-toggle input { width: 14px; height: 14px; cursor: pointer; }

/* ── Saved Views ── */
.saved-views-dropdown { position: relative; }
.saved-views-panel {
    position: absolute; top: 100%; right: 0; z-index: 30;
    width: 280px; background: var(--bg-elevated); border: 1px solid var(--border);
    border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,0.3); padding: 0.75rem;
}
.sv-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.5rem; font-size: 0.85rem; }
.sv-list { display: flex; flex-direction: column; gap: 0.25rem; max-height: 200px; overflow-y: auto; }
.sv-item { display: flex; align-items: center; gap: 0.375rem; }
.sv-load {
    flex: 1; text-align: left; padding: 0.375rem 0.5rem; border: none; background: none;
    color: var(--text); cursor: pointer; font-size: 0.8rem; border-radius: 4px;
}
.sv-load:hover { background: var(--surface); }
.sv-type { font-size: 0.65rem; color: var(--text-muted); background: var(--surface); padding: 1px 6px; border-radius: 3px; }
.sv-del { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 0.9rem; padding: 0 4px; }
.sv-del:hover { color: var(--danger); }

/* ── Board Notes ── */
#board-notes-text {
    width: 100%; min-height: 200px; padding: 0.75rem; font-size: 0.9rem;
    background: var(--surface); border: 1px solid var(--border); border-radius: 6px;
    color: var(--text); resize: vertical; font-family: inherit;
}

/* ── Notifications ── */
.notif-wrap { position: relative; }
.notif-bell { position: relative; }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    min-width: 16px; height: 16px; border-radius: 8px;
    background: var(--danger); color: #fff; font-size: 0.6rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    padding: 0 4px; line-height: 1;
}
.notif-panel {
    position: absolute; top: 100%; right: 0; z-index: 40;
    width: 340px; max-height: 420px; background: var(--bg-elevated);
    border: 1px solid var(--border); border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3); overflow: hidden;
}
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.85rem;
}
.notif-list { overflow-y: auto; max-height: 360px; }
.notif-item {
    padding: 0.75rem 1rem; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.15s;
}
.notif-item:hover { background: var(--surface); }
.notif-item.unread { border-left: 3px solid var(--primary); background: rgba(99,102,241,0.04); }
.notif-title { font-size: 0.82rem; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.notif-body { font-size: 0.75rem; color: var(--text-muted); line-height: 1.4; }
.notif-time { font-size: 0.65rem; color: var(--text-muted); margin-top: 4px; opacity: 0.7; }

/* ── Calendar View ── */
.calendar-container { padding: 1rem; max-width: 1000px; margin: 0 auto; }
.cal-header { display: flex; align-items: center; justify-content: center; gap: 1rem; margin-bottom: 1rem; }
.cal-title { margin: 0; font-size: 1.1rem; color: var(--text); min-width: 180px; text-align: center; }
.cal-nav { font-size: 1.5rem; padding: 0.25rem 0.75rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--border); border-radius: 8px; overflow: hidden; }
.cal-dow { background: var(--bg-elevated); padding: 0.5rem; text-align: center; font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.cal-day { background: var(--surface); min-height: 100px; padding: 0.375rem; display: flex; flex-direction: column; }
.cal-day.empty { background: var(--bg); opacity: 0.3; }
.cal-day.today { background: rgba(99,102,241,0.08); }
.cal-day.today .cal-date { background: var(--primary); color: #fff; border-radius: 50%; width: 24px; height: 24px; display: flex; align-items: center; justify-content: center; }
.cal-date { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); margin-bottom: 4px; }
.cal-tasks { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.cal-task { font-size: 0.7rem; padding: 2px 4px; background: var(--bg-elevated); border-radius: 3px; cursor: pointer; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: var(--text); border-left: 3px solid var(--primary); }
.cal-task:hover { background: var(--primary-soft); }
.cal-more { font-size: 0.65rem; color: var(--text-muted); padding: 1px 4px; }

/* ── Attachments ── */
.attachments-list { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 0.5rem; }
.att-item { display: flex; align-items: center; gap: 0.5rem; padding: 0.375rem 0.5rem; background: var(--surface); border-radius: 6px; font-size: 0.8rem; }
.att-thumb { width: 32px; height: 32px; object-fit: cover; border-radius: 4px; }
.att-name { flex: 1; color: var(--primary); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att-name:hover { text-decoration: underline; }
.att-size { font-size: 0.7rem; color: var(--text-muted); }
.att-del { border: none; background: none; color: var(--text-muted); cursor: pointer; font-size: 1rem; padding: 0 4px; }
.att-del:hover { color: var(--danger); }
.attachment-upload { display: flex; align-items: center; gap: 0.5rem; }

/* ── Comments ── */
.comments-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 200px; overflow-y: auto; margin-bottom: 0.5rem; padding-right: 0.25rem; }
.comment-item { padding: 0.5rem; background: var(--surface); border-radius: 6px; }
.comment-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.25rem; font-size: 0.75rem; }
.comment-meta strong { color: var(--text); }
.comment-text { font-size: 0.82rem; color: var(--text); line-height: 1.4; }
.comment-input-row { display: flex; gap: 0.375rem; }
.comment-input-row input { flex: 1; }

/* ── Activity Log ── */
.activity-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 500px; overflow-y: auto; }
.activity-item { display: flex; gap: 0.75rem; padding: 0.5rem; border-radius: 6px; background: var(--surface); }
.activity-icon { font-size: 1rem; flex-shrink: 0; width: 24px; text-align: center; }
.activity-detail { flex: 1; font-size: 0.82rem; color: var(--text); line-height: 1.4; }
.activity-time { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

.auth-divider { display: flex; align-items: center; gap: 0.75rem; margin: 1rem 0; color: var(--text-muted); font-size: 0.8rem; }
.auth-divider::before, .auth-divider::after { content: ''; flex: 1; border-top: 1px solid var(--border); }
.btn-google { display: flex; align-items: center; justify-content: center; gap: 0.5rem; width: 100%; padding: 0.625rem; }

/* ── Mobile Responsive ── */
@media (max-width: 768px) {
    .app-header { flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem; }
    .header-left { width: 100%; justify-content: space-between; }
    .header-right { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 0.5rem; }
    .view-switcher { order: 1; }
    .search-box { order: 2; flex: 1; min-width: 120px; }

    .board-select { max-width: 140px; font-size: 0.8rem; }

    .modal-content { width: 95vw !important; max-width: 95vw !important; margin: 0.5rem; max-height: 90vh; }
    .modal-xl { width: 95vw !important; }

    #grid-container { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .task-grid { min-width: max-content; }

    .column-headers { min-width: max-content; position: sticky; top: 0; z-index: 5; }
    .row-headers { position: sticky; left: 0; z-index: 4; }

    .sidebar { width: 100% !important; max-width: 100% !important; }

    .saved-views-panel { width: 260px; right: -40px; }
    .notif-panel { width: 300px; right: -20px; }

    .cal-grid { font-size: 0.75rem; }
    .cal-day { min-height: 60px; padding: 0.25rem; }
    .cal-task { font-size: 0.6rem; }

    .dropdown { right: 0; left: auto; }

    .btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
}

@media (max-width: 480px) {
    .header-brand span { display: none; }
    .view-switcher { gap: 0; }
    .view-btn { padding: 0.375rem; }
    .search-box { display: none; }

    .cal-day { min-height: 40px; }
    .cal-task { display: none; }
    .cal-day.has-tasks::after { content: ''; display: block; width: 6px; height: 6px; border-radius: 50%; background: var(--primary); margin: 2px auto; }
}
