/* === PRECIS APP STYLES === */
/* Design tokens from landing page */

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

:root {
    --bg: #0a0b0f;
    --surface: #12131a;
    --surface-raised: #1a1b24;
    --border: #2a2b36;
    --border-light: #353644;
    --text: #e8e9ed;
    --text-dim: #8b8d98;
    --text-muted: #5c5e6a;
    --accent: #c9a227;
    --accent-dim: rgba(201, 162, 39, 0.12);
    --accent-hover: #d4ad30;
    --red: #d94040;
    --red-dim: rgba(217, 64, 64, 0.12);
    --green: #3dba6c;
    --green-dim: rgba(61, 186, 108, 0.12);
    --orange: #e0923e;
    --orange-dim: rgba(224, 146, 62, 0.12);
    --panel-width: 480px;
}

body {
    font-family: 'DM Sans', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

h1, h2, h3, h4 { font-family: 'Space Grotesk', sans-serif; }

/* === NAV === */
nav {
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg);
    z-index: 100;
}

.logo {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--accent);
    text-decoration: none;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-updated {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-refresh {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-refresh:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-refresh.spinning svg {
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* === MAIN LAYOUT === */
.app-layout {
    display: flex;
    min-height: calc(100vh - 57px);
}

.list-container {
    flex: 1;
    padding: 28px 32px;
    transition: margin-right 0.3s ease;
}

.list-container.panel-open {
    margin-right: var(--panel-width);
}

/* === LIST HEADER === */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.list-header h2 {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.list-meta {
    display: flex;
    align-items: center;
    gap: 16px;
}

#assetCount {
    font-size: 13px;
    color: var(--text-muted);
}

.filter-pills {
    display: flex;
    gap: 4px;
    background: var(--surface);
    border-radius: 8px;
    padding: 3px;
}

.pill {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    padding: 5px 14px;
    border: none;
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: 0.3px;
}

.pill:hover { color: var(--text); }
.pill.active {
    background: var(--surface-raised);
    color: var(--text);
}

/* === SEARCH BAR === */
.search-container {
    position: relative;
    margin-bottom: 20px;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 14px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input-wrapper input {
    width: 100%;
    padding: 12px 44px 12px 40px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-family: 'DM Sans', sans-serif;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.search-input-wrapper input::placeholder {
    color: var(--text-muted);
}

.search-input-wrapper input:focus {
    border-color: var(--accent);
}

.search-kbd {
    position: absolute;
    right: 12px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 11px;
    color: var(--text-muted);
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 2px 7px;
    pointer-events: none;
}

/* Search results dropdown */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    margin-top: 4px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 60;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

.search-loading,
.search-empty {
    padding: 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover:not(.already-added) {
    background: rgba(255,255,255,0.03);
}

.search-result-item.already-added {
    opacity: 0.5;
    cursor: default;
}

.search-result-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--surface-raised);
    object-fit: contain;
    flex-shrink: 0;
}

.search-result-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.search-result-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 500;
}

.search-result-symbol {
    font-size: 12px;
    color: var(--text-dim);
}

.search-result-action {
    flex-shrink: 0;
}

.add-badge {
    font-size: 12px;
    color: var(--accent);
    font-weight: 500;
    padding: 4px 12px;
    border: 1px solid var(--accent);
    border-radius: 6px;
    transition: all 0.15s;
}

.search-result-item:hover:not(.already-added) .add-badge {
    background: var(--accent);
    color: var(--bg);
}

.added-badge {
    font-size: 11px;
    color: var(--text-muted);
    padding: 4px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

/* === ASSET TABLE === */
.asset-table {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
}

.table-header {
    display: grid;
    grid-template-columns: 2fr 110px 90px 90px 120px 80px 100px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    background: rgba(255,255,255,0.015);
}

.table-header span { padding: 0 4px; }
.table-header .col-price,
.table-header .col-change,
.table-header .col-mcap { text-align: right; }
.table-header .col-tag { text-align: center; }
.table-header .col-spark { text-align: right; }

/* === ASSET ROW === */
.asset-row {
    display: grid;
    grid-template-columns: 2fr 110px 90px 90px 120px 80px 100px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.asset-row:last-child { border-bottom: none; }
.asset-row:hover { background: rgba(255,255,255,0.02); }
.asset-row.active { background: var(--accent-dim); }

.asset-row > span { padding: 0 4px; }

/* Asset cell */
.asset-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.asset-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--surface-raised);
    object-fit: contain;
}

.asset-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 14px;
}

.asset-symbol {
    font-size: 12px;
    color: var(--text-dim);
}

/* Number cells */
.price-cell {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

.change-cell {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 500;
    text-align: right;
}

.change-cell.positive { color: var(--green); }
.change-cell.negative { color: var(--red); }

.mcap-cell {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    color: var(--text-dim);
    text-align: right;
}

/* Tag */
.tag {
    display: inline-block;
    font-size: 10px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
    cursor: pointer;
    transition: all 0.15s;
}

.tag-hold { background: var(--green-dim); color: var(--green); }
.tag-watch { background: var(--accent-dim); color: var(--accent); }
.tag-cell { text-align: center; }

/* Sparkline */
.sparkline-cell { text-align: right; }
.sparkline-cell svg { vertical-align: middle; }

/* === ACTIVITY FEED === */
.activity-section {
    margin-top: 32px;
    padding-top: 28px;
    border-top: 1px solid var(--border);
}

.activity-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 16px;
}

.activity-header h3 {
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.3px;
}

.activity-subtitle {
    font-size: 12px;
    color: var(--text-muted);
}

.activity-feed {
    display: flex;
    flex-direction: column;
}

.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
}

.dot-amber { background: var(--accent); }
.dot-orange { background: var(--orange); }
.dot-green { background: var(--green); }
.dot-red { background: var(--red); }
.dot-dim { background: var(--text-muted); }

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 13px;
    line-height: 1.4;
}

