* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f5f7fb;
    --card: #ffffff;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --danger: #dc2626;
    --success: #16a34a;
    --warning: #d97706;
}

body {
    font-family:
        Inter,
        Arial,
        Helvetica,
        sans-serif;

    background: var(--bg);
    color: var(--text);
}


/* ================= COMMON ================= */

.hidden {
    display: none !important;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 14px;
    outline: none;
    background: white;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
    min-height: 110px;
    resize: vertical;
}

label {
    display: block;
    margin-bottom: 7px;
    font-size: 13px;
    font-weight: 600;
}

.field {
    margin-bottom: 20px;
}

.form-grid {
    display: grid;
    grid-template-columns:
        repeat(2, minmax(0, 1fr));

    gap: 20px;
}

.primary-btn,
.secondary-btn,
.analyze-btn {
    border: none;
    border-radius: 8px;
    padding: 11px 18px;
    font-weight: 600;
    transition: 0.2s;
}

.primary-btn {
    background: var(--primary);
    color: white;
}

.primary-btn:hover {
    background: var(--primary-dark);
}

.secondary-btn {
    background: #eff6ff;
    color: var(--primary);
}

.analyze-btn {
    background: #111827;
    color: white;
}

.description,
.hint {
    color: var(--muted);
    margin: 7px 0 25px;
}


/* ================= AUTH ================= */

.auth-page {
    min-height: 100vh;

    display: flex;
    justify-content: center;
    align-items: center;

    padding: 20px;
}

.auth-card {
    width: 100%;
    max-width: 430px;

    background: white;
    border: 1px solid var(--border);

    border-radius: 16px;

    padding: 35px;

    box-shadow:
        0 15px 40px
        rgba(0, 0, 0, 0.06);
}

.logo {
    font-size: 27px;
    font-weight: 800;
    text-align: center;
    margin-bottom: 10px;
}

.logo span,
.sidebar-logo span {
    color: var(--primary);
}

.subtitle {
    color: var(--muted);
    text-align: center;
    line-height: 1.6;
    margin-bottom: 30px;
}

.auth-card h2 {
    margin-bottom: 20px;
}

.auth-card input {
    margin-bottom: 14px;
}

.auth-card form button {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 13px;
    font-weight: 600;
}

.switch {
    text-align: center;
    color: var(--muted);
    margin-top: 20px;
}

.switch button {
    border: none;
    background: none;
    color: var(--primary);
    font-weight: 600;
}

#authMessage {
    margin-top: 15px;
    text-align: center;
}


/* ================= APP ================= */

#appPage {
    min-height: 100vh;
    display: flex;
}

.sidebar {
    position: fixed;

    width: 250px;
    height: 100vh;

    background: #111827;
    color: white;

    padding: 25px 15px;

    display: flex;
    flex-direction: column;
}

.sidebar-logo {
    font-size: 22px;
    font-weight: 800;

    padding: 0 15px 30px;
}

.sidebar nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-btn {
    border: none;
    background: transparent;
    color: #9ca3af;

    padding: 12px 15px;
    border-radius: 8px;

    text-align: left;
    font-size: 14px;
}

.nav-btn:hover,
.nav-btn.active {
    background: #1f2937;
    color: white;
}

.sidebar-bottom {
    margin-top: auto;
    padding: 15px;
    border-top: 1px solid #374151;
}

#userName {
    font-size: 13px;
    color: #d1d5db;
    margin-bottom: 15px;
}

.logout-btn {
    width: 100%;
    padding: 10px;

    background: #374151;
    color: white;

    border: none;
    border-radius: 7px;
}

.main {
    margin-left: 250px;
    width: calc(100% - 250px);

    padding: 30px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 30px;
}

.topbar h1 {
    font-size: 27px;
}

.topbar p {
    color: var(--muted);
    margin-top: 5px;
}


/* ================= CARDS ================= */

.stats {
    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 20px;

    margin-bottom: 25px;
}

.stat-card,
.section-card {
    background: var(--card);

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 22px;
}

.stat-card span {
    color: var(--muted);
    font-size: 13px;
}

.stat-card strong {
    display: block;

    margin-top: 8px;

    font-size: 28px;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;

    margin-bottom: 25px;
}

.section-header p {
    color: var(--muted);
    margin-top: 5px;
}


/* ================= IPO CARDS ================= */

.ipo-grid {
    display: grid;

    grid-template-columns:
        repeat(3, minmax(0, 1fr));

    gap: 18px;
}

.ipo-card {
    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 20px;

    background: white;
}

.ipo-card h3 {
    margin-bottom: 7px;
}

.ipo-sector {
    color: var(--muted);
    font-size: 13px;
}

