:root {
    --navy: #15213b;
    --navy-2: #21345d;
    --blue: #2563eb;
    --blue-soft: #eaf1ff;
    --lime: #c9f24a;
    --orange: #ff8a3d;
    --green: #16a34a;
    --red: #dc2626;
    --amber: #d97706;
    --ink: #162033;
    --muted: #68758a;
    --line: #dfe6ef;
    --surface: #ffffff;
    --canvas: #f4f7fb;
    --shadow: 0 16px 44px rgba(21, 33, 59, .09);
    --radius: 18px;
    --sidebar: 260px;
}

* { box-sizing: border-box; }
html { font-size: 16px; }
body { margin: 0; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; color: var(--ink); background: var(--canvas); }
button, input, select { font: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: var(--sidebar); padding: 22px 18px; background: linear-gradient(180deg, var(--navy), #101a31); color: white; z-index: 30; display: flex; flex-direction: column; }
.brand { display: flex; align-items: center; gap: 12px; padding: 2px 8px 22px; }
.brand-mark { width: 46px; height: 46px; display: grid; place-items: center; border-radius: 14px; background: var(--lime); color: var(--navy); font-weight: 900; font-size: 24px; box-shadow: 0 9px 24px rgba(201,242,74,.2); }
.brand strong { display: block; font-size: 19px; }
.brand small { color: #aebbd3; }
.side-nav { display: grid; gap: 7px; }
.nav-item { border: 0; color: #d9e2f2; background: transparent; border-radius: 13px; padding: 13px 14px; display: flex; align-items: center; gap: 12px; text-align: left; font-weight: 700; }
.nav-item:hover, .nav-item.active { color: white; background: rgba(255,255,255,.11); }
.nav-icon { width: 25px; font-size: 19px; text-align: center; }
.sidebar-note { margin-top: auto; padding: 16px; border: 1px solid rgba(255,255,255,.12); border-radius: 16px; background: rgba(255,255,255,.06); }
.sidebar-note strong { display: block; margin-bottom: 6px; }
.sidebar-note p { margin: 0; color: #b9c5d9; font-size: 13px; line-height: 1.5; }

.main { margin-left: var(--sidebar); min-height: 100vh; }
.topbar { position: sticky; top: 0; height: 76px; z-index: 20; padding: 0 30px; display: flex; align-items: center; justify-content: space-between; background: rgba(244,247,251,.9); backdrop-filter: blur(16px); border-bottom: 1px solid rgba(223,230,239,.8); }
.topbar-left, .topbar-right, .user-chip { display: flex; align-items: center; gap: 12px; }
.topbar h1 { margin: 0; font-size: 23px; }
.menu-btn { display: none; border: 0; background: white; border-radius: 11px; width: 42px; height: 42px; box-shadow: 0 5px 18px rgba(21,33,59,.08); }
.status-pill { padding: 8px 11px; border-radius: 999px; font-size: 13px; font-weight: 800; }
.status-ok { background: #eaf8ef; color: #137139; }
.status-error { background: #fff0f0; color: #b42318; }
.user-avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; background: var(--navy); color: white; font-weight: 800; }
.user-copy strong, .user-copy small { display: block; }
.user-copy small { color: var(--muted); margin-top: 2px; }

.content { padding: 28px 30px 100px; max-width: 1500px; margin: 0 auto; }
.hero { display: grid; grid-template-columns: minmax(0,1.6fr) minmax(280px,.7fr); gap: 22px; margin-bottom: 22px; }
.hero-main { position: relative; overflow: hidden; padding: 32px; border-radius: 24px; color: white; background: linear-gradient(135deg, var(--navy), var(--navy-2)); box-shadow: var(--shadow); }
.hero-main::after { content: ""; position: absolute; width: 230px; height: 230px; border-radius: 50%; right: -65px; top: -75px; background: rgba(201,242,74,.13); }
.hero-main .kicker { color: var(--lime); font-weight: 900; letter-spacing: .04em; text-transform: uppercase; font-size: 13px; }
.hero-main h2 { margin: 10px 0 10px; max-width: 700px; font-size: clamp(27px, 4vw, 42px); line-height: 1.1; }
.hero-main p { color: #d8e2f2; max-width: 720px; font-size: 17px; line-height: 1.65; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 11px; margin-top: 24px; }
.hero-side { padding: 24px; border-radius: 24px; background: linear-gradient(145deg, #f2ffd0, #e8f5b9); border: 1px solid #d9eb9c; }
.hero-side .big-icon { font-size: 40px; }
.hero-side h3 { font-size: 21px; margin: 15px 0 7px; }
.hero-side p { color: #52612e; line-height: 1.55; }

.btn { border: 0; border-radius: 12px; padding: 11px 16px; font-weight: 800; transition: .18s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--lime); color: var(--navy); }
.btn-dark { background: var(--navy); color: white; }
.btn-secondary { background: white; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost { background: var(--blue-soft); color: var(--blue); }
.btn-danger { background: #fff0f0; color: var(--red); }
.btn-small { padding: 8px 11px; font-size: 13px; }

.metrics { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 16px; margin: 22px 0; }
.metric { background: white; border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; align-items: center; gap: 15px; box-shadow: 0 8px 28px rgba(21,33,59,.04); }
.metric-icon { width: 48px; height: 48px; border-radius: 15px; display: grid; place-items: center; background: var(--blue-soft); font-size: 21px; }
.metric strong { display: block; font-size: 27px; }
.metric span { color: var(--muted); font-size: 14px; }

.section-card { margin-top: 20px; padding: 22px; border-radius: 22px; background: white; border: 1px solid var(--line); box-shadow: 0 10px 34px rgba(21,33,59,.045); }
.section-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-head h2 { margin: 0 0 5px; font-size: 21px; }
.section-head p { margin: 0; color: var(--muted); }
.project-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.project-card { border: 1px solid var(--line); border-radius: 17px; padding: 18px; background: #fff; }
.project-card-top, .project-card-footer, .progress-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.project-card h3 { margin: 5px 0 0; font-size: 18px; }
.eyebrow { color: var(--blue); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: .04em; }
.project-meta { color: var(--muted); margin: 11px 0 15px; }
.project-status { font-size: 12px; font-weight: 900; border-radius: 999px; padding: 6px 9px; background: #edf2f7; color: #536174; }
.status-ready { background: #e9f9ee; color: #15733b; }
.status-archived { background: #f3f4f6; color: #6b7280; }
.progress-row strong { font-size: 13px; color: var(--muted); }
.progress-track { flex: 1; height: 8px; overflow: hidden; border-radius: 999px; background: #eef2f7; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--blue), #5b8cff); }
.project-card-footer { margin-top: 15px; padding-top: 14px; border-top: 1px solid #edf1f5; color: var(--muted); font-size: 12px; }
.empty-state { padding: 38px 20px; text-align: center; border: 1px dashed #cdd7e5; border-radius: 17px; background: #fbfcfe; }
.empty-state.compact { padding: 28px; }
.empty-icon { font-size: 39px; }
.empty-state h3 { margin: 10px 0 6px; }
.empty-state p { color: var(--muted); margin: 0 0 18px; }

.phase-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 13px; }
.phase-card { padding: 17px; border-radius: 16px; border: 1px solid var(--line); background: #fff; }
.phase-number { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--navy); color: white; font-weight: 900; }
.phase-card h3 { margin: 13px 0 6px; font-size: 16px; }
.phase-card p { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }
.phase-card.current { background: #f3ffd3; border-color: #d4e98e; }
.phase-card.current .phase-number { background: var(--lime); color: var(--navy); }
.phase-card.locked { opacity: .55; }

.dialog { width: min(620px, calc(100% - 28px)); padding: 0; border: 0; border-radius: 22px; box-shadow: 0 24px 80px rgba(10,20,40,.25); }
.dialog::backdrop { background: rgba(12,20,35,.55); backdrop-filter: blur(5px); }
.dialog-head { padding: 22px 24px 15px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; }
.dialog-head h2 { margin: 0; }
.icon-btn { width: 38px; height: 38px; border: 0; border-radius: 10px; background: #f0f3f8; }
.dialog-body { padding: 22px 24px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 15px; }
.field { display: grid; gap: 7px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 800; }
.field input, .field select { width: 100%; border: 1px solid #cad5e2; border-radius: 11px; padding: 11px 12px; background: white; color: var(--ink); }
.field input:focus, .field select:focus { outline: 3px solid rgba(37,99,235,.13); border-color: var(--blue); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 0 24px 22px; }
.workspace-dialog { width: min(920px, calc(100% - 28px)); }
.workspace-summary { display: grid; grid-template-columns: 1fr auto auto; gap: 13px; align-items: center; padding: 18px; border: 1px solid var(--line); border-radius: 16px; }
.workspace-summary h3 { margin: 0 0 4px; }
.workspace-summary p { margin: 0; color: var(--muted); }
.workspace-stat { padding: 11px 14px; background: #f3f6fb; border-radius: 12px; font-weight: 800; }
.workspace-steps { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 11px; margin-top: 16px; }
.workspace-step { padding: 15px; border-radius: 14px; border: 1px solid var(--line); background: #fff; }
.workspace-step strong { display: block; margin-bottom: 5px; }
.workspace-step small { color: var(--muted); }
.workspace-step.active { background: #eff5ff; border-color: #bfd2ff; }
.workspace-step.locked { opacity: .5; }

.toast-host { position: fixed; z-index: 100; right: 22px; bottom: 22px; display: grid; gap: 9px; }
.toast { min-width: 250px; max-width: 390px; padding: 13px 15px; border-radius: 12px; background: var(--navy); color: white; box-shadow: var(--shadow); transform: translateY(12px); opacity: 0; transition: .2s ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.toast-success { background: #15733b; }
.toast-warning { background: #9a5b08; }
.toast-error { background: #ad2b2b; }

.bottom-nav { display: none; }

@media (max-width: 1100px) {
    .hero { grid-template-columns: 1fr; }
    .phase-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

@media (max-width: 899px) {
    :root { --sidebar: 278px; }
    .sidebar { transform: translateX(-105%); transition: transform .22s ease; box-shadow: 20px 0 60px rgba(5,15,30,.25); }
    body.sidebar-open .sidebar { transform: translateX(0); }
    .main { margin-left: 0; }
    .menu-btn { display: grid; place-items: center; }
    .topbar { padding: 0 18px; }
    .content { padding: 20px 18px 100px; }
    .user-copy, #connectionStatus { display: none; }
    .project-grid { grid-template-columns: 1fr; }
    .bottom-nav { position: fixed; display: grid; grid-template-columns: repeat(4,1fr); inset: auto 0 0; height: 70px; background: rgba(255,255,255,.96); border-top: 1px solid var(--line); backdrop-filter: blur(14px); z-index: 25; }
    .bottom-nav button { border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
    .bottom-nav button span { display: block; font-size: 19px; margin-bottom: 3px; }
    .bottom-nav button.active { color: var(--blue); }
}

@media (max-width: 640px) {
    .hero-main { padding: 25px 21px; }
    .metrics { grid-template-columns: 1fr; }
    .phase-grid, .form-grid, .workspace-steps { grid-template-columns: 1fr; }
    .workspace-summary { grid-template-columns: 1fr 1fr; }
    .workspace-summary > div:first-child { grid-column: 1 / -1; }
    .section-card { padding: 17px; }
    .section-head { align-items: stretch; flex-direction: column; }
    .section-head .btn { width: 100%; }
}