.activity-title strong {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
}

.activity-time {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 2px;
}

.activity-empty {
    padding: 24px 0;
}

.activity-empty p {
    font-size: 13px;
    color: var(--text-muted);
}

/* === LOADING === */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 16px;
}

.loading-state p {
    font-size: 14px;
    color: var(--text-dim);
}

.loading-spinner {
    width: 28px;
    height: 28px;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.error-state {
    text-align: center;
    padding: 80px 20px;
}

.error-state p {
    color: var(--text-dim);
    margin-bottom: 16px;
}

.btn-retry {
    font-family: 'DM Sans', sans-serif;
    font-size: 13px;
    padding: 8px 20px;
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.btn-retry:hover { border-color: var(--accent); }

/* === SUMMARY PANEL === */
.summary-panel {
    position: fixed;
    top: 57px;
    right: 0;
    width: var(--panel-width);
    height: calc(100vh - 57px);
    background: var(--surface);
    border-left: 1px solid var(--border);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
    z-index: 50;
}

.summary-panel.open {
    transform: translateX(0);
}

.panel-content {
    padding: 28px;
}

/* Panel header */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.panel-asset-info {
    display: flex;
    align-items: center;
    gap: 14px;
}

.panel-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--surface-raised);
}

.panel-asset-name {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.panel-asset-symbol {
    font-size: 13px;
    color: var(--text-dim);
}

.btn-close {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-dim);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
    flex-shrink: 0;
}

.btn-close:hover {
    border-color: var(--text-dim);
    color: var(--text);
}

/* Panel price */
.panel-price-block {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border);
}

.panel-price {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -1px;
}

.panel-changes {
    display: flex;
    gap: 16px;
    margin-top: 6px;
}

.panel-change {
    font-size: 13px;
    font-weight: 500;
}

.panel-change .label {
    color: var(--text-muted);
    margin-right: 4px;
}

/* Panel actions row (tag toggle + act button) */
.panel-actions-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.panel-tag-row {
    display: flex;
    gap: 8px;
}

