:root {
    --bg: #ffffff;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --surface-hover: #f8fafc;
    --accent: #0f172a;
    --accent-hover: #1e293b;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #fecaca;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 24px;
}

.container.narrow {
    max-width: 640px;
}

/* ---------- Hero (landing) ---------- */
.hero {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.hero-inner {
    max-width: 560px;
    text-align: center;
}

.hero h1 {
    font-size: 3rem;
    margin: 0 0 24px;
    letter-spacing: -0.025em;
    font-weight: 600;
}

.tagline {
    font-size: 1.125rem;
    color: var(--muted);
    margin-bottom: 40px;
}

.cta-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-block;
    padding: 12px 24px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    font-size: 1rem;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
    font-family: inherit;
    line-height: 1.4;
}

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: transparent; color: var(--accent); }
.btn-secondary:hover { background: var(--surface-hover); }

.btn-block { width: 100%; }

.btn-link {
    background: none;
    border: none;
    color: var(--muted);
    cursor: pointer;
    font-family: inherit;
    font-size: inherit;
    padding: 0;
    text-decoration: underline;
}
.btn-link:hover { color: var(--text); }

.inline-form { display: inline; margin: 0; }

/* ---------- Pages ---------- */
.page { padding: 48px 0; }

.back-link {
    color: var(--muted);
    text-decoration: none;
    font-size: 0.9rem;
    margin-bottom: 24px;
    display: inline-block;
}
.back-link:hover { color: var(--text); }

h1 {
    font-size: 2rem;
    margin: 0 0 24px;
    letter-spacing: -0.015em;
    font-weight: 600;
}

.email-link {
    color: var(--accent);
    font-size: 1.125rem;
}

/* ---------- Login ---------- */
.login-container {
    max-width: 400px;
    margin: 0 auto;
    padding: 48px 24px;
}

.form { display: flex; flex-direction: column; gap: 16px; }
.form label { display: flex; flex-direction: column; gap: 6px; }
.form label span { font-size: 0.875rem; color: var(--muted); }

.form input {
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 1rem;
    font-family: inherit;
    background: #fff;
}
.form input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.form button { margin-top: 8px; }

.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 0.9rem;
    border: 1px solid transparent;
}
.alert-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

/* ---------- Hub ---------- */
.hub-header {
    border-bottom: 1px solid var(--border);
    padding: 16px 0;
    background: #fff;
}

.hub-header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-weight: 600;
    color: var(--text);
    text-decoration: none;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}

.user-email { color: var(--text); }

.badge {
    background: var(--accent);
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.app-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, transform 0.15s, box-shadow 0.15s;
}

.app-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
}

.app-card h3 { margin: 0; font-size: 1.125rem; font-weight: 600; }
.app-card p { margin: 0; color: var(--muted); font-size: 0.9rem; flex: 1; }

.app-link {
    color: var(--accent);
    font-size: 0.875rem;
    margin-top: 8px;
}

.muted { color: var(--muted); }

/* ---------- Project page ---------- */
.project-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}
.project-header h1 { margin: 0 0 8px; }
.project-client {
    font-size: 0.875rem;
    color: var(--muted);
    margin: 0 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.phases-section, .phase-section, .docs-section { margin-bottom: 48px; }
.phases-section h2, .phase-section h2, .docs-section h2 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin: 0 0 16px;
}

/* ===== Status colors ===== */
:root {
    --status-done: #16a34a;
    --status-done-soft: #dcfce7;
    --status-current: #f59e0b;
    --status-current-soft: #fef3c7;
    --status-current-bg: #fffbeb;
    --status-current-border: #fde68a;
}

/* ===== Phase Stepper (horizontal process) ===== */
.phase-stepper {
    list-style: none;
    padding: 24px 0 8px;
    margin: 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
    position: relative;
}
.phase-step {
    flex: 1;
    min-width: 0;
    text-align: center;
    position: relative;
    padding: 0 4px;
}
/* connector line drawn from each step (except last) toward the next */
.phase-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 27px;          /* center on 54px circle */
    left: calc(50% + 32px);
    right: calc(-50% + 32px);
    height: 3px;
    border-radius: 2px;
    background: var(--border);
    z-index: 0;
}
.phase-step.phase-done:not(:last-child)::after {
    background: var(--status-done);
}
.phase-step.phase-in_progress:not(:last-child)::after {
    background: linear-gradient(to right, var(--status-current) 0%, var(--status-current) 50%, var(--border) 50%);
}

