:root {
    --bg: #f2f5f9;
    --card-bg: #ffffff;
    --text-primary: #1f2937;
    --text-muted: #6b7280;
    --line: #e5e7eb;
    --brand: #0b79d0;
    --brand-hover: #0862aa;
    --ok-soft: #dff3e8;
    --ok-text: #13623f;
    --warn-soft: #fff5d8;
    --warn-text: #8b5e00;
    --danger: #dc3545;
    --shadow-soft: 0 6px 20px rgba(15, 23, 42, 0.06);
    --tg-safe-area-inset-top: 0px;
    --tg-safe-area-inset-bottom: 0px;
    --tg-safe-area-inset-left: 0px;
    --tg-safe-area-inset-right: 0px;
}

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

html,
body {
    min-height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
}

html[data-eitaa-webapp="1"] body {
    background: var(--tg-bg-color, var(--bg));
    color: var(--tg-text-color, var(--text-primary));
    padding-top: max(env(safe-area-inset-top, 0px), var(--tg-safe-area-inset-top));
    padding-bottom: max(env(safe-area-inset-bottom, 0px), var(--tg-safe-area-inset-bottom));
    padding-left: max(env(safe-area-inset-left, 0px), var(--tg-safe-area-inset-left));
    padding-right: max(env(safe-area-inset-right, 0px), var(--tg-safe-area-inset-right));
}

a {
    color: inherit;
    text-decoration: none;
}

.container {
    width: 100%;
    max-width: 1160px;
    margin: 0 auto;
    padding: 24px;
}

.main-content {
    width: 100%;
}

.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    padding: 16px 20px;
    margin-bottom: 18px;
}

.header h1,
.header h2 {
    margin: 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 0;
    border-radius: 10px;
    padding: 10px 16px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    background: var(--brand);
    color: #fff;
}

.btn-primary:hover {
    background: var(--brand-hover);
}

.btn-secondary {
    background: #606a77;
    color: #fff;
}

.btn-secondary:hover {
    background: #49515c;
}

.text-muted {
    color: var(--text-muted);
}

.inline-link {
    color: var(--brand);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.toast-container {
    z-index: 2000;
}

/* Dashboard */
.dashboard-page .app-header {
    border-radius: 14px;
}

.app-header-collapsible {
    display: block;
    overflow: hidden;
    transition: padding-bottom 0.22s ease;
}

.app-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-user img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d8dde5;
}

.header-user span {
    font-size: 0.95rem;
    font-weight: 600;
}

.header-settings-toggle {
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    color: #556070;
    background: #f1f4f8;
    border: none;
    position: relative;
    overflow: hidden;
    text-decoration: none;
}

.header-settings-toggle:hover {
    background: #e3e8ef;
}

.header-settings-toggle i {
    position: absolute;
    font-size: 1rem;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.header-nav-btn i {
    position: static;
    opacity: 1;
    transform: none;
    font-size: 1rem;
}

.header-nav-btn .icon-gear,
.header-nav-btn .icon-back {
    display: none;
}

.header-settings-toggle .icon-gear {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.header-settings-toggle .icon-back {
    opacity: 0;
    transform: rotate(-35deg) scale(0.7);
}

.app-header-collapsible.drawer-open .header-settings-toggle .icon-gear {
    opacity: 0;
    transform: rotate(40deg) scale(0.7);
}

.app-header-collapsible.drawer-open .header-settings-toggle .icon-back {
    opacity: 1;
    transform: rotate(0deg) scale(1);
}

.header-drawer {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.32s ease, opacity 0.26s ease, margin-top 0.2s ease;
    opacity: 0;
    margin-top: 0;
}

.app-header-collapsible.drawer-open .header-drawer {
    opacity: 1;
    margin-top: 14px;
}

.header-drawer-content {
    border-top: 1px solid #e8edf3;
    padding-top: 12px;
    display: grid;
    gap: 10px;
}

.drawer-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.88rem;
}

.drawer-row strong {
    color: #18202a;
}

.drawer-limit {
    border: 1px solid #e5ecf5;
    border-radius: 10px;
    padding: 8px 10px;
    background: #f8fbff;
}

.drawer-limit-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    font-size: 0.78rem;
    margin-bottom: 8px;
    color: #4b5563;
}

