:root {
    --bg: #f5f5f7;
    --surface: #ffffff;
    --surface-hover: #f8f8fa;
    --surface-input: #ffffff;
    --separator: rgba(60, 60, 67, 0.12);
    --text: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #8e8e93;
    --blue: #007aff;
    --green: #34c759;
    --green-bg: rgba(52, 199, 89, 0.12);
    --red: #ff3b30;
    --red-bg: rgba(255, 59, 48, 0.12);
    --neutral-bg: rgba(118, 118, 128, 0.12);
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.08);
    --font-main: Vazirmatn, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --page-gutter: 24px;
}

* {
    box-sizing: border-box;
}

html {
    color-scheme: light;
}

body {
    min-height: 100vh;
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font-main);
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

input,
button {
    font: inherit;
}

.bg-glow {
    display: none;
}

.content-layout {
    width: 100%;
    min-height: 100vh;
    padding: 0 var(--page-gutter);
    position: relative;
}

.app-container {
    width: min(100%, 760px);
    margin: 0 auto;
    padding: 28px var(--page-gutter) 42px;
}

.media {
    width: 100%;
}

.pricing-layout {
    width: 100%;
}

.side-gap-ad {
    position: fixed;
    top: 0;
    width: 130px;
    height: 420px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px 10px;
    color: var(--text-secondary);
    text-align: center;
    font-size: 0.92rem;
    font-weight: 700;
    z-index: 2;
    opacity: 0;
    visibility: hidden;
}

.side-gap-ad.is-ready {
    opacity: 1;
    visibility: visible;
}

.side-gap-ad-right {
    right: max(10px, calc((100vw - min(100vw, 760px)) / 2 - 130px - 10px));
}

.side-gap-ad-left {
    left: max(10px, calc((100vw - min(100vw, 760px)) / 2 - 130px - 10px));
}

.top-bar,
#loading,
#error-message {
    width: 100%;
    margin-inline: auto;
}

.top-bar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    margin-bottom: 14px;
}

.brand,
.brand-text {
    min-width: 0;
}

.brand h1 {
    margin: 0 0 8px;
    color: var(--text);
    font-size: clamp(2.7rem, 10vw, 3.4rem);
    font-weight: 800;
    letter-spacing: -0.06em;
    line-height: 0.95;
}

