:root,
[data-theme="dark"] {
    --bg: #0b0d12;
    --surface: #12151c;
    --surface2: #181c26;
    --border: #2a3142;
    --text: #eef2ff;
    --muted: #8b95a8;
    --accent: #6366f1;
    --accent2: #818cf8;
    --success: #22c55e;
    --success-text: #86efac;
    --warn-text: #fcd34d;
    --danger: #ef4444;
    --brand-h: #fff;
    --radius: 14px;
    --shadow: 0 12px 40px rgba(0,0,0,.35);
    --topbar-bg: rgba(11,13,18,.85);
    --body-glow: rgba(99,102,241,.18);
    --modal-overlay: rgba(0,0,0,.7);
    --nav-active-bg: rgba(99,102,241,.15);
    --row-border: rgba(42,49,66,.6);
    --btn-success-bg: rgba(34,197,94,.15);
    --btn-success-border: rgba(34,197,94,.35);
    --btn-warn-bg: rgba(245,158,11,.12);
    --btn-warn-border: rgba(245,158,11,.35);
    --tag-done: #86efac;
    --tag-done-border: rgba(34,197,94,.35);
    --tag-progress: #fcd34d;
    --tag-progress-border: rgba(245,158,11,.35);
}

[data-theme="light"] {
    --bg: #eef1f7;
    --surface: #ffffff;
    --surface2: #f5f7fb;
    --border: #d5dbe8;
    --text: #151a28;
    --muted: #5c657a;
    --accent: #4f46e5;
    --accent2: #6366f1;
    --success: #16a34a;
    --success-text: #15803d;
    --warn-text: #b45309;
    --danger: #dc2626;
    --brand-h: #151a28;
    --shadow: 0 12px 40px rgba(15,23,42,.08);
    --topbar-bg: rgba(255,255,255,.92);
    --body-glow: rgba(99,102,241,.08);
    --modal-overlay: rgba(15,23,42,.35);
    --nav-active-bg: rgba(99,102,241,.1);
    --row-border: rgba(213,219,232,.9);
    --btn-success-bg: rgba(34,197,94,.12);
    --btn-success-border: rgba(34,197,94,.28);
    --btn-warn-bg: rgba(245,158,11,.1);
    --btn-warn-border: rgba(245,158,11,.28);
    --tag-done: #15803d;
    --tag-done-border: rgba(34,197,94,.35);
    --tag-progress: #b45309;
    --tag-progress-border: rgba(245,158,11,.35);
}

html { color-scheme: dark light; }
[data-theme="dark"] { color-scheme: dark; }
[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: radial-gradient(ellipse 120% 80% at 50% -20%, var(--body-glow), transparent 55%), var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background-color .25s, color .25s;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: .88rem; }