.drawer-limit-head strong {
    color: #0b79d0;
    font-size: 0.82rem;
}

.drawer-limit-track {
    width: 100%;
    height: 7px;
    border-radius: 999px;
    background: #dce7f5;
    overflow: hidden;
}

.drawer-limit-track span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #5daeff, #0b79d0);
}

.drawer-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.drawer-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    background: #eef3f9;
    color: #516073;
    font-size: 0.72rem;
    font-weight: 600;
}

.drawer-settings {
    border: 1px dashed #d7e2f1;
    border-radius: 10px;
    padding: 8px 10px;
    display: grid;
    gap: 8px;
}

.drawer-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.8rem;
    color: #334155;
}

.drawer-setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0b79d0;
}

.drawer-reset-btn {
    border: 1px solid #d7e2f1;
    background: #ffffff;
    color: #334155;
    border-radius: 8px;
    min-height: 34px;
    font-size: 0.78rem;
    font-weight: 600;
}

.drawer-reset-btn:hover {
    background: #f8fbff;
}

.drawer-reset-btn-global {
    border-color: #cdd8ea;
    color: #1e3a5f;
    background: #f5f9ff;
}

.drawer-reset-btn-global:hover {
    background: #eaf2ff;
}

.drawer-link {
    width: 100%;
    min-height: 40px;
}

.refresh-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: background 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #556070;
    z-index: 2;
}

.refresh-btn:hover {
    background: rgba(0, 0, 0, 0.08);
}

.refresh-btn svg {
    width: 22px;
    height: 22px;
}

.refresh-btn.loading svg {
    animation: spin 1s linear infinite;
}

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

.refresh-all-section {
    background: #f8f9fa;
    padding: 18px;
    border-radius: 12px;
    margin-bottom: 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 14px;
}

.refresh-all-section h5 {
    margin-bottom: 6px;
    font-size: 1rem;
}

.refresh-all-section.loading {
    opacity: 0.7;
}

.progress-info {
    flex: 1;
    min-width: 220px;
}

.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 8px;
    margin-top: 8px;
    font-size: 0.85rem;
}

.dashboard-stat-item {
    display: flex;
    justify-content: space-between;
}

.dashboard-stat-label {
    color: #6c757d;
}

.dashboard-stat-value {
    font-weight: 700;
}

.progress-bar-container {
    background: #e9ecef;
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
    margin-top: 8px;
}

.progress-bar {
    background: linear-gradient(90deg, #007bff, #0056b3);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.75rem;
    font-weight: 700;
}

.refresh-all-btn {
    min-width: 160px;
    white-space: nowrap;
}

.refresh-all-compact {
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 14px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid #dce3eb;
    background: #fff;
    box-shadow: var(--shadow-soft);
}

.refresh-all-compact-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.refresh-all-compact-title {
    font-size: 0.88rem;
    font-weight: 700;
}

.refresh-all-compact-copy small {
    font-size: 0.74rem;
    color: #697588;
}

.refresh-all-compact .btn {
    min-width: 116px;
    font-size: 0.8rem;
    padding: 8px 10px;
    border-radius: 9px;
}

.channels-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.channel-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    min-height: 96px;
    position: relative;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
}

.dashboard-compact-cards .channel-card {
    padding: 12px;
    min-height: 82px;
    gap: 10px;
}

.dashboard-compact-cards .channel-icon {
    width: 44px;
    height: 44px;
}

.dashboard-compact-cards .channel-info h3 {
    font-size: 0.9rem;
}

.dashboard-compact-cards .channel-info .members {
    font-size: 0.78rem;
}

