:root {
    --bg-0: #0d0f12;
    --bg-1: #14171b;
    --bg-2: #1a1e23;
    --bg-3: #21262d;
    --border: #2a2f37;
    --border-light: #333941;
    --text-0: #f4f6f8;
    --text-1: #c7ccd4;
    --text-2: #8b95a5;
    --accent: #2dd4bf;
    --accent-dark: #14b8a6;
    --accent-soft: rgba(45, 212, 191, 0.12);
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, 0.12);
    --warning: #f5a524;
    --success: #22c55e;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
    --shadow-card: 0 1px 2px rgba(0,0,0,0.4), 0 8px 24px rgba(0,0,0,0.25);
    --sidebar-w: 248px;
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg-0);
    color: var(--text-0);
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-dark); }

h1, h2, h3, h4 { font-weight: 600; margin: 0 0 12px; color: var(--text-0); }
h1 { font-size: 24px; }
h2 { font-size: 18px; }
h3 { font-size: 15px; }

p { margin: 0 0 12px; }

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

.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 12px;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 8px 20px;
    font-weight: 700;
    font-size: 15px;
    letter-spacing: 0.2px;
}

.sidebar-brand .dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.nav-group { margin-bottom: 18px; }
.nav-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-2);
    padding: 0 10px 6px;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-1);
    font-size: 13.5px;
    font-weight: 500;
}

.nav-link:hover { background: var(--bg-2); color: var(--text-0); }
.nav-link.active { background: var(--accent-soft); color: var(--accent); }
.nav-link svg { flex-shrink: 0; width: 17px; height: 17px; }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    background: rgba(13,15,18,0.85);
    backdrop-filter: blur(8px);
    z-index: 20;
}

.topbar-search {
    flex: 1;
    max-width: 420px;
}

.topbar-search input {
    width: 100%;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-0);
    font-size: 13px;
}

.topbar-actions { display: flex; align-items: center; gap: 14px; }

.content { padding: 28px; flex: 1; }

.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-card);
}

.card + .card { margin-top: 16px; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

.stat-card {
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.stat-card .value { font-size: 28px; font-weight: 700; }
.stat-card .label { color: var(--text-2); font-size: 13px; }

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--border-light);
    background: var(--bg-2);
    color: var(--text-0);
    padding: 9px 16px;
    border-radius: var(--radius-md);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
}

.btn:hover { background: var(--bg-3); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #04241f; font-weight: 600; }
.btn-primary:hover { background: var(--accent-dark); }
.btn-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn.disabled { opacity: 0.4; pointer-events: none; }

form label {
    display: block;
    margin-bottom: 14px;
    font-size: 13px;
    color: var(--text-1);
    font-weight: 500;
}

form input[type=text], form input[type=password], form input[type=email],
form input[type=date], form input[type=number], form select, form textarea {
    width: 100%;
    margin-top: 6px;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 9px 12px;
    color: var(--text-0);
    font-size: 13.5px;
    font-family: var(--font);
}

form textarea { min-height: 100px; resize: vertical; }
form input:focus, form select:focus, form textarea:focus {
    outline: none;
    border-color: var(--accent);
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--bg-3);
    color: var(--text-1);
    border: 1px solid var(--border-light);
}

.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    font-size: 13.5px;
}
.alert-error { background: var(--danger-soft); color: #fca5a5; border: 1px solid rgba(239,68,68,0.35); }
.alert-success { background: rgba(34,197,94,0.12); color: #86efac; border: 1px solid rgba(34,197,94,0.35); }
.alert-info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(45,212,191,0.3); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--border); font-size: 13.5px; }
th { color: var(--text-2); font-weight: 600; font-size: 12px; text-transform: uppercase; letter-spacing: 0.4px; }
tr:hover td { background: var(--bg-2); }

.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
    color: #04241f;
    flex-shrink: 0;
}

.kanban-board { display: flex; gap: 14px; overflow-x: auto; padding-bottom: 12px; }
.kanban-column {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-width: 260px;
    max-width: 260px;
    padding: 12px;
    display: flex;
    flex-direction: column;
}
.kanban-column-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 4px 12px;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--text-1);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
.kanban-cards { display: flex; flex-direction: column; gap: 10px; min-height: 40px; }
.kanban-card {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    cursor: grab;
    font-size: 13px;
}
.kanban-card:hover { border-color: var(--accent); }
.kanban-card.dragging { opacity: 0.4; }
.kanban-cards.drag-over { background: var(--accent-soft); border-radius: var(--radius-md); }

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

.team-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 4px;
    border-bottom: 1px solid var(--border);
}
.team-item:last-child { border-bottom: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 18px; }
.tab { padding: 10px 16px; font-size: 13.5px; color: var(--text-2); border-bottom: 2px solid transparent; font-weight: 500; }
.tab.active { color: var(--text-0); border-color: var(--accent); }

