/* =====================================================================
   Coyyn Crypto Market Data — premium dark financial interface
   ===================================================================== */

:root {
    --cm-bg: #05060B;
    --cm-bg-alt: #080A12;
    --cm-surface: rgba(13, 16, 32, 0.72);
    --cm-surface-solid: #0D1020;
    --cm-border: rgba(255, 255, 255, 0.08);
    --cm-border-strong: rgba(139, 92, 246, 0.28);
    --cm-purple: #8B5CF6;
    --cm-purple-light: #A78BFA;
    --cm-cyan: #22D3EE;
    --cm-green: #34D399;
    --cm-red: #F87171;
    --cm-text: #EDEAF6;
    --cm-text-dim: #9CA3AF;
    --cm-text-mute: #6B7280;
    --cm-radius: 16px;
    --cm-radius-sm: 10px;
    --cm-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
    --cm-glow: 0 0 0 1px rgba(139, 92, 246, 0.12), 0 12px 40px rgba(139, 92, 246, 0.18);
    --cm-font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    --cm-font-display: "Outfit", "Inter", system-ui, sans-serif;
}

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

html {
    scroll-behavior: smooth;
}

body {
    background:
        radial-gradient(1200px 500px at 85% -10%, rgba(139, 92, 246, 0.16), transparent 60%),
        radial-gradient(900px 420px at 0% 0%, rgba(34, 211, 238, 0.08), transparent 55%),
        var(--cm-bg);
    color: var(--cm-text);
    font-family: var(--cm-font);
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

button {
    font-family: inherit;
    cursor: pointer;
}

.cm-shell {
    max-width: 1180px;
    margin: 0 auto;
    padding: 0 22px 60px;
}

/* ------------------------------ Header ------------------------------ */

.cm-header {
    position: relative;
    text-align: center;
    padding: 54px 16px 40px;
}

.cm-header-inner {
    position: relative;
}

.cm-back {
    position: absolute;
    left: 0;
    top: -6px;
    color: var(--cm-text-dim);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 6px 12px;
    border: 1px solid var(--cm-border);
    border-radius: 999px;
    background: var(--cm-surface);
    backdrop-filter: blur(10px);
    transition: all 0.2s ease;
}

.cm-back:hover {
    color: var(--cm-text);
    border-color: var(--cm-border-strong);
    box-shadow: 0 0 0 1px rgba(139, 92, 246, 0.2);
}

.cm-eyebrow {
    display: inline-block;
    font-family: var(--cm-font-display);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.28em;
    color: var(--cm-purple-light);
    margin-bottom: 12px;
}

.cm-header h1 {
    font-family: var(--cm-font-display);
    font-size: clamp(1.9rem, 4.5vw, 2.9rem);
    font-weight: 700;
    letter-spacing: -0.02em;
    background: linear-gradient(120deg, #FFFFFF 20%, var(--cm-purple-light) 60%, var(--cm-cyan) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.cm-header p {
    color: var(--cm-text-dim);
    max-width: 640px;
    margin: 0 auto 18px;
    font-size: 1.02rem;
}

.cm-powered {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    color: var(--cm-text-mute);
}

.cm-powered .cm-led {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--cm-green);
    box-shadow: 0 0 8px var(--cm-green);
    animation: cmPulse 2s ease-in-out infinite;
}

@keyframes cmPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.35; }
}

/* ------------------------------ Error ------------------------------- */

.cm-error {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    margin: 0 0 24px;
    border-radius: var(--cm-radius-sm);
    background: rgba(248, 113, 113, 0.08);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: var(--cm-red);
    font-size: 0.92rem;
}

.cm-error-icon {
    font-size: 1.1rem;
}

.cm-error button {
    margin-left: auto;
    background: rgba(248, 113, 113, 0.14);
    border: 1px solid rgba(248, 113, 113, 0.35);
    color: var(--cm-red);
    padding: 6px 14px;
    border-radius: 999px;
    font-size: 0.82rem;
    font-weight: 600;
    transition: background 0.2s ease;
}

.cm-error button:hover {
    background: rgba(248, 113, 113, 0.24);
}

/* ------------------------------ Sections ---------------------------- */

.cm-section {
    margin-bottom: 28px;
}

.cm-section-head {
    display: flex;
    align-items: center;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 14px;
}

