:root {
    --bg: #f4f6f8;
    --card-bg: #ffffff;
    --border: #e2e6ea;
    --text: #1f2933;
    --muted: #7b8794;
    --accent: #2563eb;
    --green: #15803d;
    --green-bg: #dcfce7;
    --red: #b91c1c;
    --red-bg: #fee2e2;
    --gray: #4b5563;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.4;
}

.app {
    max-width: 860px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

.app-title {
    font-size: 1.6rem;
    font-weight: 700;
    margin: 0 0 4px;
}

.source-link {
    font-size: 0.85rem;
    margin: 0 0 4px;
}

.source-link a {
    color: var(--accent);
    text-decoration: none;
}

.source-link a:hover {
    text-decoration: underline;
}

.refresh-note {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0 0 20px;
}

.muted {
    color: var(--muted);
    font-style: italic;
}

/* Run card */

.run-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
    padding: 16px 20px;
    margin-bottom: 20px;
}

.run-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    padding-bottom: 10px;
    margin-bottom: 4px;
}

.run-time {
    font-size: 1.1rem;
    font-weight: 600;
}

.run-duration {
    font-size: 0.85rem;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.closed {
    padding: 12px 0 4px;
    color: var(--muted);
    font-style: italic;
}

/* Section */

.section {
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

    .section:last-child {
        border-bottom: none;
        padding-bottom: 0;
    }

.section-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    margin: 0 0 8px;
}

.symbol {
    font-weight: 600;
    font-family: "SF Mono", Menlo, Consolas, monospace;
}

.num {
    font-variant-numeric: tabular-nums;
}

.value {
    font-weight: 600;
}

/* Portfolio */

.positions {
    width: 100%;
    border-collapse: collapse;
}

    .positions td {
        padding: 4px 8px;
        border-bottom: 1px solid #f0f2f4;
    }

        .positions td.num {
            text-align: right;
            color: var(--gray);
        }

        .positions td.value {
            color: var(--text);
        }

        .positions td.change-down {
            color: var(--red);
        }

.summary {
    display: flex;
    gap: 24px;
    margin-top: 10px;
    font-size: 0.95rem;
}

/* Market assessment */

.state {
    margin-bottom: 8px;
    line-height: 1.5;
    color: var(--gray);
}

/* News (progressive disclosure) */

.news {
    margin-top: 8px;
    font-size: 0.88rem;
}

.news-summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 600;
    list-style: none; /* replace the default marker with our own */
    display: inline-flex;
    align-items: center;
    gap: 6px;
    user-select: none;
}

    .news-summary::-webkit-details-marker {
        display: none;
    }

    .news-summary::before {
        content: "\25B6"; /* ▶ */
        font-size: 0.7em;
        transition: transform 0.15s ease;
    }

.news[open] .news-summary::before {
    transform: rotate(90deg);
}

.news-items {
    margin: 8px 0 4px;
    padding-left: 12px;
    border-left: 2px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.news-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.news-title {
    font-weight: 600;
    color: var(--text);
}

.news-date {
    font-size: 0.78rem;
    color: var(--muted);
}

.news-item-summary {
    color: var(--gray);
    line-height: 1.45;
}

/* Orders */

.order {
    padding: 8px 0;
    border-bottom: 1px solid #f0f2f4;
}

    .order:last-child {
        border-bottom: none;
    }

.order-head {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 2px;
}

.badge {
    display: inline-block;
    padding: 1px 9px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.action-buy {
    background: var(--green-bg);
    color: var(--green);
}

.action-sell {
    background: var(--red-bg);
    color: var(--red);
}

.order-reason {
    font-size: 0.9rem;
    color: var(--gray);
    margin-bottom: 2px;
}

.order-line {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 6px;
    background: #f0f2f4;
    font-size: 0.9rem;
}

.order .value {
    color: var(--text);
    font-weight: 400;
}

/* Errors */

.error {
    color: var(--red);
    background: var(--red-bg);
    border: 1px solid var(--red);
    border-left-width: 4px;
    border-radius: 4px;
    padding: 6px 10px;
    margin: 4px 0;
    font-size: 0.9rem;
}