.update-time {
    display: block;
    overflow: hidden;
    color: var(--text-secondary);
    font-size: 0.82rem;
    font-weight: 500;
    line-height: 1.6;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.seo-intro {
    margin: 0 0 8px;
    color: var(--text-secondary);
    font-size: 0.92rem;
    font-weight: 500;
    line-height: 1.8;
}

.search-wrapper {
    position: sticky;
    top: 12px;
    z-index: 4;
}

.search-icon {
    position: absolute;
    top: 50%;
    right: 15px;
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

#searchInput {
    width: 100%;
    height: 48px;
    border: 1px solid transparent;
    border-radius: 14px;
    outline: none;
    padding: 0 43px 0 14px;
    background: rgba(118, 118, 128, 0.12);
    color: var(--text);
    font-size: 1rem;
    font-weight: 500;
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

#searchInput::placeholder {
    color: var(--text-muted);
}

#searchInput:focus {
    border-color: rgba(0, 122, 255, 0.3);
    background: var(--surface-input);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.glass-panel {
    overflow: hidden;
    border: 1px solid var(--separator);
    border-radius: 22px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.table-container {
    width: 100%;
    flex: 1 1 auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    display: none;
}

tbody {
    display: block;
}

tbody tr {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "asset price"
        "asset change";
    align-items: center;
    gap: 4px 14px;
    min-height: 76px;
    padding: 14px 16px;
    background: var(--surface);
    transition: background 0.15s ease;
}

tbody tr:not(:last-child) {
    border-bottom: 1px solid var(--separator);
}

tbody tr:hover {
    background: var(--surface-hover);
}

tbody tr.asset-row {
    cursor: pointer;
}

tbody tr.asset-row:focus-visible {
    outline: 3px solid rgba(0, 122, 255, 0.25);
    outline-offset: -3px;
}

tbody tr.status-row {
    display: block;
    min-height: auto;
}

td {
    display: block;
    padding: 0;
    border: 0;
}

td:nth-child(1) {
    grid-area: asset;
    min-width: 0;
}

td:nth-child(2) {
    grid-area: price;
}

td:nth-child(3) {
    grid-area: change;
}

.align-left,
.align-right {
    text-align: inherit;
}

.asset-cell {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.asset-icon-box {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    flex: 0 0 42px;
    border-radius: 13px;
    background: rgba(118, 118, 128, 0.12);
    color: var(--blue);
}

.asset-icon-box svg {
    width: 20px;
    height: 20px;
    color: currentColor;
}

.asset-icon-box img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: contain;
}

.asset-icon-box img + .fallback-icon {
    display: none;
}

.fallback-icon,
.fallback-icon svg {
    width: 20px;
    height: 20px;
}

.fallback-icon {
    align-items: center;
    justify-content: center;
}

.asset-info {
    min-width: 0;
}

.asset-name {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 1rem;
    font-weight: 650;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.asset-symbol {
    display: block;
    margin-top: 2px;
    color: var(--text-secondary);
    direction: ltr;
    font-size: 0.76rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    text-align: right;
}

.price-cell {
    direction: ltr;
    color: var(--text);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.25;
    text-align: left;
    white-space: nowrap;
}

.badge {
    min-width: 76px;
    max-width: 160px;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    border-radius: 999px;
    padding: 4px 9px;
    overflow: hidden;
    direction: ltr;
    color: var(--text-secondary);
    background: var(--neutral-bg);
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, monospace;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.badge-success,
.badge.up {
    color: var(--green);
    background: var(--green-bg);
}

.badge-danger,
.badge.down {
    color: var(--red);
    background: var(--red-bg);
}

.badge-neutral,
.badge.neutral {
    color: var(--text-secondary);
    background: var(--neutral-bg);
}

.flash-up {
    animation: flashGreen 0.55s ease-out;
}

.flash-down {
    animation: flashRed 0.55s ease-out;
}

@keyframes flashGreen {
    0% {
        color: var(--green);
    }

    100% {
        color: var(--text);
    }
}

@keyframes flashRed {
    0% {
        color: var(--red);
    }

    100% {
        color: var(--text);
    }
}

.change-indicator {
    font-size: 0.8em;
    margin-left: 6px;
    white-space: nowrap;
    vertical-align: middle;
    font-weight: 700;
}

.change-indicator.up {
    color: var(--red);
}

.change-indicator.down {
    color: var(--green);
}

.status-message {
    color: var(--text-secondary);
    text-align: center;
    padding: 24px;
    font-size: 0.95rem;
    font-weight: 500;
}

.status-message.error,
.status-message.danger {
    margin-bottom: 12px;
    border-radius: 16px;
    color: var(--red);
    background: var(--red-bg);
}

.status-message.success {
    margin-bottom: 12px;
    border-radius: 16px;
    color: var(--green);
    background: var(--green-bg);
}

.spinner {
    width: 28px;
    height: 28px;
    margin: 0 auto;
    border: 2px solid var(--separator);
    border-top-color: var(--blue);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

body.modal-open {
    overflow: hidden;
}

.chart-modal[hidden] {
    display: none;
}

.chart-modal {
    position: fixed;
    inset: 0;
    z-index: 20;
    display: grid;
    place-items: center;
    padding: 18px;
}

.chart-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.42);
    backdrop-filter: blur(10px);
}

.chart-panel {
    position: relative;
    z-index: 1;
    width: min(100%, 760px);
    max-height: min(760px, 92vh);
    overflow: auto;
    padding: 20px;
}

.chart-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.chart-header h2 {
    margin: 0 0 6px;
    font-size: 1.32rem;
    letter-spacing: -0.02em;
}

.chart-subtitle {
    color: var(--text-secondary);
    font-size: 0.88rem;
    font-weight: 600;
}

.chart-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 12px;
    background: rgba(118, 118, 128, 0.14);
    color: var(--text);
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
}

.chart-ranges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
    padding: 6px;
    border: 1px solid var(--separator);
    border-radius: 999px;
    background: rgba(118, 118, 128, 0.08);
}

.chart-ranges button {
    flex: 1 1 54px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 800;
    cursor: pointer;
    transition: background 0.16s ease, color 0.16s ease, transform 0.16s ease;
}

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

.chart-ranges button.active {
    background: var(--blue);
    color: #fff;
    box-shadow: 0 10px 24px rgba(0, 122, 255, 0.24);
}

.chart-status {
    padding: 28px 12px;
    color: var(--text-secondary);
    text-align: center;
    font-weight: 600;
}

.chart-status.error {
    color: var(--red);
}

.chart-canvas {
    min-height: 410px;
    border: 1px solid var(--separator);
    border-radius: 22px;
    background:
        radial-gradient(circle at top right, rgba(0, 122, 255, 0.10), transparent 34%),
        linear-gradient(180deg, rgba(118, 118, 128, 0.08), rgba(118, 118, 128, 0.03));
    overflow: hidden;
}

.chart-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    padding: 16px;
}

