/* ═══════════════════════════════════════════════════════
   CHRONOMETRY (Хронометраж) — Phase 78
   ═══════════════════════════════════════════════════════ */

/* ── List view ──────────────────────────────────────── */
.chr-container { padding: 20px; max-width: 900px; margin: 0 auto; }
.chr-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; flex-wrap: wrap; gap: 10px; }
.chr-header h2 { font-size: 20px; font-weight: 700; color: #1d1d1f; margin: 0; }
.chr-btn-primary {
    background: #0066cc; color: #fff; border: none; border-radius: 10px;
    padding: 9px 18px; font-size: 14px; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.chr-btn-primary:hover { background: #0055aa; }
.chr-btn-secondary {
    background: #f5f5f7; color: #1d1d1f; border: none; border-radius: 10px;
    padding: 9px 18px; font-size: 14px; font-weight: 500; cursor: pointer;
    transition: background .15s;
}
.chr-btn-secondary:hover { background: #e8e8ed; }
.chr-btn-danger {
    background: #fff0f0; color: #dc2626; border: 1px solid #fecaca;
    border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer;
}
.chr-btn-danger:hover { background: #fee2e2; }
.chr-btn-sm {
    background: #f5f5f7; color: #333; border: none; border-radius: 8px;
    padding: 5px 11px; font-size: 12px; cursor: pointer;
}
.chr-btn-sm:hover { background: #e8e8ed; }

.chr-empty {
    text-align: center; padding: 60px 20px; color: #6b7280;
}
.chr-empty-icon { font-size: 48px; margin-bottom: 12px; }
.chr-empty h3 { font-size: 18px; font-weight: 600; color: #374151; margin-bottom: 8px; }
.chr-empty p { font-size: 14px; line-height: 1.6; max-width: 420px; margin: 0 auto 20px; }

.chr-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}
.chr-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
    padding: 18px; cursor: pointer; transition: box-shadow .15s, border-color .15s;
}
.chr-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.08); border-color: #0066cc40; }
.chr-card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 10px; }
.chr-card-title { font-size: 15px; font-weight: 600; color: #1d1d1f; line-height: 1.3; }
.chr-status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 99px; font-size: 11px; font-weight: 600;
    white-space: nowrap;
}
.chr-status-draft     { background: #f3f4f6; color: #6b7280; }
.chr-status-in_progress { background: #dbeafe; color: #1d4ed8; }
.chr-status-completed { background: #dcfce7; color: #16a34a; }

.chr-card-meta { font-size: 12px; color: #6b7280; margin-bottom: 12px; }
.chr-card-stats { display: flex; gap: 16px; }
.chr-stat { display: flex; flex-direction: column; }
.chr-stat-val { font-size: 18px; font-weight: 700; color: #1d1d1f; }
.chr-stat-lbl { font-size: 11px; color: #9ca3af; }

.chr-va-bar {
    margin-top: 12px; height: 6px; background: #f3f4f6; border-radius: 3px; overflow: hidden;
}
.chr-va-fill { height: 100%; border-radius: 3px; transition: width .4s; }
.chr-va-green  { background: #22c55e; }
.chr-va-yellow { background: #f59e0b; }
.chr-va-red    { background: #ef4444; }

/* ── Study detail page ──────────────────────────────── */
.chr-detail-header {
    display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap;
}
.chr-back-btn {
    background: none; border: none; cursor: pointer; font-size: 20px;
    color: #6b7280; padding: 4px; border-radius: 6px;
}
.chr-back-btn:hover { background: #f3f4f6; }
.chr-detail-title { font-size: 18px; font-weight: 700; color: #1d1d1f; flex: 1; }

.chr-tabs { display: flex; gap: 4px; border-bottom: 1px solid #e5e7eb; margin-bottom: 20px; overflow-x: auto; }
.chr-tab {
    padding: 8px 16px; font-size: 13px; font-weight: 500; cursor: pointer;
    border: none; background: none; color: #6b7280; border-bottom: 2px solid transparent;
    margin-bottom: -1px; white-space: nowrap; transition: color .15s;
}
.chr-tab:hover { color: #1d1d1f; }
.chr-tab.active { color: #0066cc; border-bottom-color: #0066cc; font-weight: 600; }

/* ── Setup tab ──────────────────────────────────────── */
.chr-form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 600px) { .chr-form-grid { grid-template-columns: 1fr; } }
.chr-form-group { display: flex; flex-direction: column; gap: 6px; }
.chr-form-group label { font-size: 12px; font-weight: 600; color: #374151; }
.chr-form-group input, .chr-form-group select, .chr-form-group textarea {
    border: 1px solid #d1d5db; border-radius: 8px; padding: 8px 12px;
    font-size: 14px; color: #1d1d1f; outline: none; transition: border-color .15s;
}
.chr-form-group input:focus, .chr-form-group select:focus, .chr-form-group textarea:focus {
    border-color: #0066cc; box-shadow: 0 0 0 3px rgba(0,102,204,.1);
}
.chr-form-group textarea { resize: vertical; min-height: 80px; }
.chr-form-full { grid-column: 1 / -1; }
.chr-form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ── Elements tab ───────────────────────────────────── */
.chr-elem-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.chr-elem-card {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 12px;
    padding: 14px 16px; display: flex; align-items: center; gap: 12px;
}
.chr-elem-pos {
    width: 28px; height: 28px; border-radius: 50%; background: #f3f4f6;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #6b7280; flex-shrink: 0;
}
.chr-elem-info { flex: 1; min-width: 0; }
.chr-elem-name { font-size: 14px; font-weight: 600; color: #1d1d1f; }
.chr-elem-meta { font-size: 12px; color: #9ca3af; margin-top: 2px; }
.chr-elem-badges { display: flex; gap: 6px; margin-top: 4px; flex-wrap: wrap; }
.chr-badge {
    display: inline-flex; padding: 2px 8px; border-radius: 99px;
    font-size: 11px; font-weight: 600;
}
.chr-badge-value          { background: #dcfce7; color: #16a34a; }
.chr-badge-waste          { background: #fee2e2; color: #dc2626; }
.chr-badge-necessary_waste { background: #fef3c7; color: #b45309; }
.chr-badge-cyclic   { background: #dbeafe; color: #1d4ed8; }
.chr-badge-periodic { background: #f3e8ff; color: #7c3aed; }
.chr-elem-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* ── Add element modal ──────────────────────────────── */
.chr-modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 9000;
    display: flex; align-items: center; justify-content: center; padding: 20px;
}
.chr-modal {
    background: #fff; border-radius: 16px; padding: 24px; width: 100%;
    max-width: 480px; max-height: 90vh; overflow-y: auto;
}
.chr-modal h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; }
.chr-modal-actions { display: flex; gap: 10px; margin-top: 20px; justify-content: flex-end; }

/* ── Session overlay (Live Timer) ───────────────────── */
.chr-session-overlay {
    position: fixed; inset: 0; background: #0f172a; z-index: 8000;
    display: flex; flex-direction: column; overflow: hidden;
}
.chr-session-top {
    background: #1e293b; padding: 16px 20px;
    display: flex; align-items: center; gap: 16px;
}
.chr-session-title { color: #e2e8f0; font-size: 15px; font-weight: 600; flex: 1; }
.chr-session-cycle {
    background: #334155; color: #94a3b8; border-radius: 8px;
    padding: 4px 12px; font-size: 13px; font-weight: 600;
}
.chr-session-close {
    background: none; border: none; cursor: pointer; color: #94a3b8;
    font-size: 22px; padding: 4px; line-height: 1;
}
.chr-session-close:hover { color: #e2e8f0; }

.chr-session-body { flex: 1; display: flex; overflow: hidden; }
.chr-session-left { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.chr-session-elements { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; }

.chr-session-elem {
    background: #1e293b; border: 2px solid #334155; border-radius: 12px;
    padding: 14px 16px; cursor: pointer; transition: all .15s; display: flex; align-items: center; gap: 12px;
}
.chr-session-elem:hover { border-color: #4b6bab; }
.chr-session-elem.active {
    border-color: #3b82f6; background: #1e3a5f;
    box-shadow: 0 0 0 4px rgba(59,130,246,.2);
}
.chr-session-elem.done { opacity: .7; }
.chr-session-elem.skipped { opacity: .4; border-style: dashed; }

.chr-session-elem-num {
    width: 32px; height: 32px; border-radius: 50%; background: #334155;
    display: flex; align-items: center; justify-content: center;
    font-size: 13px; font-weight: 700; color: #94a3b8; flex-shrink: 0;
}
.chr-session-elem.active .chr-session-elem-num { background: #3b82f6; color: #fff; }

.chr-session-elem-info { flex: 1; min-width: 0; }
.chr-session-elem-name { font-size: 14px; font-weight: 600; color: #e2e8f0; }
.chr-session-elem-type {
    font-size: 11px; margin-top: 2px;
}
.vtype-value   { color: #4ade80; }
.vtype-waste   { color: #f87171; }
.vtype-necessary_waste { color: #fbbf24; }

.chr-session-elem-time {
    font-size: 15px; font-weight: 700; color: #60a5fa;
    font-feature-settings: 'tnum'; min-width: 60px; text-align: right;
}
.chr-session-elem.active .chr-session-elem-time { color: #93c5fd; font-size: 18px; }

/* ── Session right panel (big timer) ────────────────── */
.chr-session-right {
    width: 260px; background: #1e293b; border-left: 1px solid #334155;
    display: flex; flex-direction: column; align-items: center;
    justify-content: center; padding: 24px 20px; gap: 20px;
}
@media (max-width: 650px) { .chr-session-right { display: none; } }

.chr-big-timer {
    font-size: 52px; font-weight: 800; color: #3b82f6; letter-spacing: -2px;
    font-feature-settings: 'tnum'; text-align: center; line-height: 1;
}
.chr-big-timer.running { animation: chr-pulse 1s ease-in-out infinite; }
@keyframes chr-pulse { 0%,100% { opacity:1; } 50% { opacity:.7; } }

.chr-session-active-name {
    font-size: 13px; color: #94a3b8; text-align: center; font-weight: 500;
}
.chr-session-total {
    font-size: 12px; color: #64748b; text-align: center;
}

.chr-btn-next {
    width: 100%; background: #3b82f6; color: #fff; border: none;
    border-radius: 12px; padding: 14px; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: background .15s;
}
.chr-btn-next:hover { background: #2563eb; }
.chr-btn-next:active { transform: scale(.97); }

.chr-btn-cycle-done {
    width: 100%; background: #16a34a; color: #fff; border: none;
    border-radius: 12px; padding: 12px; font-size: 14px; font-weight: 600;
    cursor: pointer; margin-top: 4px;
}
.chr-btn-skip {
    background: none; border: none; color: #64748b; font-size: 12px;
    cursor: pointer; text-decoration: underline;
}

/* ── Session footer (mobile-friendly controls) ───────── */
.chr-session-footer {
    background: #1e293b; border-top: 1px solid #334155;
    padding: 14px 20px; display: flex; gap: 10px; align-items: center;
}
.chr-btn-footer-next {
    flex: 1; background: #3b82f6; color: #fff; border: none;
    border-radius: 10px; padding: 13px; font-size: 15px; font-weight: 700;
    cursor: pointer;
}
.chr-btn-footer-next:hover { background: #2563eb; }

/* ── Cycle summary popup ─────────────────────────────── */
.chr-cycle-summary {
    position: absolute; inset: 0; background: rgba(15,23,42,.85);
    display: flex; align-items: center; justify-content: center; z-index: 100;
    padding: 20px;
}
.chr-cycle-summary-box {
    background: #1e293b; border: 1px solid #334155; border-radius: 16px;
    padding: 24px; max-width: 400px; width: 100%;
}
.chr-cycle-summary-box h3 { color: #e2e8f0; font-size: 16px; margin-bottom: 16px; }
.chr-cycle-row {
    display: flex; align-items: center; justify-content: space-between;
    padding: 6px 0; border-bottom: 1px solid #334155; font-size: 13px;
}
.chr-cycle-row:last-child { border: none; }
.chr-cycle-row-name { color: #94a3b8; flex: 1; }
.chr-cycle-row-time { color: #60a5fa; font-weight: 600; font-feature-settings:'tnum'; }
.chr-cycle-total { display: flex; justify-content: space-between; margin-top: 12px; padding-top: 12px; border-top: 2px solid #334155; }
.chr-cycle-total-lbl { color: #e2e8f0; font-weight: 700; }
.chr-cycle-total-val { color: #4ade80; font-size: 18px; font-weight: 700; font-feature-settings:'tnum'; }
.chr-cycle-actions { display: flex; gap: 10px; margin-top: 20px; }
.chr-cycle-actions button { flex: 1; }

/* ── Analysis tab ─────────────────────────────────────── */
.chr-analysis-section { margin-bottom: 28px; }
.chr-analysis-section h3 { font-size: 15px; font-weight: 700; color: #1d1d1f; margin-bottom: 14px; }

.chr-kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-bottom: 20px; }
.chr-kpi-card {
    background: #f8fafc; border: 1px solid #e5e7eb; border-radius: 12px;
    padding: 14px; text-align: center;
}
.chr-kpi-val { font-size: 24px; font-weight: 800; color: #1d1d1f; line-height: 1; }
.chr-kpi-lbl { font-size: 12px; color: #6b7280; margin-top: 4px; }

.chr-analysis-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.chr-analysis-table th {
    text-align: left; padding: 8px 12px; background: #f3f4f6;
    color: #6b7280; font-weight: 600; font-size: 11px; border-radius: 0;
}
.chr-analysis-table th:first-child { border-radius: 8px 0 0 8px; }
.chr-analysis-table th:last-child  { border-radius: 0 8px 8px 0; }
.chr-analysis-table td { padding: 10px 12px; border-bottom: 1px solid #f3f4f6; color: #374151; }
.chr-analysis-table tr:last-child td { border: none; }
.chr-analysis-table tr:hover td { background: #f9fafb; }

.chr-readings-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chr-reading-chip {
    display: inline-flex; align-items: center; gap: 4px;
    background: #f0f9ff; border: 1px solid #bae6fd; border-radius: 6px;
    padding: 2px 7px; font-size: 12px; color: #0369a1; cursor: pointer;
    font-feature-settings: 'tnum';
}
.chr-reading-chip.excluded {
    background: #fef2f2; border-color: #fecaca; color: #dc2626; text-decoration: line-through;
}
.chr-reading-chip:hover { opacity: .8; }

.chr-va-summary {
    display: flex; height: 32px; border-radius: 8px; overflow: hidden; margin-bottom: 8px;
}
.chr-va-seg {
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; color: #fff; transition: width .4s;
    min-width: 20px;
}
.chr-va-seg-value          { background: #22c55e; }
.chr-va-seg-waste          { background: #ef4444; }
.chr-va-seg-necessary_waste { background: #f59e0b; }
.chr-va-legend { display: flex; gap: 16px; font-size: 12px; color: #6b7280; }
.chr-va-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; margin-right: 4px; }

.chr-takt-line {
    background: #fef3c7; border: 1px solid #fde68a; border-radius: 10px;
    padding: 12px 16px; display: flex; align-items: center; gap: 12px;
    font-size: 13px; color: #92400e; margin-bottom: 16px;
}
.chr-takt-line-ok { background: #dcfce7; border-color: #bbf7d0; color: #15803d; }
.chr-takt-line-bad { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }
