:root {
    --bg-dark: #0e0e13;          /* Deep obsidian void */
    --bg-card: rgba(19, 19, 25, 0.65); /* Translucent glass */
    --bg-input: rgba(37, 37, 45, 0.4); /* Input field inset */
    --text-primary: #f9f5fd;     /* Bright crisp text */
    --text-secondary: #acaab1;   /* Muted metadata */
    --border-color: rgba(72, 71, 77, 0.35); /* Ghost reflections */
    --border-light: rgba(118, 116, 123, 0.5);
    --accent: #81ecff;           /* Neon Cyan primary glow */
    --accent-hover: #00e3fd;     /* Intense Cyan */
    --danger: #ff716c;           /* Critical neon red */
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    /* 모바일 가로 스크롤 방지는 내부 컨테이너에서 담당 */
}

/* Sidebar Navigation */
.nav-bar {
    width: 250px;
    background-color: rgba(14, 14, 19, 0.85);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-right: 1px solid var(--border-color);
    padding: 24px 0 0 0;
    flex-shrink: 0;
    position: fixed;
    height: 100vh;
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 24px 32px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--accent);
}

.nav-links {
    list-style: none;
    display: flex !important;
    flex-direction: column !important;
}

.nav-links li {
    padding: 16px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.nav-links li:hover {
    color: var(--text-primary);
    background-color: rgba(255, 255, 255, 0.03);
}

.nav-links li.active {
    color: var(--accent);
    background-color: rgba(59, 130, 246, 0.1);
    border-right: 3px solid var(--accent);
}

.nav-links li i {
    width: 20px;
    height: 20px;
}

/* Main Content Area */
.content-area {
    flex-grow: 1;
    margin-left: 250px;
    padding: 40px;
    max-width: 1400px;
}

.header {
    margin-bottom: 32px;
}

.header h2 {
    font-size: 1.75rem;
    margin-bottom: 8px;
    font-weight: 700;
}

.header p {
    color: var(--text-secondary);
}

/* Tab Switching */
.tab-content {
    display: none;
    animation: fadeIn 0.3s ease;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Cards & Forms */
.card {
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    padding: 24px;
}

.form-card h3 {
    margin-bottom: 20px;
    font-size: 1.125rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-color);
}

.form-group {
    margin-bottom: 20px;
}

.form-group label,
.ip-group-wrap label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-row {
    display: flex;
    gap: 16px;
}

.form-row .half {
    flex: 1;
}

.form-row .full {
    flex: 1;
    width: 100%;
}

input[type="text"],
input[type="tel"],
input[type="date"],
select,
textarea {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-family: inherit;
    transition: var(--transition);
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 1px var(--accent), 0 0 12px rgba(129, 236, 255, 0.2);
    background-color: rgba(37, 37, 45, 0.6);
}

select option {
    background-color: var(--bg-card);
    color: var(--text-primary);
}

textarea {
    resize: vertical;
}

.info-box {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    padding: 16px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.info-box strong {
    color: var(--text-primary);
}

.hidden {
    display: none !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, #a68cff 100%);
    color: #003840;
    box-shadow: 0 4px 15px rgba(129, 236, 255, 0.25);
    border: none;
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--accent-hover) 0%, #7e51ff 100%);
    box-shadow: 0 6px 20px rgba(129, 236, 255, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background-color: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.btn-danger:hover {
    background-color: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: 6px;
}

.btn-text {
    background: transparent;
    color: var(--accent);
    padding: 0;
}

.btn-text:hover {
    text-decoration: underline;
}

.btn-icon,
.btn-remove {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.btn-icon:hover {
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1.05rem;
}

.form-actions {
    display: flex;
    gap: 12px;
}

.mt-6 {
    margin-top: 24px;
}

/* Grid Forms (Work Register) */
.grid-form {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    align-items: start;
}

/* Dynamic Rows */
.dynamic-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

.dynamic-row-inner {
    display: flex;
    gap: 8px;
    width: 100%;
    align-items: center;
}

.dynamic-row input {
    flex: 1;
}

.ip-group-wrap {
    margin-bottom: 20px;
    background: rgba(255, 255, 255, 0.02);
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.ip-inputs {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ip-input-row {
    display: flex;
    gap: 8px;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.data-table th {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.data-table td {
    padding: 16px;
    border-bottom: 1px solid rgba(51, 65, 85, 0.5);
    color: var(--text-primary);
}

.data-table tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .grid-form {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .nav-bar {
        position: relative;
        width: 100%;
        height: auto;
        padding: 16px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    .logo {
        padding: 0 0 16px 0;
    }

    .nav-links {
        display: flex;
        width: 100%;
        overflow-x: auto;
        gap: 8px;
    }

    .nav-links li {
        padding: 12px 16px;
        white-space: nowrap;
        border-right: none;
        border-bottom: 3px solid transparent;
        border-radius: var(--radius-md);
    }

    .nav-links li.active {
        border-bottom: 3px solid var(--accent);
        border-right: none;
    }

    .content-area {
        margin-left: 0;
        padding: 20px;
    }

    .dynamic-row-inner {
        flex-wrap: wrap;
    }

    .dynamic-row input {
        width: 100%;
        min-width: 100%;
    }
}

/* PDF Print Styles (Hidden initially) */
#pdf-report-container {
    background: white;
    color: black;
    width: 210mm;
    /* A4 width */
    font-family: 'Pretendard', sans-serif;
    position: absolute;
    left: -9999px;
    top: 0;
}

.pdf-wrapper {
    padding: 15px 30px;
    background-color: white;
    color: #111;
}

.pdf-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 20px;
    border-bottom: 2px solid #222;
    padding-bottom: 12px;
}

.pdf-title {
    font-size: 26px;
    font-weight: 700;
    margin-bottom: 0;
    color: #000;
}

.pdf-meta {
    font-size: 14px;
    color: #555;
}

.pdf-section {
    margin-bottom: 30px;
}

.pdf-section-title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 12px;
    color: #111;
    border-left: 4px solid var(--accent);
    padding-left: 10px;
}

.pdf-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    color: #222;
}

.pdf-table th,
.pdf-table td {
    border: 1px solid #ccc;
    padding: 10px 12px;
    text-align: left;
    color: #222;
}

.pdf-table th {
    background-color: #f3f4f6;
    font-weight: 600;
    color: #111;
}

.pdf-table-striped tbody tr:nth-child(even) {
    background-color: #fafafa;
}

.pdf-notes-box {
    border: 1px solid #ccc;
    padding: 15px;
    min-height: 100px;
    font-size: 14px;
    white-space: pre-wrap;
    color: #222;
}

.pdf-footer {
    margin-top: 50px;
    text-align: center;
    font-size: 14px;
    color: #555;
}

.pdf-signatures {
    display: flex;
    justify-content: flex-end;
    gap: 40px;
    margin-top: 30px;
}

.pdf-signatures div {
    border-top: 1px solid #000;
    padding-top: 10px;
    width: 150px;
    text-align: center;
}

/* --- Modal Styles --- */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background-color: var(--bg-card);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-radius: 12px;
    padding: 25px;
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 10px 45px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(129, 236, 255, 0.1);
    border: 1px solid var(--border-color);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-primary);
}

/* --- CRM Dashboard Styles --- */
#crm-dashboard.active {
    display: flex !important;
}

.crm-dashboard-grid {
    width: 100%;
}

.crm-panel {
    position: relative;
}

.crm-log-item {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    transition: all 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.crm-log-item:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.crm-log-item.warning {
    border-color: var(--danger-color);
    background: rgba(239, 68, 68, 0.05);
    /* very light red tint */
}

.crm-log-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-color);
    padding-bottom: 8px;
}

.crm-log-store {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 1.05rem;
}

.crm-log-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    gap: 10px;
    align-items: center;
}