.chart-summary > div {
    min-width: 0;
    padding: 14px;
    border: 1px solid var(--separator);
    border-radius: 16px;
    background: var(--surface);
}

.chart-summary span {
    display: block;
    margin-bottom: 6px;
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.chart-summary strong {
    display: block;
    overflow: hidden;
    color: var(--text);
    font-size: 1rem;
    font-weight: 850;
    line-height: 1.45;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chart-summary small {
    font-size: 0.78rem;
}

.chart-summary.chart-up > div:nth-child(2) strong {
    color: var(--green);
}

.chart-summary.chart-down > div:nth-child(2) strong {
    color: var(--red);
}

.chart-plot {
    position: relative;
    padding: 0 14px;
}

.chart-canvas svg {
    display: block;
    width: 100%;
    height: 300px;
}

.chart-grid-line {
    fill: none;
    stroke: var(--separator);
    stroke-width: 1;
}

.chart-area {
    opacity: 0.14;
}

.chart-line {
    fill: none;
    stroke-width: 5;
    stroke-linecap: round;
    stroke-linejoin: round;
    filter: drop-shadow(0 8px 14px rgba(0, 0, 0, 0.10));
}

.chart-up .chart-line {
    stroke: var(--green);
}

.chart-up .chart-area {
    fill: var(--green);
}

.chart-down .chart-line {
    stroke: var(--red);
}

.chart-down .chart-area {
    fill: var(--red);
}

.chart-marker {
    fill: var(--surface);
    stroke-width: 4;
}

.chart-up .chart-marker {
    stroke: var(--green);
}

.chart-down .chart-marker {
    stroke: var(--red);
}

.chart-marker.high,
.chart-marker.low {
    opacity: 0.78;
}

.chart-marker.last {
    filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.22));
}

.chart-axis-labels {
    position: absolute;
    top: 8px;
    left: 18px;
    bottom: 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: var(--text-muted);
    direction: ltr;
    font-size: 0.74rem;
    font-weight: 700;
    pointer-events: none;
}

.chart-meta {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 12px;
    align-items: center;
    padding: 0 18px 18px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    font-weight: 650;
}

.chart-meta span:nth-child(2) {
    color: var(--text);
}

.chart-meta span:last-child {
    text-align: left;
}

.chart-single-point {
    display: grid;
    place-content: center;
    min-height: 410px;
    gap: 8px;
    color: var(--text);
    font-size: 1.5rem;
    font-weight: 850;
    text-align: center;
}

.chart-single-point span {
    color: var(--text-secondary);
    font-size: 0.86rem;
    font-weight: 650;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #000000;
        --surface: #1c1c1e;
        --surface-hover: #242426;
        --surface-input: #2c2c2e;
        --separator: rgba(255, 255, 255, 0.1);
        --text: #f5f5f7;
        --text-secondary: #a1a1a6;
        --text-muted: #6e6e73;
        --shadow: none;
        color-scheme: dark;
    }

    #searchInput {
        background: var(--surface-input);
    }
}