.tag-btn {
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    font-weight: 500;
    padding: 6px 18px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.15s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tag-btn:hover { border-color: var(--text-dim); color: var(--text); }
.tag-btn.active-hold {
    background: var(--green-dim);
    border-color: var(--green);
    color: var(--green);
}
.tag-btn.active-watch {
    background: var(--accent-dim);
    border-color: var(--accent);
    color: var(--accent);
}

/* Act button */
.btn-act {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: 'Space Grotesk', sans-serif;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 20px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    letter-spacing: -0.2px;
}

.btn-act:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-act svg {
    color: var(--bg);
}

/* Panel sparkline */
.panel-sparkline {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.panel-sparkline-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

/* Narrative */
.panel-narrative {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.panel-narrative p {
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
}

/* Key stats grid */
.panel-section-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.stat-item {
    padding: 10px 12px;
    background: var(--surface-raised);
    border-radius: 6px;
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 600;
    margin-top: 2px;
}

/* Risk flags */
.risk-flags {
    margin-bottom: 28px;
    padding-bottom: 24px;
    border-bottom: 1px solid var(--border);
}

.risk-flag {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: var(--surface-raised);
    border-radius: 6px;
    margin-bottom: 8px;
    border-left: 3px solid var(--border);
}

.risk-flag.severity-high { border-left-color: var(--red); }
.risk-flag.severity-medium { border-left-color: var(--orange); }
.risk-flag.severity-low { border-left-color: var(--accent); }

.risk-flag-name {
    font-size: 13px;
    font-weight: 500;
}

.risk-flag-detail {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 2px;
}

.risk-flag-severity {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 3px;
    flex-shrink: 0;
    margin-top: 2px;
}

.risk-flag-severity.high { background: var(--red-dim); color: var(--red); }
.risk-flag-severity.medium { background: var(--orange-dim); color: var(--orange); }
.risk-flag-severity.low { background: var(--accent-dim); color: var(--accent); }

.no-flags {
    font-size: 13px;
    color: var(--text-dim);
    padding: 16px 0;
}

/* Invalidation conditions — the star feature */
.invalidation-section {
    margin-bottom: 28px;
}

.invalidation-section .section-intro {
    font-size: 13px;
    color: var(--text-dim);
    margin-bottom: 16px;
    line-height: 1.5;
}

.wrong-card {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    border-left: 3px solid var(--red);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 12px;
}

.wrong-card .card-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--red);
    margin-bottom: 6px;
}

.wrong-card .card-condition {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
}

.wrong-card .card-context {
    font-size: 12px;
    color: var(--text-dim);
    margin-top: 6px;
    line-height: 1.4;
}

/* Panel footer — remove button */
.panel-footer {
    padding-top: 24px;
    border-top: 1px solid var(--border);
    margin-top: 12px;
}

.btn-remove {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'DM Sans', sans-serif;
    font-size: 12px;
    color: var(--text-muted);
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px 0;
    transition: color 0.15s;
}

.btn-remove:hover {
    color: var(--red);
}

/* === ACT MODAL === */
.act-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s;
}

.act-modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 36px;
    max-width: 400px;
    width: 90%;
    text-align: center;
}

.act-modal-icon {
    margin-bottom: 20px;
}

.act-modal h3 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    margin-bottom: 12px;
}

.act-modal p {
    font-size: 14px;
    color: var(--text-dim);
    line-height: 1.6;
    margin-bottom: 24px;
}

.act-modal-close {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 14px;
    font-weight: 600;
    padding: 10px 32px;
    background: var(--accent);
    color: var(--bg);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}

.act-modal-close:hover {
    background: var(--accent-hover);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* === PANEL OVERLAY (mobile) === */
.panel-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 40;
}

.panel-overlay.active { display: block; }

/* === RESPONSIVE === */
@media (max-width: 1024px) {
    .hide-tablet { display: none !important; }

    .table-header {
        grid-template-columns: 2fr 110px 90px 90px 80px;
    }

    .asset-row {
        grid-template-columns: 2fr 110px 90px 90px 80px;
    }

    .list-container.panel-open {
        margin-right: 0;
    }

    .summary-panel {
        width: 100%;
        max-width: 480px;
    }
}

@media (max-width: 768px) {
    .hide-mobile { display: none !important; }

    nav { padding: 14px 20px; }
    .list-container { padding: 20px; }

    .list-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .table-header {
        grid-template-columns: 2fr 90px 80px 60px;
        padding: 10px 14px;
        font-size: 10px;
    }

    .asset-row {
        grid-template-columns: 2fr 90px 80px 60px;
        padding: 12px 14px;
    }

    .asset-icon { width: 28px; height: 28px; }
    .asset-name { font-size: 13px; }
    .price-cell { font-size: 13px; }

    .summary-panel {
        width: 100%;
        max-width: 100%;
        top: 0;
        height: 100vh;
    }

    .panel-content { padding: 20px; }
    .panel-price { font-size: 26px; }
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }

    .panel-actions-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .btn-act {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .table-header {
        grid-template-columns: 2fr 80px 60px;
    }

    .asset-row {
        grid-template-columns: 2fr 80px 60px;
    }

    .table-header .col-change,
    .asset-row .change-cell:not(:first-of-type) {
        display: none;
    }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-light); }
