:root {
    --primary: #0D8ABC;
    --primary-dark: #096a92;
    --primary-light: #e0f2fe;
    --secondary: #3b82f6;
    --success: #10b981;
    --success-light: #d1fae5;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --danger: #ef4444;
    --danger-dark: #b91c1c;
    --dark: #1e293b;
    --gray: #64748b;
    --light-border: #e2e8f0;
    --bg-color: #f8fafc;
    --white: #ffffff;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
    --transition: all 0.3s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Pretendard', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--dark);
    line-height: 1.6;
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--white);
    border-right: 1px solid var(--light-border);
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-sm);
    z-index: 10;
    transition: var(--transition);
}

.brand {
    height: 80px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--light-border);
}

.brand-logo {
    max-width: 100%;
    height: auto;
    max-height: 48px;
    display: block;
}

.menu {
    padding: 24px 0;
    flex: 1;
}

.menu a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 24px;
    color: var(--gray);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.menu a:hover, .menu a.active {
    background: var(--primary-light);
    color: var(--primary);
    border-right: 3px solid var(--primary);
}

.menu a.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.menu i {
    font-size: 20px;
}

.sidebar-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--light-border);
    font-size: 13px;
    color: var(--gray);
}

.status.local {
    color: var(--warning);
    font-weight: 600;
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* Hamburger Button */
.hamburger-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--dark);
    padding: 4px 8px;
    border-radius: 6px;
    transition: var(--transition);
}

.hamburger-btn:hover {
    background: var(--bg-color);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.topbar {
    height: 56px;
    background: var(--white);
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--light-border);
    position: sticky;
    top: 0;
    z-index: 5;
}

.search-wrap {
    display: flex;
    align-items: center;
    background: var(--bg-color);
    padding: 8px 16px;
    border-radius: 8px;
    width: 300px;
    border: 1px solid var(--light-border);
    transition: var(--transition);
}

.search-wrap:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.search-wrap i {
    color: var(--gray);
    font-size: 18px;
}

.search-wrap input {
    border: none;
    background: none;
    outline: none;
    padding-left: 10px;
    width: 100%;
}

/* user-profile removed */

/* Widgets */
.dashboard-widgets {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 14px;
    padding: 16px 20px;
}

.widget {
    background: var(--white);
    border-radius: 10px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.widget:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.widget-icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 22px;
}

.widget-icon.primary { background: var(--primary-light); color: var(--primary); }
.widget-icon.success { background: var(--success-light); color: var(--success); }
.widget-icon.warning { background: var(--warning-light); color: var(--warning); }

.widget-info h3 {
    font-size: 12px;
    color: var(--gray);
    font-weight: 500;
    margin-bottom: 2px;
}

.widget-info p {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
}

/* Sections */
.forms-section, .table-section {
    padding: 0 20px 16px;
}