.dashboard-compact-cards .status-badge {
    margin-top: 5px;
    font-size: 0.68rem;
    padding: 3px 8px;
}

.channel-card:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
    text-decoration: none;
    color: inherit;
}

.channel-card:focus,
.channel-card:active,
.channel-card:visited {
    text-decoration: none;
    color: inherit;
}

.channel-card.loading {
    opacity: 0.8;
    pointer-events: none;
    background: #f8f9fa;
}

.channel-card.loading::before {
    content: "";
    position: absolute;
    inset: 0;
    transform: translateX(-100%);
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.65), transparent);
    animation: card-shimmer 1.1s infinite;
}

.channel-card.loading::after {
    content: none;
}

@keyframes card-shimmer {
    100% {
        transform: translateX(100%);
    }
}

.channel-card.loading .channel-icon {
    background: #e9ecef;
}

.channel-card.loading .channel-icon img,
.channel-card.loading .channel-icon span {
    opacity: 0.5;
}

.channel-icon {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    overflow: hidden;
    background: #eef2f7;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.channel-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.channel-icon span {
    font-size: 1.2rem;
}

.channel-info h3 {
    font-size: 1rem;
    margin: 0 0 3px;
}

.members {
    font-size: 0.88rem;
    color: var(--text-muted);
}

.status-badge {
    display: inline-block;
    margin-top: 8px;
    margin-inline-start: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 0.72rem;
}

.dashboard-page .status-badge.processing {
    background: var(--warn-soft);
    color: var(--warn-text);
}

.dashboard-page .status-badge.ready {
    background: var(--ok-soft);
    color: var(--ok-text);
}

.dashboard-page .status-badge.inactive {
    background: #eef1f5;
    color: #6b7280;
}

.dashboard-page .add-channel-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px;
    min-height: 96px;
    border-radius: 14px;
    border: 2px dashed #606a77;
    background: transparent;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.08);
    transition: border-color 0.2s ease, background-color 0.2s ease;
    text-decoration: none;
    color: inherit;
}

.dashboard-page .add-channel-card:hover,
.dashboard-page .add-channel-card:focus,
.dashboard-page .add-channel-card:active,
.dashboard-page .add-channel-card:visited {
    border-color: #49515c;
    background: transparent;
    transform: translateY(-1px);
    box-shadow: 0 14px 30px rgba(15, 23, 42, 0.1);
    text-decoration: none;
    color: inherit;
}

.dashboard-page .add-channel-card .add-icon {
    font-size: 1.6rem;
    color: #7b8794;
    line-height: 1;
}

.dashboard-page .add-channel-card p {
    font-size: 0.9rem;
    color: #5d6673;
    margin: 0;
}

.empty-state {
    text-align: center;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 48px 20px;
}

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

/* Stats loading page */
.stats-loading-page {
    background: linear-gradient(180deg, #f7fafd 0%, #eef4fb 100%);
    min-height: 100vh;
}

.stats-loading-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 16px;
}

.stats-loading-card {
    width: min(460px, 100%);
    border-radius: 18px;
    background: #fff;
    border: 1px solid #deebf9;
    box-shadow: 0 18px 42px rgba(15, 23, 42, 0.12);
    padding: 22px 18px;
    text-align: center;
}

.stats-loading-spinner {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #0d6efd;
    margin-bottom: 12px;
}

.stats-loading-spinner .spinner-grow:nth-child(2) {
    animation-delay: 0.12s;
}

.stats-loading-spinner .spinner-grow:nth-child(3) {
    animation-delay: 0.24s;
}

.stats-loading-card h1 {
    font-size: 1.03rem;
    margin: 0 0 6px;
}

.stats-loading-card p {
    color: #5f6b7b;
    font-size: 0.84rem;
    margin: 0 0 14px;
}

.stats-loading-channel-preview {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 10px;
    background: #f6faff;
    border: 1px solid #deebf9;
    border-radius: 12px;
    padding: 9px 10px;
    margin: 0 0 12px;
}

