/* ========================================
   Develop Setuper - Design System v2
   Clean dev aesthetic. Terminal vibes.
   ======================================== */

/* ---------- Theme Variables ---------- */
:root {
    --primary: #818cf8;
    --primary-hover: #6366f1;
    --primary-light: #eef2ff;
    --primary-dark: #4f46e5;
    --primary-glow: rgba(129, 140, 248, 0.1);

    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;

    --bg-body: #f8f8f8;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a19;
    --bg-sidebar-hover: #2a2a28;
    --bg-input: #ffffff;
    --bg-hover: #f4f4f3;
    --bg-code: #f4f4f3;

    --text-primary: #1a1a19;
    --text-secondary: #6b6b6a;
    --text-muted: #a1a1a0;
    --text-sidebar: #8a8a88;
    --text-sidebar-active: #e8e8e6;

    --border: #e8e8e6;
    --border-focus: #818cf8;

    --shadow-sm: none;
    --shadow: 0 1px 2px rgb(0 0 0 / 0.04);
    --shadow-md: 0 2px 8px rgb(0 0 0 / 0.06);
    --shadow-lg: 0 4px 16px rgb(0 0 0 / 0.08);

    --radius: 6px;
    --radius-lg: 8px;

    --sidebar-width: 240px;
    --topbar-height: 56px;

    --transition: 120ms ease;

    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
}

/* ---------- Dark Theme ---------- */
[data-theme="dark"] {
    --bg-body: #1e1e1c;
    --bg-card: #262624;
    --bg-sidebar: #1a1a19;
    --bg-sidebar-hover: #303030;
    --bg-input: #2e2e2c;
    --bg-hover: #2e2e2c;
    --bg-code: #2e2e2c;

    --text-primary: #e8e8e6;
    --text-secondary: #a1a1a0;
    --text-muted: #6b6b6a;
    --text-sidebar: #6b6b6a;
    --text-sidebar-active: #e8e8e6;

    --border: #363634;
    --border-focus: #818cf8;

    --primary-light: rgba(129, 140, 248, 0.1);

    --shadow-sm: none;
    --shadow: none;
    --shadow-md: none;
    --shadow-lg: 0 4px 24px rgb(0 0 0 / 0.3);
}

/* ---------- Base ---------- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ---------- Mono Accent ---------- */
.mono {
    font-family: var(--font-mono);
}

/* ---------- Layout ---------- */
.app-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 40;
    transition: transform var(--transition);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-width: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
}

.main-content {
    flex: 1;
    padding: 1.5rem;
    max-width: 1400px;
}

/* ---------- Sidebar ---------- */
.sidebar-brand {
    padding: 1.25rem 1.25rem;
    border-bottom: 1px solid #2a2a28;
}

.sidebar-brand h1 {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    letter-spacing: -0.02em;
}

.sidebar-brand h1 .cursor {
    display: inline-block;
    width: 2px;
    height: 1em;
    background: var(--primary);
    animation: blink 1s step-end infinite;
    margin-left: 2px;
}

@keyframes blink {
    50% { opacity: 0; }
}

.sidebar-nav {
    padding: 0.75rem 0;
    flex: 1;
}

.nav-section {
    padding: 0.75rem 1.25rem 0.25rem;
}

.nav-section-title {
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: #4a4a48;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1.25rem;
    color: var(--text-sidebar);
    text-decoration: none;
    font-size: 0.8rem;
    font-weight: 400;
    transition: all var(--transition);
    border-left: 2px solid transparent;
}

.nav-link:hover {
    color: var(--text-sidebar-active);
    background: var(--bg-sidebar-hover);
}

.nav-link.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: rgba(129, 140, 248, 0.05);
}

.nav-link i {
    width: 1.1rem;
    text-align: center;
    font-size: 0.85rem;
    opacity: 0.7;
}

.nav-link.active i {
    opacity: 1;
}

/* ---------- Nav Toggle (Expandable Menu) ---------- */
.nav-group {
    position: relative;
}

.nav-toggle {
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    justify-content: flex-start;
}

.nav-toggle-icon {
    margin-left: auto;
    font-size: 0.65rem;
    transition: transform var(--transition);
}

.nav-toggle.open .nav-toggle-icon {
    transform: rotate(180deg);
}

.nav-submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.2s ease;
}

.nav-submenu.open {
    max-height: 200px;
}

