:root {
    color-scheme: light;
    --bg: #f4f7fb;
    --card: #ffffff;
    --muted: #64748b;
    --text: #0f172a;
    --border: #dbe5f0;
    --blue: #3b82f6;
    --blue-dark: #2563eb;
    --green: #22c55e;
    --red: #f97316;
    --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Inter, "Segoe UI", Arial, sans-serif;
    background: linear-gradient(180deg, #f8fbff 0%, var(--bg) 100%);
    color: var(--text);
}

a {
    color: inherit;
    text-decoration: none;
}

code {
    background: #eef3fb;
    border-radius: 6px;
    padding: 0.15rem 0.35rem;
}

.page-shell {
    max-width: 1280px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

.content-shell {
    display: grid;
    gap: 1.5rem;
}

.topbar,
.page-header,
.section-header,
.topbar-actions,
.detail-meta,
.filter-actions,
.form-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.topbar {
    margin-bottom: 1.5rem;
}

.brand-link {
    font-size: 1.7rem;
    font-weight: 700;
}

.eyebrow {
    margin: 0 0 0.35rem;
    color: var(--blue);
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

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

.tiny {
    font-size: 0.82rem;
}

.btn {
    border: 1px solid transparent;
    border-radius: 12px;
    padding: 0.8rem 1.1rem;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
    box-shadow: 0 12px 28px rgba(37, 99, 235, 0.18);
}

.btn-secondary {
    background: #fff;
    border-color: var(--border);
    color: var(--text);
}

.btn-full {
    width: 100%;
}

.auth-card,
.filter-panel,
.form-card,
.detail-card,
.table-card {
    background: var(--card);
    border: 1px solid rgba(219, 229, 240, 0.85);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.auth-card {
    max-width: 460px;
    margin: 4rem auto 0;
    padding: 2rem;
    display: grid;
    gap: 1.25rem;
}

.stack-form,
.stack-fields {
    display: grid;
    gap: 1rem;
}

.filter-panel,
.form-card,
.detail-card,
.table-card {
    padding: 1.25rem;
}

.filter-grid,
.form-grid,
.stats-grid,
.detail-grid {
    display: grid;
    gap: 1rem;
}

.filter-grid {
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    align-items: end;
}

.stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.stat-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1rem 1.2rem;
}

.stat-card p {
    margin: 0;
    color: var(--muted);
}

.stat-card strong {
    display: block;
    margin-top: 0.5rem;
    font-size: 2rem;
}

.trade-form {
    display: grid;
    gap: 1.25rem;
}

.detail-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

label {
    display: grid;
    gap: 0.45rem;
    font-size: 0.94rem;
    font-weight: 600;
}

input,
select,
textarea {
    width: 100%;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 0.82rem 0.95rem;
    font: inherit;
    color: var(--text);
    background: #fbfdff;
}

textarea {
    resize: vertical;
    min-height: 132px;
}

.full-width {
    grid-column: 1 / -1;
}

.alert {
    border-radius: 18px;
    padding: 1rem 1.1rem;
}

.alert ul {
    margin-bottom: 0;
}

.alert-error {
    background: #fff1f2;
    border: 1px solid #fecdd3;
    color: #9f1239;
}

.table-section {
    display: grid;
    gap: 0.85rem;
}

.trade-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}

.trade-table th,
.trade-table td {
    padding: 0.95rem 0.85rem;
    border-bottom: 1px solid #edf2f7;
    text-align: left;
    vertical-align: middle;
}

.trade-table th {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: #f8fbff;
}

.trade-table tbody tr:hover {
    background: #f8fbff;
}

.badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 0.35rem 0.7rem;
    font-size: 0.84rem;
    font-weight: 700;
}

.badge-long,
.badge-win {
    background: #e7f9ef;
    color: #15803d;
}

.badge-short,
.badge-loss {
    background: #fff1ea;
    color: #c2410c;
}

.badge-neutral {
    background: #eef2ff;
    color: #4338ca;
}

.table-link {
    color: var(--blue-dark);
    font-weight: 700;
}

.empty-state {
    color: var(--muted);
    text-align: center;
    padding: 1.6rem 0;
}

.detail-list {
    display: grid;
    gap: 0.85rem;
}

.detail-list div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid #eef2f7;
}

.detail-list dt {
    color: var(--muted);
}

.detail-list dd {
    margin: 0;
    text-align: right;
    font-weight: 600;
}

.detail-copy {
    display: grid;
    gap: 0.9rem;
}

.detail-copy h3 {
    margin: 0;
}

.detail-copy p {
    margin: 0;
    line-height: 1.7;
}

.reference-list {
    margin: 0;
    padding-left: 1.2rem;
    color: var(--text);
}

.reference-list li {
    margin: 0.3rem 0;
    word-break: break-word;
}

.reference-list a {
    color: var(--blue-dark);
}

.image-grid,
.image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
}

.image-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 0.75rem;
    background: #f8fbff;
    display: grid;
    gap: 0.6rem;
    text-align: left;
    cursor: pointer;
}

.image-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 14px;
    display: block;
}

.image-card.selectable {
    cursor: default;
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.9rem;
    color: var(--muted);
}

.checkbox-row input {
    width: auto;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.88);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    z-index: 1000;
}

.lightbox[hidden] {
    display: none !important;
}

.lightbox img {
    max-width: min(1100px, 92vw);
    max-height: 88vh;
    border-radius: 20px;
    box-shadow: 0 30px 80px rgba(15, 23, 42, 0.5);
}

.lightbox-close {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    border: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    border-radius: 999px;
    width: 48px;
    height: 48px;
    font-size: 1.8rem;
    cursor: pointer;
}

@media (max-width: 900px) {
    .topbar,
    .page-header,
    .section-header,
    .topbar-actions,
    .detail-meta,
    .filter-actions,
    .form-actions {
        flex-direction: column;
        align-items: flex-start;
    }

    .trade-table {
        min-width: 820px;
    }

    .table-card {
        overflow-x: auto;
    }
}
