/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Pretendard Variable', 'Pretendard', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f5f7fa;
    min-height: 100vh;
    display: flex;
    font-size: 12px;
    color: var(--gray-700);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}
code, kbd, pre, samp {
    font-family: inherit;
    font-size: inherit;
}

/* ===== Variables ===== */
:root {
    --sidebar-width: 220px;
    --primary: #667eea;
    --primary-dark: #5568d3;
    --primary-light: #eef0ff;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-light: #fee2e2;
    --info: #3b82f6;
    --info-light: #eff6ff;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --border-radius: 8px;
    --border-radius-lg: 12px;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
    --shadow: 0 2px 10px rgba(0,0,0,0.05);
    --shadow-lg: 0 4px 20px rgba(0,0,0,0.15);
    --transition: all 0.3s;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--gray-800);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
}
.sidebar-header {
    padding: 16.5px 20px;
    background: var(--gray-900);
    border-bottom: 1px solid var(--gray-700);
}
.sidebar-header a {
    text-decoration: none;
    color: white;
}
.sidebar-logo {
    font-size: 18px;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 8px;
    color: white;
}
.sidebar-logo i {
    font-size: 20px;
    color: var(--primary);
}
.sidebar-menu {
    padding: 12px 0;
    flex: 1;
    overflow-y: auto;
}
.sidebar-menu::-webkit-scrollbar {
    width: 6px;
}
.sidebar-menu::-webkit-scrollbar-track {
    background: var(--gray-800);
}
.sidebar-menu::-webkit-scrollbar-thumb {
    background: var(--gray-600);
    border-radius: 3px;
}
.sidebar-menu::-webkit-scrollbar-thumb:hover {
    background: var(--gray-500);
}

/* Menu Section */
.menu-section {
    margin-bottom: 8px;
}
.menu-section-title {
    padding: 16px 20px 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Menu Item */
.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--gray-300);
    text-decoration: none;
    transition: var(--transition);
    cursor: pointer;
    border-left: 3px solid transparent;
    font-size: 13px;
}
.menu-item i {
    font-size: 16px;
    width: 20px;
    text-align: center;
    opacity: 0.7;
}
.menu-item:hover {
    background: var(--gray-700);
    color: white;
    border-left-color: var(--primary);
}
.menu-item:hover i {
    opacity: 1;
}
.menu-item.active {
    background: var(--gray-700);
    color: white;
    border-left-color: var(--primary);
}
.menu-item.active i {
    opacity: 1;
}
.badge-hot {
    font-size: 9px;
    font-weight: 700;
    color: #fff;
    background: #ef4444;
    border-radius: 3px;
    padding: 1px 4px;
    margin-left: 4px;
    vertical-align: middle;
    line-height: 1;
}

/* ===== Main Wrapper ===== */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    min-width: 0;
    overflow-x: clip;
}

/* ===== Header ===== */
.header {
    background: white;
    padding: 14px 30px;
    box-shadow: var(--shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.header-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}
.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}
.header-icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    color: var(--gray-500);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}
.header-icon-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}
.header-icon-btn-danger:hover {
    background: var(--danger-light);
    border-color: #fecaca;
    color: var(--danger);
}
.header-text-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 32px;
    font-size: 12px;
    color: var(--gray-500);
    padding: 0 12px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}
.header-text-btn:hover {
    background: var(--gray-200);
    color: var(--gray-700);
}
.header-text-label {
    color: var(--gray-400);
}
.header-text-value {
    color: var(--gray-700);
    font-weight: 500;
}

/* ===== Content ===== */
.content {
    flex: 1;
    padding: 24px 30px;
    display: flex;
    flex-direction: column;
    min-width: 800px;
}

/* ===== Cards ===== */
.card {
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s;
}
.card:hover {
    box-shadow: var(--shadow);
}
.card-header {
    background: transparent;
    border-bottom: 1px solid var(--gray-200);
    font-weight: 600;
    padding: 14px 20px;
    font-size: 13px;
    color: var(--gray-800);
    min-height: 52px;
    display: flex;
    align-items: center;
}
.card-header.no-border {
    border-bottom: none;
}
.card-header .card-desc {
    font-size: 12px;
    font-weight: 400;
    color: var(--gray-500);
}
.card-body {
    padding: 20px;
}
.card-footer {
    background: white;
    border-top: 1px solid var(--gray-100);
    padding: 10px 20px;
}
.card.card-table {
    border-radius: 0;
}

/* ===== Alert (설명 영역) ===== */
.alert.alert-info { font-size: 12px; line-height: 1.7; }

/* ===== Summary Cards (Dashboard) ===== */
.summary-card {
    border: none;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    overflow: hidden;
}
.summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}
.summary-card .card-body {
    padding: 24px;
}
.summary-card .summary-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}
.summary-card .summary-value {
    font-size: 1.75rem;
    font-weight: 700;
    line-height: 1.2;
    color: var(--gray-900);
}
.summary-card .summary-label {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 2px;
}
.bg-primary-light { background-color: var(--primary-light); color: var(--primary); }
.bg-success-light { background-color: var(--success-light); color: var(--success); }
.bg-warning-light { background-color: var(--warning-light); color: var(--warning); }
.bg-danger-light { background-color: var(--danger-light); color: var(--danger); }
.bg-info-light { background-color: var(--info-light); color: var(--info); }

