:root {
    --bg-base: #080d1a;
    --bg-card: #0f172a;
    --bg-card-hover: #141f38;
    --bg-card-active: #182645;
    --bg-input: #0a0f1d;
    --border: #1e293b;
    --border-bright: #334155;
    
    --green: #10b981;
    --green-glow: rgba(16, 185, 129, 0.25);
    --green-bg: rgba(16, 185, 129, 0.12);
    
    --cyan: #00e5ff;
    --cyan-glow: rgba(0, 229, 255, 0.25);
    --cyan-bg: rgba(0, 229, 255, 0.1);
    
    --purple: #818cf8;
    --purple-bg: rgba(129, 140, 248, 0.12);
    
    --amber: #f59e0b;
    --amber-bg: rgba(245, 158, 11, 0.12);
    
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.12);
    
    --text-main: #f8fafc;
    --text-sub: #94a3b8;
    --text-muted: #64748b;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-full: 9999px;
    
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-sans);
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
}

.app-wrapper {
    max-width: 1000px;
    margin: 0 auto;
    padding: 16px 16px 40px 16px;
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 14px;
}

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

.radar-dot {
    width: 12px;
    height: 12px;
    background: var(--cyan);
    border-radius: 50%;
    box-shadow: 0 0 12px var(--cyan);
    animation: radarPulse 2s infinite;
}

@keyframes radarPulse {
    0% { transform: scale(0.95); opacity: 0.8; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 16px var(--cyan); }
    100% { transform: scale(0.95); opacity: 0.8; }
}

.header-title h1 {
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.3px;
    color: var(--text-main);
}

.header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: var(--text-muted);
}

.indicator-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
}
.indicator-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.indicator-dot.offline { background: var(--text-muted); }
.indicator-dot.loading { background: var(--amber); animation: pulse 1s infinite; }

/* Target Chips Bar (Horizontal Scrollable contact list) */
.targets-chips-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 14px;
    scrollbar-width: none;
}
.targets-chips-bar::-webkit-scrollbar { display: none; }

.target-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 6px 14px 6px 8px;
    border-radius: var(--radius-full);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
    flex-shrink: 0;
}
.target-chip:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-bright);
}
.target-chip.active {
    background: #1e293b;
    border-color: var(--cyan);
    box-shadow: 0 0 10px var(--cyan-glow);
}

.chip-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: var(--text-main);
    position: relative;
}

.chip-status-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: 2px solid var(--bg-card);
}
.chip-status-dot.online { background: var(--green); }
.chip-status-dot.offline { background: var(--text-muted); }

.chip-info {
    display: flex;
    flex-direction: column;
}
.chip-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}
.chip-sub {
    font-size: 10px;
    color: var(--text-muted);
}

/* Card */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 14px;
}

/* Hero Card */
.hero-card {
    padding: 18px;
    border-left: 4px solid var(--cyan);
    background: linear-gradient(135deg, #10192e 0%, #0f172a 100%);
}

.hero-main-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.hero-user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.hero-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #0ea5e9);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(14, 165, 233, 0.3);
}

.hero-name-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.hero-name-badge h2 {
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.status-pill {
    font-size: 10px;
    font-family: var(--font-mono);
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-full);
    letter-spacing: 0.5px;
}
.status-pill.online {
    background: var(--green-bg);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 8px rgba(16, 185, 129, 0.3);
}
.status-pill.offline {
    background: rgba(148, 163, 184, 0.1);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.2);
}

.hero-tags {
    font-size: 12px;
    color: var(--text-sub);
    font-family: var(--font-mono);
    margin-top: 2px;
}

/* Live Status Banner */
.hero-live-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.hero-live-banner.online {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.15) 0%, rgba(15, 23, 42, 0.6) 100%);
    border-color: rgba(16, 185, 129, 0.3);
}

.live-banner-icon {
    font-size: 20px;
}

.live-banner-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-main);
}
.live-banner-sub {
    font-size: 12px;
    color: var(--text-sub);
    font-family: var(--font-mono);
    margin-top: 1px;
}

