/* ============================================
   Flow – Design System
   Modern, clean project tracker UI
   ============================================ */

/* ---------- CSS Variables ---------- */
:root {
    --bg-primary: #0f1117;
    --bg-secondary: #161822;
    --bg-card: #1c1e2e;
    --bg-card-hover: #232538;
    --bg-input: #1c1e2e;
    --bg-sidebar: #12131f;

    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --text-link: #818cf8;

    --border-color: #2a2d3e;
    --border-hover: #3d4055;

    --indigo: #6366f1;
    --indigo-soft: rgba(99, 102, 241, 0.15);
    --purple: #8b5cf6;
    --emerald: #10b981;
    --emerald-soft: rgba(16, 185, 129, 0.15);
    --amber: #f59e0b;
    --amber-soft: rgba(245, 158, 11, 0.15);
    --rose: #f43f5e;
    --rose-soft: rgba(244, 63, 94, 0.15);
    --sky: #0ea5e9;

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.3);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.4);

    --sidebar-width: 260px;
    --transition: 0.2s ease;
}

/* ---------- Reset ---------- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--text-link);
    text-decoration: none;
    transition: color var(--transition);
}
a:hover {
    color: var(--indigo);
    text-decoration: underline;
}

/* ---------- App Shell ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.app-shell.no-sidebar .main-content {
    margin-left: 0;
    width: 100%;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 20px 16px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    gap: 2px;
}

.nav-group-label {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 16px 14px 4px;
}
.nav-group-label:first-child {
    padding-top: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--transition);
    text-decoration: none !important;
}
.nav-item:hover {
    background: var(--bg-card);
    color: var(--text-primary);
    text-decoration: none;
}
.nav-item.active {
    background: var(--indigo-soft);
    color: var(--indigo);
}

.nav-icon {
    font-size: 1.1rem;
    width: 24px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.user-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: var(--indigo);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.btn-logout {
    width: 100%;
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    transition: all var(--transition);
}
.btn-logout:hover {
    background: var(--rose-soft);
    border-color: var(--rose);
    color: var(--rose);
}

/* ---------- Main Content ---------- */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
    min-height: 100vh;
}

/* ---------- Page Header ---------- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    margin-bottom: 2px;
}

.page-subtitle {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.back-link {
    font-size: 0.85rem;
    color: var(--text-muted);
    display: inline-block;
    margin-bottom: 8px;
}
.back-link:hover { color: var(--text-link); }

/* ---------- Stats Grid ---------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}
.stats-grid-sm { margin-bottom: 32px; }

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    transition: all var(--transition);
}
.stat-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.stat-icon { font-size: 1.8rem; }
.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    display: block;
    line-height: 1.2;
}
.stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-indigo .stat-value { color: var(--indigo); }
.stat-amber .stat-value { color: var(--amber); }
.stat-emerald .stat-value { color: var(--emerald); }
.stat-rose .stat-value { color: var(--rose); }

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
    transition: all var(--transition);
}
.card:hover { border-color: var(--border-hover); }

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}
.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-body { padding: 12px 20px; }

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

/* ---------- Project Row (dashboard) ---------- */
.project-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
}
.project-row:last-child { border-bottom: none; }
.project-row:hover { background: var(--bg-card-hover); padding-left: 4px; text-decoration: none; }

.project-color {
    width: 4px;
    height: 32px;
    border-radius: 2px;
    flex-shrink: 0;
}

.project-row-info { flex: 1; min-width: 0; }
.project-row-name { font-weight: 500; display: block; font-size: 0.9rem; }
.project-row-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Task Row (dashboard) ---------- */
.task-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
    text-decoration: none;
    color: var(--text-primary);
    transition: all var(--transition);
}
.task-row:hover { background: var(--bg-card-hover); padding-left: 4px; text-decoration: none; }
.task-row:last-child { border-bottom: none; }

