:root {
    --bg: #050816;
    --bg-card: #0b1020;
    --bg-card-soft: #10172b;
    --accent: #6366f1;
    --accent-soft: rgba(99, 102, 241, 0.15);
    --accent-strong: rgba(99, 102, 241, 0.3);
    --text: #f3f4f6;
    --text-soft: #9ca3af;
    --border: #1f2937;
    --danger: #f97373;
    --danger-soft: rgba(239, 68, 68, 0.15);
    --radius-lg: 18px;
    --radius-md: 12px;
    --shadow-soft: 0 18px 45px rgba(15, 23, 42, 0.75);
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
    background: radial-gradient(circle at top, #111827 0, #020617 45%, #000 100%);
    color: var(--text);
}

.page {
    min-height: 100vh;
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 16px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.logo {
    font-weight: 700;
    font-size: 26px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.logo span {
    font-weight: 500;
    font-size: 18px;
    padding: 2px 8px;
    border-radius: 999px;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.25), rgba(236, 72, 153, 0.25));
    border: 1px solid rgba(129, 140, 248, 0.4);
}

.header-subtitle {
    color: var(--text-soft);
    font-size: 13px;
}

.header-user {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-soft);
    display: flex;
    align-items: center;
    gap: 12px;
}

.logout-link {
    color: #a5b4fc;
    text-decoration: none;
    font-size: 12px;
}

.logout-link:hover {
    text-decoration: underline;
}

.btn-instagram {
    display: inline-block;
    padding: 14px 28px;
    background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 8px 20px rgba(220, 38, 67, 0.4);
    font-size: 15px;
}

.btn-instagram:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 28px rgba(220, 38, 67, 0.5);
}

.btn-instagram:active {
    transform: translateY(0);
    box-shadow: 0 6px 16px rgba(220, 38, 67, 0.35);
}

.main {
    flex: 1;
}

.card {
    background: linear-gradient(145deg, rgba(15, 23, 42, 0.9), rgba(15, 23, 42, 0.97));
    border-radius: 26px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: var(--shadow-soft);
    padding: 22px 22px 24px;
    margin-bottom: 20px;
}

.card h1 {
    margin: 0 0 12px;
    font-size: 22px;
}

.card h2 {
    margin: 0 0 16px;
    font-size: 18px;
}

.reel-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 14px;
}

.reel-form label {
    font-size: 13px;
    color: var(--text-soft);
}

.form-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.form-row input[type="url"] {
    flex: 1 1 260px;
    min-width: 0;
    padding: 11px 12px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: rgba(15, 23, 42, 0.95);
    color: var(--text);
    font-size: 14px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.form-row input[type="url"]::placeholder {
    color: rgba(148, 163, 184, 0.7);
}

.form-row input[type="url"]:focus {
    border-color: rgba(129, 140, 248, 0.8);
    box-shadow: 0 0 0 1px rgba(129, 140, 248, 0.6);
    background: #020617;
}

button[type="submit"] {
    border: none;
    padding: 11px 20px;
    border-radius: 999px;
    background: linear-gradient(135deg, #6366f1, #ec4899);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.6);
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

button[type="submit"]:hover {
    transform: translateY(-1px);
    box-shadow: 0 16px 32px rgba(79, 70, 229, 0.7);
    filter: brightness(1.02);
}

button[type="submit"]:active {
    transform: translateY(0);
    box-shadow: 0 8px 18px rgba(79, 70, 229, 0.55);
}

.form-help {
    margin: 0;
    font-size: 12px;
    color: var(--text-soft);
}

.alert {
    border-radius: 16px;
    padding: 10px 12px;
    font-size: 13px;
    margin-top: 10px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(248, 113, 113, 0.5);
}

.card-metrics {
    margin-top: 18px;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}

.metric {
    background: radial-gradient(circle at top left, rgba(129, 140, 248, 0.16), rgba(15, 23, 42, 0.9));
    border-radius: 18px;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.33);
}

.metric-label {
    font-size: 12px;
    color: var(--text-soft);
    margin-bottom: 4px;
}

.metric-value {
    font-size: 22px;
    font-weight: 700;
}

.meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 6px 18px;
    font-size: 13px;
    color: var(--text-soft);
}

.meta a {
    color: #a5b4fc;
    text-decoration: none;
}

.meta a:hover {
    text-decoration: underline;
}

.caption-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px dashed rgba(55, 65, 81, 0.8);
}

.caption-title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.caption-text {
    font-size: 13px;
    color: var(--text-soft);
}

.empty {
    margin: 0;
    font-size: 13px;
    color: var(--text-soft);
}