.install-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-0); }
.install-wrap { width: 100%; max-width: 520px; padding: 24px; }
.install-header { text-align: center; margin-bottom: 20px; }
.install-steps { display: flex; justify-content: space-between; margin-bottom: 20px; font-size: 11px; color: var(--text-2); flex-wrap: wrap; gap: 6px; }
.install-steps .step.active { color: var(--accent); font-weight: 600; }
.req-list { list-style: none; padding: 0; margin: 0 0 20px; }
.req-list li { padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.req-list li.ok { color: var(--success); }
.req-list li.fail { color: var(--danger); }

.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: var(--bg-0); }
.login-card { width: 100%; max-width: 380px; padding: 32px; }
.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo h1 { font-size: 22px; }

.notif-panel {
    position: absolute;
    top: 54px;
    right: 24px;
    width: 340px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    display: none;
    z-index: 50;
}
.notif-panel.open { display: block; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.notif-item.unread { background: var(--accent-soft); }
.notif-item small { color: var(--text-2); }

.search-panel {
    position: absolute;
    top: 54px;
    left: 24px;
    width: 420px;
    max-height: 460px;
    overflow-y: auto;
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-card);
    display: none;
    z-index: 50;
}
.search-panel.open { display: block; }
.search-result { padding: 12px 16px; border-bottom: 1px solid var(--border); display: block; }
.search-result:hover { background: var(--bg-2); }
.search-result-type { font-size: 11px; text-transform: uppercase; color: var(--accent); font-weight: 700; }

.checklist-item { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border); }
.checklist-item.done span { text-decoration: line-through; color: var(--text-2); }

.comment { padding: 12px 0; border-bottom: 1px solid var(--border); }
.comment-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 13px; }
.comment-body { font-size: 13.5px; white-space: pre-wrap; }
.comment-body pre { background: var(--bg-2); padding: 10px; border-radius: var(--radius-sm); overflow-x: auto; }

.timeline-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-top: 6px; flex-shrink: 0; }

.progress-bar { height: 6px; border-radius: 999px; background: var(--bg-3); overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--accent); }

.lock-banner {
    background: var(--danger-soft);
    border: 1px solid rgba(239,68,68,0.35);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.mobile-toggle { display: none; }

#nl-palette {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding-top: 12vh;
    z-index: 200;
}
#nl-palette.open { display: flex; }
.palette-box {
    width: 100%;
    max-width: 560px;
    background: var(--bg-1);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
    overflow: hidden;
}
#nl-palette-input {
    width: 100%;
    background: transparent;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 16px 18px;
    color: var(--text-0);
    font-size: 15px;
    outline: none;
    box-sizing: border-box;
}
#nl-palette-results { max-height: 340px; overflow-y: auto; }
.palette-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    font-size: 13.5px;
    cursor: pointer;
    color: var(--text-1);
}
.palette-item.active, .palette-item:hover { background: var(--accent-soft); color: var(--text-0); }
.palette-type {
    font-size: 10.5px;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: 700;
    min-width: 74px;
}
.palette-keys {
    margin-left: auto;
    font-size: 11px;
    color: var(--text-2);
    background: var(--bg-3);
    padding: 2px 8px;
    border-radius: 4px;
}

.heatmap { display: flex; flex-wrap: wrap; gap: 3px; }
.heat-cell { width: 12px; height: 12px; border-radius: 3px; background: var(--bg-3); }
.heat-1 { background: rgba(45,212,191,0.25); }
.heat-2 { background: rgba(45,212,191,0.5); }
.heat-3 { background: rgba(45,212,191,0.75); }
.heat-4 { background: var(--accent); }

.md-content h2, .md-content h3, .md-content h4 { margin-top: 18px; }
.md-p { margin: 0 0 8px; }
.md-list { margin: 8px 0; padding-left: 22px; }
.md-code {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px;
    overflow-x: auto;
    font-size: 12.5px;
}
.md-inline {
    background: var(--bg-3);
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 12.5px;
    color: var(--accent);
}

[data-theme="light"] {
    --bg-0: #f5f6f8;
    --bg-1: #ffffff;
    --bg-2: #eef0f3;
    --bg-3: #e2e5ea;
    --border: #d7dbe2;
    --border-light: #c9ced7;
    --text-0: #16181d;
    --text-1: #3c4250;
    --text-2: #6b7280;
    --accent: #0d9488;
    --accent-dark: #0f766e;
    --accent-soft: rgba(13,148,136,0.1);
    --shadow-card: 0 1px 2px rgba(0,0,0,0.06), 0 8px 24px rgba(0,0,0,0.06);
}
[data-theme="light"] .topbar { background: rgba(245,246,248,0.85); }

@media (max-width: 960px) {
    .sidebar { position: fixed; left: -260px; z-index: 100; transition: left 0.2s ease; box-shadow: var(--shadow-card); }
    .sidebar.open { left: 0; }
    .mobile-toggle { display: inline-flex; }
    .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
    .content { padding: 16px; }
    .topbar { padding: 0 14px; }
    .topbar-search { display: none; }
}