.stats-loading-channel-icon {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    overflow: hidden;
    background: #dfe8f4;
    flex-shrink: 0;
}

.stats-loading-channel-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.stats-loading-channel-meta {
    display: grid;
    gap: 3px;
    min-width: 0;
    text-align: right;
}

.stats-loading-channel-meta strong {
    font-size: 0.86rem;
    color: #1f2d3d;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-loading-channel-meta small {
    font-size: 0.74rem;
    color: #607185;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stats-loading-channel-status {
    font-size: 0.72rem;
    color: #41566f;
    background: #ebf2fb;
    border-radius: 999px;
    padding: 4px 8px;
    white-space: nowrap;
}

.stats-loading-progress {
    height: 8px;
    background: #e6edf7;
    border-radius: 999px;
    overflow: hidden;
}

.stats-loading-progress span {
    display: block;
    width: 0;
    height: 100%;
    background: linear-gradient(90deg, #0d6efd, #38a3ff);
    transition: width 0.16s ease;
}

/* Stats */
.stats-page .stats-toolbar {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    padding: 10px 12px;
    margin-bottom: 12px;
}

.stats-page .entry-transition-item {
    transition:
        opacity var(--entry-duration, 0.34s) cubic-bezier(0.22, 1, 0.36, 1) var(--entry-delay, 0ms),
        transform var(--entry-duration, 0.34s) cubic-bezier(0.22, 1, 0.36, 1) var(--entry-delay, 0ms);
}

.stats-page.stats-entry-transition .entry-transition-item {
    opacity: 0;
    transform: translateY(12px);
}

.stats-page.stats-entry-transition.stats-entry-transition-active .entry-transition-item {
    opacity: 1;
    transform: translateY(0);
}

.stats-page.stats-overlay-open {
    overflow: hidden;
    overscroll-behavior: none;
}

.stats-toolbar-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
}

.stats-toolbar-main .header-settings-toggle {
    flex-shrink: 0;
}

.stats-drawer {
    margin-top: 0;
}

.stats-toolbar.drawer-open .stats-drawer {
    margin-top: 10px;
}

.stats-drawer-content {
    background: transparent;
    border-radius: 0;
    box-shadow: none;
    padding: 12px 0 0;
    display: grid;
    gap: 10px;
}

.stats-toolbar-main .header-nav-btn {
    order: 1;
}

.stats-toolbar-main #statsSettingsToggle {
    order: 2;
}

.stats-subscription-card {
    border: 1px solid #e3e9f2;
    border-radius: 10px;
    background: #f8fbff;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.stats-subscription-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.82rem;
}

.subscription-badge {
    border-radius: 999px;
    padding: 3px 10px;
    font-size: 0.72rem;
    font-weight: 700;
}

.subscription-badge.normal {
    background: #eef2f7;
    color: #475569;
}

.subscription-badge.premium {
    background: #d8f3dc;
    color: #166534;
}

.subscription-remaining-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    width: fit-content;
}

.subscription-remaining {
    border: 0;
    background: transparent;
    color: #0f4c81;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0;
    cursor: pointer;
}

.subscription-muted {
    color: #64748b;
    font-size: 0.74rem;
}

.premium-tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    inset-inline-start: 0;
    min-width: 170px;
    max-width: min(82vw, 280px);
    padding: 6px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.92);
    color: #fff;
    font-size: 0.74rem;
    line-height: 1.55;
    box-shadow: 0 10px 24px rgba(15, 23, 42, 0.22);
    opacity: 0;
    transform: translateY(4px);
    pointer-events: none;
    transition: opacity 0.22s ease, transform 0.22s ease;
    z-index: 20;
}

.premium-tooltip.show {
    opacity: 1;
    transform: translateY(0);
}

.stats-setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    font-size: 0.82rem;
    color: #334155;
}