/* ===== Tables ===== */
/* ===== Content area links ===== */
.content a:not(.btn):not(.nav-link):not(.badge):not(.dropdown-item):not(.page-link):not(.manual-nav-link) {
    color: inherit !important;
    text-decoration: underline;
}

.table {
    font-size: 12px;
}
.table thead th {
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-500);
    border-bottom: 1px solid var(--gray-200);
    white-space: nowrap;
    padding: 10px 16px;
    background: var(--gray-50);
    text-align: center;
}
.table tbody td {
    padding: 10px 16px;
    vertical-align: middle;
    color: var(--gray-700);
    border-bottom: 1px solid var(--gray-100);
    text-align: center;
    font-size: 12px;
}
.table-hover tbody tr:hover {
    --bs-table-hover-bg: transparent;
    background: transparent !important;
}

/* Fixed-width columns */
.col-datetime { width: 125px; max-width: 125px; white-space: nowrap; }
.col-date { width: 95px; max-width: 95px; white-space: nowrap; }

/* Sortable columns */
.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable:hover { color: var(--primary); }
.sortable.active { color: var(--primary); font-weight: 700; }
.sortable.active .bi-chevron-expand:before { content: "\F282"; }
.sortable.active.asc .bi-chevron-expand:before { content: "\F286"; }

/* ===== Badges ===== */
.badge {
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 12px;
}
.badge.bg-success-subtle, .badge.bg-success { background: #22c55e !important; color: #fff !important; }
.badge.bg-danger-subtle, .badge.bg-danger { background: #ef4444 !important; color: #fff !important; }
.badge.bg-warning-subtle, .badge.bg-warning { background: #f59e0b !important; color: #fff !important; }
.badge.bg-info-subtle, .badge.bg-info { background: #3b82f6 !important; color: #fff !important; }
.badge.bg-secondary-subtle, .badge.bg-secondary { background: #9ca3af !important; color: #fff !important; }
.badge.bg-primary { background: var(--primary) !important; color: #fff !important; }
.table .badge { font-size: 11px; }

/* ===== Buttons ===== */
.btn {
    padding: 7px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 500;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    transition: var(--transition);
}
.btn-primary {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}
.btn-secondary, .btn-outline-secondary {
    background: white;
    color: var(--gray-500);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover, .btn-outline-secondary:hover {
    background: var(--gray-50);
    color: var(--gray-700);
}
.btn-outline-primary {
    color: var(--primary);
    border: 1px solid var(--primary);
    background: transparent;
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}
.btn:disabled {
    background: var(--gray-200);
    color: var(--gray-400);
    cursor: not-allowed;
}

/* ===== Forms ===== */
.form-control, .form-select {
    border-radius: 6px;
    border: 1px solid var(--gray-300);
    font-size: 12px;
    padding: 8px 12px;
    transition: all 0.2s;
}
.form-control-sm, .form-select-sm {
    font-size: 12px;
    padding: 5px 10px;
}
.input-group-text {
    font-size: 12px;
    color: var(--gray-600);
}
.form-text {
    font-size: 12px;
    color: var(--gray-500);
    margin-top: 4px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}
.form-label {
    font-weight: 600;
    font-size: 12px;
    color: var(--gray-700);
    margin-bottom: 4px;
}
.form-check-input:checked {
    background-color: var(--primary);
    border-color: var(--primary);
}
.form-switch .form-check-input {
    width: 2.8em;
    height: 1.5em;
}
.form-check-label {
    font-size: 12px;
    color: var(--gray-700);
}

/* 토글 카드 */
.toggle-card {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    padding: 16px 20px;
    margin-bottom: 12px;
}
.toggle-card .toggle-card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}
.toggle-card .toggle-card-header label {
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-800);
    margin: 0;
    cursor: pointer;
}
.toggle-card .toggle-card-body {
    padding-top: 16px;
}

/* Filter bar inside card-header */
.card-header .filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-header .filter-group .form-control,
.card-header .filter-group .form-select,
.card-header .filter-group .input-group {
    font-size: 12px;
}

/* Section dividers */
.section-divider {
    border-top: 1px solid var(--gray-300);
    margin-top: 16px;
    padding-top: 16px;
}

/* Summary box */
.summary-box {
    background: var(--gray-50);
    border-radius: var(--border-radius);
    padding: 16px;
}
.summary-box .summary-item {
    text-align: center;
}
.summary-box .summary-item .label {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 2px;
}
.summary-box .summary-item .value {
    font-weight: 600;
    font-size: 13px;
    color: var(--gray-800);
}

/* Inline info text */
.info-text {
    font-size: 12px;
    color: var(--gray-500);
}

/* Note/hint text */
.hint-text {
    font-size: 12px;
    color: var(--gray-400);
}

/* 공통 설명 영역 (녹색) */
.help-text-box {
    font-size: 12px;
    color: #166534;
    line-height: 1.6;
    padding: 12px 16px;
    background: #f0fdf4;
    border: 1px solid #86efac;
    border-radius: 8px;
}

/* ===== Filter Bar ===== */
.filter-bar {
    background: white;
    border-radius: var(--border-radius-lg);
    border: 1px solid var(--gray-200);
    padding: 16px 20px;
    margin-bottom: 20px;
}

/* ===== Page Header ===== */
.page-header {
    margin-bottom: 24px;
}
.page-header h4 {
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 4px;
}
.page-header p {
    color: var(--gray-500);
    font-size: 12px;
    margin-bottom: 0;
}

/* ===== Quick Target Buttons ===== */
.quick-target-btn {
    border: 1px dashed var(--gray-300);
    border-radius: var(--border-radius);
    padding: 12px 16px;
    background: white;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--gray-500);
    font-size: 12px;
}
.quick-target-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}
.quick-target-btn i {
    display: block;
    font-size: 1.5rem;
    margin-bottom: 4px;
}

/* ===== Status Dot ===== */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.status-dot.active { background: var(--success); }
.status-dot.inactive { background: var(--gray-400); }
.status-dot.error { background: var(--danger); }

/* ===== Group Card ===== */
.group-card {
    border: 1px solid var(--gray-200);
    border-radius: var(--border-radius-lg);
    padding: 20px;
    text-align: center;
    transition: all 0.2s;
    cursor: pointer;
    background: white;
}
.group-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow);
}
.group-card .group-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary-light);
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1.2rem;
}
.group-card .group-name {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 4px;
}
.group-card .group-count {
    font-size: 12px;
    color: var(--gray-500);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--gray-400);
}
.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
}

