* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
    color: #172033;
    background: linear-gradient(135deg, #f4f7fb, #eef3f9);
}

/* Login */
.page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 32px; }
.login-card {
    width: 100%; max-width: 480px; padding: 48px 42px; text-align: center; background: #fff;
    border-radius: 24px; box-shadow: 0 18px 60px rgba(34,51,84,.12);
}
.brand-mark {
    width: 68px; height: 68px; margin: 0 auto 22px; display: flex; align-items: center; justify-content: center;
    border-radius: 20px; font-size: 30px; font-weight: 800; color: #fff;
    background: linear-gradient(135deg, #2868e8, #1745a7);
}
.login-card h1 { margin: 0 0 8px; font-size: 30px; }
.login-card h2 { margin: 0 0 22px; color: #516078; font-size: 20px; line-height: 1.6; }
.description { margin-bottom: 30px; color: #7a879b; line-height: 1.8; }
.google-button {
    width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 15px 22px;
    text-decoration: none; color: #202124; background: #fff; border: 1px solid #d8dee9; border-radius: 12px; font-weight: 600;
}
.google-icon {
    width: 27px; height: 27px; display: inline-flex; align-items: center; justify-content: center; border-radius: 50%;
    color: #4285f4; background: #f5f8ff; font-weight: 800;
}
.phase-label { margin-top: 28px; color: #a0a9b8; font-size: 12px; }

/* Dashboard */
.dashboard-page { min-height: 100vh; }
.topbar {
    min-height: 88px; display: flex; align-items: center; justify-content: space-between; gap: 30px;
    padding: 18px 34px; background: #fff; border-bottom: 1px solid #e7ebf1;
}
.small-title { color: #2463d4; font-size: 13px; font-weight: 800; letter-spacing: .08em; }
.topbar-title { margin-top: 4px; font-size: 20px; font-weight: 700; }
.user-area { display: flex; align-items: center; gap: 12px; }
.user-picture { width: 42px; height: 42px; object-fit: cover; border-radius: 50%; }
.user-text { min-width: 160px; }
.user-name { font-size: 14px; font-weight: 700; }
.user-email { margin-top: 2px; color: #778399; font-size: 12px; }
.logout-button {
    margin-left: 10px; padding: 9px 14px; color: #5f6d83; background: #f1f4f8; border-radius: 9px;
    text-decoration: none; font-size: 13px;
}
.dashboard-content { max-width: 1180px; margin: 0 auto; padding: 44px 28px 80px; }

/* Header */
.phase-header { margin-bottom: 24px; }
.phase-header h1 { margin: 10px 0 8px; font-size: 30px; }
.phase-header p { margin: 0; color: #778399; }
.phase-badge, .phase3-kicker {
    display: inline-block; padding: 7px 12px; color: #fff; background: #2868e8; border-radius: 8px; font-size: 12px; font-weight: 800;
}

/* Cards */
.process-card, .phase3-card {
    padding: 30px; background: #fff; border-radius: 20px; box-shadow: 0 10px 36px rgba(34,51,84,.07);
}
.phase3-card { margin-top: 24px; border: 1px solid #dbe6ff; }
.section-title { margin: 0 0 20px; font-size: 18px; }
.folder-card {
    min-height: 98px; display: flex; align-items: center; gap: 20px; padding: 20px;
    border: 1px solid #e1e6ee; border-radius: 14px; margin-bottom: 14px;
}
.folder-number {
    flex: 0 0 42px; width: 42px; height: 42px; display: flex; align-items: center; justify-content: center;
    color: #2868e8; background: #edf3ff; border-radius: 12px; font-weight: 800;
}
.folder-content { flex: 1; }
.folder-content strong { display: block; margin-bottom: 6px; }
.folder-info { color: #8994a7; font-size: 13px; }
.folder-info strong { display: inline; margin-right: 12px; color: #334155; }
.folder-info span { color: #778399; }
.select-button {
    flex: 0 0 auto; padding: 11px 17px; cursor: pointer; color: #2459b9; background: #edf3ff;
    border-radius: 9px; font-size: 14px; font-weight: 700;
}
.select-button:hover { background: #e0eaff; }

.upload-actions { display: flex; gap: 12px; margin-top: 24px; }
.start-button, .phase3-start-button {
    flex: 1; padding: 15px; border: 0; border-radius: 11px; color: #fff; background: #2868e8;
    font-size: 16px; font-weight: 700; cursor: pointer;
}
.start-button:disabled, .phase3-start-button:disabled { color: #97a0af; background: #e8ebf0; cursor: not-allowed; }
.secondary-button {
    padding: 15px 18px; border: 0; border-radius: 11px; color: #657287; background: #eef1f5; cursor: pointer;
}

/* Phase 3 */
.phase3-heading { display: flex; align-items: center; justify-content: space-between; gap: 28px; }
.phase3-heading h2 { margin: 10px 0 6px; }
.phase3-heading p { margin: 0; color: #778399; line-height: 1.7; }
.phase3-start-button { flex: 0 0 280px; background: #1745a7; }
.phase3-action-buttons {
    flex: 0 0 300px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.phase3-action-buttons .phase3-start-button {
    flex: 0 0 auto;
    width: 100%;
}
.phase3-reset-button {
    width: 100%;
    padding: 13px 16px;
    border: 1px solid #e0a09a;
    border-radius: 11px;
    color: #b42318;
    background: #fff7f6;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}
.phase3-reset-button:hover { background: #ffefed; }
.phase3-reset-button:disabled { opacity: 0.55; cursor: not-allowed; }
.phase3-recovery-note {
    margin-top: 14px;
    padding: 13px 15px;
    border-radius: 10px;
    color: #6b4d00;
    background: #fff9e8;
    border: 1px solid #f0df9f;
    font-size: 13px;
    line-height: 1.7;
}

/* Progress */
.progress-area { margin-top: 28px; padding: 20px; background: #f8fafc; border-radius: 14px; }
.progress-header { display: flex; justify-content: space-between; gap: 20px; margin-bottom: 12px; font-size: 14px; font-weight: 700; }
.progress-track { width: 100%; height: 11px; overflow: hidden; background: #e3e8ef; border-radius: 99px; }
.progress-bar { width: 0%; height: 100%; background: #2868e8; border-radius: 99px; transition: width .2s ease; }
.progress-bar.phase3 { background: linear-gradient(90deg, #1745a7, #2868e8); }
.progress-detail { margin-top: 9px; color: #7c8798; font-size: 12px; }

/* Results */
.result-area { margin-top: 24px; padding: 22px; border-radius: 14px; }
.result-area.success { background: #edf9f3; border: 1px solid #bce7cf; }
.result-area.error { background: #fff2f0; border: 1px solid #f3c1bb; }
.result-area.warning { background: #fff9e8; border: 1px solid #efd58b; }
.result-title { margin-bottom: 16px; font-size: 18px; font-weight: 800; }
.result-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.result-grid div { padding: 14px; background: rgba(255,255,255,.72); border-radius: 10px; }
.result-grid span { display: block; margin-bottom: 4px; color: #718096; font-size: 12px; }
.result-grid strong { font-size: 18px; }
.error-summary { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.error-summary span { padding: 9px 12px; background: rgba(255,255,255,.7); border-radius: 9px; color: #59667a; font-size: 13px; }
.error-summary strong { margin-left: 5px; color: #172033; }

/* Phase status */
.phase-status { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-top: 24px; }
.status-row {
    display: flex; align-items: center; gap: 14px; padding: 18px; background: #fff; border-radius: 14px;
    box-shadow: 0 7px 25px rgba(34,51,84,.05);
}
.status-row p { margin: 4px 0 0; color: #8792a4; font-size: 12px; }
.status-check, .status-number {
    flex: 0 0 35px; width: 35px; height: 35px; display: flex; align-items: center; justify-content: center;
    border-radius: 10px; font-weight: 800;
}
.done .status-check { color: #fff; background: #22a06b; }
.current .status-number { color: #fff; background: #2868e8; }
.future { opacity: .58; }
.future .status-number { color: #606b7b; background: #e7eaf0; }

.hidden { display: none !important; }

@media (max-width: 840px) {
    .topbar { align-items: flex-start; flex-direction: column; }
    .user-area { width: 100%; }
    .user-text { flex: 1; }
    .folder-card { align-items: flex-start; flex-wrap: wrap; }
    .folder-content { min-width: 200px; }
    .select-button { width: 100%; text-align: center; }
    .upload-actions, .phase3-heading { flex-direction: column; align-items: stretch; }
    .phase3-start-button { flex-basis: auto; width: 100%; }
    .phase3-action-buttons { flex-basis: auto; width: 100%; }
    .result-grid, .phase-status { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
    .result-grid, .phase-status { grid-template-columns: 1fr; }
}

/* ==========================================================
   PHASE 4
   ========================================================== */
.phase4-card { border-color: #cfe3ff; }
.phase4-kicker { background: #0f766e; }
.phase4-start-button { background: #0f766e; }
.phase4-start-button:hover { background: #0b5f59; }
.phase4-warning {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 11px;
    color: #6b4d00;
    background: #fff9e8;
    border: 1px solid #f0df9f;
    font-size: 13px;
    line-height: 1.7;
}
.progress-bar.phase4 { background: linear-gradient(90deg, #0f766e, #22a06b); }
.phase4-downloads {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}
.download-button {
    display: inline-block;
    padding: 11px 15px;
    border-radius: 10px;
    text-decoration: none;
    color: #1745a7;
    background: #edf3ff;
    font-size: 13px;
    font-weight: 700;
}
.download-button:hover { background: #e0eaff; }
.warning-download {
    color: #8a5a00;
    background: #fff5d6;
}

@media (max-width: 840px) {
    .phase4-downloads { flex-direction: column; }
    .download-button { width: 100%; text-align: center; }
}