.nav-sublink {
    padding-left: 2.5rem !important;
    font-size: 0.75rem !important;
}

.nav-sublink i {
    font-size: 0.75rem !important;
}

.sidebar-footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid #2a2a28;
}

/* ---------- Cards ---------- */
.card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.card-header {
    padding: 0.85rem 1.25rem;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-body {
    padding: 1.25rem;
}

/* ---------- Stat Cards ---------- */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.stat-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
    color: var(--text-primary);
    letter-spacing: -0.03em;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.1rem;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.5;
    font-family: inherit;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-success {
    background: var(--success);
    color: #0a0a0a;
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: var(--danger);
}
.btn-danger:hover {
    background: var(--danger);
    color: #fff;
}

.btn-secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: var(--border);
}
.btn-secondary:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.55rem 1.25rem;
    font-size: 0.85rem;
}

/* ---------- Forms ---------- */
.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.3rem;
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 0.45rem 0.7rem;
    font-size: 0.85rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    transition: border-color var(--transition);
    font-family: inherit;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--border-focus);
}

.form-textarea {
    min-height: 90px;
    resize: vertical;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 0.2rem;
}

/* ---------- Tables ---------- */
.table-wrapper {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.table th {
    text-align: left;
    padding: 0.6rem 1rem;
    font-family: var(--font-mono);
    font-weight: 500;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: 0.6rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
}

.table tr:hover td {
    background: var(--bg-hover);
}

.table th a {
    color: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    cursor: pointer;
}

.table th a:hover {
    color: var(--primary);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.5rem;
    font-family: var(--font-mono);
    font-size: 0.6rem;
    font-weight: 500;
    border-radius: var(--radius);
    letter-spacing: 0.02em;
}

.badge-low       { background: #dbeafe; color: #2563eb; }
.badge-medium    { background: #fef3c7; color: #b45309; }
.badge-high      { background: #fed7aa; color: #c2410c; }
.badge-urgent    { background: #fecaca; color: #dc2626; }

[data-theme="dark"] .badge-low       { background: rgba(96, 165, 250, 0.12); color: #93c5fd; }
[data-theme="dark"] .badge-medium    { background: rgba(251, 191, 36, 0.12); color: #fcd34d; }
[data-theme="dark"] .badge-high      { background: rgba(251, 146, 60, 0.12); color: #fdba74; }
[data-theme="dark"] .badge-urgent    { background: rgba(248, 113, 113, 0.12); color: #fca5a5; }

/* ---------- Kanban Board ---------- */
.kanban-board {
    display: flex;
    gap: 0.75rem;
    overflow-x: auto;
    padding-bottom: 1rem;
    min-height: 400px;
}

.kanban-column {
    min-width: 270px;
    max-width: 300px;
    flex-shrink: 0;
    background: var(--bg-body);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.kanban-column-header {
    padding: 0.65rem 0.85rem;
    font-weight: 600;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.kanban-column-body {
    padding: 0.5rem;
    min-height: 200px;
}

.kanban-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.65rem 0.75rem;
    padding-left: 1.5rem;
    margin-bottom: 0.4rem;
    position: relative;
    cursor: pointer;
    transition: border-color var(--transition), box-shadow var(--transition);
    user-select: none;
    -webkit-user-select: none;
}

.kanban-card:hover {
    border-color: var(--primary);
}

.kanban-card.sortable-ghost {
    opacity: 0.4;
    box-shadow: var(--shadow-md);
}

.kanban-card.sortable-chosen {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-light);
}

.kanban-card.sortable-drag {
    transform: rotate(2deg);
    box-shadow: var(--shadow-lg);
}

/* Drag Handle */
.kanban-drag-handle {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s, background 0.15s, color 0.15s;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.65rem;
}

.kanban-card:hover .kanban-drag-handle {
    opacity: 0.6;
}

.kanban-drag-handle:hover {
    opacity: 1 !important;
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.kanban-drag-handle:active {
    cursor: grabbing;
}

/* ---------- Waterfall Pipeline ---------- */
.waterfall-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    overflow-x: auto;
    padding: 1.5rem 0;
}

.waterfall-phase {
    flex: 1;
    min-width: 140px;
    text-align: center;
    position: relative;
    padding: 1rem 0.5rem;
    border-radius: var(--radius-lg);
    transition: all var(--transition);
}

.waterfall-phase.active {
    background: var(--primary-light);
}

.waterfall-phase.completed {
    opacity: 0.7;
}

.waterfall-phase-icon {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.waterfall-phase-name {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.waterfall-phase-count {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-family: var(--font-mono);
    margin-bottom: 0.5rem;
}

.waterfall-phase-bar {
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin-top: 0.5rem;
    overflow: hidden;
}

.waterfall-phase-fill {
    height: 100%;
    border-radius: 2px;
    transition: width 0.3s ease;
}

.waterfall-phase-connector {
    flex-shrink: 0;
    color: var(--text-muted);
    font-size: 0.75rem;
    padding: 0 0.25rem;
    display: flex;
    align-items: center;
}

/* ---------- Waterfall Accordion ---------- */
.waterfall-acc-header {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.25rem;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    transition: background var(--transition);
}

.waterfall-acc-header:hover {
    background: var(--bg-hover);
}

.waterfall-acc-chevron {
    transition: transform 0.25s ease;
    flex-shrink: 0;
}

.waterfall-acc-body.open + .waterfall-acc-header .waterfall-acc-chevron,
.waterfall-acc.open > .waterfall-acc-header .waterfall-acc-chevron {
    transform: rotate(180deg);
}

.waterfall-acc-body {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.waterfall-acc-body.open {
    max-height: 2000px;
}

.waterfall-acc-inner {
    padding: 0 0.75rem 0.75rem;
    border-top: 1px solid var(--border);
}

.waterfall-acc-inner .kanban-column-body {
    padding: 0.5rem 0;
    min-height: 40px;
}

.waterfall-acc-empty {
    text-align: center;
    padding: 1.25rem;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.waterfall-acc-empty i {
    margin-right: 0.3rem;
    opacity: 0.5;
}

/* ---------- Markdown Body ---------- */
.markdown-body h1 { font-size: 1.4rem; font-weight: 700; margin: 1.25rem 0 0.5rem; }
.markdown-body h2 { font-size: 1.15rem; font-weight: 700; margin: 1rem 0 0.4rem; }
.markdown-body h3 { font-size: 1rem; font-weight: 600; margin: 0.85rem 0 0.35rem; }
.markdown-body h1:first-child,
.markdown-body h2:first-child,
.markdown-body h3:first-child { margin-top: 0; }

.markdown-body p { margin: 0.5rem 0; }

.markdown-body ul,
.markdown-body ol { margin: 0.5rem 0; padding-left: 1.5rem; }
.markdown-body li { margin: 0.2rem 0; }

.markdown-body strong { font-weight: 600; }
.markdown-body a { color: var(--primary); text-decoration: none; }
.markdown-body a:hover { text-decoration: underline; }

.markdown-body code {
    font-family: var(--font-mono);
    font-size: 0.8em;
    background: var(--bg-code);
    padding: 0.15rem 0.35rem;
    border-radius: 3px;
    border: 1px solid var(--border);
}

.markdown-body pre {
    background: var(--bg-code);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.85rem 1rem;
    overflow-x: auto;
    margin: 0.75rem 0;
}

.markdown-body pre code {
    background: none;
    border: none;
    padding: 0;
    font-size: 0.8rem;
    line-height: 1.6;
}

/* Markdown checkboxes */
.markdown-body input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid var(--border);
    border-radius: 4px;
    background: var(--bg-input);
    cursor: pointer;
    vertical-align: middle;
    position: relative;
    margin-right: 0.45rem;
    margin-top: 0.1rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.markdown-body input[type="checkbox"]:checked {
    background: var(--success);
    border-color: var(--success);
    animation: cbPop 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.markdown-body input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.markdown-body input[type="checkbox"]:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.1);
}

@keyframes cbPop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.2); }
    100% { transform: scale(1); }
}

.markdown-body li:has(> input[type="checkbox"]) {
    list-style: none;
    margin-left: -1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 0.1rem 0;
    border-radius: 3px;
    transition: background 0.15s ease;
}

.markdown-body li:has(> input[type="checkbox"]):hover {
    background: rgba(129, 140, 248, 0.04);
}

.markdown-body li:has(> input[type="checkbox"]:checked) {
    color: var(--text-muted);
    text-decoration: line-through;
    text-decoration-color: var(--border);
}

.markdown-body blockquote {
    border-left: 3px solid var(--primary);
    margin: 0.75rem 0;
    padding: 0.35rem 1rem;
    color: var(--text-secondary);
}

.markdown-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1rem 0;
}

.markdown-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}

.markdown-body th,
.markdown-body td {
    border: 1px solid var(--border);
    padding: 0.4rem 0.65rem;
    text-align: left;
}

.markdown-body th {
    background: var(--bg-code);
    font-weight: 600;
}

/* ---------- Progress Bar ---------- */
.progress-bar {
    height: 3px;
    background: var(--border);
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 2px;
    background: var(--primary);
    transition: width 0.3s ease;
}

/* ---------- Empty State ---------- */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 0.75rem;
    display: block;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 0.95rem;
    color: var(--text-secondary);
    margin-bottom: 0.35rem;
}

.empty-state p {
    font-size: 0.8rem;
    margin-bottom: 1.25rem;
}

/* ---------- Flash Messages ---------- */
.flash-message {
    padding: 0.6rem 0.85rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8rem;
    border-left: 3px solid;
    animation: flashIn 0.2s ease;
}

.flash-success { background: var(--bg-card); color: var(--success); border-left-color: var(--success); }
.flash-error   { background: var(--bg-card); color: var(--danger);  border-left-color: var(--danger); }
.flash-warning { background: var(--bg-card); color: var(--warning); border-left-color: var(--warning); }
.flash-info    { background: var(--bg-card); color: var(--info);    border-left-color: var(--info); }

@keyframes flashIn {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---------- Auth Layout ---------- */
.auth-layout {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1a1a19;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 380px;
    background: #262624;
    border-radius: var(--radius-lg);
    border: 1px solid #363634;
    padding: 2.5rem;
}

.auth-card .form-input {
    background: #2e2e2c;
    border-color: #363634;
    color: #e8e8e6;
}

.auth-card .form-input:focus {
    border-color: var(--primary);
}

.auth-card .form-label {
    color: #8a8a88;
}

.auth-logo {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-logo h1 {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

/* ---------- Responsive Grid Utilities ---------- */
.grid-stats   { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-2       { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.grid-3       { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.grid-4       { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; }
.grid-2-1     { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; }
.grid-cards   { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 1rem; }
.form-row-2   { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-row-3   { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1rem; }
.form-row-4   { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; gap: 1rem; }

.page-header  { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem; }
.filter-bar   { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: end; }
.form-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1rem; }
.form-container { max-width: 720px; margin: 0 auto; }
.tabs-nav     { display: flex; gap: 0; border-bottom: 2px solid var(--border); margin-bottom: 1.5rem; overflow-x: auto; }
.tabs-nav .tab-btn { border-radius: var(--radius) var(--radius) 0 0; margin-bottom: -2px; border-bottom: 2px solid transparent; color: var(--text-muted); transition: all var(--transition); }
.tabs-nav .tab-btn:hover { color: var(--text-primary); background: var(--bg-hover); }
.tabs-nav .tab-btn.active { border-bottom-color: var(--primary); color: var(--primary); background: var(--primary-light); font-weight: 600; }

/* ---------- KB Editor (Confluence-style) ---------- */
.kb-editor-container {
    max-width: 900px;
    margin: 0 auto;
}

.kb-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.kb-breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color var(--transition);
}

.kb-breadcrumb a:hover {
    color: var(--primary);
}

.kb-breadcrumb .kb-breadcrumb-sep {
    color: var(--text-muted);
    font-size: 0.65rem;
}

.kb-title-input {
    border: none;
    border-bottom: 2px solid transparent;
    font-size: 1.5rem;
    font-weight: 700;
    padding: 1rem 1.25rem;
    width: 100%;
    background: transparent;
    color: var(--text-primary);
    outline: none;
    transition: border-bottom-color var(--transition);
    font-family: inherit;
}

.kb-title-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.kb-title-input:focus {
    border-bottom-color: var(--primary);
}

.kb-metadata-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.kb-meta-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.kb-meta-item label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.kb-category-select {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    cursor: pointer;
}

.kb-category-select:focus {
    outline: none;
    border-color: var(--border-focus);
}

.kb-pin-toggle {
    cursor: pointer;
    display: flex;
    gap: 0.35rem;
    align-items: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
    user-select: none;
}

.kb-pin-toggle input {
    display: none;
}

.kb-pin-toggle i {
    color: var(--text-muted);
    transition: color var(--transition);
}

.kb-pin-toggle input:checked ~ i {
    color: var(--warning);
}

.kb-project-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    align-items: center;
}

.kb-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.2rem 0.5rem 0.2rem 0.6rem;
    background: var(--bg-hover);
    border: 1px solid var(--border);
    border-radius: 9999px;
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.kb-chip-remove {
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.65rem;
    line-height: 1;
    transition: color var(--transition);
}

.kb-chip-remove:hover {
    color: var(--danger);
}

.kb-add-project {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border);
    border-radius: 9999px;
    font-family: inherit;
    cursor: pointer;
    width: auto;
}

.kb-add-project:focus {
    outline: none;
    border-color: var(--border-focus);
}

.kb-info-bar {
    display: flex;
    gap: 1.5rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    font-family: var(--font-mono);
}

.kb-info-bar span {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.kb-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
}

.kb-show-title {
    font-size: 1.25rem;
    font-weight: 700;
    padding: 1.25rem 1.25rem 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: start;
    gap: 1rem;
}

.kb-show-meta {
    display: flex;
    gap: 0.75rem;
    padding: 0 1.25rem 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.kb-show-content {
    padding: 1.5rem 1.25rem;
    border-top: 1px solid var(--border);
    font-size: 0.9rem;
    line-height: 1.7;
}

.kb-show-actions {
    display: flex;
    gap: 0.5rem;
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    justify-content: flex-end;
}

@media (max-width: 640px) {
    .kb-metadata-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    .kb-title-input {
        font-size: 1.2rem;
        padding: 0.75rem 1rem;
    }

    .kb-info-bar {
        flex-wrap: wrap;
        gap: 1rem;
    }
}

/* ---------- Mobile Responsive ---------- */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-wrapper {
        margin-left: 0;
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 35;
    }

    .sidebar-overlay.active {
        display: block;
    }
}

@media (max-width: 768px) {
    .grid-stats   { grid-template-columns: repeat(2, 1fr); }
    .grid-2       { grid-template-columns: 1fr; }
    .grid-3       { grid-template-columns: repeat(2, 1fr); }
    .grid-4       { grid-template-columns: repeat(2, 1fr); }
    .grid-2-1     { grid-template-columns: 1fr; }
    .form-row-4   { grid-template-columns: 1fr 1fr; }

    .hide-tablet  { display: none !important; }

    .topbar { padding: 0 1rem; }

    .filter-bar > * { flex: 1 1 140px; }
    .roadmap-filter-grid { grid-template-columns: repeat(2, 1fr) !important; }

    .tabs-nav { -webkit-overflow-scrolling: touch; }
    .tabs-nav .btn { white-space: nowrap; flex-shrink: 0; }
}

@media (max-width: 640px) {
    .main-content {
        padding: 1rem;
    }

    .kanban-column {
        min-width: 260px;
    }

    .grid-stats   { grid-template-columns: 1fr; }
    .grid-3       { grid-template-columns: 1fr; }
    .grid-4       { grid-template-columns: 1fr; }
    .grid-cards   { grid-template-columns: 1fr; }
    .form-row-2   { grid-template-columns: 1fr; }
    .form-row-3   { grid-template-columns: 1fr; }
    .form-row-4   { grid-template-columns: 1fr; }
    .roadmap-filter-grid { grid-template-columns: 1fr !important; }

    .hide-mobile  { display: none !important; }

    .form-actions { flex-direction: column; }
    .form-actions .btn { width: 100%; justify-content: center; }

    .page-header { flex-direction: column; align-items: stretch; }
}

/* ---------- Scrollbar ---------- */
::-webkit-scrollbar {
    width: 4px;
    height: 4px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 2px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* ---------- Utility ---------- */
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-primary-color { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* ---------- Modal System ---------- */
.modal {
    position: fixed;
    inset: 0;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.modal.open {
    opacity: 1;
    visibility: visible;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.7);
}

.modal-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    margin: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(20px) scale(0.98);
    transition: transform 0.2s ease;
}

.modal.open .modal-container {
    transform: translateY(0) scale(1);
}

.modal-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius);
    transition: all var(--transition);
    z-index: 10;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-content {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-header {
    margin-bottom: 1rem;
    padding-right: 2rem;
}

.modal-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.modal-meta {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.modal-description {
    background: var(--bg-hover);
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.modal-details {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    font-size: 0.85rem;
}

.modal-details-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.modal-details-label {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.modal-details-value {
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 0.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    margin-top: 1rem;
}

.modal-actions-left {
    flex: 1;
}

.modal-actions-right {
    display: flex;
    gap: 0.5rem;
}

.modal-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-muted);
    gap: 0.5rem;
}

.modal-error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    color: var(--danger);
    gap: 0.5rem;
}

.modal-flash {
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    animation: flashIn 0.2s ease;
    transition: opacity 0.3s ease;
}

.modal-flash.flash-success {
    background: rgba(52, 211, 153, 0.1);
    color: var(--success);
}

.modal-flash.flash-error {
    background: rgba(248, 113, 113, 0.1);
    color: var(--danger);
}

/* Modal Form Styles */
.modal-edit-form .form-group {
    margin-bottom: 0.85rem;
}

.modal-edit-form .form-label {
    font-size: 0.75rem;
}

.modal-edit-form .form-input,
.modal-edit-form .form-select,
.modal-edit-form .form-textarea {
    font-size: 0.85rem;
}

.modal-edit-form .form-textarea {
    min-height: 70px;
}

.modal-edit-form .form-row-2 {
    gap: 0.75rem;
}

/* Mobile: Bottom sheet style */
@media (max-width: 640px) {
    .modal {
        align-items: flex-end;
    }

    .modal-container {
        margin: 0;
        max-width: 100%;
        max-height: 85vh;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        transform: translateY(100%);
    }

    .modal.open .modal-container {
        transform: translateY(0);
    }

    .modal-details {
        grid-template-columns: 1fr;
    }

    .modal-actions {
        flex-direction: column;
    }

    .modal-actions-right {
        flex-direction: column;
    }

    .modal-actions .btn {
        width: 100%;
        justify-content: center;
    }
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }

/* ---------- Notifications ---------- */
.notif-bell-btn:hover {
    color: var(--primary) !important;
    border-color: var(--primary) !important;
}

.notif-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 360px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 50;
    animation: notifDropIn 0.15s ease;
}

@keyframes notifDropIn {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.notif-item:hover {
    background: var(--bg-hover);
}

.notif-item:last-child {
    border-bottom: none !important;
}

@media (max-width: 640px) {
    .notif-dropdown {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    }
}

/* ---------- Cornell Notes Layout ---------- */
.cornell-grid {
    display: flex;
    flex-direction: column;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.cornell-section {
    padding: 1rem 1.25rem;
}

.cornell-section h2 {
    font-size: 0.7rem;
    font-family: var(--font-mono);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    margin: 0 0 0.5rem;
}

.cornell-section h2:first-child {
    margin-top: 0;
}

.cornell-dados {
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.cornell-dados ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.cornell-dados li {
    margin: 0;
}

.cornell-columns {
    display: grid;
    grid-template-columns: 1fr 2fr;
    border-bottom: 1px solid var(--border);
}

.cornell-cues {
    border-right: 1px solid var(--border);
    background: var(--bg-hover);
}

.cornell-cues ul,
.cornell-cues ol {
    padding-left: 1.25rem;
    margin: 0;
}

.cornell-cues li {
    font-size: 0.85rem;
    margin: 0.25rem 0;
    font-weight: 500;
}

.cornell-notes-col {
    background: var(--bg-card);
}

.cornell-notes-col ul,
.cornell-notes-col ol {
    padding-left: 1.25rem;
    margin: 0;
}

.cornell-notes-col li {
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.cornell-decisions {
    background: rgba(251, 191, 36, 0.05);
    border-bottom: 1px solid var(--border);
}

.cornell-decisions ul {
    padding-left: 1.25rem;
    margin: 0;
}

.cornell-decisions li {
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

.cornell-summary {
    background: var(--bg-hover);
}

.cornell-summary blockquote {
    border-left: 3px solid var(--primary);
    padding: 0.35rem 1rem;
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.cornell-summary p {
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

/* Cornell Form Fields */
.cornell-form-fields {
    margin-bottom: 1rem;
}

.cornell-form-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.65rem;
    background: var(--primary-light);
    color: var(--primary);
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.cornell-form-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 0;
}


@media (max-width: 640px) {
    .cornell-columns {
        grid-template-columns: 1fr;
    }

    .cornell-cues {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .cornell-form-columns {
        grid-template-columns: 1fr;
    }

    .cornell-dados ul {
        flex-direction: column;
        gap: 0.35rem;
    }

}

/* ---------- Selection ---------- */
::selection {
    background: var(--primary);
    color: #fff;
}
