/* =============================================================================
   ALERTS — header bell + inbox, Account › Alerts card, New alert popup
   Terminal page only (alerts.js).
   ============================================================================= */

/* ── Tones shared by inbox rows, rule rows and the popup ───────────────── */
.al-ico {
    width: 32px; height: 32px; flex-shrink: 0; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: rgba(240, 185, 11, 0.12); color: var(--accent);
}
.al-ico svg { width: 16px; height: 16px; }
.al-ico.up      { background: rgba(14, 203, 129, 0.12); color: var(--green); }
.al-ico.down    { background: rgba(246, 70, 93, 0.12);  color: var(--red); }
.al-ico.info    { background: rgba(91, 143, 255, 0.14); color: #5B8FFF; }

/* ── Header bell ───────────────────────────────────────────────────────── */
.al-bell-wrap { position: relative; display: flex; }
.header .al-bell { position: relative; display: flex; align-items: center; justify-content: center; cursor: pointer; }
.header .al-bell[aria-expanded="true"] { border-color: #474D57; color: var(--text-primary); background: var(--bg-tertiary); }
.al-badge {
    position: absolute; top: -6px; right: -6px;
    min-width: 18px; height: 18px; padding: 0 5px; box-sizing: border-box;
    border-radius: 999px; border: 2px solid var(--bg-primary);
    background: var(--red); color: #fff;
    font-size: 0.6875rem; font-weight: 700; line-height: 14px; text-align: center;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}
.al-badge[hidden] { display: none; }

/* ── Inbox panel ───────────────────────────────────────────────────────── */
.al-panel {
    position: fixed; top: 74px; right: 12px; z-index: 1200;   /* placed under the bell by alerts.js */
    width: 420px; max-width: calc(100vw - 24px);
    display: flex; flex-direction: column;
    max-height: min(620px, calc(100vh - 90px));
    background: var(--bg-secondary); border: 1px solid #2B3139; border-radius: 16px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
    overflow: hidden; text-align: left;
    font-family: Inter, -apple-system, BlinkMacSystemFont, sans-serif;
}
.al-panel[hidden] { display: none; }
.al-panel-head { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--bg-tertiary); flex-shrink: 0; }
.al-panel-title { font-size: 0.9375rem; font-weight: 600; color: var(--text-primary); }
.al-new { padding: 1px 7px; border-radius: 999px; background: rgba(246, 70, 93, 0.14); color: var(--red); font-size: 0.6875rem; font-weight: 700; }
.al-new[hidden] { display: none; }
.al-link {
    padding: 0; border: 0; background: none; cursor: pointer;
    font: inherit; font-size: 0.75rem; color: var(--text-secondary);
}
.al-link:hover { color: var(--text-primary); }
.al-link:disabled { opacity: 0.4; cursor: default; }
.al-link--accent { font-size: 0.8125rem; font-weight: 500; color: var(--accent); }
.al-link--accent:hover { color: #FCD535; }
.al-back { display: none; }
.al-panel-head .al-link { margin-left: auto; }

.al-list { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.al-grp { padding: 10px 16px 6px; font-size: 0.6875rem; font-weight: 600; color: var(--text-tertiary); background: var(--bg-primary); }
.al-item {
    position: relative; display: flex; gap: 12px; width: 100%;
    padding: 14px 16px 14px 18px; box-sizing: border-box;
    border: 0; border-bottom: 1px solid var(--bg-tertiary); background: transparent;
    font: inherit; text-align: left; color: inherit;
}
.al-item:last-child { border-bottom: 0; }
.al-item.unread { background: rgba(240, 185, 11, 0.04); }
.al-item.unread::before {
    content: ''; position: absolute; left: 6px; top: 26px;
    width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
}
.al-item-text { flex: 1; min-width: 0; }
.al-item-title { font-size: 0.8125rem; font-weight: 600; line-height: 1.4; color: var(--text-primary); }
.al-item-body { margin-top: 2px; font-size: 0.75rem; line-height: 1.5; color: var(--text-secondary); }
.al-item-meta { margin-top: 6px; font-size: 0.6875rem; color: var(--text-tertiary); }

.al-empty { padding: 36px 24px; text-align: center; }
.al-empty-ico { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; background: var(--bg-tertiary); color: var(--text-secondary); display: flex; align-items: center; justify-content: center; }
.al-empty-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); }
.al-empty-sub { margin-top: 4px; font-size: 0.8125rem; line-height: 1.5; color: var(--text-secondary); }

.al-panel-foot {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-shrink: 0;
    padding: 12px 16px; border-top: 1px solid var(--bg-tertiary); background: var(--bg-primary);
}
.al-foot-note { font-size: 0.75rem; color: var(--text-tertiary); }

/* Phone: the inbox is a full screen of its own */
@media (max-width: 600px) {
    .al-panel {
        position: fixed; inset: 0; top: 0; right: 0; width: 100%; max-width: none;
        max-height: none; height: 100%; height: 100dvh; border: 0; border-radius: 0; z-index: 3000;
    }
    .al-panel-head { height: 60px; box-sizing: border-box; padding: 0 12px; }
    .al-back {
        display: flex; align-items: center; justify-content: center;
        width: 40px; height: 40px; margin-left: -4px; padding: 0; border: 0; border-radius: 10px;
        background: transparent; color: var(--text-secondary); cursor: pointer;
    }
    .al-panel-title { font-size: 1rem; }
    .al-panel-foot { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}

/* ── Account › Alerts ──────────────────────────────────────────────────── */
#accountSection .al-intro { margin: -8px 0 16px; font-size: 0.8125rem; line-height: 1.5; color: var(--text-secondary); }
#accountSection .al-strip {
    display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
    padding: 12px 14px; margin-bottom: 10px; border-radius: 12px;
    background: var(--bg-tertiary); font-size: 0.8125rem; line-height: 1.5; color: var(--acc-label);
}
#accountSection .al-strip > svg { flex-shrink: 0; color: var(--accent); }
#accountSection .al-strip-text { flex: 1; min-width: 200px; }
#accountSection .al-strip-text strong { color: var(--text-primary); font-weight: 600; }
#accountSection .al-strip .acc2-btn { height: 34px; padding: 0 12px; font-size: 0.8125rem; }
#accountSection .al-strip .acc2-actions { flex-wrap: nowrap; }
#accountSection .al-strip--on > svg { color: var(--green); }

#accountSection .al-rules { margin-top: 6px; border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; }
#accountSection .al-rules-head {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) 150px 44px 80px; gap: 14px;
    padding: 9px 16px; background: var(--bg-tertiary); font-size: 0.75rem; color: var(--text-secondary);
}
#accountSection .al-rule {
    display: grid; grid-template-columns: 32px minmax(0, 1fr) 150px 44px 80px; gap: 14px; align-items: center;
    padding: 14px 16px; border-top: 1px solid var(--bg-tertiary);
}
#accountSection .al-rules-head + .al-rule { border-top: 0; }
#accountSection .al-rule.off .al-ico,
#accountSection .al-rule.off .al-rule-text,
#accountSection .al-rule.off .al-chips { opacity: 0.55; }
#accountSection .al-rule-title { font-size: 0.875rem; font-weight: 600; color: var(--text-primary); overflow-wrap: anywhere; }
#accountSection .al-rule-sub { margin-top: 3px; font-size: 0.75rem; line-height: 1.45; color: var(--text-secondary); }
#accountSection .al-chips { display: flex; flex-wrap: wrap; gap: 6px; }
#accountSection .al-chip { padding: 2px 8px; border-radius: 999px; background: var(--bg-tertiary); font-size: 0.6875rem; color: var(--acc-label); white-space: nowrap; }
#accountSection .al-del {
    width: 36px; height: 36px; padding: 0; border: 0; border-radius: 10px; background: transparent;
    color: var(--text-secondary); cursor: pointer; display: flex; align-items: center; justify-content: center;
}
#accountSection .al-del:hover { background: rgba(246, 70, 93, 0.08); color: var(--red); }
#accountSection .al-acts { display: flex; gap: 4px; justify-content: flex-end; }
#accountSection .al-edit:hover { background: var(--bg-tertiary); color: var(--text-primary); }
#accountSection .al-rules-empty { padding: 22px 16px; font-size: 0.8125rem; color: var(--text-secondary); text-align: center; }