.phase-circle {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--border-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
    position: relative;
    z-index: 1;
    color: var(--muted);
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}
.phase-done .phase-circle {
    background: var(--status-done);
    border-color: var(--status-done);
    color: #fff;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.2);
}
.phase-in_progress .phase-circle {
    background: var(--status-current);
    border-color: var(--status-current);
    color: #fff;
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.35);
}
.phase-upcoming .phase-circle {
    border-style: dashed;
}
.phase-num { font-size: 1.05rem; }
.phase-pulse-dot {
    width: 14px;
    height: 14px;
    background: #fff;
    border-radius: 50%;
    position: relative;
}
.phase-pulse-dot::before {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid #fff;
    opacity: 0.6;
    animation: phase-ring 2s ease-out infinite;
}
@keyframes phase-ring {
    0%   { transform: scale(0.6); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}

.phase-meta { margin-top: 12px; }
.phase-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
    line-height: 1.3;
}
.phase-upcoming .phase-name { color: var(--muted); }
.phase-sub {
    margin-top: 2px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
}
.phase-done .phase-sub { color: var(--status-done); }
.phase-in_progress .phase-sub { color: var(--status-current); font-weight: 600; }

/* ===== Inline dots (used inside cards for tasks) ===== */
.dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}
.dot-done { background: var(--status-done); color: #fff; }
.dot-current { background: var(--status-current); color: #fff; }
.dot-upcoming { background: transparent; color: var(--muted); border: 1px solid var(--border-strong); }

/* ===== Sprint Timeline (vertical) ===== */
.sprint-timeline {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
}
/* vertical rail behind the dots */
.sprint-timeline::before {
    content: '';
    position: absolute;
    left: 13px;
    top: 14px;
    bottom: 14px;
    width: 2px;
    background: var(--border);
    border-radius: 1px;
}
.sprint-node {
    display: flex;
    gap: 20px;
    margin-bottom: 14px;
    position: relative;
    align-items: flex-start;
}
.sprint-node:last-child { margin-bottom: 0; }

.sprint-dot {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--border-strong);
    flex-shrink: 0;
    margin-top: 14px;
    z-index: 1;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    transition: transform 0.2s;
}
.sprint-done .sprint-dot {
    background: var(--status-done);
    border-color: var(--status-done);
    color: #fff;
    box-shadow: 0 2px 6px rgba(22, 163, 74, 0.25);
}
.sprint-in_progress .sprint-dot {
    background: var(--status-current);
    border-color: var(--status-current);
    color: #fff;
    box-shadow: 0 0 0 4px var(--status-current-soft);
}
.sprint-pulse {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    animation: sprint-pulse 1.6s ease-in-out infinite;
}
@keyframes sprint-pulse {
    0%, 100% { transform: scale(0.7); opacity: 0.7; }
    50%      { transform: scale(1.0); opacity: 1; }
}

.sprint-card {
    flex: 1;
    min-width: 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 20px;
    transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}
.sprint-card:hover {
    border-color: var(--border-strong);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.05);
}
.sprint-in_progress .sprint-card {
    background: linear-gradient(135deg, var(--status-current-bg) 0%, #fff 70%);
    border-color: var(--status-current-border);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.08);
}
.sprint-upcoming .sprint-card {
    background: var(--surface-hover);
    border-style: dashed;
}

.sprint-card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}
.sprint-name {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}
.sprint-upcoming .sprint-name { color: var(--muted); font-weight: 500; }

.sprint-card-meta {
    margin-top: 8px;
    font-size: 0.85rem;
    color: var(--muted);
}

.sprint-link {
    display: inline-block;
    margin-top: 10px;
    font-size: 0.85rem;
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
}
.sprint-link:hover { text-decoration: underline; }

/* ===== Task progress bar ===== */
.task-progress {
    margin-top: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}
.task-progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.task-progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--status-current), #fbbf24);
    border-radius: 3px;
    transition: width 0.4s ease;
}
.task-progress-text {
    font-size: 0.8rem;
    color: var(--muted);
    font-weight: 500;
    white-space: nowrap;
}