.task-priority {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.priority-low { background: var(--emerald); }
.priority-medium { background: var(--amber); }
.priority-high { background: #f97316; }
.priority-critical { background: var(--rose); }

.task-row-info { flex: 1; min-width: 0; }
.task-row-title { font-weight: 500; font-size: 0.9rem; display: block; }
.task-row-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Dashboard Drag-and-Drop ---------- */
.project-row-wrap, .task-row-wrap {
    display: flex;
    align-items: center;
    gap: 0;
    border-bottom: 1px solid var(--border-color);
}
.project-row-wrap:last-child, .task-row-wrap:last-child { border-bottom: none; }
.project-row-wrap .project-row, .task-row-wrap .task-row { border-bottom: none; flex: 1; min-width: 0; }
.dash-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1rem;
    opacity: 0.3;
    transition: opacity 0.15s, color 0.15s;
    user-select: none;
    padding: 8px 6px 8px 2px;
    flex-shrink: 0;
    line-height: 1;
}
.dash-drag-handle:hover { opacity: 1; color: var(--indigo); }
.dash-drag-handle:active { cursor: grabbing; }
.dash-drag-over {
    border-top: 2px solid var(--indigo) !important;
}
.dash-drag-over .project-row,
.dash-drag-over .task-row {
    background: rgba(99, 102, 241, 0.06);
}

/* ---------- Reminder Row (dashboard) ---------- */
.reminder-row {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.reminder-row:last-child { border-bottom: none; }
.reminder-overdue { color: var(--rose); }
.reminder-row-title { font-weight: 500; font-size: 0.9rem; display: block; }
.reminder-row-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ---------- Story Row (dashboard) ---------- */
.story-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}
.story-row:last-child { border-bottom: none; }
.story-row-info { flex: 1; }
.story-row-title { font-weight: 500; font-size: 0.9rem; display: block; }
.story-row-meta { font-size: 0.75rem; color: var(--text-muted); }

.story-impact {
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.impact-low { background: rgba(100,116,139,0.2); color: #94a3b8; }
.impact-medium { background: var(--amber-soft); color: var(--amber); }
.impact-high { background: rgba(249,115,22,0.15); color: #f97316; }
.impact-transformational { background: var(--rose-soft); color: var(--rose); }

/* ---------- Badges ---------- */
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}
.badge-lg { padding: 4px 14px; font-size: 0.8rem; }

.badge-planning { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-active { background: var(--emerald-soft); color: var(--emerald); }
.badge-onhold { background: var(--amber-soft); color: var(--amber); }
.badge-completed { background: var(--indigo-soft); color: var(--indigo); }
.badge-archived { background: rgba(100,116,139,0.15); color: #94a3b8; }

.badge-backlog { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-todo { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-inprogress { background: var(--indigo-soft); color: var(--indigo); }
.badge-inreview { background: var(--amber-soft); color: var(--amber); }
.badge-done { background: var(--emerald-soft); color: var(--emerald); }

.badge-notstarted { background: rgba(100,116,139,0.15); color: #94a3b8; }
.badge-achieved { background: var(--emerald-soft); color: var(--emerald); }
.badge-missed { background: var(--rose-soft); color: var(--rose); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    text-decoration: none;
}
.btn:hover { text-decoration: none; }

.btn-primary {
    background: var(--indigo);
    color: white;
}
.btn-primary:hover { background: #5558e6; transform: translateY(-1px); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-ghost:hover { background: var(--bg-card-hover); border-color: var(--border-hover); color: var(--text-primary); }

.btn-danger-ghost {
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}
.btn-danger-ghost:hover { background: var(--rose-soft); color: var(--rose); }

.btn-danger {
    background: var(--rose);
    color: #fff;
    border: 1px solid var(--rose);
}
.btn-danger:hover { background: #e11d48; border-color: #e11d48; }

.btn-sm { padding: 5px 12px; font-size: 0.78rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    transition: background var(--transition);
    color: var(--text-secondary);
}
.btn-icon:hover { background: var(--bg-card-hover); }
.btn-icon-danger:hover { background: var(--rose-soft); }

.link-btn {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-link);
}

.link-subtle {
    color: var(--text-muted);
    font-size: 0.8rem;
}
.link-subtle:hover { color: var(--text-link); }

/* ---------- Filter Tabs ---------- */
.filter-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.filter-tab {
    background: none;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 16px;
    border-radius: 99px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}
.filter-tab:hover { border-color: var(--border-hover); color: var(--text-primary); }
.filter-tab.active {
    background: var(--indigo);
    border-color: var(--indigo);
    color: white;
}

.filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}
.filter-group {
    display: flex;
    gap: 8px;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 16px;
    flex: 1;
}

.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.label-with-hint {
    display: flex !important;
    align-items: baseline;
    gap: 8px;
}
.label-with-hint small {
    text-transform: none;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: 0;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: inherit;
    transition: border-color var(--transition);
}
.form-input:focus {
    outline: none;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px var(--indigo-soft);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input-sm { padding: 6px 10px; font-size: 0.82rem; }

select.form-input { cursor: pointer; }
textarea.form-input { resize: vertical; min-height: 60px; }

.form-row {
    display: flex;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-top: 16px;
}

.flex-2 { flex: 2; }

/* ---------- Color Picker ---------- */
.color-picker {
    display: flex;
    gap: 8px;
    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.active { border-color: white; box-shadow: 0 0 0 2px var(--indigo); }

/* ---------- Modal ---------- */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 28px 32px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}
.modal-lg { max-width: 720px; }

.modal-card h2 {
    font-size: 1.25rem;
    font-weight: 700;
    margin-bottom: 20px;
}

/* ---------- Inline Form ---------- */
.inline-form {
    margin-bottom: 20px;
}

/* ---------- Projects Grid ---------- */
.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
}

.project-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    cursor: pointer;
    transition: all var(--transition);
}
.project-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.project-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}
.project-card-header h3 { font-size: 1.05rem; font-weight: 600; }

.project-card-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 14px;
    line-height: 1.5;
}

.project-card-stats {
    display: flex;
    gap: 16px;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.project-card-due {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.project-card-actions {
    display: flex;
    gap: 8px;
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    margin-top: 8px;
}

/* ---------- Kanban Board ---------- */
.kanban-board {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 16px;
    margin-bottom: 32px;
}

.kanban-column {
    min-width: 220px;
    flex: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
}

.kanban-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
}

.kanban-count {
    background: var(--bg-card);
    border-radius: 99px;
    padding: 1px 8px;
    font-size: 0.72rem;
}

.kanban-cards {
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    min-height: 80px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 12px;
    transition: all var(--transition);
}
.kanban-card:hover { border-color: var(--border-hover); }

.kanban-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}
.kanban-card-title { font-size: 0.85rem; font-weight: 500; }
.kanban-card-desc { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 6px; }
.kanban-card-due { font-size: 0.72rem; color: var(--text-muted); display: block; margin-bottom: 8px; }

.kanban-card-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
}

/* ---------- Task Table ---------- */
.task-table {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.task-table-header {
    display: flex;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.task-table-row {
    display: flex;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: background var(--transition);
}
.task-table-row:last-child { border-bottom: none; }
.task-table-row:hover { background: var(--bg-card-hover); }
.task-table-row.clickable { cursor: pointer; }

.task-table-item { border-bottom: 1px solid var(--border-color); }
.task-table-item:last-child { border-bottom: none; }
.task-table-item .task-table-row { border-bottom: none; }
.task-table-item.expanded {
    background: var(--bg-secondary);
    border: 1px solid var(--indigo);
    border-radius: var(--radius);
    margin: 8px 8px;
    box-shadow: 0 0 0 1px var(--indigo-soft), 0 4px 12px rgba(0,0,0,0.15);
}
.task-table-item.expanded .task-table-row {
    border-bottom: 1px solid var(--border-color);
}

.task-detail-panel {
    padding: 20px 24px;
    animation: slideDown 0.15s ease-out;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

.col-drag { width: 28px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.col-priority { width: 100px; display: flex; align-items: center; gap: 8px; font-size: 0.82rem; }

/* Drag handle */
.drag-handle {
    cursor: grab;
    color: var(--text-muted);
    font-size: 1.1rem;
    opacity: 0.4;
    transition: opacity 0.15s, color 0.15s;
    user-select: none;
    line-height: 1;
}
.drag-handle:hover { opacity: 1; color: var(--indigo); }
.drag-handle:active { cursor: grabbing; }

/* Drag-over visual */
.task-table-item.drag-over {
    border-top: 2px solid var(--indigo);
    margin-top: -1px;
}
.task-table-item.drag-over .task-table-row {
    background: rgba(99, 102, 241, 0.06);
}
.col-title { flex: 1; min-width: 0; }
.col-title strong { display: block; font-size: 0.9rem; font-weight: 500; }
.col-title small { color: var(--text-muted); font-size: 0.78rem; }
.col-project { width: 160px; }
.col-status { width: 140px; }
.col-due { width: 130px; font-size: 0.82rem; color: var(--text-secondary); }

/* ---------- Completed Tasks Section ---------- */
.completed-section {
    margin-top: 32px;
}
.completed-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 4px;
    cursor: pointer;
    transition: color var(--transition);
    width: 100%;
    text-align: left;
}
.completed-section-header:hover { color: var(--text-primary); }
.completed-toggle {
    font-size: 0.75rem;
    width: 16px;
    text-align: center;
}
.completed-count {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 600;
    padding: 1px 8px;
    border-radius: 99px;
}
.completed-task-table {
    opacity: 0.65;
    transition: opacity var(--transition);
}
.completed-task-table:hover { opacity: 0.9; }
.completed-task-table .col-title strong {
    text-decoration: line-through;
    text-decoration-color: var(--text-muted);
}

.badge-select {
    border: none;
    background: transparent;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 99px;
    cursor: pointer;
}

/* ---------- Goals ---------- */
.goals-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 16px;
}

.goal-card-full {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
}
.goal-card-full:hover { border-color: var(--border-hover); }

.goal-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}
.goal-card-header h3 { font-size: 1rem; font-weight: 600; }

.goal-desc {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 14px;
}

.goal-metrics {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 10px;
}

.goal-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}

/* Progress bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: var(--bg-primary);
    border-radius: 99px;
    overflow: hidden;
    margin-top: 8px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--indigo), var(--purple));
    border-radius: 99px;
    transition: width 0.4s ease;
}
.progress-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 4px;
    display: block;
}

.goals-list {
    display: grid;
    gap: 12px;
    margin-bottom: 32px;
}

.goal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
}
.goal-title { font-weight: 500; font-size: 0.9rem; }

/* ---------- Stories Grid ---------- */
.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    gap: 16px;
}
.stories-list { display: grid; gap: 12px; margin-bottom: 24px; }

.story-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 20px;
    transition: all var(--transition);
}
.story-card:hover { border-color: var(--border-hover); }

.story-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.story-card h3 { font-size: 1.05rem; font-weight: 600; margin-bottom: 14px; }

.star-section {
    margin-bottom: 10px;
}
.star-label {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 2px;
}
.star-section p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.star-framework {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 16px;
}

.story-tags {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 12px;
}
.tag {
    background: var(--indigo-soft);
    color: var(--indigo);
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.72rem;
    font-weight: 500;
}

.story-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-color);
}
.story-date { font-size: 0.78rem; color: var(--text-muted); }

