/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: #111;
    color: #e8e8e8;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ===== PIN SCREEN ===== */
#pin-screen {
    position: fixed; inset: 0;
    background: #111;
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
}

.pin-wrap { text-align: center; width: 280px; }

.pin-logo {
    font-size: 52px;
    color: #4ade80;
    display: block;
    margin-bottom: 8px;
    line-height: 1;
}

.pin-title {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: 0.06em;
    margin-bottom: 36px;
    color: #ccc;
}

.pin-dots {
    display: flex;
    justify-content: center;
    gap: 18px;
    margin-bottom: 10px;
}

.pin-dots span {
    width: 14px; height: 14px;
    border-radius: 50%;
    border: 2px solid #333;
    transition: all 0.15s;
}

.pin-dots span.filled {
    background: #4ade80;
    border-color: #4ade80;
    box-shadow: 0 0 8px #4ade8066;
}

.pin-error {
    color: #f87171;
    font-size: 13px;
    min-height: 20px;
    margin-bottom: 8px;
}

.pin-pad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 20px;
}

.pin-key {
    background: #1e1e1e;
    border: 1px solid #2a2a2a;
    border-radius: 14px;
    color: #e8e8e8;
    font-size: 22px;
    font-weight: 400;
    height: 68px;
    cursor: pointer;
    transition: background 0.1s, transform 0.08s;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

.pin-key:active { background: #2a2a2a; transform: scale(0.94); }
.pin-del { color: #888; font-size: 18px; }
.pin-ok {
    background: #4ade80;
    color: #111;
    border-color: #4ade80;
    font-weight: 700;
    font-size: 24px;
}
.pin-ok:active { background: #22c55e; }

/* ===== APP ===== */
body.mobile { min-height: 100dvh; }

#app-screen {
    display: flex;
    flex-direction: column;
    min-height: 100dvh;
}

#top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px 9px;
    padding-top: calc(10px + env(safe-area-inset-top, 0px));
    background: #161616;
    border-bottom: 1px solid #222;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    z-index: 5;
}

.top-bar-title {
    font-size: 14px;
    font-weight: 700;
    color: #4ade80;
    letter-spacing: 0.06em;
}

#btn-refresh {
    background: none;
    border: 1px solid #2a2a2a;
    border-radius: 20px;
    color: #555;
    font-size: 16px;
    font-weight: 600;
    padding: 5px 14px;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s, border-color 0.15s;
}

#btn-refresh:active { color: #4ade80; border-color: #4ade80; }
#btn-refresh.spinning { color: #4ade80; border-color: #4ade80; animation: spin 0.8s linear infinite; }

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

#content {
    flex: 1;
    padding: 14px 14px 32px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.loading {
    text-align: center;
    color: #555;
    font-size: 14px;
    padding: 40px 0;
}
.loading.err { color: #f87171; }

.quote-banner {
    background: #16211a;
    border: 1px solid #1f3a2a;
    color: #86efac;
    font-size: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    text-align: center;
}
.quote-banner.warn {
    background: #211616;
    border-color: #3a1f1f;
    color: #fca5a5;
}

.card {
    background: #161616;
    border: 1px solid #222;
    border-radius: 14px;
    overflow: hidden;
}

.card-header {
    padding: 12px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    border-bottom: 1px solid #222;
}

.txn-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid #1c1c1c;
}
.txn-row:last-of-type { border-bottom: none; }
.txn-row.pending { opacity: 0.75; }

.txn-left { min-width: 0; }
.txn-fund { font-size: 14px; font-weight: 500; color: #e8e8e8; }
.txn-date { font-size: 12px; color: #666; margin-top: 2px; }

.txn-right { text-align: right; flex-shrink: 0; }
.txn-value { font-size: 14px; font-weight: 600; }
.txn-gain { font-size: 12px; margin-top: 2px; }
.txn-pending-label { font-size: 12px; color: #888; font-style: italic; }

.gain-pos { color: #4ade80; }
.gain-neg { color: #f87171; }

.entity-subtotal {
    background: #131313;
    padding: 4px 0;
}

.subtotal-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 700;
    color: #ccc;
}
