/* css/telegram-admin.css — HASRI AI 텔레그램 봇 관리 센터 스타일
 * ★ v3.96: 전면 리디자인 — 가로 그리드 레이아웃, 직관적 관리 UX
 * 기존 HASRI-Trade Pro 다크 테마와 조화
 */

/* ═══ 페이지 컨테이너 ═══ */
#page-telegram {
    padding: 20px 24px;
    max-width: 1400px;
    margin: 0 auto;
}

/* ═══ 헤더 ═══ */
.tg-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.12);
}

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

.tg-header-left h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #e2e8f0;
}

.tg-bot-badge {
    background: rgba(0, 136, 204, 0.15);
    color: #0088cc;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid rgba(0, 136, 204, 0.3);
    letter-spacing: 0.5px;
}

.tg-header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tg-connection-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.75rem;
    color: #94a3b8;
    background: rgba(30, 41, 59, 0.6);
    padding: 5px 12px;
    border-radius: 20px;
    border: 1px solid rgba(99, 179, 237, 0.1);
}

.tg-connection-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    animation: tg-pulse 2s infinite;
}

.tg-connection-dot.offline { background: #f87171; animation: none; }

@keyframes tg-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.tg-version-badge {
    font-size: 0.65rem;
    color: #64748b;
    background: rgba(100, 116, 139, 0.15);
    padding: 3px 8px;
    border-radius: 4px;
}

/* ═══ 탭 네비게이션 ═══ */
.tg-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 24px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.12);
    overflow-x: auto;
    scrollbar-width: none;
}

.tg-tabs::-webkit-scrollbar { display: none; }

.tg-tab {
    padding: 11px 20px;
    font-size: 0.82rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
    user-select: none;
}