.card {
    background: var(--white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 12px 18px;
    border-bottom: 1px solid var(--light-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-header h3 {
    font-size: 15px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* Toggle Buttons */
.toggle-group {
    display: flex;
    background: var(--bg-color);
    border-radius: 8px;
    padding: 4px;
    border: 1px solid var(--light-border);
}

.toggle-group input {
    display: none;
}

.toggle-group label {
    padding: 6px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    color: var(--gray);
    transition: var(--transition);
}

.toggle-group input:checked + label {
    background: var(--primary);
    color: var(--white);
    box-shadow: var(--shadow-sm);
}

#typeOut:checked + label {
    background: var(--success);
}

/* Forms */
.grid-form {
    padding: 14px 18px;
    display: grid;
    gap: 12px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.form-group.row-group {
    flex-direction: row;
    gap: 12px;
}

.half {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}

input, select {
    padding: 7px 10px;
    border: 1px solid var(--light-border);
    border-radius: 6px;
    font-size: 13px;
    outline: none;
    transition: var(--transition);
    background: var(--white);
}

input:focus, select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.hint {
    font-size: 12px;
    color: var(--gray);
    margin-top: -4px;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    border: none;
    padding: 9px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-danger {
    background: var(--white);
    color: var(--danger);
    border: 1px solid var(--danger);
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-danger:hover {
    background: var(--danger);
    color: var(--white);
}

.btn-success {
    background: var(--success);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-success:hover {
    background: #059669;
}

/* Inline Edit */
.inline-input {
    width: 100%;
    min-width: 60px;
    padding: 4px 8px;
    border: 1px solid var(--primary);
    border-radius: 4px;
    font-size: 14px;
}

.btn-action {
    background: none;
    border: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-action:hover {
    background: var(--primary-light);
}

.btn-action.save {
    color: var(--success);
}

.btn-action.save:hover {
    background: var(--success-light);
}

/* Autocomplete */
.autocomplete {
    position: relative;
    display: inline-block;
    width: 100%;
}

.autocomplete-items {
    position: absolute;
    border: 1px solid var(--light-border);
    border-bottom: none;
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 250px;
    overflow-y: auto;
    border-radius: 0 0 8px 8px;
    box-shadow: var(--shadow-md);
}

.autocomplete-items div {
    padding: 12px;
    cursor: pointer;
    background-color: var(--white);
    border-bottom: 1px solid var(--light-border);
    font-size: 14px;
}

.autocomplete-items div:hover {
    background-color: var(--primary-light);
}

.autocomplete-active {
    background-color: var(--primary-light) !important;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.readonly-input {
    background-color: #f1f5f9 !important;
    color: var(--gray);
}

/* Transaction Detail Text */
.tx-detail {
    font-size: 12px;
    color: var(--gray);
    font-weight: 400;
}

/* Table */
.table-responsive {
    overflow-x: auto;
}

.modern-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.modern-table th {
    background: var(--bg-color);
    padding: 10px 14px;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--gray);
    font-weight: 600;
    border-bottom: 1px solid var(--light-border);
}

.modern-table td {
    padding: 9px 14px;
    font-size: 13px;
    border-bottom: 1px solid var(--light-border);
    color: var(--dark);
    font-weight: 500;
}

.modern-table tbody tr:hover {
    background: var(--bg-color);
}

.modern-table td:nth-child(5), 
.modern-table td:nth-child(6),
.modern-table td:nth-child(8) {
    font-variant-numeric: tabular-nums;
}

.stock-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    background: var(--primary-light);
    color: var(--primary);
}

.stock-badge.low {
    background: var(--danger);
    color: var(--white);
}

/* Loading Skeleton */
.loading-row td {
    padding: 20px 24px;
}

.skeleton {
    height: 16px;
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    width: 100%;
}

@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 16px 24px;
    border-top: 1px solid var(--light-border);
    flex-wrap: wrap;
}

.page-btn {
    padding: 6px 12px;
    border: 1px solid var(--light-border);
    background: var(--white);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: var(--transition);
    color: var(--dark);
}

.page-btn:hover:not(:disabled) {
    background: var(--primary-light);
    border-color: var(--primary);
}

.page-btn.active {
    background: var(--primary);
    color: var(--white);
    border-color: var(--primary);
}

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

.page-info {
    font-size: 13px;
    color: var(--gray);
    margin-left: 8px;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    padding: 14px 20px;
    border-radius: 10px;
    color: var(--white);
    font-weight: 500;
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 420px;
    pointer-events: auto;
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.fade-out {
    opacity: 0;
    transform: translateX(30px);
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--dark); }
.toast.info { background: var(--primary); }

.toast i {
    font-size: 20px;
    flex-shrink: 0;
}

@keyframes toastSlideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        width: 250px;
        z-index: 100;
        border-right: none;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        left: 0;
    }
    
    .hamburger-btn {
        display: block;
    }

    .topbar {
        padding: 0 16px;
        height: 64px;
    }
    
    .search-wrap {
        width: 160px;
        padding: 6px 12px;
    }

    .user-profile span {
        display: none;
    }

    .dashboard-widgets {
        padding: 16px;
        gap: 12px;
        grid-template-columns: 1fr;
    }

    .widget {
        padding: 16px;
    }

    .widget-info p {
        font-size: 18px;
    }
    
    .forms-section, .table-section {
        padding: 0 16px 16px;
    }

    .card-header {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }
    
    .form-group.row-group {
        flex-direction: column;
        gap: 16px;
    }

    .modern-table th,
    .modern-table td {
        padding: 12px 10px;
        font-size: 12px;
    }

    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
    }

    .toast {
        max-width: 100%;
    }
}
