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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #1a1a2e;
    color: #eee;
    padding: 20px;
}

.container {
    max-width: 1600px;
    margin: 0 auto;
}

h1 {
    text-align: center;
    margin-bottom: 20px;
    color: #00d4ff;
}

.admin-badge {
    display: inline-block;
    background: #ff6b6b;
    color: #fff;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 0.5em;
    margin-left: 10px;
    vertical-align: middle;
}

/* 탭 네비게이션 */
.tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    justify-content: center;
}

.tab-btn {
    padding: 12px 30px;
    background: #16213e;
    border: none;
    color: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1em;
    transition: all 0.2s;
}

.tab-btn:hover {
    background: #0f3460;
}

.tab-btn.active {
    background: #00d4ff;
    color: #000;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* 레이아웃 */
.layout {
    display: flex;
    gap: 30px;
}

.sidebar {
    width: 280px;
    flex-shrink: 0;
}

.main-content {
    flex: 1;
}

/* 카드 스타일 */
.card {
    background: #16213e;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 20px;
}

.card h3 {
    color: #00d4ff;
    margin-bottom: 15px;
}

/* 날짜 선택 */
.date-input {
    width: 100%;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: #0f3460;
    color: #fff;
    font-size: 1em;
    cursor: pointer;
}

.date-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 15px;
}

.date-item {
    padding: 10px 15px;
    margin: 5px 0;
    background: #0f3460;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s;
}

.date-item:hover {
    background: #00d4ff;
    color: #000;
}

.date-item.selected {
    background: #00d4ff;
    color: #000;
    font-weight: bold;
}

/* 테이블 */
.group-container {
    margin-bottom: 25px;
}

.group-header {
    padding: 12px 20px;
    border-radius: 10px 10px 0 0;
    font-size: 1.1em;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.group-header.백팀 { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); }
.group-header.청팀 { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); }
.group-header.선물지표 { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); }

.stock-table {
    width: 100%;
    border-collapse: collapse;
    background: #16213e;
    border-radius: 0 0 10px 10px;
    overflow: hidden;
    table-layout: fixed;
}