.cm-section-head h2,
.cm-section-title {
    font-family: var(--cm-font-display);
    font-size: 1.35rem;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.cm-count {
    font-size: 0.8rem;
    color: var(--cm-text-mute);
    margin-left: 4px;
}

.cm-updated {
    margin-left: auto;
    font-size: 0.78rem;
    color: var(--cm-text-mute);
    font-variant-numeric: tabular-nums;
}

/* ------------------------------ Stats ------------------------------- */

.cm-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.cm-stat {
    position: relative;
    background: linear-gradient(160deg, rgba(139, 92, 246, 0.10), transparent 55%), var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    padding: 20px 20px 18px;
    backdrop-filter: blur(12px);
    box-shadow: var(--cm-shadow);
    overflow: hidden;
    transition: transform 0.2s ease, border-color 0.2s ease;
}

.cm-stat::before {
    content: "";
    position: absolute;
    inset: 0;
    background: radial-gradient(120px 120px at 85% -20%, rgba(139, 92, 246, 0.22), transparent 70%);
    pointer-events: none;
}

.cm-stat:hover {
    transform: translateY(-3px);
    border-color: var(--cm-border-strong);
}

.cm-stat-label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--cm-text-mute);
    margin-bottom: 10px;
}

.cm-stat-value {
    display: block;
    font-family: var(--cm-font-display);
    font-size: 1.6rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.cm-stat-sub {
    display: block;
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--cm-text-dim);
}

.cm-stat-sub.positive { color: var(--cm-green); }
.cm-stat-sub.negative { color: var(--cm-red); }

/* ------------------------------ Toolbar ----------------------------- */

.cm-toolbar {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    padding: 16px;
    margin-bottom: 24px;
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    backdrop-filter: blur(12px);
}

.cm-search {
    position: relative;
    flex: 1 1 260px;
}

.cm-search-icon {
    position: absolute;
    left: 13px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--cm-text-mute);
    pointer-events: none;
}

.cm-search input {
    width: 100%;
    padding: 11px 38px 11px 38px;
    background: var(--cm-bg-alt);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    color: var(--cm-text);
    font-family: inherit;
    font-size: 0.92rem;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.cm-search input::placeholder {
    color: var(--cm-text-mute);
}

.cm-search input:focus {
    border-color: var(--cm-border-strong);
    box-shadow: var(--cm-glow);
}

.cm-clear {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(255, 255, 255, 0.08);
    color: var(--cm-text-dim);
    border-radius: 50%;
    font-size: 0.95rem;
    line-height: 1;
}

.cm-clear:hover { color: var(--cm-text); }

.cm-tools {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.cm-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cm-field > span {
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cm-text-mute);
}

.cm-field select {
    padding: 10px 12px;
    background: var(--cm-bg-alt);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    color: var(--cm-text);
    font-family: inherit;
    font-size: 0.9rem;
    outline: none;
    cursor: pointer;
    appearance: auto;
}

.cm-field select:focus {
    border-color: var(--cm-border-strong);
    box-shadow: var(--cm-glow);
}

/* ------------------------------ Buttons ----------------------------- */

.cm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 16px;
    border-radius: var(--cm-radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    border: 1px solid var(--cm-border);
    background: transparent;
    color: var(--cm-text);
    transition: all 0.2s ease;
}

.cm-btn-primary {
    background: linear-gradient(135deg, var(--cm-purple), #6D28D9);
    border: 1px solid rgba(139, 92, 246, 0.5);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.28);
}

.cm-btn-primary:hover {
    box-shadow: 0 10px 30px rgba(139, 92, 246, 0.45);
    transform: translateY(-1px);
}

.cm-btn-primary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.cm-btn-ghost:hover {
    border-color: var(--cm-border-strong);
    background: rgba(139, 92, 246, 0.08);
}

.cm-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.cm-refresh-icon.spinning {
    animation: cmSpin 0.7s linear infinite;
}

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

/* ------------------------------ Table ------------------------------- */

.cm-table-wrap {
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    overflow: hidden;
    backdrop-filter: blur(12px);
    box-shadow: var(--cm-shadow);
}

.cm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.cm-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: rgba(10, 12, 24, 0.97);
    backdrop-filter: blur(10px);
    padding: 13px 14px;
    text-align: left;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--cm-text-mute);
    border-bottom: 1px solid var(--cm-border);
    white-space: nowrap;
    user-select: none;
}

.cm-sort {
    cursor: pointer;
    transition: color 0.15s ease;
}

.cm-sort:hover { color: var(--cm-text); }

.cm-sort.active { color: var(--cm-purple-light); }

.cm-sort-arrow {
    display: inline-block;
    width: 0;
    height: 0;
    margin-left: 5px;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    opacity: 0.35;
    vertical-align: 1px;
}

.cm-sort.asc .cm-sort-arrow {
    border-bottom: 5px solid currentColor;
    opacity: 1;
}

.cm-sort.desc .cm-sort-arrow {
    border-top: 5px solid currentColor;
    opacity: 1;
}

.cm-table tbody td {
    padding: 11px 14px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.045);
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.cm-table tbody tr {
    cursor: pointer;
    transition: background 0.15s ease;
}