.login-screen {
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px;
}
.login-card {
    width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border);
    border-radius: 20px; padding: 32px; box-shadow: var(--shadow);
}
.brand { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.brand-r { color: #f87171; }
.brand-h { color: var(--brand-h); }
.brand small { display: block; font-size: .78rem; color: var(--muted); font-weight: 500; margin-top: 4px; }
.login-desc { color: var(--muted); font-size: .9rem; margin-bottom: 20px; line-height: 1.45; }
label { display: block; font-size: .78rem; color: var(--muted); margin: 10px 0 6px; }
input, textarea, select {
    width: 100%; background: var(--bg); border: 1px solid var(--border); color: var(--text);
    border-radius: 10px; padding: 10px 12px; font: inherit; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); }
.btn {
    border: none; border-radius: 10px; padding: 10px 16px; font: inherit; font-weight: 600;
    cursor: pointer; transition: .15s;
}
.btn-primary { background: linear-gradient(135deg, var(--accent), #4f46e5); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-ghost { background: transparent; color: var(--muted); border: 1px solid var(--border); }
.btn-ghost:hover { color: var(--text); border-color: var(--accent2); }
.btn-success { background: var(--btn-success-bg); color: var(--success-text); border: 1px solid var(--btn-success-border); }
.btn-warn { background: var(--btn-warn-bg); color: var(--warn-text); border: 1px solid var(--btn-warn-border); }
.btn-sm { padding: 6px 10px; font-size: .78rem; }
.login-err { color: var(--danger); font-size: .84rem; margin-top: 12px; min-height: 1.2em; }
.login-card .btn-primary { width: 100%; margin-top: 16px; }

.topbar {
    position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 20px;
    padding: 12px 24px; background: var(--topbar-bg); backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    transition: background-color .25s, border-color .25s;
}
.topbar-brand { font-weight: 800; white-space: nowrap; }
.topbar-nav { display: flex; gap: 6px; flex: 1; flex-wrap: wrap; }
.nav-btn {
    background: transparent; border: none; color: var(--muted); padding: 8px 14px;
    border-radius: 999px; font: inherit; font-weight: 600; cursor: pointer;
}
.nav-btn.on, .nav-btn:hover { background: var(--nav-active-bg); color: var(--accent2); }
.topbar-user { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-weight: 700; font-size: .9rem; }
.user-title { font-size: .72rem; color: var(--muted); }

.avatar {
    width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: .85rem; background: linear-gradient(135deg, var(--accent), #ec4899); color: #fff;
    flex-shrink: 0;
}
.avatar.sm { width: 32px; height: 32px; font-size: .72rem; }
.avatar.lg { width: 72px; height: 72px; font-size: 1.4rem; margin: 0 auto 12px; }

.badge {
    display: inline-flex; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
    background: var(--danger); color: #fff; font-size: .68rem; font-weight: 700; align-items: center; justify-content: center;
}

.layout {
    display: grid; grid-template-columns: 260px minmax(0, 1fr) 240px; gap: 20px;
    max-width: 1280px; margin: 0 auto; padding: 20px 24px 40px;
}
.sidebar-left, .sidebar-right { position: sticky; top: 76px; align-self: start; }
.profile-card, .sidebar-block {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 14px;
    transition: background-color .25s, border-color .25s;
}
.profile-card { text-align: center; }
.profile-card h3 { font-size: 1rem; margin-bottom: 4px; }
.profile-card p { color: var(--muted); font-size: .82rem; margin-bottom: 14px; }
.profile-stats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.profile-stats b { display: block; font-size: 1.2rem; }
.profile-stats span { font-size: .72rem; color: var(--muted); }
.sidebar-block h4 { font-size: .82rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 10px; }
.progress-bar { height: 8px; background: var(--bg); border-radius: 999px; overflow: hidden; margin-bottom: 8px; }
.progress-fill { height: 100%; background: linear-gradient(90deg, var(--accent), var(--success)); transition: width .3s; }

.composer {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.composer-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; font-weight: 600; }
.composer input, .composer textarea { margin-bottom: 10px; }
.composer-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.composer-row select { width: auto; min-width: 120px; flex: 1; }

.view { display: none; }
.view.on { display: block; }

.post {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; margin-bottom: 12px; animation: fadeIn .25s ease;
}
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.post-head { display: flex; gap: 12px; margin-bottom: 12px; }
.post-meta { flex: 1; min-width: 0; }
.post-name { font-weight: 700; }
.post-time { font-size: .76rem; color: var(--muted); }
.post-action { font-size: .92rem; line-height: 1.45; margin-bottom: 10px; }
.post-action strong { color: var(--accent2); }
.task-card {
    background: var(--surface2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px;
}
.task-card h4 { font-size: .95rem; margin-bottom: 6px; }
.task-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.tag {
    font-size: .72rem; padding: 3px 8px; border-radius: 999px; background: var(--bg);
    border: 1px solid var(--border); color: var(--muted);
}
.tag.done { color: var(--tag-done); border-color: var(--tag-done-border); }
.tag.progress { color: var(--tag-progress); border-color: var(--tag-progress-border); }
.post-text { font-size: .88rem; color: var(--muted); margin-top: 8px; line-height: 1.5; white-space: pre-wrap; }
.post-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.phase-block {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    margin-bottom: 12px; overflow: hidden;
}
.phase-head {
    padding: 14px 16px; background: var(--surface2); border-bottom: 1px solid var(--border);
    display: flex; justify-content: space-between; gap: 10px;
}
.phase-head h3 { font-size: .95rem; }
.phase-head p { font-size: .8rem; color: var(--muted); margin-top: 4px; }
.task-row {
    display: grid; grid-template-columns: 1fr auto; gap: 12px; padding: 12px 16px;
    border-bottom: 1px solid var(--row-border); align-items: start;
}
.task-row:last-child { border-bottom: none; }

.team-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.team-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 16px; text-align: center;
}
.team-mini .team-line {
    display: flex; align-items: center; gap: 8px; padding: 6px 0; font-size: .84rem;
}
.team-stats {
    margin-top: 8px; font-size: .8rem; line-height: 1.45; color: var(--muted);
}
.team-stats b { color: var(--text); font-weight: 600; }
.team-stats + .team-stats { margin-top: 4px; }
.chip {
    display: block; width: 100%; text-align: left; margin-bottom: 6px; padding: 8px 10px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px; color: var(--text);
    font: inherit; cursor: pointer;
}
.chip:hover { border-color: var(--accent); }

.modal {
    position: fixed; inset: 0; background: var(--modal-overlay); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; z-index: 100; padding: 20px;
}
.modal-box {
    background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
    padding: 22px; width: min(480px, 100%); box-shadow: var(--shadow);
}
.modal-box h3 { margin-bottom: 6px; }
.modal-box textarea { margin: 12px 0; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; }

.toast {
    position: fixed; bottom: 20px; right: 20px; background: var(--surface2); border: 1px solid var(--success);
    padding: 12px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 200;
}
.toast.show { opacity: 1; }
.toast.err { border-color: var(--danger); }

.theme-toggle {
    width: 40px; height: 40px; border-radius: 999px; border: 1px solid var(--border);
    background: var(--surface); color: var(--text); font-size: 1.1rem; line-height: 1;
    cursor: pointer; display: inline-flex; align-items: center; justify-content: center;
    transition: .2s; flex-shrink: 0;
}
.theme-toggle:hover { border-color: var(--accent); transform: scale(1.04); }
.theme-toggle.login-theme {
    position: fixed; top: 18px; right: 18px; z-index: 60;
    box-shadow: var(--shadow);
}
body:has(#app:not(.hidden)) .login-theme { display: none; }

@media (max-width: 1024px) {
    .layout { grid-template-columns: 1fr; }
    .sidebar-left, .sidebar-right { position: static; }
    .sidebar-right { display: none; }
}