#accountSection .al-sug-title { margin: 20px 0 10px; font-size: 0.8125rem; font-weight: 600; color: var(--acc-muted); }
#accountSection .al-sugs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#accountSection .al-sug { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; border: 1px dashed var(--border-color); }
#accountSection .al-sug-text { flex: 1; min-width: 0; }
#accountSection .al-sug-name { font-size: 0.8125rem; font-weight: 600; color: var(--text-primary); }
#accountSection .al-sug-sub { margin-top: 2px; font-size: 0.75rem; color: var(--text-secondary); }
#accountSection .al-sug .acc2-btn { height: 32px; padding: 0 12px; font-size: 0.75rem; font-weight: 600; }
#accountSection .al-msg { margin-top: 10px; font-size: 0.8125rem; color: var(--red); }
#accountSection .al-msg[hidden] { display: none; }

@media (max-width: 600px) {
    #accountSection .al-rules-head { display: none; }
    #accountSection .al-rule { grid-template-columns: 32px minmax(0, 1fr) 44px; grid-template-areas: "i t s" "i c d"; row-gap: 8px; }
    #accountSection .al-rule > .al-ico { grid-area: i; align-self: start; }
    #accountSection .al-rule > .al-rule-text { grid-area: t; }
    #accountSection .al-rule > .al-chips { grid-area: c; }
    #accountSection .al-rule > .acc2-switch { grid-area: s; justify-self: end; }
    #accountSection .al-rule > .al-acts { grid-area: d; justify-self: end; }
    #accountSection .al-sugs { grid-template-columns: minmax(0, 1fr); }
    #accountSection .al-strip .acc2-actions { width: auto; }
}