.cm-table tbody tr:hover {
    background: rgba(139, 92, 246, 0.09);
}

.cm-table tbody tr:last-child td {
    border-bottom: none;
}

.cm-rank {
    color: var(--cm-text-mute);
    font-size: 0.82rem;
    min-width: 34px;
    display: inline-block;
}

.cm-coin {
    display: flex;
    align-items: center;
    gap: 11px;
}

.cm-coin img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.cm-coin .cm-coin-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.cm-coin .cm-coin-name {
    font-weight: 600;
    color: var(--cm-text);
}

.cm-coin .cm-coin-sym {
    font-size: 0.75rem;
    color: var(--cm-text-mute);
    text-transform: uppercase;
}

.cm-up { color: var(--cm-green); }
.cm-down { color: var(--cm-red); }

.cm-cell-num {
    font-variant-numeric: tabular-nums;
}

.cm-no-results {
    padding: 34px;
    text-align: center;
    color: var(--cm-text-mute);
}

/* ------------------------------ Pagination -------------------------- */

.cm-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 18px;
    flex-wrap: wrap;
}

.cm-page-nums {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cm-page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border-radius: 8px;
    border: 1px solid var(--cm-border);
    background: transparent;
    color: var(--cm-text-dim);
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.15s ease;
}

.cm-page-btn:hover {
    border-color: var(--cm-border-strong);
    color: var(--cm-text);
}

.cm-page-btn.active {
    background: linear-gradient(135deg, var(--cm-purple), #6D28D9);
    color: #fff;
    border-color: transparent;
    box-shadow: 0 6px 18px rgba(139, 92, 246, 0.35);
}

/* ------------------------- Gainers / Losers ------------------------- */

.cm-split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px;
}

.cm-panel {
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius);
    padding: 20px;
    backdrop-filter: blur(12px);
    box-shadow: var(--cm-shadow);
}

.cm-panel-title {
    font-family: var(--cm-font-display);
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 14px;
}

.cm-panel-title.gain { color: var(--cm-green); }
.cm-panel-title.loss { color: var(--cm-red); }

.cm-move-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cm-move-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 10px;
    border-radius: var(--cm-radius-sm);
    transition: background 0.15s ease;
    cursor: pointer;
}

.cm-move-item:hover {
    background: rgba(139, 92, 246, 0.09);
}

.cm-move-item img {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.cm-move-item .cm-move-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
    flex: 1;
}

.cm-move-item .cm-move-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-move-item .cm-move-sym {
    font-size: 0.74rem;
    color: var(--cm-text-mute);
}

.cm-move-item .cm-move-price {
    font-variant-numeric: tabular-nums;
    color: var(--cm-text-dim);
    font-size: 0.86rem;
}

.cm-move-item .cm-move-pct {
    font-weight: 700;
    font-size: 0.86rem;
    min-width: 62px;
    text-align: right;
}

/* ------------------------------ Trending ---------------------------- */

.cm-trending {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px;
}

.cm-trend-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px;
    background: var(--cm-surface);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    backdrop-filter: blur(12px);
    transition: all 0.2s ease;
    cursor: pointer;
}

.cm-trend-card:hover {
    border-color: var(--cm-border-strong);
    box-shadow: var(--cm-glow);
    transform: translateY(-2px);
}

.cm-trend-card img {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
}

.cm-trend-card .cm-trend-meta {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
    min-width: 0;
    flex: 1;
}

.cm-trend-card .cm-trend-name {
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cm-trend-card .cm-trend-sym {
    font-size: 0.74rem;
    color: var(--cm-text-mute);
    text-transform: uppercase;
}

.cm-trend-card .cm-trend-rank {
    font-size: 0.72rem;
    color: var(--cm-cyan);
    background: rgba(34, 211, 238, 0.08);
    border: 1px solid rgba(34, 211, 238, 0.2);
    padding: 3px 8px;
    border-radius: 999px;
    white-space: nowrap;
}

/* ------------------------------ Disclaimer -------------------------- */

.cm-disclaimer {
    margin-top: 10px;
    padding: 16px 18px;
    font-size: 0.78rem;
    color: var(--cm-text-mute);
    text-align: center;
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    background: rgba(255, 255, 255, 0.02);
}

/* ------------------------------ Skeleton ---------------------------- */

.cm-skeleton {
    display: inline-block;
    border-radius: 8px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.04) 25%, rgba(255, 255, 255, 0.10) 50%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 200% 100%;
    animation: cmShimmer 1.4s infinite;
    pointer-events: none;
}

@keyframes cmShimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

.cm-stat .cm-skeleton {
    height: 26px;
    width: 70%;
    margin-bottom: 8px;
}