.stats-setting-select {
    min-width: 115px;
    min-height: 34px;
    border: 1px solid #d5ddea;
    border-radius: 8px;
    background: #fff;
    padding: 0 10px;
    font-size: 0.8rem;
}

.stats-setting-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: #0b79d0;
}

.stats-reset-btn {
    border: 1px solid #d7e2f1;
    background: #ffffff;
    color: #334155;
    border-radius: 8px;
    min-height: 34px;
    font-size: 0.78rem;
    font-weight: 600;
}

.stats-reset-btn:hover {
    background: #f8fbff;
}

.stats-reset-btn-global {
    border-color: #cdd8ea;
    color: #1e3a5f;
    background: #f5f9ff;
}

.stats-reset-btn-global:hover {
    background: #eaf2ff;
}

.stats-drawer-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.drawer-action-btn {
    min-height: 38px;
    border-radius: 9px;
    border: 1px solid #d2dbe7;
    background: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.drawer-action-report {
    border-color: #1f4968;
    color: #1f4968;
    width: 100%;
}

.drawer-action-delete {
    border-color: #dc3545;
    color: #b42333;
    width: 100%;
    flex-direction: row-reverse;
}

.issue-sheet-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    border: 0;
    padding: 0;
    background: rgba(15, 23, 42, 0.44);
    z-index: 1250;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.issue-sheet-backdrop.show {
    display: block;
    opacity: 1;
}

.issue-sheet {
    position: fixed;
    left: 10px;
    right: 10px;
    bottom: calc(10px + env(safe-area-inset-bottom));
    max-height: min(64vh, 420px);
    overflow: auto;
    background: #fff;
    border: 1px solid #dbe3ee;
    border-radius: 14px;
    box-shadow: 0 20px 34px rgba(15, 23, 42, 0.22);
    padding: 10px;
    z-index: 1260;
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.issue-sheet.show {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
}

.issue-sheet-handle {
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: #cbd5e1;
    margin: 2px auto 10px;
}

.issue-sheet-title {
    font-size: 0.9rem;
    margin: 0 0 10px;
    text-align: center;
}

.issue-sheet-menu {
    display: grid;
    gap: 6px;
}

.issue-sheet-menu button {
    border: 1px solid #e2e8f0;
    background: #f8fbff;
    color: #334155;
    border-radius: 9px;
    min-height: 42px;
    font-size: 0.8rem;
    font-weight: 600;
    text-align: right;
}

.channel-header-card {
    position: relative;
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-soft);
    padding: 20px 18px;
    margin-bottom: 16px;
}

.channel-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 0;
}

.channel-avatar {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid #eef2f7;
    margin-top: 6px;
    margin-bottom: 16px;
}

.channel-title {
    font-size: 1.18rem;
    font-weight: 700;
    margin: 0;
}

.channel-uid {
    display: block;
    font-size: 0.78rem;
    color: #94a3b8;
    direction: ltr;
    margin-top: -8px;
    margin-bottom: 14px;
}

.channel-header .members {
    display: block;
    margin-top: 18px;
    font-size: 0.93rem;
    margin-bottom: 9px;
}

.separator {
    width: 100%;
    height: 1px;
    background: var(--line);
    margin: 0 0 12px;
}

.updated-at {
    color: #7a8697;
    font-size: 0.86rem;
    margin: 0;
}

.channel-header-card .refresh-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    margin: 0;
}

.activity-rate-card {
    width: 100%;
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 14px;
    margin-bottom: 14px;
}

.activity-rate-top {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
}

.activity-title {
    font-size: 0.95rem;
    margin: 0;
    white-space: nowrap;
    font-weight: 700;
}

.activity-rate-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.activity-progress {
    flex: 1;
    min-width: 120px;
    height: 10px;
    background: #e7ebf0;
    border-radius: 999px;
    overflow: hidden;
}