.story-card-mini {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
}
.story-card-mini strong { font-size: 0.9rem; display: block; margin-bottom: 2px; }
.story-card-mini p { font-size: 0.8rem; color: var(--text-muted); margin: 0; }

.impact-statement {
    margin-top: 14px;
    background: var(--indigo-soft);
    border-left: 3px solid var(--indigo);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
}
.impact-label {
    display: block;
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--indigo);
    margin-bottom: 4px;
}
.impact-statement p {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.6;
    margin: 0;
}

/* ---------- Calibration Report ---------- */
.calibration-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
}
.calibration-section h2 {
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.calibration-project-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}
.calibration-project-header h2 { margin-bottom: 0; }

.calibration-story {
    padding: 16px 0;
    border-bottom: 1px solid var(--border-color);
}
.calibration-story:last-child { border-bottom: none; }

.calibration-story-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}
.calibration-story-header h3 { font-size: 0.95rem; font-weight: 600; flex: 1; }

.calibration-impact {
    background: var(--indigo-soft);
    border-left: 3px solid var(--indigo);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 12px 16px;
    margin: 8px 0;
}
.calibration-impact p { font-size: 0.88rem; line-height: 1.6; margin: 0; }

.calibration-sar p { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 4px; line-height: 1.5; }

.goals-summary { display: grid; gap: 10px; }
.goal-summary-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
}
.goal-summary-row div { display: flex; flex-direction: column; gap: 2px; }
.goal-summary-row strong { font-size: 0.9rem; }
.goal-metric { font-size: 0.78rem; color: var(--text-muted); }