.cm-stat .cm-skeleton + .cm-skeleton {
    width: 45%;
    height: 14px;
    display: block;
}

.cm-skel-row td {
    padding: 0 !important;
}

.cm-skel-row .cm-skel-line {
    height: 46px;
    margin: 0;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.02) 25%, rgba(255, 255, 255, 0.06) 50%, rgba(255, 255, 255, 0.02) 75%);
    background-size: 200% 100%;
    animation: cmShimmer 1.4s infinite;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
}

.cm-chart-empty {
    position: absolute;
    inset: 0;
}

/* ------------------------------ Modal ------------------------------- */

.cm-modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(3, 4, 9, 0.72);
    backdrop-filter: blur(8px);
    overflow-y: auto;
}

.cm-modal-card {
    position: relative;
    width: 100%;
    max-width: 720px;
    max-height: 92vh;
    overflow-y: auto;
    background: linear-gradient(170deg, rgba(139, 92, 246, 0.08), transparent 40%), var(--cm-surface-solid);
    border: 1px solid var(--cm-border-strong);
    border-radius: 20px;
    padding: 26px 26px 22px;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
    animation: cmModalIn 0.25s ease;
}

@keyframes cmModalIn {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
}

.cm-modal-close {
    position: absolute;
    right: 16px;
    top: 14px;
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.15rem;
    line-height: 1;
}

.cm-coin-head {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 20px;
    padding-right: 40px;
}

.cm-coin-head img {
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.06);
}

.cm-coin-head .cm-coin-titles {
    flex: 1;
}

.cm-coin-head h3 {
    font-family: var(--cm-font-display);
    font-size: 1.5rem;
    font-weight: 700;
}

.cm-coin-head .cm-coin-sym-big {
    font-size: 0.85rem;
    color: var(--cm-text-mute);
    text-transform: uppercase;
}

.cm-coin-price {
    text-align: right;
}

.cm-coin-price .cm-coin-price-val {
    font-family: var(--cm-font-display);
    font-size: 1.7rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    display: block;
}

.cm-coin-price .cm-coin-price-chg {
    font-weight: 600;
    font-size: 0.9rem;
}

.cm-coin-facts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin-bottom: 22px;
}

.cm-coin-facts > div {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    padding: 10px 12px;
}

.cm-coin-facts dt {
    font-size: 0.68rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--cm-text-mute);
    margin-bottom: 4px;
}

.cm-coin-facts dd {
    font-size: 0.92rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    word-break: break-word;
}

.cm-coin-facts dd.muted {
    color: var(--cm-text-dim);
    font-weight: 500;
}

.cm-chart-block {
    margin-top: 6px;
}

.cm-chart-tools {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.cm-chart-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.cm-chart-ranges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.cm-chart-ranges button {
    padding: 6px 11px;
    border-radius: 8px;
    border: 1px solid var(--cm-border);
    background: transparent;
    color: var(--cm-text-dim);
    font-size: 0.76rem;
    font-weight: 600;
    transition: all 0.15s ease;
}

.cm-chart-ranges button:hover {
    color: var(--cm-text);
    border-color: var(--cm-border-strong);
}

.cm-chart-ranges button.active {
    background: rgba(139, 92, 246, 0.16);
    color: var(--cm-purple-light);
    border-color: var(--cm-border-strong);
}

.cm-chart-wrap {
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-sm);
    overflow: hidden;
}

.cm-chart-wrap canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ------------------------------ Responsive -------------------------- */

@media (max-width: 900px) {
    .cm-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
    .cm-shell { padding: 0 14px 44px; }
    .cm-header { padding-top: 46px; }
    .cm-back { position: static; margin-bottom: 16px; }
    .cm-stats { grid-template-columns: 1fr 1fr; gap: 10px; }
    .cm-stat { padding: 16px 14px; }
    .cm-stat-value { font-size: 1.25rem; }
    .cm-split { grid-template-columns: 1fr; }
    .cm-toolbar { flex-direction: column; align-items: stretch; }
    .cm-tools { flex-wrap: wrap; }
    .cm-field select { flex: 1; }
    .cm-btn-primary { flex: 1; }
    .cm-coin-head { flex-wrap: wrap; }
    .cm-coin-price { text-align: left; }
    .cm-chart-tools { flex-direction: column; align-items: flex-start; }
    .cm-modal-card { padding: 18px 16px 16px; }
    .cm-table-wrap { overflow-x: auto; }
    .cm-table { min-width: 760px; }
}

/* Hidden-attribute fixes (display:flex overrides the UA [hidden] rule) */
.cm-error[hidden],
.cm-modal[hidden],
.cm-pagination[hidden] {
    display: none !important;
}