.ipo-status {
    display: inline-block;

    margin-top: 15px;

    padding: 5px 9px;

    border-radius: 20px;

    background: #eff6ff;
    color: var(--primary);

    font-size: 12px;
}

.ipo-score {
    margin-top: 15px;

    font-size: 23px;
    font-weight: 800;
}

.ipo-actions {
    display: flex;
    gap: 8px;

    margin-top: 18px;
}

.ipo-actions button {
    flex: 1;
}


/* ================= RESEARCH ================= */

.research-header {
    display: flex;

    align-items: center;
    gap: 20px;

    margin-bottom: 20px;
}

.research-header > div {
    flex: 1;
}

.back-btn {
    border: none;
    background: white;

    border: 1px solid var(--border);

    padding: 9px 13px;

    border-radius: 8px;
}

.tabs {
    background: white;

    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 8px;

    display: flex;
    gap: 5px;

    overflow-x: auto;

    margin-bottom: 15px;
}

.tab {
    white-space: nowrap;

    border: none;
    background: transparent;

    padding: 10px 14px;

    border-radius: 7px;

    color: var(--muted);
}

.tab:hover,
.tab.active {
    background: #eff6ff;
    color: var(--primary);
}

.research-content {
    background: white;

    border: 1px solid var(--border);

    border-radius: 12px;

    padding: 28px;
}

.tab-content h3 {
    margin-bottom: 25px;
}


/* ================= TABLE ================= */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border: 1px solid var(--border);

    padding: 8px;

    text-align: left;
}

th {
    background: #f9fafb;

    font-size: 13px;
}

td:first-child {
    font-weight: 600;
}

td input {
    min-width: 100px;
}


/* ================= SAVE ================= */

.save-area {
    display: flex;
    justify-content: flex-end;

    gap: 10px;

    border-top: 1px solid var(--border);

    padding-top: 25px;

    margin-top: 30px;
}


/* ================= RISK ================= */

.risk-item,
.evidence-item {
    background: #f9fafb;

    border: 1px solid var(--border);

    padding: 18px;

    border-radius: 9px;

    margin-bottom: 15px;
}

.risk-item-header {
    display: flex;
    justify-content: space-between;

    margin-bottom: 15px;
}

.remove-btn {
    border: none;

    background: #fee2e2;
    color: var(--danger);

    padding: 6px 10px;

    border-radius: 6px;
}


/* ================= RESULT ================= */

.result-header {
    display: flex;
    align-items: center;

    gap: 20px;

    margin-bottom: 25px;
}

.result-header h2 {
    flex: 1;
}

.result-score-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 14px;

    padding: 35px;

    text-align: center;

    margin-bottom: 20px;
}

.big-score {
    font-size: 65px;
    font-weight: 900;

    color: var(--primary);
}

.rating {
    display: inline-block;

    margin-top: 5px;

    padding: 7px 15px;

    border-radius: 20px;

    background: #eff6ff;

    color: var(--primary);

    font-weight: 700;
}

.step-grid {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 15px;

    margin-bottom: 20px;
}

.step-card {
    background: white;

    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 20px;
}

.step-card strong {
    font-size: 20px;
}

.step-card p {
    color: var(--muted);

    margin-top: 5px;
}

.result-columns {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 20px;
}

.result-box {
    background: white;

    border: 1px solid var(--border);

    border-radius: 10px;

    padding: 22px;
}

.result-box h3 {
    margin-bottom: 15px;
}

.result-box ul {
    padding-left: 20px;
}

.result-box li {
    margin-bottom: 8px;
}


/* ================= TOAST ================= */

#toast {
    position: fixed;

    right: 25px;
    bottom: 25px;

    background: #111827;
    color: white;

    padding: 13px 18px;

    border-radius: 8px;

    opacity: 0;

    transform: translateY(20px);

    pointer-events: none;

    transition: 0.25s;

    z-index: 9999;
}

#toast.show {
    opacity: 1;

    transform: translateY(0);
}


/* ================= MOBILE ================= */

@media (max-width: 1000px) {

    .stats {
        grid-template-columns:
            repeat(2, 1fr);
    }

    .ipo-grid {
        grid-template-columns:
            repeat(2, 1fr);
    }

}

@media (max-width: 700px) {

    .sidebar {
        position: relative;

        width: 100%;
        height: auto;
    }

    #appPage {
        flex-direction: column;
    }

    .main {
        margin-left: 0;

        width: 100%;

        padding: 15px;
    }

    .sidebar nav {
        flex-direction: row;
        overflow-x: auto;
    }

    .sidebar-bottom {
        display: none;
    }

    .stats,
    .ipo-grid,
    .form-grid,
    .step-grid,
    .result-columns {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
    }

    .topbar .primary-btn {
        display: none;
    }

    .research-header {
        flex-wrap: wrap;
    }

}