/* ---------- Reminders ---------- */
.reminders-list {
    display: grid;
    gap: 12px;
}

.reminder-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 16px 20px;
    transition: all var(--transition);
}
.reminder-card:hover { border-color: var(--border-hover); }
.reminder-card.overdue { border-left: 3px solid var(--rose); }
.reminder-card.dismissed { opacity: 0.5; }

.reminder-card-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
}
.reminder-card-info h3 { font-size: 0.95rem; font-weight: 600; margin-bottom: 2px; }
.reminder-card-info p { font-size: 0.82rem; color: var(--text-secondary); margin-bottom: 4px; }
.reminder-time { font-size: 0.78rem; color: var(--text-muted); }

.reminder-card-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

/* ---------- Section Header ---------- */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    margin-top: 8px;
}
.section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
}

/* ---------- Auth Pages ---------- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-primary);
    padding: 20px;
}

.auth-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 40px 36px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}
.auth-logo h1 {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 28px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}
.auth-hint {
    text-align: center;
    margin-top: 8px;
    font-size: 0.78rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 6px 12px;
    border-radius: var(--radius-sm);
}

/* ---------- Alerts ---------- */
.alert {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    margin-bottom: 16px;
}
.alert-error {
    background: var(--rose-soft);
    color: var(--rose);
    border: 1px solid rgba(244,63,94,0.3);
}
.alert-success {
    background: rgba(34,197,94,0.1);
    color: #22c55e;
    border: 1px solid rgba(34,197,94,0.3);
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}
.empty-icon { font-size: 3rem; margin-bottom: 16px; }
.empty-state h3 { color: var(--text-primary); font-size: 1.15rem; margin-bottom: 8px; }
.empty-state p { margin-bottom: 20px; font-size: 0.9rem; }

.empty-state-sm {
    padding: 20px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ---------- Loading / Spinners ---------- */
.loading-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px;
    gap: 16px;
    color: var(--text-muted);
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border-color);
    border-top-color: var(--indigo);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
.spinner-sm {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 4px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ---------- Overdue ---------- */
.overdue { color: var(--rose) !important; }

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ---------- Blazor Error UI ---------- */
#blazor-error-ui {
    background: var(--rose);
    color: white;
    padding: 8px 16px;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: none;
    font-size: 0.85rem;
}
#blazor-error-ui .dismiss,
#blazor-error-ui .reload {
    color: white;
    margin-left: 12px;
}

/* ---------- Responsive ---------- */

/* ── Mobile Hamburger Button ── */
.mobile-hamburger {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    z-index: 150;
    width: 40px;
    height: 40px;
    border-radius: var(--radius);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: var(--shadow-md);
    transition: background var(--transition);
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}
.mobile-hamburger:hover { background: var(--bg-card-hover); }
.mobile-hamburger:active { background: var(--bg-card-hover); }
.mobile-hamburger span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: all 0.25s ease;
    pointer-events: none;
}

/* ── Sidebar Overlay (mobile) ── */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.55);
    -webkit-backdrop-filter: blur(4px);
    backdrop-filter: blur(4px);
    z-index: 99;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

/* ── Sidebar Close Button (mobile) ── */
.sidebar-close-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px;
    margin-left: auto;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}
.sidebar-close-btn:hover { color: var(--text-primary); background: var(--bg-card-hover); }

@media (max-width: 1024px) {
    .dashboard-grid { grid-template-columns: 1fr; }
    .stories-grid { grid-template-columns: 1fr; }
}