/* ── New alert popup (frame/header/close come from popups-v2.css) ─────── */
#newAlertModal .modal { max-width: 540px !important; overflow-y: auto; }
#newAlertModal .modal-content { display: flex; flex-direction: column; gap: 18px; overflow-y: auto; }
.na-label { margin-bottom: 8px; font-size: 0.8125rem; font-weight: 500; color: var(--text-secondary); }
.na-types { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.na-type {
    display: flex; flex-direction: column; gap: 4px; padding: 11px 12px; min-width: 0;
    border: 1px solid var(--border-color); border-radius: 12px; background: transparent;
    font: inherit; text-align: left; color: var(--text-primary); cursor: pointer;
}
.na-type:hover { border-color: #474D57; }
.na-type b { font-size: 0.8125rem; font-weight: 600; }
.na-type span { font-size: 0.6875rem; line-height: 1.4; color: var(--text-secondary); }
.na-type[aria-checked="true"] { border-color: var(--accent); background: rgba(240, 185, 11, 0.06); }

.na-seg { display: flex; flex-wrap: wrap; gap: 6px; }
.na-pill {
    height: 32px; padding: 0 12px; border: 1px solid var(--border-color); border-radius: 999px;
    background: transparent; color: var(--acc-label, #B7BDC6); font: inherit; font-size: 0.8125rem; cursor: pointer;
}
.na-pill:hover { border-color: #474D57; }
.na-pill[aria-pressed="true"], .na-pill[aria-checked="true"] { border-color: var(--accent); color: var(--accent); background: rgba(240, 185, 11, 0.08); }

.na-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
#newAlertModal .na-input {
    height: 42px; box-sizing: border-box; padding: 0 12px; border-radius: 10px;
    border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary);
    font: inherit; font-size: 0.875rem; color-scheme: dark;
}
#newAlertModal .na-input:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.12); }
.na-num { width: 110px; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.na-price { width: 170px; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.na-suffix { font-size: 0.8125rem; color: var(--text-secondary); }
.na-hint { margin-top: 6px; font-size: 0.75rem; line-height: 1.5; color: var(--text-secondary); }

.na-coins { border: 1px solid var(--border-color); border-radius: 12px; overflow: hidden; }
.na-coins .na-input { width: 100%; border: 0; border-bottom: 1px solid var(--bg-tertiary); border-radius: 0; }
.na-coins .na-input:focus-visible { box-shadow: none; }
.na-coin-list { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px; max-height: 148px; overflow-y: auto; }
.na-coin-list .na-pill { height: 28px; padding: 0 10px; font-size: 0.75rem; font-family: 'IBM Plex Mono', ui-monospace, monospace; }
.na-coin-none { font-size: 0.75rem; color: var(--text-secondary); padding: 2px; }

.na-check { display: inline-flex; align-items: center; gap: 8px; font-size: 0.875rem; color: var(--text-primary); cursor: pointer; }
.na-check input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); cursor: pointer; }
.na-check input:disabled { cursor: default; }
.na-check--muted { color: var(--text-secondary); cursor: default; }
.na-deliver { display: flex; gap: 20px; flex-wrap: wrap; }

.na-preview { padding: 12px 14px; border-radius: 12px; background: var(--bg-primary); border: 1px solid var(--bg-tertiary); font-size: 0.8125rem; line-height: 1.5; color: var(--acc-label, #B7BDC6); }
.na-preview-k { display: block; margin-bottom: 4px; font-size: 0.6875rem; color: var(--text-tertiary); }
.na-preview b { color: var(--text-primary); font-weight: 600; }
#newAlertModal .pm-actions { margin-top: 0; }

@media (max-width: 600px) {
    .na-types { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .na-price { width: 100%; flex: 1; }
}
#newAlertModal .pm-msg { margin: 0 !important; }

/* Alerts paused by a plan downgrade */
#accountSection .al-paused {
    justify-self: center; padding: 2px 3px; border-radius: 6px; border: 1px solid var(--accent);
    background: transparent; color: var(--accent); font-size: 0.6875rem; font-weight: 600; cursor: pointer;
    white-space: nowrap; letter-spacing: -0.2px;
}
#accountSection .al-paused-note { color: var(--accent); }