/* ===== Expiration Type Toggle ===== */
.exp-type-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}
.exp-type-row:last-child {
    border-bottom: none;
}
.exp-type-label {
    font-weight: 500;
    font-size: 12px;
    min-width: 180px;
}

/* ===== Pagination ===== */
.pagination { gap: 3px; }
.pagination .page-link {
    border-radius: 4px !important;
    min-width: 26px;
    padding: 3px 5px;
    text-align: center;
    font-size: 12px;
    line-height: 1.4;
    color: var(--gray-700);
    border: 1px solid var(--gray-200);
}
.pagination .page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.pagination .page-link:focus {
    box-shadow: 0 0 0 0.2rem rgba(102,126,234,.25);
}

/* ===== Offcanvas ===== */
.offcanvas {
    width: 480px !important;
}
.offcanvas-header {
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 20px;
}
.offcanvas-body {
    padding: 20px;
}

/* ===== Chart Card ===== */
.chart-card .card-body {
    padding: 16px;
}

/* ===== Sticky Footer Form ===== */
.sticky-bottom-form {
    position: sticky;
    bottom: 0;
    background: white;
    border-top: 1px solid var(--gray-200);
    padding: 16px 20px;
    box-shadow: 0 -2px 8px rgba(0,0,0,0.06);
    z-index: 10;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 12px;
}
.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #6ee7b7;
}
.alert-danger, .alert-error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fca5a5;
}
.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fcd34d;
}
.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ===== Modal ===== */
.modal-content {
    border-radius: var(--border-radius-lg);
    box-shadow: 0 8px 32px rgba(0,0,0,.12);
    border: none;
}
.modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
}
.modal-header .modal-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gray-800);
}
.modal-body {
    padding: 20px;
}
.modal-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-200);
}

/* App Alert/Confirm Modal */
#appModal .modal-dialog { max-width: 340px; }
#appModal .modal-content { border-radius: 12px; }
#appModal .modal-body { padding: 24px 24px 12px; text-align: center; }
#appModal .modal-footer { padding: 4px 24px 20px; justify-content: center; border: none; }
.app-modal-icon { font-size: 2rem; margin-bottom: 8px; }
.app-modal-message { font-size: 13px; font-weight: 600; color: var(--gray-800); margin-bottom: 4px; }
.app-modal-sub { font-size: 12px; color: var(--gray-500); line-height: 1.5; }

/* ===== Toast ===== */
.toast-container {
    z-index: 9999;
}

/* ===== Scrollbar ===== */
.main-wrapper::-webkit-scrollbar {
    width: 6px;
}
.main-wrapper::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 3px;
}

/* ===== Mobile Toggle ===== */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1001;
    background: white;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    width: 40px;
    height: 40px;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--shadow);
    color: var(--gray-700);
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 999;
}
.sidebar-overlay.show {
    display: block;
}

/* ===== Responsive ===== */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .sidebar-toggle {
        display: flex;
    }
    .main-wrapper {
        margin-left: 0;
    }
    .header {
        padding: 15px 20px 15px 60px;
    }
    .content {
        padding: 20px;
    }
    .offcanvas {
        width: 100% !important;
    }
}

@media (max-width: 575.98px) {
    .summary-card .summary-value {
        font-size: 1.3rem;
    }
    .page-header h4 {
        font-size: 1.1rem;
    }
    .header-title {
        font-size: 15px;
    }
    .header-actions {
        gap: 8px;
    }
    .content {
        padding: 16px;
    }
}