.tg-tab:hover { color: #94a3b8; background: rgba(99, 179, 237, 0.03); }

.tg-tab.active {
    color: #63b3ed;
    border-bottom-color: #63b3ed;
    font-weight: 600;
}

.tg-tab-panel {
    display: none;
    animation: tg-fadeIn 0.25s ease;
}

.tg-tab-panel.active {
    display: block;
}

@keyframes tg-fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ═══ 대시보드: 요약 카드 그리드 ═══ */
.tg-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.tg-summary-card {
    background: rgba(30, 41, 59, 0.65);
    border: 1px solid rgba(99, 179, 237, 0.1);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    transition: border-color 0.2s, transform 0.15s;
}

.tg-summary-card:hover {
    border-color: rgba(99, 179, 237, 0.25);
    transform: translateY(-1px);
}

.tg-summary-label {
    font-size: 0.7rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 500;
}

.tg-summary-value {
    font-size: 1.35rem;
    font-weight: 700;
    color: #e2e8f0;
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.tg-summary-value .tg-unit {
    font-size: 0.75rem;
    font-weight: 400;
    color: #64748b;
}

.tg-summary-sub {
    font-size: 0.68rem;
    color: #475569;
}

.tg-summary-card.status-active .tg-summary-value { color: #4ade80; }
.tg-summary-card.status-warning .tg-summary-value { color: #fbbf24; }
.tg-summary-card.status-error .tg-summary-value { color: #f87171; }
.tg-summary-card.status-quiet .tg-summary-value { color: #a78bfa; }

/* ═══ 대시보드: 채널 현황 그리드 ═══ */
.tg-channels-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-bottom: 24px;
}

.tg-channel-status-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: border-color 0.2s;
}

.tg-channel-status-card:hover {
    border-color: rgba(99, 179, 237, 0.2);
}

.tg-channel-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.tg-channel-icon.volSurge { background: rgba(234, 88, 12, 0.12); }
.tg-channel-icon.popularRank { background: rgba(239, 68, 68, 0.12); }
.tg-channel-icon.news { background: rgba(59, 130, 246, 0.12); }
.tg-channel-icon.bow { background: rgba(16, 185, 129, 0.12); }
.tg-channel-icon.morningBrief { background: rgba(251, 191, 36, 0.15); }
.tg-channel-icon.marketStatus { background: rgba(139, 92, 246, 0.12); }
.tg-channel-icon.closingBrief { background: rgba(236, 72, 153, 0.12); }
.tg-channel-icon.dartSignal { background: rgba(52, 211, 153, 0.12); }

.tg-channel-status-info {
    flex: 1;
    min-width: 0;
}

.tg-channel-status-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 3px;
}

.tg-channel-status-detail {
    font-size: 0.7rem;
    color: #64748b;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.tg-channel-status-detail span {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.tg-channel-status-badge {
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

.tg-badge-active { background: rgba(74, 222, 128, 0.12); color: #4ade80; }
.tg-badge-warning { background: rgba(251, 191, 36, 0.12); color: #fbbf24; }
.tg-badge-off { background: rgba(100, 116, 139, 0.12); color: #64748b; }

/* ═══ 대시보드: 최근 로그 ═══ */
.tg-recent-log {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    overflow: hidden;
}

.tg-recent-log-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.08);
}

.tg-recent-log-header h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #94a3b8;
}

.tg-recent-log-header a {
    font-size: 0.7rem;
    color: #63b3ed;
    cursor: pointer;
    text-decoration: none;
}

.tg-recent-log-header a:hover { text-decoration: underline; }

.tg-log-table {
    width: 100%;
    font-size: 0.75rem;
}

.tg-log-table tr {
    border-bottom: 1px solid rgba(99, 179, 237, 0.04);
    transition: background 0.15s;
}

.tg-log-table tr:hover { background: rgba(99, 179, 237, 0.04); }
.tg-log-table tr:last-child { border-bottom: none; }

.tg-log-table td {
    padding: 9px 14px;
    vertical-align: middle;
}

.tg-log-time { color: #475569; width: 65px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tg-log-channel { width: 100px; }
.tg-log-msg { color: #94a3b8; }
.tg-log-status { width: 24px; text-align: center; }

/* ═══ 채널 설정: 2열 레이아웃 ═══ */
.tg-config-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.tg-config-channels {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

/* ═══ 채널 설정 카드 ═══ */
.tg-ch-card {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 18px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.tg-ch-card:hover {
    border-color: rgba(99, 179, 237, 0.2);
}

.tg-ch-card.disabled {
    opacity: 0.5;
}

.tg-ch-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.tg-ch-title {
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-ch-title .icon {
    font-size: 1.1rem;
}

.tg-ch-title .name {
    font-size: 0.88rem;
    font-weight: 600;
    color: #e2e8f0;
}

.tg-ch-desc {
    font-size: 0.7rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 14px;
    padding-bottom: 12px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.06);
}

.tg-ch-params {
    display: grid;
    gap: 9px;
}

.tg-param-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.tg-param-label {
    display: flex;
    flex-direction: column;
    gap: 1px;
    flex: 1;
    min-width: 0;
}

.tg-param-label .main {
    font-size: 0.76rem;
    color: #cbd5e1;
    font-weight: 500;
}

.tg-param-label .hint {
    font-size: 0.62rem;
    color: #4a5568;
    line-height: 1.3;
}

.tg-param-input {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.tg-param-input input[type="number"] {
    width: 62px;
    padding: 5px 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.78rem;
    text-align: center;
    transition: border-color 0.2s;
}

.tg-param-input input[type="number"]:focus {
    outline: none;
    border-color: #0088cc;
}

.tg-param-input .unit {
    font-size: 0.65rem;
    color: #475569;
    min-width: 14px;
}

/* ★ v4.05: select 드롭다운 스타일 (intervalMode 등) */
.tg-param-input .tg-select {
    width: 140px;
    padding: 5px 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.78rem;
    cursor: pointer;
    transition: border-color 0.2s;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%2394a3b8'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    padding-right: 24px;
}
.tg-param-input .tg-select:focus {
    outline: none;
    border-color: #0088cc;
}
.tg-param-input .tg-select:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ═══ 사이드 패널 (공통 설정) ═══ */
.tg-config-sidebar {
    display: grid;
    gap: 14px;
}

.tg-side-card {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 16px 18px;
}

.tg-side-card-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tg-side-card-title h4 {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tg-side-card-desc {
    font-size: 0.68rem;
    color: #64748b;
    line-height: 1.5;
    margin-bottom: 12px;
}

.tg-quiet-times {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 10px;
}

.tg-quiet-field label {
    display: block;
    font-size: 0.65rem;
    color: #64748b;
    margin-bottom: 4px;
}

.tg-quiet-field input[type="time"] {
    width: 100%;
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.15);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.78rem;
}

.tg-quiet-field input[type="time"]:focus { outline: none; border-color: #0088cc; }

.tg-quiet-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    padding: 6px 10px;
    border-radius: 6px;
    background: rgba(74, 222, 128, 0.08);
    color: #4ade80;
}

.tg-quiet-status.is-quiet {
    background: rgba(167, 139, 250, 0.08);
    color: #a78bfa;
}

.tg-cron-info {
    font-size: 0.72rem;
    color: #94a3b8;
    line-height: 1.6;
}

.tg-cron-info code {
    background: rgba(15, 23, 42, 0.6);
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 0.68rem;
    color: #63b3ed;
}

.tg-bot-info-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 1px solid rgba(99, 179, 237, 0.05);
    font-size: 0.72rem;
}

.tg-bot-info-row:last-child { border-bottom: none; }

.tg-bot-info-row .label { color: #64748b; }
.tg-bot-info-row .value { color: #e2e8f0; font-family: 'JetBrains Mono', monospace; font-size: 0.68rem; }
.tg-bot-info-row .value .ok { color: #4ade80; }

/* ═══ 설정 저장 바 ═══ */
.tg-config-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid rgba(99, 179, 237, 0.08);
}

/* ═══ 메시지 전송: 2열 레이아웃 ═══ */
.tg-send-layout {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 20px;
    align-items: start;
}

.tg-send-editor {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 18px;
}

.tg-send-editor-title {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tg-textarea {
    width: 100%;
    min-height: 180px;
    padding: 14px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 10px;
    color: #e2e8f0;
    font-size: 0.82rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    line-height: 1.6;
    resize: vertical;
    margin-bottom: 14px;
    transition: border-color 0.2s;
}

.tg-textarea::placeholder { color: #3e4c5e; }
.tg-textarea:focus { outline: none; border-color: #0088cc; }

.tg-template-select {
    margin-bottom: 12px;
    display: none; /* v3.96b: replaced by quick templates */
}
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 14px;
}

.tg-template-select select {
    flex: 1;
    padding: 7px 12px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.78rem;
}

.tg-template-select select:focus { outline: none; border-color: #0088cc; }

.tg-send-options {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.tg-radio-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tg-radio-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    color: #94a3b8;
    cursor: pointer;
}

.tg-radio-label input[type="radio"] {
    accent-color: #0088cc;
}

.tg-schedule-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.12);
    border-radius: 8px;
    margin-bottom: 14px;
}

.tg-schedule-row.hidden { display: none; }

.tg-schedule-row input {
    padding: 5px 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 5px;
    color: #e2e8f0;
    font-size: 0.76rem;
}

.tg-schedule-row input:focus { outline: none; border-color: #f59e0b; }

.tg-check-label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: #64748b;
    cursor: pointer;
}

.tg-check-label input[type="checkbox"] { accent-color: #f59e0b; }

.tg-send-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* 전송 사이드바 */
.tg-send-sidebar {
    display: grid;
    gap: 14px;
}

.tg-preview-card {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 16px 18px;
}

.tg-preview-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tg-preview-body {
    background: rgba(15, 23, 42, 0.5);
    border-radius: 8px;
    padding: 12px 14px;
    font-size: 0.78rem;
    color: #cbd5e1;
    line-height: 1.6;
    min-height: 80px;
    max-height: 200px;
    overflow-y: auto;
    word-break: break-all;
}

.tg-html-guide {
    font-size: 0.68rem;
    color: #64748b;
    line-height: 1.7;
}

.tg-html-guide code {
    background: rgba(99, 179, 237, 0.08);
    padding: 1px 5px;
    border-radius: 3px;
    color: #63b3ed;
    font-size: 0.65rem;
}

.tg-send-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.tg-send-stat {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 8px 10px;
    background: rgba(15, 23, 42, 0.3);
    border-radius: 6px;
}

.tg-send-stat .label { font-size: 0.62rem; color: #475569; }
.tg-send-stat .value { font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }

/* ═══ 템플릿 그리드 ═══ */
.tg-templates-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tg-templates-header h3 {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #e2e8f0;
}

.tg-templates-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

.tg-tmpl-card {
    background: rgba(30, 41, 59, 0.55);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    transition: border-color 0.2s;
}

.tg-tmpl-card:hover { border-color: rgba(99, 179, 237, 0.2); }

.tg-tmpl-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tg-tmpl-preview {
    font-size: 0.7rem;
    color: #94a3b8;
    background: rgba(15, 23, 42, 0.4);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 10px;
    font-family: 'JetBrains Mono', monospace;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-all;
    flex: 1;
    max-height: 80px;
    overflow: hidden;
}

.tg-tmpl-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.65rem;
    color: #475569;
}

.tg-tmpl-vars {
    font-size: 0.65rem;
    color: #f59e0b;
    margin-bottom: 10px;
}

.tg-tmpl-actions {
    display: flex;
    gap: 6px;
}

.tg-var-guide {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.12);
    border-radius: 10px;
    padding: 14px 16px;
}

.tg-var-guide-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: #f59e0b;
    margin-bottom: 8px;
}

.tg-var-guide-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tg-var-tag {
    font-size: 0.65rem;
    padding: 3px 8px;
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.15);
    border-radius: 4px;
    color: #fbbf24;
    font-family: monospace;
}

/* ═══ v3.96b: 빠른 템플릿 (전송 패널 내 병합) ═══ */
.tg-quick-templates {
    background: rgba(30, 41, 59, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.08);
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.tg-quick-tmpl-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 8px;
}

.tg-quick-tmpl-label {
    font-size: 0.72rem;
    font-weight: 600;
    color: #94a3b8;
    margin-right: 4px;
    white-space: nowrap;
}

.tg-tmpl-btn {
    padding: 4px 10px;
    background: rgba(0, 136, 204, 0.1);
    border: 1px solid rgba(0, 136, 204, 0.25);
    border-radius: 6px;
    color: #63b3ed;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

.tg-tmpl-btn:hover {
    background: rgba(0, 136, 204, 0.2);
    border-color: rgba(0, 136, 204, 0.4);
    color: #90cdf4;
}

.tg-quick-tmpl-actions {
    display: flex;
    justify-content: flex-end;
}

/* 접이식 템플릿 관리 패널 */
.tg-tmpl-mgmt-panel {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease, margin 0.3s ease;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.06);
    border-radius: 10px;
    margin-bottom: 0;
    padding: 0 14px;
}

.tg-tmpl-mgmt-panel.open {
    max-height: 600px;
    padding: 14px;
    margin-bottom: 14px;
    border-color: rgba(99, 179, 237, 0.12);
}

.tg-tmpl-mgmt-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.tg-tmpl-mgmt-header h4 {
    margin: 0;
    font-size: 0.8rem;
    font-weight: 600;
    color: #e2e8f0;
}

.tg-tmpl-mgmt-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 14px;
    max-height: 300px;
    overflow-y: auto;
}

.tg-tmpl-mgmt-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(30, 41, 59, 0.6);
    border-radius: 8px;
    border: 1px solid rgba(99, 179, 237, 0.06);
}

.tg-tmpl-mgmt-name {
    font-size: 0.74rem;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    min-width: 80px;
}

.tg-tmpl-mgmt-preview {
    font-size: 0.68rem;
    color: #64748b;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tg-tmpl-mgmt-meta {
    font-size: 0.62rem;
    color: #475569;
    white-space: nowrap;
}

.tg-tmpl-mgmt-btns {
    display: flex;
    gap: 4px;
}

/* ═══ v3.96b: 채널별 스케줄 설정 UI ═══ */
/* ── 브리핑 채널: 섹션 선택 체크박스 ── */
.tg-ch-sections {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(99, 179, 237, 0.08);
}
.tg-ch-sections-title {
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 10px;
}
.tg-sections-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}
.tg-section-check {
    display: flex;
    align-items: flex-start;
    gap: 7px;
    padding: 8px 10px;
    border-radius: 8px;
    background: rgba(15, 23, 42, 0.4);
    border: 1px solid rgba(99, 179, 237, 0.08);
    cursor: pointer;
    transition: all 0.15s ease;
}
.tg-section-check:hover { background: rgba(15, 23, 42, 0.6); border-color: rgba(99, 179, 237, 0.2); }
.tg-section-check.checked { border-color: rgba(59, 130, 246, 0.35); background: rgba(59, 130, 246, 0.06); }
.tg-section-check.disabled { opacity: 0.5; cursor: not-allowed; }
.tg-section-check input[type="checkbox"] { margin-top: 2px; accent-color: #3b82f6; }
.tg-section-icon { font-size: 1rem; line-height: 1; }
.tg-section-info { display: flex; flex-direction: column; gap: 2px; }
.tg-section-name { font-size: 0.72rem; font-weight: 600; color: #e2e8f0; }
.tg-section-desc { font-size: 0.62rem; color: #64748b; line-height: 1.3; }

@media (max-width: 600px) {
    .tg-sections-grid { grid-template-columns: 1fr; }
}

.tg-ch-schedule {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid rgba(99, 179, 237, 0.08);
}

.tg-ch-schedule-title {
    font-size: 0.74rem;
    font-weight: 600;
    color: #94a3b8;
    margin-bottom: 10px;
}

.tg-sched-presets {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.tg-preset-btn {
    padding: 4px 10px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.1);
    border-radius: 6px;
    color: #94a3b8;
    font-size: 0.68rem;
    cursor: pointer;
    transition: all 0.15s;
}

.tg-preset-btn:hover {
    background: rgba(0, 136, 204, 0.1);
    border-color: rgba(0, 136, 204, 0.3);
    color: #63b3ed;
}

.tg-preset-btn.active {
    background: rgba(0, 136, 204, 0.15);
    border-color: rgba(0, 136, 204, 0.4);
    color: #63b3ed;
    font-weight: 600;
}

.tg-preset-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tg-sched-days {
    display: flex;
    gap: 4px;
    margin-bottom: 10px;
}

.tg-day-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 28px;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid rgba(99, 179, 237, 0.1);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

.tg-day-check input { display: none; }

.tg-day-check span {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
}

.tg-day-check.checked {
    background: rgba(0, 136, 204, 0.15);
    border-color: rgba(0, 136, 204, 0.4);
}

.tg-day-check.checked span {
    color: #63b3ed;
    font-weight: 600;
}

.tg-day-check:has(input:disabled) {
    opacity: 0.4;
    cursor: not-allowed;
}

.tg-sched-time {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}

.tg-sched-time-field {
    display: flex;
    align-items: center;
    gap: 6px;
}

.tg-sched-time-field label {
    font-size: 0.65rem;
    color: #64748b;
}

.tg-sched-time-field input[type="time"] {
    padding: 4px 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.72rem;
    width: 130px;
}

.tg-sched-time-field input[type="time"]:disabled {
    opacity: 0.4;
}

.tg-sched-time-sep {
    font-size: 0.8rem;
    color: #475569;
}

.tg-24h-check {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: 8px;
    cursor: pointer;
}

.tg-24h-check input { margin: 0; accent-color: #0088cc; }
.tg-24h-check span { font-size: 0.68rem; color: #f59e0b; font-weight: 600; }

.tg-sched-holiday {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tg-sched-holiday-label {
    font-size: 0.68rem;
    color: #64748b;
    font-weight: 500;
}

.tg-radio-sm {
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.66rem;
    color: #94a3b8;
    cursor: pointer;
}

.tg-radio-sm input {
    margin: 0;
    accent-color: #0088cc;
    width: 12px;
    height: 12px;
}

/* ═══ v3.97: 즉시 전송 버튼 ═══ */
.tg-ch-instant-send {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid rgba(99, 179, 237, 0.08);
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tg-btn-instant {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #fff;
    border: none;
    padding: 7px 16px;
    border-radius: 8px;
    font-size: 0.72rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(245, 158, 11, 0.25);
    white-space: nowrap;
}

.tg-btn-instant:hover:not(:disabled) {
    background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
}

.tg-btn-instant:active:not(:disabled) {
    transform: translateY(0);
}

.tg-btn-instant:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.tg-instant-hint {
    font-size: 0.62rem;
    color: #64748b;
    line-height: 1.3;
}

/* ═══ v3.96b: 공휴일 관리 ═══ */
.tg-holidays-input {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
}

.tg-holidays-input input {
    padding: 5px 8px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.72rem;
}

.tg-holidays-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
}

.tg-holiday-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    background: rgba(239, 68, 68, 0.08);
    border: 1px solid rgba(239, 68, 68, 0.15);
    border-radius: 5px;
    font-size: 0.65rem;
    color: #f87171;
}

.tg-holiday-tag button {
    background: none;
    border: none;
    color: #f87171;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
    opacity: 0.7;
}

.tg-holiday-tag button:hover {
    opacity: 1;
}

/* ═══ 전송 이력 ═══ */
.tg-history-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
    padding: 12px 16px;
    background: rgba(30, 41, 59, 0.4);
    border-radius: 10px;
    border: 1px solid rgba(99, 179, 237, 0.06);
}

.tg-filter-select {
    padding: 6px 10px;
    background: rgba(15, 23, 42, 0.7);
    border: 1px solid rgba(99, 179, 237, 0.12);
    border-radius: 6px;
    color: #e2e8f0;
    font-size: 0.75rem;
}

.tg-filter-select:focus { outline: none; border-color: #0088cc; }

.tg-history-summary {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 14px;
    padding: 10px 16px;
    background: rgba(99, 179, 237, 0.04);
    border-radius: 8px;
    font-size: 0.72rem;
    color: #94a3b8;
}

.tg-history-summary .num {
    font-weight: 700;
    color: #e2e8f0;
}

.tg-history-summary .success { color: #4ade80; }
.tg-history-summary .fail { color: #f87171; }

.tg-history-table {
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid rgba(99, 179, 237, 0.06);
    border-radius: 12px;
    overflow: hidden;
}

.tg-history-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.75rem;
}

.tg-history-table thead th {
    padding: 10px 14px;
    text-align: left;
    font-size: 0.68rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    border-bottom: 1px solid rgba(99, 179, 237, 0.08);
    background: rgba(15, 23, 42, 0.3);
}

.tg-history-table tbody tr {
    border-bottom: 1px solid rgba(99, 179, 237, 0.04);
    transition: background 0.15s;
}

.tg-history-table tbody tr:hover { background: rgba(99, 179, 237, 0.04); }
.tg-history-table tbody tr:last-child { border-bottom: none; }

.tg-history-table tbody td {
    padding: 10px 14px;
    color: #cbd5e1;
    vertical-align: middle;
}

.tg-hist-time { color: #64748b; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tg-hist-type { font-size: 0.68rem; padding: 2px 7px; border-radius: 4px; }
.tg-hist-type.auto { background: rgba(99, 179, 237, 0.1); color: #63b3ed; }
.tg-hist-type.manual { background: rgba(167, 139, 250, 0.1); color: #a78bfa; }
.tg-hist-msg { max-width: 300px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tg-hist-status-ok { color: #4ade80; }
.tg-hist-status-fail { color: #f87171; }

.tg-hist-detail-btn {
    background: rgba(99, 179, 237, 0.08);
    border: 1px solid rgba(99, 179, 237, 0.15);
    color: #63b3ed;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.15s;
}

.tg-hist-detail-btn:hover { background: rgba(99, 179, 237, 0.15); }

.tg-history-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px;
    border-top: 1px solid rgba(99, 179, 237, 0.06);
}

.tg-history-pagination button {
    padding: 5px 12px;
    background: rgba(99, 179, 237, 0.08);
    border: 1px solid rgba(99, 179, 237, 0.15);
    border-radius: 5px;
    color: #63b3ed;
    font-size: 0.72rem;
    cursor: pointer;
}

.tg-history-pagination button:hover { background: rgba(99, 179, 237, 0.15); }
.tg-history-pagination button:disabled { opacity: 0.4; cursor: default; }

.tg-history-pagination span {
    font-size: 0.72rem;
    color: #64748b;
}

/* ═══ 상세 모달 ═══ */
.tg-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.tg-modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.tg-modal {
    background: #1e293b;
    border: 1px solid rgba(99, 179, 237, 0.2);
    border-radius: 14px;
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

.tg-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.tg-modal-header h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #e2e8f0;
}

.tg-modal-close {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.2);
    color: #f87171;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.75rem;
}

.tg-modal-body {
    font-size: 0.78rem;
    color: #cbd5e1;
    line-height: 1.7;
}

.tg-modal-body .detail-row {
    display: flex;
    gap: 10px;
    padding: 6px 0;
    border-bottom: 1px solid rgba(99, 179, 237, 0.06);
}

.tg-modal-body .detail-row .dl { color: #64748b; min-width: 70px; }
.tg-modal-body .detail-row .dv { color: #e2e8f0; }

.tg-modal-body .msg-preview {
    background: rgba(15, 23, 42, 0.6);
    border-radius: 8px;
    padding: 14px;
    margin-top: 12px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.75rem;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-all;
}

.tg-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
    padding-top: 14px;
    border-top: 1px solid rgba(99, 179, 237, 0.08);
}

/* ═══ 버튼 ═══ */
.tg-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 7px;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.tg-btn-primary {
    background: #0088cc;
    color: #fff;
}
.tg-btn-primary:hover { background: #006fa8; transform: translateY(-1px); }

.tg-btn-secondary {
    background: rgba(99, 179, 237, 0.1);
    color: #63b3ed;
    border: 1px solid rgba(99, 179, 237, 0.2);
}
.tg-btn-secondary:hover { background: rgba(99, 179, 237, 0.18); }

.tg-btn-success {
    background: rgba(74, 222, 128, 0.12);
    color: #4ade80;
    border: 1px solid rgba(74, 222, 128, 0.25);
}
.tg-btn-success:hover { background: rgba(74, 222, 128, 0.2); }

.tg-btn-danger {
    background: rgba(248, 113, 113, 0.1);
    color: #f87171;
    border: 1px solid rgba(248, 113, 113, 0.2);
}
.tg-btn-danger:hover { background: rgba(248, 113, 113, 0.2); }

.tg-btn-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.2);
}
.tg-btn-warning:hover { background: rgba(245, 158, 11, 0.18); }

.tg-btn-sm { padding: 6px 12px; font-size: 0.73rem; }
.tg-btn-xs { padding: 4px 9px; font-size: 0.68rem; border-radius: 5px; }

/* ═══ 토글 스위치 ═══ */
.tg-toggle {
    position: relative;
    width: 40px;
    height: 21px;
    display: inline-block;
    flex-shrink: 0;
}

.tg-toggle input { opacity: 0; width: 0; height: 0; position: absolute; }

.tg-toggle-slider {
    position: absolute;
    inset: 0;
    background: #334155;
    border-radius: 21px;
    cursor: pointer;
    transition: 0.3s;
}

.tg-toggle-slider::before {
    content: '';
    position: absolute;
    width: 15px;
    height: 15px;
    left: 3px;
    bottom: 3px;
    background: #94a3b8;
    border-radius: 50%;
    transition: 0.3s;
}

.tg-toggle input:checked + .tg-toggle-slider {
    background: #0088cc;
}

.tg-toggle input:checked + .tg-toggle-slider::before {
    transform: translateX(19px);
    background: #fff;
}

/* ═══ Empty State ═══ */
.tg-empty {
    text-align: center;
    padding: 32px 20px;
    color: #475569;
    font-size: 0.82rem;
}

.tg-empty .icon {
    font-size: 2rem;
    margin-bottom: 10px;
    opacity: 0.4;
}

/* ═══ 토스트 ═══ */
.tg-toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.82rem;
    font-weight: 500;
    z-index: 10000;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.3s;
    max-width: 360px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.tg-toast-show {
    opacity: 1;
    transform: translateY(0);
}

.tg-toast-success { background: #065f46; color: #6ee7b7; border: 1px solid #059669; }
.tg-toast-error { background: #7f1d1d; color: #fca5a5; border: 1px solid #dc2626; }
.tg-toast-info { background: #1e3a5f; color: #93c5fd; border: 1px solid #2563eb; }

/* ═══ Worker 미배포 알림 ═══ */
.tg-deploy-notice {
    background: rgba(245, 158, 11, 0.08);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 12px;
    padding: 18px 20px;
    margin-bottom: 20px;
}

.tg-deploy-notice-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #f59e0b;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tg-deploy-notice-body {
    font-size: 0.75rem;
    color: #94a3b8;
    line-height: 1.7;
}

.tg-deploy-notice-body code {
    display: block;
    background: rgba(0, 0, 0, 0.3);
    padding: 10px 14px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.72rem;
    line-height: 1.8;
    color: #63b3ed;
}

/* ═══ 반응형 ═══ */
@media (max-width: 1200px) {
    .tg-config-layout { grid-template-columns: 1fr 280px; }
    .tg-send-layout { grid-template-columns: 1fr 280px; }
}

@media (max-width: 1024px) {
    .tg-config-layout { grid-template-columns: 1fr; }
    .tg-send-layout { grid-template-columns: 1fr; }
    .tg-config-channels { grid-template-columns: repeat(2, 1fr); }
    .tg-templates-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    #page-telegram { padding: 12px; }
    .tg-summary-grid { grid-template-columns: repeat(2, 1fr); }
    .tg-channels-grid { grid-template-columns: 1fr; }
    .tg-config-channels { grid-template-columns: 1fr; }
    .tg-templates-grid { grid-template-columns: 1fr; }
    .tg-tab { padding: 9px 14px; font-size: 0.75rem; }
    .tg-header { flex-direction: column; align-items: flex-start; gap: 10px; }
    .tg-send-buttons { flex-direction: column; }
    .tg-history-filters { flex-direction: column; align-items: stretch; }
}

@media (max-width: 480px) {
    .tg-summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .tg-quiet-times { grid-template-columns: 1fr; }
    .tg-send-stats { grid-template-columns: 1fr; }
}