/* Time Window Filter Pills */
.time-filter-section {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
    overflow-x: auto;
    scrollbar-width: none;
    padding-bottom: 2px;
}
.time-filter-section::-webkit-scrollbar { display: none; }

.time-filter-label {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 600;
    flex-shrink: 0;
}

.time-pills {
    display: flex;
    gap: 5px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    padding: 3px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.time-pill {
    background: transparent;
    border: none;
    color: var(--text-sub);
    font-size: 11px;
    font-family: var(--font-mono);
    padding: 5px 11px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.15s;
    font-weight: 500;
}
.time-pill:hover { color: var(--text-main); }
.time-pill.active {
    background: #1e293b;
    color: var(--cyan);
    font-weight: 700;
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 14px;
}

.metric-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.metric-icon {
    font-size: 18px;
    flex-shrink: 0;
    margin-top: 1px;
}

.metric-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.metric-label {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.metric-value {
    font-size: 17px;
    font-weight: 700;
    font-family: var(--font-mono);
    margin: 2px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.metric-sub {
    font-size: 10px;
    color: var(--text-sub);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-green { color: var(--green); }
.text-amber { color: var(--amber); }

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-main);
}
.card-sub {
    font-size: 11px;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Visual Daily Strip */
.visual-strip-wrapper {
    margin-top: 6px;
}

.visual-strip-time-labels {
    display: flex;
    justify-content: space-between;
    font-family: var(--font-mono);
    font-size: 10px;
    color: var(--text-muted);
    margin-bottom: 5px;
}

.visual-strip-bar {
    position: relative;
    width: 100%;
    height: 28px;
    background: #090e1a;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.strip-segment {
    position: absolute;
    top: 2px;
    bottom: 2px;
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
    border-radius: 2px;
    box-shadow: 0 0 6px rgba(16, 185, 129, 0.4);
    min-width: 3px;
    cursor: pointer;
}
.strip-segment:hover {
    filter: brightness(1.3);
    z-index: 5;
}

.strip-legend {
    display: flex;
    gap: 8px;
    font-size: 10px;
}
.legend-chip {
    padding: 2px 7px;
    border-radius: var(--radius-full);
    font-family: var(--font-mono);
}
.legend-chip.green { background: var(--green-bg); color: #34d399; }
.legend-chip.dark { background: rgba(255, 255, 255, 0.05); color: var(--text-muted); }

/* ========================================================
   THE HERO COMPONENT: ХРОНОЛОГИЧЕСКАЯ ЛЕНТА СЕССИЙ (FEED)
   ======================================================== */
.feed-count-badge {
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--cyan);
    font-weight: 600;
}

.sessions-feed-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

/* Day Divider */
.feed-day-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 14px 0 6px 0;
}
.feed-day-divider:first-child { margin-top: 0; }

.feed-day-title {
    font-size: 11px;
    font-weight: 700;
    color: var(--cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: var(--font-mono);
    white-space: nowrap;
}
.feed-day-line {
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* Session Card */
.session-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #0d1527;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    transition: all 0.15s ease;
}
.session-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-bright);
}

.session-card.active-now {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.12) 0%, #0d1527 100%);
    border-color: rgba(16, 185, 129, 0.4);
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.15);
}

.session-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.session-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 8px var(--green);
    flex-shrink: 0;
}
.session-dot.pulsating {
    animation: pulse 1s infinite;
}

.session-times {
    display: flex;
    flex-direction: column;
}

.session-range {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
}