/* ===== Task list (inside in-progress sprint) ===== */
.task-list {
    list-style: none;
    padding: 14px 0 0;
    margin: 14px 0 0;
    border-top: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.task-list.standalone { border-top: none; padding-top: 14px; margin-top: 14px; border-top: 1px dashed var(--border); }
.task { display: flex; align-items: center; gap: 10px; font-size: 0.92rem; }
.task-done span { color: var(--muted); text-decoration: line-through; }
.task-upcoming span { color: var(--muted); }

/* Optional free-form detail under a task (rendered as preformatted text). */
.task-detail {
    width: 100%;
    margin: 6px 0 4px 30px;
    padding: 10px 14px;
    background: var(--surface-hover);
    border-left: 3px solid var(--accent);
    border-radius: 4px;
    font-size: 0.84rem;
    line-height: 1.6;
    color: var(--text);
    white-space: pre-line;
}
.task-done .task-detail { text-decoration: none; color: var(--text); }

.doc-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.doc-item a {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text);
    background: #fff;
    transition: border-color 0.15s, transform 0.15s;
}
.doc-item a:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.doc-kind {
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    padding: 4px 8px;
    border-radius: 4px;
    background: var(--surface-hover);
    color: var(--muted);
    min-width: 38px;
    text-align: center;
}
.doc-kind-pdf { background: #fee2e2; color: #991b1b; }
.doc-kind-md { background: #e0e7ff; color: #3730a3; }
.doc-kind-image { background: #dcfce7; color: #166534; }
.doc-title { flex: 1; font-weight: 500; }
.doc-arrow { color: var(--muted); }

.status-pill {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.status-pill.status-done { background: #dcfce7; color: #166534; }
.status-pill.status-current { background: #fef3c7; color: #92400e; }
.status-pill.status-upcoming { background: var(--surface-hover); color: var(--muted); }

.mt-32 { margin-top: 32px; }

/* Rendered markdown */
.md-content { line-height: 1.7; }
.md-content h1, .md-content h2, .md-content h3 { margin-top: 32px; margin-bottom: 12px; }
.md-content h1 { font-size: 1.75rem; }
.md-content h2 { font-size: 1.4rem; }
.md-content h3 { font-size: 1.15rem; }
.md-content p { margin: 0 0 14px; }
.md-content ul, .md-content ol { margin: 0 0 14px; padding-left: 24px; }
.md-content code {
    background: var(--surface-hover);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.md-content pre {
    background: var(--surface-hover);
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-size: 0.9em;
}
.md-content pre code { background: none; padding: 0; }
.md-content table { border-collapse: collapse; margin: 16px 0; width: 100%; }
.md-content th, .md-content td {
    border: 1px solid var(--border);
    padding: 8px 12px;
    text-align: left;
}
.md-content th { background: var(--surface-hover); font-weight: 600; }
.md-content blockquote {
    border-left: 3px solid var(--border-strong);
    padding-left: 16px;
    margin: 16px 0;
    color: var(--muted);
}

/* ---------- Audit table ---------- */
.hub-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}
.btn-sm { padding: 6px 14px; font-size: 0.875rem; }

.audit-table-wrap {
    overflow-x: auto;
    margin-top: 24px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
}
.audit-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.audit-table th, .audit-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
.audit-table th {
    background: var(--surface-hover);
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.75rem;
    white-space: nowrap;
}
.audit-table tbody tr:last-child td { border-bottom: none; }
.audit-row.audit-fail { background: #fff7f7; }
.audit-time { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; color: var(--muted); }
.audit-email { font-weight: 500; }
.audit-ip { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.audit-ua { color: var(--muted); font-size: 0.8rem; max-width: 320px; }
.status-fail { background: #fee2e2; color: #991b1b; }

/* ---------- Mobile ---------- */
@media (max-width: 700px) {
    .project-header { flex-direction: column; }
    .project-header .btn { width: 100%; text-align: center; }
    .phase-stepper {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .phase-step { display: flex; align-items: center; gap: 14px; text-align: left; padding: 0; width: 100%; }
    .phase-step:not(:last-child)::after {
        top: 54px;
        left: 26px;
        right: auto;
        bottom: -14px;
        width: 3px;
        height: auto;
    }
    .phase-step.phase-in_progress:not(:last-child)::after {
        background: linear-gradient(to bottom, var(--status-current) 0%, var(--status-current) 50%, var(--border) 50%);
    }
    .phase-circle { margin: 0; }
    .phase-meta { margin-top: 0; }
}
@media (max-width: 600px) {
    .hero h1 { font-size: 2.25rem; }
    .cta-row { flex-direction: column; }
    .cta-row .btn { width: 100%; }
    .user-info { gap: 8px; font-size: 0.85rem; }
}