.activity-progress-bar {
    height: 100%;
    background: var(--activity-bar-gradient, linear-gradient(90deg, #76e5b1, #4fd39c));
    transition-property: width;
    transition-timing-function: cubic-bezier(0.22, 1, 0.36, 1);
}

.activity-rate-bottom {
    margin-top: 20px;
}

.activity-rate-value {
    display: inline-flex;
    flex-shrink: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0f766e;
    min-width: 56px;
    justify-content: flex-end;
}

.stats-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    padding: 14px;
    text-align: center;
}

.mini-stat-card {
    box-shadow: none;
    border: 1px solid var(--line);
    background: #fcfdff;
    padding: 21px;
}

.stat-label {
    display: block;
    font-size: 0.82rem;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--brand);
}

.chart-section,
.info-section {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 16px;
    margin-bottom: 14px;
}

.chart-section {
    padding-left: 12px;
}

.chart-section h2,
.info-section h2 {
    font-size: 1rem;
    margin-bottom: 24px;
}

.chart-container {
    position: relative;
    height: 300px;
}

.chart-skeleton {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 12px;
    padding: 16px;
}

.chart-skeleton .placeholder {
    height: 14px;
    border-radius: 999px;
}

.chart-canvas-hidden {
    opacity: 0;
}

.chart-scroll-shell {
    position: relative;
    height: 240px;
    overflow-x: hidden;
    overflow-y: hidden;
}

.chart-scroll-shell.is-scrollable {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.chart-scroll-shell::-webkit-scrollbar {
    height: 8px;
}

.chart-scroll-shell::-webkit-scrollbar-thumb {
    background: #ccd5df;
    border-radius: 10px;
}

.chart-width-track {
    width: 100%;
    min-width: 100%;
    height: 100%;
    transition: width var(--chart-width-transition, 0.42s) cubic-bezier(0.22, 1, 0.36, 1);
}

.chart-width-track.is-resizing {
    will-change: width;
}

.chart-width-track canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
    justify-content: center;
}

.tab-btn {
    border: 1px solid #d2d9e3;
    background: #fff;
    color: #4b5563;
    border-radius: 8px;
    padding: 7px 12px;
    font-size: 0.83rem;
    cursor: pointer;
}