.range-in { color: #ffffff; }
.range-arrow { color: var(--text-muted); font-size: 12px; }
.range-out { color: #ffffff; }
.range-out.active-now { color: #34d399; font-weight: 800; }

.session-sub {
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 1px;
}

.session-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.session-duration-pill {
    background: var(--green-bg);
    color: #34d399;
    font-family: var(--font-mono);
    font-size: 12px;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

.session-duration-pill.live {
    background: rgba(16, 185, 129, 0.25);
    border-color: var(--green);
    animation: liveGlow 1.5s infinite;
}
@keyframes liveGlow {
    0%, 100% { box-shadow: 0 0 4px var(--green); }
    50% { box-shadow: 0 0 12px var(--green); }
}

.session-state-text {
    font-size: 10px;
    color: var(--text-muted);
    text-transform: lowercase;
}

/* Offline Gap Divider */
.gap-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 3px 0;
    margin: 2px 0;
}

.gap-line {
    flex: 1;
    height: 1px;
    background: rgba(255, 255, 255, 0.04);
}

.gap-badge {
    font-size: 11px;
    font-family: var(--font-mono);
    color: var(--text-muted);
    background: #090e1a;
    border: 1px dashed rgba(255, 255, 255, 0.08);
    padding: 2px 10px;
    border-radius: var(--radius-full);
}

.gap-divider.sleep-gap .gap-badge {
    color: #fcd34d;
    background: rgba(245, 158, 11, 0.08);
    border-color: rgba(245, 158, 11, 0.25);
    font-weight: 600;
}

/* Hourly Chart Box */
.chart-box {
    position: relative;
    height: 190px;
    margin-top: 6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.15s ease;
}

.btn-primary {
    background: linear-gradient(135deg, #0ea5e9 0%, #0284c7 100%);
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(14, 165, 233, 0.35);
}
.btn-primary:hover {
    filter: brightness(1.1);
}

.btn-outline {
    background: transparent;
    border-color: var(--border);
    color: var(--text-sub);
}
.btn-outline:hover {
    border-color: var(--border-bright);
    color: #fff;
}

.btn-danger-icon {
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.25);
    color: #f87171;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 11px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: all 0.15s;
}
.btn-danger-icon:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--red);
    color: #fff;
}

/* Footer */
.app-footer {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border);
}
.footer-stats {
    display: flex;
    justify-content: center;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 11px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

/* Empty States */
.empty-state {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
}
.empty-icon { font-size: 28px; margin-bottom: 6px; }
.empty-text { font-size: 12px; }

.no-targets-view {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
}
.no-targets-box {
    text-align: center;
    max-width: 380px;
    padding: 30px 20px;
}
.no-targets-icon { font-size: 44px; margin-bottom: 12px; }
.no-targets-box h2 { font-size: 18px; margin-bottom: 8px; color: #fff; }
.no-targets-box p { font-size: 13px; color: var(--text-sub); margin-bottom: 18px; }
.btn-large { padding: 12px 20px; font-size: 14px; }

/* Modal Sheet */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 16px;
}
.modal-backdrop.open { display: flex; }

.modal-sheet {
    background: var(--bg-card);
    border: 1px solid var(--border-bright);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 420px;
    padding: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.modal-header h3 { font-size: 16px; color: #fff; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 24px; color: var(--text-muted); cursor: pointer; }

.modal-hint { font-size: 12px; color: var(--text-sub); margin-bottom: 14px; line-height: 1.4; }

.sleek-input-large {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-bright);
    color: #fff;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s;
}
.sleek-input-large:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 0 2px var(--cyan-glow);
}

.error-banner {
    background: var(--red-bg);
    border: 1px solid var(--red);
    color: #fca5a5;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    margin-top: 10px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}

.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================================
   MOBILE RESPONSIVENESS (SMARTPHONES & TABLETS)
   ======================================================== */
@media (max-width: 768px) {
    .app-wrapper {
        padding: 12px 10px 30px 10px;
    }

    .header-title h1 {
        font-size: 15px;
    }

    .btn-primary span {
        display: none;
    }
    .btn-primary {
        padding: 8px 10px;
    }

    .metrics-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .metric-value {
        font-size: 15px;
    }

    .hero-main-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .hero-actions {
        width: 100%;
        display: flex;
        justify-content: flex-end;
    }

    .session-range {
        font-size: 13px;
    }

    .session-duration-pill {
        font-size: 11px;
        padding: 2px 7px;
    }

    .session-card {
        padding: 10px 12px;
    }

    .gap-badge {
        font-size: 10px;
        padding: 2px 7px;
    }

    .card {
        padding: 14px;
        border-radius: var(--radius-md);
    }
}

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

    .session-range {
        font-size: 12px;
    }
}