/* ── Tablet & Mobile (≤768px) ── */
@media (max-width: 768px) {

    /* Show hamburger */
    .mobile-hamburger { display: flex; }

    /* Sidebar: off-canvas, hidden by default */
    .sidebar {
        width: 280px;
        -webkit-transform: translateX(-100%);
        transform: translateX(-100%);
        -webkit-transition: -webkit-transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
        will-change: transform;
    }

    /* Show sidebar when open */
    .sidebar-open .sidebar {
        -webkit-transform: translateX(0);
        transform: translateX(0);
        box-shadow: 8px 0 30px rgba(0, 0, 0, 0.5);
    }
    .sidebar-open .sidebar-overlay {
        display: block;
    }

    /* Show close X on mobile */
    .sidebar-close-btn { display: block; }

    /* Hide hamburger when sidebar is open */
    .sidebar-open .mobile-hamburger { opacity: 0; pointer-events: none; }

    /* Main content goes full-width */
    .main-content {
        margin-left: 0 !important;
        padding: 24px 20px;
        padding-top: 68px; /* room for hamburger */
    }

    /* Page headers stack */
    .page-header { flex-direction: column; align-items: flex-start; gap: 12px; }
    .page-header h1 { font-size: 1.35rem; }
    .header-actions { width: 100%; }

    /* Kanban stacks */
    .kanban-board { flex-direction: column; }
    .kanban-column { min-width: 100%; }

    /* Forms stack */
    .form-row { flex-direction: column; }

    /* Stats 2-col */
    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    /* Filter bar stacks */
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-tabs { overflow-x: auto; flex-wrap: nowrap; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }

    /* Task table mobile layout */
    .task-table-header { display: none; }
    .task-table-row { flex-wrap: wrap; gap: 8px; padding: 12px 16px; }
    .task-table-item .task-table-row { flex-wrap: wrap; gap: 8px; }
    .col-priority, .col-project, .col-status, .col-due { width: auto; }
    .col-drag { display: none; }
    .dash-drag-handle { display: none; }
    .col-title { width: 100%; }
    .task-detail-panel { padding: 16px; }
    .task-detail-panel .form-row { flex-direction: column; }

    /* Projects grid */
    .projects-grid { grid-template-columns: 1fr; }

    /* Goals grid */
    .goals-grid { grid-template-columns: 1fr; }

    /* Stories grid */
    .stories-grid { grid-template-columns: 1fr; }

    /* Ideas grid */
    .ideas-grid { grid-template-columns: 1fr; }

    /* Reminders */
    .reminder-card-main { flex-direction: column; align-items: flex-start; gap: 10px; }
    .reminder-card-actions { width: 100%; }

    /* User table mobile */
    .user-table-header { display: none; }
    .user-table-row {
        display: flex;
        flex-direction: column;
        gap: 6px;
        padding: 14px 16px;
    }
    .user-actions-cell { justify-content: flex-start; }

    /* Modals */
    .modal-backdrop { padding: 12px; align-items: flex-end; }
    .modal-card { padding: 20px; border-radius: var(--radius-lg) var(--radius-lg) 0 0; max-height: 85vh; }
    .modal-lg { max-width: 100%; }

    /* Settings */
    .settings-form { max-width: 100%; }

    /* ADO */
    .ado-create-row { flex-direction: column; align-items: stretch; }
    .ado-type-select { max-width: 100%; }

    /* Notepad */
    .notepad-layout { flex-direction: column; min-height: calc(100vh - 140px); }
    .notepad-list {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    /* Calibration */
    .calibration-project-header { flex-wrap: wrap; }

    /* Quick capture */
    .quick-capture { flex-direction: column; }
    .quick-capture .btn { width: 100%; justify-content: center; }

    /* 2FA setup */
    .twofa-setup-box { flex-direction: column; align-items: center; }

    /* Section headers */
    .section-header { flex-direction: column; align-items: flex-start; gap: 8px; }

    /* PAT banner */
    .pat-expiry-banner { flex-direction: column; text-align: center; }
}

/* ---------- Header Actions ---------- */
.header-actions {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

/* ---------- Azure DevOps Integration ---------- */
.ado-link-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    padding: 2px 8px;
    border-radius: 12px;
    background: rgba(0, 120, 212, 0.15);
    color: #4fc3f7;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}
.ado-link-badge:hover {
    background: rgba(0, 120, 212, 0.3);
    color: #81d4fa;
}
.ado-create-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}
.ado-type-select {
    max-width: 170px;
    padding: 4px 8px;
    font-size: 0.85rem;
}
.ado-link-row {
    margin-bottom: 8px;
}
.btn-ado {
    background: linear-gradient(135deg, #0078d4, #106ebe);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
.btn-ado:hover:not(:disabled) {
    background: linear-gradient(135deg, #1a8ae6, #0078d4);
    transform: translateY(-1px);
}
.btn-ado:disabled {
    opacity: 0.6;
    cursor: wait;
}
.ado-config-hint {
    margin-bottom: 12px;
    padding: 8px 12px;
    background: var(--indigo-soft);
    border-radius: 8px;
    border-left: 3px solid var(--indigo);
}
.ado-config-hint small {
    color: var(--text-secondary);
}
.ado-config-hint a {
    color: var(--text-link);
}

/* ---------- Settings Page ---------- */
.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 24px;
}
.settings-section h2 {
    font-size: 1.2rem;
    margin: 0 0 8px 0;
    color: var(--text-primary);
}
.settings-desc {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.settings-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 560px;
}
.form-hint {
    display: block;
    margin-top: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.form-hint code {
    background: var(--bg-secondary);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.76rem;
}
.text-success {
    color: var(--emerald);
}
.text-danger {
    color: var(--rose);
}

/* ── PAT Expiry Banner ──────────────────────────── */
.pat-expiry-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.9rem;
}
.pat-expiry-ok {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.pat-expiry-warning {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.4);
}
.pat-expiry-critical {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.4);
}
.pat-expiry-unknown {
    background: rgba(99, 102, 241, 0.08);
    border: 1px solid rgba(99, 102, 241, 0.25);
}
.pat-expiry-info {
    flex: 1;
    min-width: 200px;
}

/* ---------- User Management Table ---------- */
.user-table {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    overflow: hidden;
}

.user-table-header {
    display: grid;
    grid-template-columns: 2fr 2.5fr 0.8fr 1.2fr 1.8fr;
    gap: 1rem;
    padding: 12px 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.user-table-row {
    display: grid;
    grid-template-columns: 2fr 2.5fr 0.8fr 1.2fr 1.8fr;
    gap: 1rem;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border-color);
    align-items: center;
    transition: background var(--transition);
}
.user-table-row:last-child { border-bottom: none; }
.user-table-row:hover { background: var(--bg-card-hover); }

.user-name-cell { font-weight: 500; }
.user-email-cell { color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; }
.user-date-cell { color: var(--text-muted); font-size: 0.85rem; }
.user-actions-cell {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    flex-wrap: wrap;
    align-items: center;
}

.user-delete-confirm {
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.08);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
    color: var(--rose);
    font-size: 0.9rem;
}

.badge-admin {
    background: rgba(239, 68, 68, 0.12);
    color: var(--rose);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}
.badge-user {
    background: rgba(99, 102, 241, 0.12);
    color: var(--indigo);
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* ============================================
   Ideas
   ============================================ */

/* Quick Capture */
.quick-capture {
    display: flex;
    gap: 10px;
    margin-bottom: 24px;
    align-items: center;
}
.quick-capture-input {
    flex: 1;
    font-size: 1rem;
    padding: 12px 18px;
    border-radius: var(--radius);
    border: 1px dashed var(--border-color);
    background: var(--bg-card);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.quick-capture-input:focus {
    border-style: solid;
    border-color: var(--indigo);
    box-shadow: 0 0 0 3px var(--indigo-soft);
}

/* Toolbar */
.ideas-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}
.ideas-sort {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Ideas Grid */
.ideas-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}
.idea-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 18px 20px;
    transition: border-color var(--transition), box-shadow var(--transition);
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.idea-card:hover {
    border-color: var(--border-hover);
    box-shadow: var(--shadow-sm);
}
.idea-card.idea-converted { opacity: 0.7; }
.idea-card.idea-discarded { opacity: 0.5; }

.idea-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.idea-category {
    font-size: 0.78rem;
    color: var(--text-muted);
}
.idea-title {
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: color var(--transition);
}
.idea-title:hover { color: var(--indigo); }

.idea-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* Meta: effort + impact + tags */
.idea-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}
.effort-badge, .impact-badge {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.effort-badge { background: rgba(100,116,139,0.12); color: #94a3b8; }
.effort-tiny { background: rgba(16,185,129,0.12); color: var(--emerald); }
.effort-small { background: rgba(16,185,129,0.12); color: var(--emerald); }
.effort-medium { background: rgba(245,158,11,0.12); color: var(--amber); }
.effort-large { background: rgba(249,115,22,0.12); color: #f97316; }
.effort-epic { background: rgba(244,63,94,0.12); color: var(--rose); }

.impact-badge { background: rgba(100,116,139,0.12); color: #94a3b8; }
.impact-low { background: rgba(100,116,139,0.12); color: #94a3b8; }
.impact-medium { background: rgba(99,102,241,0.12); color: var(--indigo); }
.impact-high { background: rgba(16,185,129,0.12); color: var(--emerald); }
.impact-gamechanger { background: rgba(139,92,246,0.15); color: #a78bfa; }

.idea-tag {
    font-size: 0.72rem;
    color: var(--text-link);
    background: var(--indigo-soft);
    padding: 2px 8px;
    border-radius: 999px;
}

.idea-converted-info {
    font-size: 0.8rem;
    color: var(--emerald);
    font-weight: 500;
}

.idea-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}
.idea-actions {
    display: flex;
    gap: 4px;
}

/* Idea status badges */
.badge-idea-new { background: rgba(14,165,233,0.12); color: var(--sky); }
.badge-idea-exploring { background: rgba(139,92,246,0.15); color: #a78bfa; }
.badge-idea-promising { background: var(--emerald-soft); color: var(--emerald); }
.badge-idea-parked { background: var(--amber-soft); color: var(--amber); }
.badge-idea-converted { background: var(--indigo-soft); color: var(--indigo); }
.badge-idea-discarded { background: rgba(100,116,139,0.12); color: #64748b; }

/* Convert modal options */
.convert-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.convert-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
    color: var(--text-primary);
    font-family: inherit;
}
.convert-option:hover {
    border-color: var(--indigo);
    background: var(--bg-card-hover);
}
.convert-icon { font-size: 1.5rem; }
.convert-label { font-weight: 600; font-size: 0.95rem; }
.convert-desc { font-size: 0.8rem; color: var(--text-secondary); }
.convert-divider {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
}

/* Extra small button */
.btn-xs {
    padding: 3px 8px;
    font-size: 0.75rem;
    border-radius: var(--radius-sm);
}

/* ============================================
   Notepad
   ============================================ */

.notepad-layout {
    display: flex;
    gap: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    min-height: calc(100vh - 220px);
    background: var(--bg-card);
}

/* Note list sidebar */
.notepad-list {
    width: 280px;
    min-width: 280px;
    border-right: 1px solid var(--border-color);
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}
.notepad-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}
.notepad-list-item {
    padding: 12px 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    border-left: 3px solid transparent;
    transition: background var(--transition), border-color var(--transition);
}
.notepad-list-item:hover {
    background: var(--bg-card-hover);
}
.notepad-list-item.active {
    background: var(--bg-card);
    border-left-color: var(--indigo);
}
.notepad-list-item-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2px;
}
.notepad-list-title {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.notepad-list-preview {
    font-size: 0.78rem;
    color: var(--text-muted);
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.notepad-list-empty {
    padding: 24px;
    text-align: center;
}

/* Color left-border accents for list items */
.notepad-list-item.notepad-color-red { border-left-color: var(--rose); }
.notepad-list-item.notepad-color-orange { border-left-color: #f97316; }
.notepad-list-item.notepad-color-yellow { border-left-color: var(--amber); }
.notepad-list-item.notepad-color-green { border-left-color: var(--emerald); }
.notepad-list-item.notepad-color-blue { border-left-color: var(--sky); }
.notepad-list-item.notepad-color-purple { border-left-color: var(--purple); }
/* Active note keeps its color */
.notepad-list-item.active.notepad-color-red { border-left-color: var(--rose); }
.notepad-list-item.active.notepad-color-orange { border-left-color: #f97316; }
.notepad-list-item.active.notepad-color-yellow { border-left-color: var(--amber); }
.notepad-list-item.active.notepad-color-green { border-left-color: var(--emerald); }
.notepad-list-item.active.notepad-color-blue { border-left-color: var(--sky); }
.notepad-list-item.active.notepad-color-purple { border-left-color: var(--purple); }

/* Editor panel */
.notepad-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    position: relative;
}
.notepad-editor-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}
.notepad-title-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    outline: none;
    padding: 4px 0;
}
.notepad-title-input::placeholder { color: var(--text-muted); }
.notepad-toolbar-actions {
    display: flex;
    gap: 4px;
    align-items: center;
    flex-shrink: 0;
}
.notepad-editor-meta {
    display: flex;
    justify-content: space-between;
    padding: 6px 16px;
    border-bottom: 1px solid var(--border-color);
}
.notepad-textarea {
    flex: 1;
    width: 100%;
    padding: 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.92rem;
    line-height: 1.7;
    resize: none;
    outline: none;
}
.notepad-textarea::placeholder { color: var(--text-muted); }
.notepad-editor-empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--text-secondary);
}
.notepad-editor-empty h3 { color: var(--text-primary); margin-bottom: 4px; }

/* Save indicator */
.notepad-save-indicator {
    position: absolute;
    bottom: 16px;
    right: 16px;
    font-size: 0.78rem;
    padding: 4px 12px;
    border-radius: 999px;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
.notepad-save-indicator.saved {
    background: var(--emerald-soft);
    color: var(--emerald);
}
.notepad-save-indicator.saving {
    background: var(--amber-soft);
    color: var(--amber);
}

/* Color picker dropdown */
.notepad-color-picker-wrap {
    position: relative;
}
.notepad-color-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 8px;
    display: flex;
    gap: 6px;
    z-index: 50;
    box-shadow: var(--shadow-md);
}
.notepad-color-dot {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform var(--transition);
}
.notepad-color-dot:hover { transform: scale(1.2); }
.notepad-color-dot.active { border-color: white; box-shadow: 0 0 0 2px var(--indigo); }
.notepad-dot-default { background: var(--bg-card-hover); }
.notepad-dot-red { background: var(--rose); }
.notepad-dot-orange { background: #f97316; }
.notepad-dot-yellow { background: var(--amber); }
.notepad-dot-green { background: var(--emerald); }
.notepad-dot-blue { background: var(--sky); }
.notepad-dot-purple { background: var(--purple); }

/* Responsive: handled in main responsive section */

/* Helper */
.text-xs { font-size: 0.72rem; }

/* ── Two-Factor Authentication ────────────────────────────────── */

.twofa-code-input {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 1.5rem;
    letter-spacing: 0.5em;
    text-align: center;
    max-width: 240px;
    padding: 12px;
}

.twofa-remember {
    margin-top: 4px;
}

.twofa-remember .checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    color: var(--text-secondary);
}

.twofa-remember .checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--indigo);
    cursor: pointer;
}

.twofa-back {
    text-align: center;
    margin-top: 16px;
}

.twofa-back a {
    color: var(--text-muted);
    font-size: 0.85rem;
    text-decoration: none;
    transition: color var(--transition);
}

.twofa-back a:hover {
    color: var(--indigo);
}

/* 2FA Settings section */
.twofa-status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.88rem;
    font-weight: 500;
    margin-top: 8px;
}

.twofa-status-badge.twofa-enabled {
    background: var(--emerald-soft);
    color: var(--emerald);
}

.twofa-setup-box {
    display: flex;
    align-items: flex-start;
    gap: 24px;
    margin-top: 16px;
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.twofa-qr {
    flex-shrink: 0;
    background: white;
    padding: 8px;
    border-radius: 8px;
}

.twofa-qr img {
    display: block;
    border-radius: 4px;
}

.twofa-manual-key {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.twofa-manual-key label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.twofa-secret-display {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    font-size: 0.95rem;
    background: var(--bg-primary);
    padding: 10px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border-color);
    color: var(--indigo);
    word-break: break-all;
    user-select: all;
    letter-spacing: 0.08em;
}

.twofa-confirm-box {
    padding: 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
}

.twofa-confirm-box p {
    margin-bottom: 12px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

/* 2FA responsive: handled in main responsive section */

/* ── iPhone / Small Phone (≤480px) ── */
@media (max-width: 480px) {

    /* Even tighter padding */
    .main-content {
        padding: 16px 14px;
        padding-top: 62px;
    }

    /* Typography scale-down */
    .page-header h1 { font-size: 1.2rem; }
    .page-header p { font-size: 0.8rem; }

    /* Stats: single column on tiny screens */
    .stats-grid { grid-template-columns: 1fr; }
    .stat-card { padding: 14px 16px; }
    .stat-value { font-size: 1.6rem; }

    /* Cards tighter padding */
    .card { padding: 16px; }
    .card h2 { font-size: 1rem; }

    /* Dashboard */
    .dashboard-grid { gap: 12px; }

    /* Buttons: slightly larger tap targets */
    .btn { padding: 11px 18px; font-size: 0.84rem; }
    .btn-sm { padding: 8px 14px; }

    /* Filter tabs: horizontal scroll, no wrap */
    .filter-tabs { gap: 6px; }
    .filter-tab { padding: 6px 14px; font-size: 0.78rem; white-space: nowrap; }

    /* Project cards */
    .project-card { padding: 16px; }
    .project-card-stats { flex-wrap: wrap; gap: 10px; }
    .project-card-actions { flex-wrap: wrap; }

    /* Goal cards */
    .goal-card-full { padding: 16px; }
    .goal-card-header { flex-direction: column; gap: 8px; }
    .goal-metrics { gap: 10px; }

    /* Story cards */
    .story-card { padding: 16px; }

    /* Kanban card */
    .kanban-card { padding: 10px; }

    /* Task table row */
    .task-table-row { padding: 10px 12px; }
    .col-title strong { font-size: 0.85rem; }

    /* Reminder */
    .reminder-card { padding: 14px 16px; }

    /* Modals: full-screen slide up */
    .modal-backdrop { padding: 0; }
    .modal-card {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
        padding: 20px 16px;
    }

    /* Auth */
    .auth-card { padding: 28px 20px; }
    .auth-logo h1 { font-size: 1.3rem; }

    /* Notepad */
    .notepad-list { max-height: 160px; }
    .notepad-editor-toolbar { padding: 8px 12px; flex-wrap: wrap; }
    .notepad-title-input { font-size: 0.95rem; }
    .notepad-textarea { padding: 12px; font-size: 0.85rem; }

    /* Ideas */
    .idea-card { padding: 14px 16px; }
    .quick-capture-input { font-size: 0.9rem; padding: 10px 14px; }

    /* Calibration */
    .calibration-section { padding: 16px; }
    .calibration-section h2 { font-size: 1rem; }

    /* Settings */
    .settings-section { padding: 16px; }
    .settings-section h2 { font-size: 1.05rem; }

    /* 2FA */
    .twofa-code-input { font-size: 1.2rem; letter-spacing: 0.35em; max-width: 200px; }
    .twofa-setup-box { padding: 14px; gap: 16px; }
    .twofa-secret-display { font-size: 0.8rem; padding: 8px 10px; }

    /* Empty state */
    .empty-state { padding: 40px 16px; }
    .empty-icon { font-size: 2.4rem; }

    /* Badges */
    .badge { font-size: 0.68rem; padding: 2px 8px; }

    /* Inline date columns */
    .col-due { font-size: 0.78rem; }

    /* User delete confirm */
    .user-delete-confirm { flex-direction: column; text-align: center; gap: 8px; }
}

/* ── Ultra-small (iPhone SE / 320px) ── */
@media (max-width: 374px) {
    .main-content { padding: 12px 10px; padding-top: 58px; }
    .mobile-hamburger { top: 10px; left: 10px; width: 36px; height: 36px; }
    .mobile-hamburger span { width: 16px; }
    .stats-grid { gap: 8px; }
    .stat-card { padding: 12px 14px; }
    .stat-value { font-size: 1.4rem; }
    .page-header h1 { font-size: 1.1rem; }
    .btn { padding: 10px 14px; }
    .filter-tab { padding: 5px 10px; font-size: 0.75rem; }
}

/* ── Touch-friendly: increase tap targets on touch devices ── */
@media (hover: none) and (pointer: coarse) {
    .nav-item { padding: 12px 16px; min-height: 44px; }
    .btn-icon { padding: 8px 10px; min-width: 36px; min-height: 36px; }
    .btn-sm { min-height: 36px; }
    .filter-tab { min-height: 36px; }
    .kanban-card-actions .btn-icon { min-width: 32px; min-height: 32px; }
    .notepad-list-item { min-height: 44px; }
    .color-swatch { width: 34px; height: 34px; }
    .notepad-color-dot { width: 28px; height: 28px; }
}

/* ── Safe areas (iPhone notch / home indicator) ── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    @media (max-width: 768px) {
        .sidebar {
            padding-bottom: env(safe-area-inset-bottom);
        }
        .main-content {
            padding-bottom: calc(16px + env(safe-area-inset-bottom));
        }
        .modal-card {
            padding-bottom: calc(20px + env(safe-area-inset-bottom));
        }
    }
}