.tab-btn.active {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.posts-info-text {
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 8px;
    margin-bottom: 0;
}

.dense-probe-panel {
    margin-top: 10px;
    border: 1px solid #dce7f5;
    border-radius: 12px;
    background: #f8fbff;
    padding: 10px;
    display: grid;
    gap: 8px;
}

.dense-probe-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.dense-probe-mode {
    font-size: 0.78rem;
    font-weight: 700;
    color: #124a73;
}

.dense-probe-count {
    font-size: 0.74rem;
    color: #5d6b7a;
}

.dense-probe-metrics {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.dense-probe-metric {
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e0e8f4;
    padding: 8px 7px;
    text-align: center;
    display: grid;
    gap: 4px;
}

.dense-probe-metric small {
    font-size: 0.7rem;
    color: #6b7a8a;
}

.dense-probe-metric strong {
    font-size: 0.82rem;
    color: #1f2d3d;
    line-height: 1.3;
}

.dense-probe-slider-wrap {
    display: grid;
    gap: 6px;
}

.dense-probe-slider-wrap span {
    font-size: 0.74rem;
    color: #556273;
}

.dense-probe-slider-wrap input[type="range"] {
    width: 100%;
    accent-color: #0d6efd;
}

.side-by-side {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.side-by-side .info-section {
    margin-bottom: 0;
}

.best-posts-section {
    background: var(--card-bg);
    margin-bottom: 14px;
}

.golden-hours {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.time-badge {
    background: #e8f5e9;
    color: #2e7d32;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.time-range {
    display: inline-flex;
    flex-direction: row-reverse;
    align-items: center;
    gap: 5px;
    direction: ltr;
}

.dead-days-badges {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.day-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 0.82rem;
    font-weight: 600;
    background: #fff7ed;
    color: #9a3412;
}

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

.posts-table th,
.posts-table td {
    border-bottom: 1px solid #edf1f6;
    padding: 10px 8px;
    font-size: 0.88rem;
}

.posts-table th {
    background: #f8fafc;
    color: #4b5563;
    font-weight: 700;
}

.top-posts-mobile-scroll {
    display: none;
}

.top-post-mobile-card {
    min-width: min(78vw, 300px);
    background: #f9fbff;
    border: 1px solid #dce5f1;
    border-radius: 14px;
    padding: 12px;
    scroll-snap-align: center;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.06);
}

.top-post-mobile-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.top-post-rank {
    font-size: 0.84rem;
    font-weight: 700;
    color: #334155;
}

.top-post-open-link {
    font-size: 0.78rem;
    font-weight: 700;
    color: #0b79d0;
}

.top-post-mobile-body {
    display: grid;
    gap: 6px;
}

.top-post-mobile-body strong {
    color: #0b79d0;
    font-size: 1rem;
}

.top-post-mobile-body small {
    color: #64748b;
    font-size: 0.76rem;
}

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 420px;
    width: 90%;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.modal-content h3 {
    margin-bottom: 16px;
}

.modal-content p {
    color: #333;
    margin-bottom: 20px;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 20px;
}

.btn-danger {
    background: #dc3545;
    color: #fff;
    border: none;
    padding: 10px 24px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s ease;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-danger:disabled {
    background: #e0a8ae;
    cursor: not-allowed;
}

/* Add Channel */
.add-channel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.add-channel-header h1 {
    font-size: 1.05rem;
    margin: 0;
}

.add-channel-page .add-channel-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 24px;
    max-width: 480px;
    margin: 0 auto;
}

.add-channel-page .add-channel-subtitle {
    color: #64748b;
    margin-bottom: 14px;
    font-size: 0.9rem;
}

.add-channel-page .add-channel-form {
    display: grid;
    gap: 10px;
}

.add-channel-page .add-channel-input {
    min-height: 46px;
    border-radius: 10px;
}

.add-channel-page .add-channel-input.error {
    border-color: #dc3545;
}

.add-channel-page .error-message {
    color: #dc3545;
    font-size: 0.84rem;
    margin: 2px 0 0;
    display: none;
}

.add-channel-page .error-message.visible {
    display: block;
}

.add-channel-page .add-channel-submit {
    width: 100%;
    min-height: 46px;
    margin-top: 4px;
}

.btn-loading {
    opacity: 0.72;
    pointer-events: none;
}

.add-channel-page .add-channel-modal {
    max-width: 460px;
}

/* Settings */
.settings-card {
    background: var(--card-bg);
    border-radius: 14px;
    box-shadow: var(--shadow-soft);
    padding: 24px;
    text-align: center;
}

.settings-user {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.settings-user img {
    width: 76px;
    height: 76px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid #d8dde5;
}

/* Tablet: iPad + tablets */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        padding: 18px;
    }

    .channels-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .refresh-all-section {
        padding: 16px;
    }

    .chart-container {
        height: 280px;
    }

    .chart-scroll-shell {
        height: 230px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .container {
        padding: 12px;
    }

    .header {
        border-radius: 12px;
        padding: 12px 14px;
        margin-bottom: 14px;
    }

    .dashboard-page .app-header {
        min-height: 56px;
    }

    .header-user img {
        width: 34px;
        height: 34px;
    }

    .header-user span {
        font-size: 0.9rem;
    }

    .header-settings-toggle {
        width: 34px;
        height: 34px;
    }

    .drawer-row {
        font-size: 0.8rem;
    }

    .refresh-all-desktop {
        display: none !important;
    }

    .refresh-all-compact {
        display: flex;
    }

    .refresh-all-compact .refresh-all-btn {
        min-width: 102px;
        padding: 7px 9px;
        font-size: 0.77rem;
    }

    .channels-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .channel-card,
    .dashboard-page .add-channel-card {
        min-height: 92px;
        padding: 14px;
    }

    .channel-icon {
        width: 48px;
        height: 48px;
    }

    .stats-page .stats-toolbar {
        margin-bottom: 10px;
    }

    .stats-toolbar-main {
        padding: 0;
    }

    .stats-drawer-content {
        padding: 10px 0 0;
        gap: 8px;
    }

    .stats-setting-item {
        font-size: 0.78rem;
    }

    .stats-setting-select {
        min-width: 102px;
        min-height: 32px;
        font-size: 0.75rem;
    }

    .stats-reset-btn,
    .drawer-reset-btn {
        min-height: 32px;
        font-size: 0.74rem;
    }

    .channel-header-card {
        padding: 16px 14px;
    }

    .channel-avatar {
        width: 82px;
        height: 82px;
        margin-top: 8px;
        margin-bottom: 18px;
    }

    .channel-title {
        font-size: 1.05rem;
    }

    .channel-uid {
        font-size: 0.72rem;
        margin-top: -7px;
        margin-bottom: 12px;
    }

    .channel-header .members {
        margin-top: 16px;
        margin-bottom: 8px;
    }

    .separator {
        margin: 0 0 10px;
    }

    .updated-at {
        font-size: 0.8rem;
    }

    .activity-progress {
        min-width: 108px;
    }

    .activity-rate-top {
        gap: 8px;
    }

    .activity-rate-value {
        min-width: 48px;
        font-size: 0.95rem;
    }

    .stats-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .mini-stat-card {
        padding: 15px;
    }

    .mini-stat-card .stat-label {
        font-size: 0.76rem;
        margin-bottom: 4px;
    }

    .mini-stat-card .stat-value {
        font-size: 1rem;
    }

    .chart-section,
    .info-section {
        padding: 14px;
    }

    .chart-section {
        padding-left: 10px;
    }

    .chart-section h2,
    .info-section h2 {
        margin-bottom: 20px;
    }

    .chart-container {
        height: 230px;
    }

    .chart-scroll-shell {
        height: 220px;
    }

    .chart-tabs {
        gap: 6px;
    }

    .tab-btn {
        font-size: 0.78rem;
        padding: 6px 10px;
    }

    .dense-probe-panel {
        padding: 8px;
        gap: 7px;
    }

    .dense-probe-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .dense-probe-metric:last-child {
        grid-column: span 2;
    }

    .dense-probe-metric strong {
        font-size: 0.78rem;
    }

    .side-by-side {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .posts-table-desktop {
        display: none;
    }

    .top-posts-mobile-scroll {
        display: flex;
        gap: 10px;
        overflow-x: auto;
        padding-bottom: 6px;
        scroll-snap-type: x mandatory;
    }

    .time-badge {
        font-size: 0.76rem;
    }

    .add-channel-header {
        flex-direction: row-reverse;
    }

    .add-channel-header h1 {
        font-size: 0.95rem;
    }

    .add-channel-page .add-channel-card {
        padding: 16px;
        border-radius: 12px;
    }

    .add-channel-page .add-channel-subtitle {
        font-size: 0.82rem;
    }

    .add-channel-page .add-channel-submit {
        min-height: 44px;
        font-size: 0.88rem;
    }

    .stats-drawer-actions {
        grid-template-columns: 1fr 1fr;
    }

    .issue-sheet {
        left: 8px;
        right: 8px;
        bottom: calc(8px + env(safe-area-inset-bottom));
        max-height: min(72vh, 440px);
    }

    .settings-card {
        padding: 18px;
    }

    .stats-loading-channel-preview {
        grid-template-columns: auto 1fr;
    }

    .stats-loading-channel-status {
        grid-column: span 2;
        justify-self: start;
    }
}

@media (prefers-reduced-motion: reduce) {
    .btn,
    .header-settings-toggle i,
    .header-drawer,
    .stats-drawer,
    .refresh-btn svg,
    .channel-card,
    .channel-card.loading::before {
        transition: none !important;
        animation: none !important;
    }
}