.stock-table th,
.stock-table td {
    padding: 12px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* 컬럼별 고정 너비 (8컬럼) */
.stock-table th:nth-child(1),
.stock-table td:nth-child(1) { width: 8%; }   /* 종목 */
.stock-table th:nth-child(2),
.stock-table td:nth-child(2) { width: 12%; }  /* 섹터 */
.stock-table th:nth-child(3),
.stock-table td:nth-child(3) { width: 10%; }  /* 수집시간 */
.stock-table th:nth-child(4),
.stock-table td:nth-child(4) { width: 12%; }  /* 가격 */
.stock-table th:nth-child(5),
.stock-table td:nth-child(5) { width: 12%; }  /* 변동 */
.stock-table th:nth-child(6),
.stock-table td:nth-child(6) { width: 12%; }  /* 변동률 */
.stock-table th:nth-child(7),
.stock-table td:nth-child(7) { width: 12%; }  /* 거래량 */
.stock-table th:nth-child(8),
.stock-table td:nth-child(8) { width: 14%; }  /* 거래대금 */

.stock-table th {
    background: #0f3460;
    color: #00d4ff;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background 0.2s;
}

.stock-table th:hover {
    background: #1a4a7a;
}

.stock-table th::after {
    content: ' ⇅';
    font-size: 0.8em;
    opacity: 0.4;
}

.stock-table th.sort-asc::after {
    content: ' ▲';
    opacity: 1;
    color: #00d4ff;
}

.stock-table th.sort-desc::after {
    content: ' ▼';
    opacity: 1;
    color: #00d4ff;
}

.stock-table tr:hover {
    background: #1f3a5f;
}

.stock-table tr:not(:last-child) td {
    border-bottom: 1px solid #0f3460;
}

.ticker { font-weight: bold; color: #fff; }
.sector { color: #aaa; font-size: 0.9em; }
.price { font-size: 1.1em; }
.change-positive { color: #ff6b6b; }
.change-negative { color: #4dabf7; }
.time-slot { color: #888; font-size: 0.9em; }

/* 종목 관리 */
.stock-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 10px;
}

.form-input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 5px;
    background: #0f3460;
    color: #fff;
    font-size: 0.95em;
}

.form-input::placeholder {
    color: #666;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95em;
    transition: all 0.2s;
}

.btn-primary {
    background: #00d4ff;
    color: #000;
}

.btn-primary:hover {
    background: #00b8e6;
}

.btn-danger {
    background: #ff6b6b;
    color: #fff;
}

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

.btn-sm {
    padding: 5px 10px;
    font-size: 0.85em;
}

/* 종목 리스트 */
.stock-list-table {
    width: 100%;
    border-collapse: collapse;
}

.stock-list-table th,
.stock-list-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #0f3460;
}

.stock-list-table th {
    background: #0f3460;
    color: #00d4ff;
}

/* 메시지 */
.message {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    text-align: center;
}

.message.success {
    background: rgba(17, 153, 142, 0.3);
    color: #38ef7d;
}

.message.error {
    background: rgba(255, 107, 107, 0.3);
    color: #ff6b6b;
}

.message.info {
    background: rgba(0, 212, 255, 0.2);
    color: #00d4ff;
}

.message.warning {
    background: rgba(255, 193, 7, 0.3);
    color: #ffc107;
}

.no-data {
    text-align: center;
    padding: 50px;
    color: #888;
    font-size: 1.2em;
}

.loading {
    text-align: center;
    padding: 30px;
    color: #00d4ff;
}

/* 프로그레스 바 */
.progress-container {
    background: #0f3460;
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 15px;
}

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

.progress-title {
    color: #00d4ff;
    font-weight: 600;
}

.progress-percent {
    color: #fff;
    font-size: 1.2em;
    font-weight: bold;
}

.progress-bar-outer {
    background: #1a1a2e;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    position: relative;
}

.progress-bar-inner {
    background: linear-gradient(90deg, #00d4ff 0%, #38ef7d 100%);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    position: relative;
}

.progress-bar-inner.running::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255,255,255,0.3) 50%,
        transparent 100%
    );
    animation: shimmer 1.5s infinite;
}

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

.progress-message {
    margin-top: 10px;
    color: #aaa;
    font-size: 0.9em;
    text-align: center;
}

.progress-bar-inner.success {
    background: linear-gradient(90deg, #38ef7d 0%, #11998e 100%);
}

.progress-bar-inner.error {
    background: linear-gradient(90deg, #ff6b6b 0%, #f5576c 100%);
}

/* 반응형 - 태블릿 */
@media (max-width: 900px) {
    .layout {
        flex-direction: column;
    }
    .sidebar {
        width: 100%;
    }
    .charts-container {
        grid-template-columns: 1fr;
    }
}

/* 반응형 - 모바일 */
@media (max-width: 600px) {
    body {
        padding: 10px;
    }

    h1 {
        font-size: 1.4em;
        margin-bottom: 15px;
    }

    /* 탭 버튼 */
    .tabs {
        flex-wrap: wrap;
        gap: 8px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9em;
        flex: 1;
        min-width: 100px;
        text-align: center;
    }

    /* 카드 */
    .card {
        padding: 15px;
    }

    .card h3 {
        font-size: 1em;
    }

    /* 날짜 리스트 */
    .date-list {
        max-height: 200px;
    }

    .date-item {
        padding: 12px 15px;
        font-size: 0.95em;
    }

    /* 테이블 - 가로 스크롤 */
    .group-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .stock-table {
        min-width: 700px;
        table-layout: auto;
    }

    .stock-table th,
    .stock-table td {
        padding: 10px 8px;
        font-size: 0.85em;
    }

    .group-header {
        padding: 10px 15px;
        font-size: 0.95em;
    }

    /* 폼 */
    .form-row {
        flex-direction: column;
    }

    .form-input {
        width: 100%;
    }

    .btn {
        width: 100%;
        padding: 12px;
    }

    /* 메시지 */
    .message {
        padding: 12px;
        font-size: 0.9em;
    }

    .no-data {
        padding: 30px;
        font-size: 1em;
    }

    /* 프로그레스 */
    .progress-container {
        padding: 15px;
    }

    .progress-title {
        font-size: 0.9em;
    }
}

/* 모바일 테이블 스크롤 힌트 */
@media (max-width: 600px) {
    .group-container::after {
        content: '← 스크롤 →';
        display: block;
        text-align: center;
        color: #666;
        font-size: 0.8em;
        padding: 8px 0;
    }
}

/* 터치 디바이스 최적화 */
@media (hover: none) and (pointer: coarse) {
    .tab-btn:hover {
        background: #16213e;
    }

    .tab-btn.active:hover {
        background: #00d4ff;
    }

    .date-item:hover {
        background: #0f3460;
        color: #fff;
    }

    .date-item.selected:hover {
        background: #00d4ff;
        color: #000;
    }

    .stock-table th:hover {
        background: #0f3460;
    }

    .btn-primary:hover {
        background: #00d4ff;
    }

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