.comments-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 520px;
    padding-right: 4px;
    overflow: auto;
}

.comment {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    padding: 10px 11px;
    border: 1px solid rgba(31, 41, 55, 0.9);
}

.replies {
    margin-top: 8px;
    border-left: 2px solid rgba(75, 85, 99, 0.8);
    padding-left: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reply {
    background: rgba(15, 23, 42, 0.9);
    border-radius: 12px;
    padding: 7px 8px;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    margin-bottom: 3px;
}

.comment-user {
    font-size: 13px;
    font-weight: 600;
}

.comment-time {
    font-size: 11px;
    color: var(--text-soft);
}

.comment-text {
    font-size: 13px;
    line-height: 1.4;
    margin-bottom: 4px;
}

.comment-meta {
    font-size: 11px;
    color: var(--text-soft);
}

.footer {
    margin-top: auto;
    font-size: 11px;
    color: var(--text-soft);
    text-align: center;
    padding-top: 6px;
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 8px;
    flex-wrap: wrap;
}

.header-nav a {
    color: var(--text-soft);
    text-decoration: none;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.header-nav a:hover {
    background: rgba(99, 102, 241, 0.2);
    color: var(--text);
}

.header-user-id {
    font-size: 12px;
    color: var(--text-soft);
}

.monitor-section,
.analyze-section {
    margin-bottom: 20px;
}

.divider {
    height: 1px;
    background: linear-gradient(90deg, transparent, var(--border), transparent);
    margin: 24px 0;
}

.btn-start {
    background: linear-gradient(135deg, #10b981, #059669) !important;
    box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4) !important;
}

.btn-start:hover {
    box-shadow: 0 16px 32px rgba(16, 185, 129, 0.5) !important;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.5);
}

.monitor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 12px;
}

.monitor-status {
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.status-active {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
    border: 1px solid rgba(16, 185, 129, 0.4);
}

.status-completed {
    background: rgba(99, 102, 241, 0.2);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.4);
}

.status-stopped {
    background: rgba(148, 163, 184, 0.2);
    color: var(--text-soft);
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.monitor-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px 16px;
    font-size: 13px;
    color: var(--text-soft);
    margin-bottom: 20px;
}

.monitor-info a {
    color: #a5b4fc;
    text-decoration: none;
    word-break: break-all;
}

.monitor-info a:hover {
    text-decoration: underline;
}

.chart-container {
    margin: 24px 0;
    padding: 16px;
    background: rgba(15, 23, 42, 0.5);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    height: 400px;
}

.table-container {
    margin-top: 24px;
    overflow-x: auto;
}

.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.metrics-table thead {
    background: rgba(99, 102, 241, 0.1);
}

.metrics-table th {
    padding: 10px 8px;
    text-align: left;
    font-weight: 600;
    color: var(--text);
    border-bottom: 2px solid rgba(99, 102, 241, 0.3);
}

.metrics-table td {
    padding: 10px 8px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.1);
    color: var(--text-soft);
}

.metrics-table tbody tr:hover {
    background: rgba(99, 102, 241, 0.05);
}

.metrics-table .positive {
    color: #10b981;
    font-weight: 600;
}

.metrics-table .negative {
    color: #f97373;
    font-weight: 600;
}

.monitors-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-top: 16px;
}

.monitor-item {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 12px;
    padding: 12px 14px;
    border: 1px solid rgba(148, 163, 184, 0.1);
    transition: border-color 0.2s, background 0.2s;
}

.monitor-item:hover {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(15, 23, 42, 0.8);
}

.monitor-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.monitor-link {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    word-break: break-all;
    flex: 1;
}

.monitor-link:hover {
    color: #a5b4fc;
    text-decoration: underline;
}

.monitor-status-small {
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.monitor-item-info {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: var(--text-soft);
    flex-wrap: wrap;
}

.btn-back {
    display: inline-block;
    margin-top: 16px;
    color: #a5b4fc;
    text-decoration: none;
    font-size: 13px;
}

.btn-back:hover {
    text-decoration: underline;
}

@media (max-width: 640px) {
    .page {
        padding-top: 22px;
    }

    .card {
        border-radius: 22px;
        padding: 18px 16px 20px;
    }

    .metrics {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    }

    .comments-list {
        max-height: 400px;
    }

    .chart-container {
        height: 300px;
    }

    .metrics-table {
        font-size: 12px;
    }

    .metrics-table th,
    .metrics-table td {
        padding: 8px 6px;
    }

    .monitor-item-header {
        flex-direction: column;
        align-items: flex-start;
    }
}