.crm-log-badge {
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-hover);
    color: var(--text-primary);
}

.crm-log-badge.type {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.crm-log-badge.status-pending {
    background: rgba(245, 158, 11, 0.2);
    color: #fcd34d;
}

.crm-log-badge.status-done {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

.crm-log-content {
    font-size: 0.95rem;
    line-height: 1.5;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-all;
}

.crm-log-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

/* --- Mobile Header Base (Hidden on Desktop) --- */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 60px;
    background-color: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    z-index: 1000;
    padding: 0 20px;
    align-items: center;
    justify-content: space-between;
}

/* --- Mobile Responsive (max-width: 768px) --- */
/* Dashboard Grid & Cards */
.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 25px;
}

.stat-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-info h4 {
    margin: 0 0 10px 0;
    color: var(--text-secondary);
    font-size: 0.9em;
}

.stat-sub-info p {
    margin: 0;
    font-size: 0.9em;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.stat-sub-info strong {
    font-size: 1.15em;
    margin-left: 5px;
}

.dashboard-main-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 25px;
}

.dashboard-panel {
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    gap: 10px;
}

.panel-header h3 {
    margin: 0;
    font-size: 1.1em;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-content {
    padding: 20px;
    flex: 1;
}

.schedule-split {
    display: flex;
    flex: 1;
}

.schedule-col {
    flex: 1;
    padding: 20px;
    border-right: 1px solid var(--border-color);
}

.schedule-col:last-child {
    border-right: none;
}

.schedule-col-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.schedule-col-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1em;
}

.schedule-list,
.game-request-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.schedule-item,
.request-item {
    background: var(--bg-hover);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 12px;
    word-break: break-all;
}