@media (max-width: 640px) {
    .chart-panel {
        padding: 16px;
    }

    .chart-ranges {
        border-radius: 18px;
    }

    .chart-summary {
        grid-template-columns: 1fr;
        padding: 12px;
    }

    .chart-canvas {
        min-height: 500px;
    }

    .chart-canvas svg {
        height: 260px;
    }

    .chart-meta {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .chart-meta span:last-child {
        text-align: center;
    }
}

@media (min-width: 720px) {
    .app-container {
        padding-top: 46px;
    }

    .top-bar {
        grid-template-columns: minmax(0, 1fr) 320px;
        align-items: end;
        margin-bottom: 18px;
    }

    thead {
        display: table-header-group;
    }

    tbody {
        display: table-row-group;
    }

    thead th {
        padding: 13px 18px;
        border-bottom: 1px solid var(--separator);
        color: var(--text-secondary);
        font-size: 0.76rem;
        font-weight: 650;
        text-align: right;
    }

    thead th.align-left {
        text-align: left;
    }

    tbody tr {
        display: table-row;
    }

    td {
        display: table-cell;
        height: 72px;
        padding: 13px 18px;
        vertical-align: middle;
    }

    td:nth-child(2),
    td:nth-child(3) {
        text-align: left;
    }
}

@media (max-width: 1199px) {
    .content-layout {
        padding-top: 24px;
        padding-bottom: 24px;
    }

    .side-gap-ad {
        position: static;
        transform: none;
        width: 100%;
        max-width: 760px;
        min-height: 96px;
        height: auto !important;
        margin: 12px auto 0;
        opacity: 1;
        visibility: visible;
    }

    .side-gap-ad-right {
        display: none;
    }

    .side-gap-ad-left {
        margin-top: 12px;
    }
}

@media (max-width: 420px) {
    .app-container {
        padding: 22px 12px 32px;
    }

    .brand h1 {
        font-size: 2.45rem;
    }

    tbody tr {
        min-height: 72px;
        padding: 13px 12px;
        gap: 4px 10px;
    }

    .asset-icon-box {
        width: 38px;
        height: 38px;
        flex-basis: 38px;
        border-radius: 12px;
    }

    .asset-name {
        font-size: 0.96rem;
    }

    .price-cell {
        font-size: 0.94rem;
    }

    .badge {
        min-width: 70px;
        max-width: 110px;
        font-size: 0.68rem;
    }
}

.admin-shell {
    width: min(100%, 560px);
}

.admin-card {
    padding: 18px;
}

.admin-header {
    margin-bottom: 18px;
}

.admin-form {
    display: grid;
    gap: 14px;
}

.admin-field {
    display: grid;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.admin-field input {
    width: 100%;
    height: 48px;
    border: 1px solid transparent;
    border-radius: 14px;
    outline: none;
    padding: 0 14px;
    background: rgba(118, 118, 128, 0.12);
    color: var(--text);
    transition: background 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.admin-field input:focus {
    border-color: rgba(0, 122, 255, 0.3);
    background: var(--surface-input);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1);
}

.admin-button {
    height: 48px;
    border: 0;
    border-radius: 14px;
    background: var(--blue);
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

.admin-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.admin-button.secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.admin-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.82rem;
    line-height: 1.6;
}

.admin-panel {
    display: grid;
    gap: 16px;
}

.admin-panel h2 {
    margin: 0 0 8px;
    font-size: 1.3rem;
}

.admin-panel p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.8;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.admin-stat-card {
    display: grid;
    gap: 6px;
    padding: 16px;
    border: 1px solid var(--separator);
    border-radius: 18px;
    background: rgba(118, 118, 128, 0.08);
}

.admin-stat-label,
.admin-stat-caption {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.admin-stat-value {
    font-size: 1.7rem;
    font-weight: 800;
    letter-spacing: -0.04em;
}

.admin-table-shell {
    overflow: hidden;
}

.admin-table-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--separator);
}

.admin-table-header h3 {
    margin: 0;
    font-size: 1rem;
}

.admin-table-header span {
    color: var(--text-secondary);
    font-size: 0.84rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--separator);
    text-align: right;
    font-size: 0.92rem;
}

.admin-table th {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
}

.admin-table td {
    direction: ltr;
}

.admin-table td:nth-child(2),
.admin-table td:nth-child(3) {
    direction: rtl;
}

@media (max-width: 640px) {
    .admin-table-shell {
        overflow-x: auto;
    }

    .admin-table {
        min-width: 620px;
    }
}






.price-red {
    color: #ef4444 !important;
}

.price-green {
    color: #22c55e !important;
}

.change-indicator.up {
    color: #ef4444;
    font-weight: 700;
    margin-right: 8px;
}

.change-indicator.down {
    color: #22c55e;
    font-weight: 700;
    margin-right: 8px;
}