.schedule-item.done .text-content,
.request-item.done .text-content {
    text-decoration: line-through;
    color: var(--text-secondary);
}

/* =========================================
   전체 일정 달력 (Calendar Grid) Styles
========================================= */
.calendar-wrapper-inner {
    min-width: 700px;
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    grid-auto-rows: minmax(90px, auto);
    gap: 1px;
    background: var(--border-color);
    border: 1px solid var(--border-color);
    flex: 1;
    overflow-y: auto;
    min-width: 700px;
}

.calendar-grid-header {
    min-width: 700px;
    /* Force horizontal scroll on small devices */
}

.calendar-cell {
    background: var(--bg-card);
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.calendar-cell:hover {
    background: var(--bg-hover);
}

.calendar-cell.other-month {
    background: rgba(0, 0, 0, 0.2);
    color: var(--text-secondary);
}

.calendar-cell.today {
    background: rgba(59, 130, 246, 0.1);
}

.calendar-cell .date-num {
    font-weight: bold;
    font-size: 1.05em;
    margin-bottom: 5px;
}

.calendar-cell:nth-child(7n+1) .date-num {
    color: #ef4444;
    /* 일요일 */
}

.calendar-cell:nth-child(7n) .date-num {
    color: #3b82f6;
    /* 토요일 */
}

.calendar-schedule-item {
    font-size: 0.75em;
    background: #3b82f6;
    color: white;
    padding: 4px 6px;
    border-radius: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.calendar-schedule-item.done {
    background: var(--text-secondary);
    text-decoration: line-through;
    opacity: 0.6;
}

.calendar-schedule-item i.del-btn {
    width: 12px;
    height: 12px;
    cursor: pointer;
    color: #fca5a5;
    margin-left: 5px;
}

.calendar-schedule-item i.del-btn:hover {
    color: white;
}

@media (max-width: 768px) {
    /* 모바일 달력 주간 뷰 최적화 (가로 분할 제거, 세로 1줄 리스트) */
    .calendar-wrapper-inner { min-width: 0 !important; width: 100% !important; }
    .calendar-grid-header { display: none !important; }
    .calendar-grid { 
        grid-template-columns: 1fr !important; 
        min-width: 0 !important; 
        display: flex !important; 
        flex-direction: column !important; 
    }

    .mobile-header {
        display: flex;
    }

    .nav-bar {
        position: fixed !important;
        left: 0;
        top: 0;
        width: 250px !important;
        height: 100vh !important;
        display: flex !important;
        flex-direction: column !important;
        /* 명시적 top 고정 (플렉스 영향 방지) */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        z-index: 1001;
        /* 모바일 헤더(1000)보다 높게 하여 메뉴가 덮도록 설정 */
    }

    .nav-bar.show-sidebar {
        transform: translateX(0);
    }

    /* 사이드바 켰을 때 바탕을 어둡게 막아주는 오버레이 */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0, 0, 0, 0.5);
        z-index: 998;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .content-area {
        margin-left: 0 !important;
        padding: 80px 15px 20px 15px !important;
        /* 모바일 헤더용 여백 확보 */
        width: 100%;
        max-width: 100vw;
    }

    .form-row,
    .flex-row {
        flex-direction: column;
        gap: 15px;
    }

    /* 탭 최상단 제목 및 우측 버튼/검색창 구역의 세로 압축 파괴 방어 */
    .content-area .header {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 15px !important;
    }

    .content-area .header>div:last-child {
        width: 100% !important;
        max-width: 100% !important;
    }

    /* 필터 영역 모바일 레이아웃 최적화 (2단 분할 Grid) */
    .customer-filter-row {
        flex-direction: row !important;
        /* 위 기본 form-row 규칙 차단 */
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 10px !important;
    }

    .customer-filter-row .form-group:first-child {
        grid-column: 1 / -1;
        /* 검색창 풀 너비 */
    }

    .customer-filter-row .form-group:last-child {
        grid-column: 1 / -1;
        /* 장비임대 체크박스 풀 너비 */
    }

    .dashboard-stats-grid,
    .dashboard-main-grid {
        grid-template-columns: 1fr;
    }

    .schedule-split {
        flex-direction: column;
    }

    .schedule-col {
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .schedule-col:last-child {
        border-bottom: none;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .crm-dashboard-grid {
        flex-direction: column;
    }

    .crm-sidebar {
        width: 100% !important;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: auto;
    }

    .crm-content {
        flex: 1;
    }

    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 800px;
    }

    /* 표 안의 내용물(글자)이 가로 공간 부족으로 세로로 늘어지는 것을 강제 방지 (버그 픽스) */
    table th,
    table td {
        white-space: nowrap !important;
    }
}
/* Fix date picker calendar icon color in dark mode */
input[type='date']::-webkit-calendar-picker-indicator { filter: invert(0.8); cursor: pointer; }
