@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    /* macOS Light Theme Palette */
    --bg-app: #f5f5f7;
    --bg-gradient: linear-gradient(180deg, #f5f5f7 0%, #e8e8ed 100%);
    --bg-card: rgba(255, 255, 255, 0.85);
    --border-color: rgba(0, 0, 0, 0.07);
    --border-focus: #007aff; /* Apple System Blue */
    --primary: #007aff;
    --primary-hover: #0062cc;
    --primary-light: rgba(0, 122, 255, 0.08);
    
    --text-main: #1d1d1f; /* Apple primary text */
    --text-muted: #86868b; /* Apple secondary text */
    --text-dark: #1d1d1f;
    
    /* Semantic Colors */
    --color-success: #34c759; /* Apple Green */
    --color-warning: #ff9500; /* Apple Orange */
    --color-danger: #ff3b30; /* Apple Red */
    --color-info: #007aff;

    /* Transitions & Shadows */
    --transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.06);
    --shadow-glow: 0 0 0 3px rgba(0, 122, 255, 0.25);

    /* Fonts */
    --font-thai: 'Sarabun', sans-serif;
    --font-eng: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    background: var(--bg-app);
    background-image: var(--bg-gradient);
    color: var(--text-main);
    font-family: var(--font-thai);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.03);
}
::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border: 2px solid transparent;
    background-clip: padding-box;
    border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* Sidebar Navigation Layout (macOS Finder style) */
body:not(.login-active) #app-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    min-height: 100vh;
}

body.login-active .sidebar {
    display: none !important;
}

.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 99;
    transition: var(--transition);
}

.sidebar-brand {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-brand .brand-logo {
    width: 36px;
    height: 36px;
    background: linear-gradient(180deg, #358bf0 0%, #007aff 100%);
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 1.1rem;
    box-shadow: 0 2px 5px rgba(0, 122, 255, 0.25);
    flex-shrink: 0;
}

.sidebar-brand .brand-title h1 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: -0.15px;
    margin-bottom: 0.1rem;
}

.sidebar-brand .brand-title p {
    font-size: 0.68rem;
    color: var(--text-muted);
}

.sidebar-user-card {
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 0.5rem;
}

.sidebar-menu {
    flex: 1;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.85rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-main);
    text-decoration: none;
    transition: var(--transition);
}

.menu-item i {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.menu-item:hover {
    background: rgba(0, 0, 0, 0.03);
}

.menu-item.active {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.menu-item.active i {
    color: var(--primary);
}

/* Offset main-content for sidebar */
body:not(.login-active) .main-content {
    margin-left: 280px;
    width: calc(100% - 280px);
    max-width: 100% !important;
    padding: 2rem 2.5rem;
    flex: 1;
}

/* Views Management */
.view-section {
    display: none;
    animation: slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.view-section.active {
    display: block;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

/* macOS Window Card Styling */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    padding: 2rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-md);
}

/* macOS Styled Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    font-family: var(--font-thai);
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(180deg, #358bf0 0%, #007aff 100%);
    color: #ffffff;
    border: 1px solid #006ddb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.btn-primary:hover {
    background: linear-gradient(180deg, #2a7fe5 0%, #0069d9 100%);
    transform: translateY(0);
}

.btn-secondary {
    background: #ffffff;
    color: var(--text-main);
    border: 1px solid rgba(0, 0, 0, 0.15);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: #f5f5f7;
    border-color: rgba(0, 0, 0, 0.2);
}

.btn-danger {
    background: rgba(255, 59, 48, 0.08);
    color: #cc1f1a;
    border: 1px solid rgba(255, 59, 48, 0.15);
}

.btn-danger:hover {
    background: #ff3b30;
    color: white;
    border-color: #e02d24;
}

.btn-success {
    background: rgba(52, 199, 89, 0.08);
    color: #248a3d;
    border: 1px solid rgba(52, 199, 89, 0.15);
}

.btn-success:hover {
    background: #34c759;
    color: white;
    border-color: #2ab04d;
}

.btn-sm {
    padding: 0.35rem 0.75rem;
    font-size: 0.82rem;
    border-radius: 6px;
}

/* Forms controls */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--text-main);
}

.form-control {
    width: 100%;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    font-family: var(--font-thai);
    font-size: 0.9rem;
    transition: var(--transition);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}

.form-control:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: var(--shadow-glow);
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2386868b'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.25rem;
}

/* Dashboard Grid Layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
}

.stat-info h3 {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-weight: 500;
    margin-bottom: 0.15rem;
}

.stat-info p {
    font-size: 1.85rem;
    font-family: var(--font-eng);
    font-weight: 700;
    color: var(--text-dark);
}

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

.stat-icon.blue { background: rgba(0, 122, 255, 0.08); color: #007aff; }
.stat-icon.green { background: rgba(52, 199, 89, 0.08); color: #34c759; }
.stat-icon.orange { background: rgba(255, 149, 0, 0.08); color: #ff9500; }
.stat-icon.red { background: rgba(255, 59, 48, 0.08); color: #ff3b30; }

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

/* Reports Table List (macOS Finder-like table) */
.reports-table-container {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
}

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

.reports-list-table th, 
.reports-list-table td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.reports-list-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.82rem;
    background: #f5f5f7;
}

.reports-list-table tbody tr {
    transition: var(--transition);
}

.reports-list-table tbody tr:hover {
    background: rgba(0, 122, 255, 0.015);
}

.reports-list-table td {
    font-size: 0.9rem;
    color: var(--text-dark);
}

/* macOS Badge Tags */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.78rem;
    font-weight: 600;
    border-radius: 5px;
}

.badge-normal {
    background: rgba(52, 199, 89, 0.12);
    color: #248a3d;
}

.badge-warning {
    background: rgba(255, 149, 0, 0.12);
    color: #b25900;
}

.badge-danger {
    background: rgba(255, 59, 48, 0.12);
    color: #cc1f1a;
}

/* Empty state */
.empty-state {
    padding: 4rem 1rem;
    text-align: center;
    color: var(--text-muted);
}

.empty-state svg {
    margin-bottom: 1rem;
    opacity: 0.4;
    color: var(--text-muted);
}

/* Form View Layout */
.form-grid-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 0.5rem;
}

/* Dynamic Rows Editor Table */
.inspection-editor-table-wrapper {
    overflow-x: auto;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    background: #ffffff;
    margin-top: 0.75rem;
    margin-bottom: 1.25rem;
}

.inspection-editor-table {
    width: 100%;
    border-collapse: collapse;
}

.inspection-editor-table th {
    padding: 0.75rem 0.5rem;
    color: var(--text-muted);
    font-size: 0.82rem;
    font-weight: 600;
    background: #f5f5f7;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.inspection-editor-table td {
    padding: 0.75rem 0.5rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
}

/* Compact editor form controls */
.inspection-editor-table .form-control {
    padding: 0.35rem 0.5rem;
    font-size: 0.82rem;
    border-radius: 6px;
    height: auto;
}

.inspection-editor-table select.form-control {
    padding-right: 1.5rem;
    background-position: right 0.4rem center;
    background-size: 0.8rem;
}

.row-no-cell {
    font-family: var(--font-eng);
    font-weight: 600;
    color: var(--text-muted);
    width: 40px;
    text-align: center;
}

/* Action button group inside cell */
.actions-cell {
    width: 50px;
    text-align: center;
}

/* macOS Speed choices tags */
.pill-container {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.35rem;
}

.pill-option {
    background: #f5f5f7;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 5px;
    padding: 0.15rem 0.4rem;
    font-size: 0.72rem;
    color: var(--text-dark);
    cursor: pointer;
    transition: var(--transition);
}

.pill-option:hover {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* Segmented Control Selector (macOS Style Toggles) */
.quality-pills {
    display: flex;
    gap: 2px;
    background: rgba(120, 120, 128, 0.08);
    padding: 2px;
    border: 1px solid rgba(0, 0, 0, 0.03);
    border-radius: 7px;
    width: fit-content;
    user-select: none;
}

.quality-pill {
    padding: 0.3rem 0.65rem;
    font-size: 0.78rem;
    font-weight: 500;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.15s ease-in-out;
    text-align: center;
    border: 0.5px solid transparent;
    color: var(--text-main);
}

.quality-pill.active {
    background: #ffffff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
    border-color: rgba(0, 0, 0, 0.04);
}

.quality-pill.active[data-val="ปกติ"] {
    color: #248a3d;
    font-weight: 600;
}

.quality-pill.active[data-val*="ชำรุด"], 
.quality-pill.active[data-val*="เปี"],
.quality-pill.active[data-val*="ฉีก"] {
    color: #cc1f1a;
    font-weight: 600;
}

.quality-pill.active[data-val*="จับตัว"],
.quality-pill.active[data-val*="ชื้น"],
.quality-pill.active[data-val*="เม็ด"] {
    color: #b25900;
    font-weight: 600;
}

.quality-pill:not(.active) {
    color: var(--text-muted);
}
.quality-pill:not(.active):hover {
    color: var(--text-main);
}

/* Photo Upload Button and Preview */
.photo-uploader {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.photo-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.photo-preview-container {
    display: flex;
    gap: 0.25rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.photo-thumb {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: var(--transition);
}

.photo-thumb:hover {
    transform: scale(1.08);
    border-color: var(--primary);
}

.thumb-wrapper {
    position: relative;
    width: 44px;
    height: 44px;
}

.remove-photo-btn {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 15px;
    height: 15px;
    background: var(--color-danger);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    border: none;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 1px 2px rgba(0,0,0,0.25);
}

/* Lightbox Modal (Retained dark style for image focusing - like macOS Preview) */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.lightbox.active {
    display: flex;
}

.lightbox-content {
    max-width: 90%;
    max-height: 80%;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    font-size: 2.2rem;
    cursor: pointer;
    background: none;
    border: none;
}

.lightbox-caption {
    position: absolute;
    bottom: 20px;
    color: white;
    font-size: 1.05rem;
    text-align: center;
    width: 100%;
}

/* Responsive Table conversion for Mobile edit */
@media (max-width: 1024px) {
    .inspection-editor-table-wrapper {
        border: none;
        background: transparent;
    }
    
    .inspection-editor-table, 
    .inspection-editor-table tbody, 
    .inspection-editor-table tr, 
    .inspection-editor-table td, 
    .inspection-editor-table th {
        display: block;
    }
    
    .inspection-editor-table thead {
        display: none;
    }
    
    .inspection-editor-table tr {
        background: #ffffff;
        border: 1px solid var(--border-color);
        border-radius: 12px;
        padding: 1rem;
        margin-bottom: 1rem;
        position: relative;
        box-shadow: var(--shadow-sm);
    }
    
    .inspection-editor-table td {
        border: none;
        padding: 0.4rem 0;
        display: flex;
        flex-direction: column;
    }
    
    .inspection-editor-table td::before {
        content: attr(data-label);
        font-size: 0.78rem;
        font-weight: 600;
        color: var(--text-muted);
        margin-bottom: 0.2rem;
    }

    .row-no-cell {
        width: 100%;
        text-align: left;
        font-size: 1.05rem;
        border-bottom: 1px solid var(--border-color) !important;
        padding-bottom: 0.4rem !important;
        margin-bottom: 0.4rem;
    }

    .row-no-cell::before {
        content: "ลำดับที่" !important;
        display: inline-block;
        margin-right: 0.5rem;
    }

    .actions-cell {
        width: 100%;
        margin-top: 0.5rem;
        border-top: 1px solid var(--border-color) !important;
        padding-top: 0.65rem !important;
        align-items: flex-end !important;
    }
}

/* Footer style */
footer {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    border-top: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.4);
    margin-top: auto;
}

/* PRINT PREVIEW / REPORT PRINT STYLE (Screen & Print mode) */
#print-section {
    display: none;
    background: #ffffff;
    color: #000000;
    padding: 20px;
    width: 210mm; /* A4 width */
    min-height: 297mm; /* A4 height */
    margin: 20px auto;
    box-shadow: 0 0 10px rgba(0,0,0,0.1);
}

body.print-layout-active #app-container {
    display: none !important;
}

body.print-layout-active #print-section {
    display: block !important;
}

/* Print UI control bar */
.print-control-bar {
    background: #f5f5f7;
    padding: 0.75rem;
    position: sticky;
    top: 0;
    display: flex;
    justify-content: center;
    gap: 0.75rem;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}

/* Typography and structures on the print sheet */
.sheet-header {
    text-align: center;
    margin-bottom: 20px;
    position: relative;
}

.sheet-title {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 10px;
    font-family: var(--font-thai);
}

.sheet-meta-grid {
    display: flex;
    justify-content: space-between;
    font-size: 14px;
    margin-bottom: 15px;
    padding: 0 10px;
}

.sheet-meta-item {
    font-family: var(--font-thai);
}

.sheet-meta-val {
    border-bottom: 1px dotted #000;
    padding: 0 15px;
    font-weight: 600;
}

/* Print Table Styles */
.sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
    margin-bottom: 30px;
}

.sheet-table th, 
.sheet-table td {
    border: 1px solid #000000;
    padding: 6px 8px;
    text-align: center;
}

.sheet-table th {
    background-color: #f3f4f6;
    font-weight: 700;
}

.sheet-table td.text-left {
    text-align: left;
}

.sheet-table td.text-center {
    text-align: center;
}

/* Signatures section */
.sheet-signatures {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding: 0 40px;
}

.signature-box {
    text-align: center;
    width: 200px;
}

.signature-line {
    border-bottom: 1px solid #000000;
    height: 40px;
    margin-bottom: 8px;
}

.signature-title {
    font-size: 13px;
}

/* Photo appendix section on the printout */
.photo-appendix-title {
    font-size: 16px;
    font-weight: 700;
    margin-top: 40px;
    margin-bottom: 15px;
    border-bottom: 2px solid #000000;
    padding-bottom: 5px;
    page-break-before: always;
}

.photo-grid-print {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.photo-card-print {
    border: 1px solid #ccc;
    padding: 10px;
    border-radius: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    page-break-inside: avoid;
}

.photo-card-print img {
    max-width: 100%;
    height: 180px;
    object-fit: contain;
    margin-bottom: 8px;
}

.photo-card-desc {
    font-size: 11px;
    text-align: center;
    color: #444;
}

/* ACTUAL BROWSER PRINTING OVERRIDES */
@media print {
    body {
        background: #ffffff !important;
        color: #000000 !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    #app-container, 
    .print-control-bar {
        display: none !important;
    }
    
    #print-section {
        display: block !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    
    .sheet-table th {
        background-color: #f3f4f6 !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
    
    .photo-appendix-title {
        page-break-before: always !important;
    }
    
    .photo-card-print {
        page-break-inside: avoid !important;
    }
}

/* Master Data Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
    margin-top: 1rem;
}

/* Login Screen Style overrides */
.login-active header,
.login-active footer {
    display: none !important;
}

body.login-active {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    height: 100vh !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #ececef;
    background-image: linear-gradient(135deg, #f5f5f7 0%, #d2d2d7 100%) !important;
}

.login-active #app-container {
    box-shadow: none;
    background: transparent;
    border: none;
    max-width: 450px;
    width: 100%;
    margin: 0;
    padding: 1rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 100vh !important;
    height: 100vh !important;
}

.login-active .main-content {
    padding: 0 !important;
    width: 100% !important;
    margin: 0 !important;
}

.login-active #login-view {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    width: 100% !important;
}

.login-active .login-wrapper {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    padding: 0 !important;
    min-height: unset !important;
}

.login-card {
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(30px) !important;
    -webkit-backdrop-filter: blur(30px) !important;
    border: 1px solid rgba(255, 255, 255, 0.4) !important;
    width: 100% !important;
}

/* User Management badging overrides */
.badge-danger {
    background: rgba(255, 59, 48, 0.1) !important;
    color: var(--color-danger) !important;
    border: 1px solid rgba(255, 59, 48, 0.2);
}

/* User Settings Grid override */
.users-settings-grid {
    grid-template-columns: 1fr 2fr;
}

/* Desktop Full-Screen Lock (ออกแบบให้เต็มหน้า) */
@media (min-width: 961px) {
    body:not(.login-active):not(.print-layout-active) {
        height: 100vh !important;
        overflow: hidden !important;
    }
    body:not(.login-active):not(.print-layout-active) #app-container {
        height: 100vh !important;
        overflow: hidden !important;
        display: flex;
        flex-direction: row;
    }
    body:not(.login-active):not(.print-layout-active) .main-content {
        height: 100vh !important;
        overflow-y: auto !important;
        display: flex;
        flex-direction: column;
    }
}

/* Mobile and Tablet Media Queries */
@media (max-width: 960px) {
    body:not(.login-active) #app-container {
        flex-direction: column;
    }
    
    .sidebar {
        position: relative;
        width: 100% !important;
        height: auto !important;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        flex-direction: column;
        padding: 0.75rem;
    }
    
    .sidebar-brand {
        padding: 0.5rem;
        justify-content: center;
        border-bottom: none;
    }
    
    .sidebar-user-card {
        padding: 0.5rem;
        margin-bottom: 0;
        justify-content: center;
        border-bottom: none;
    }
    
    .sidebar-action {
        padding: 0.25rem 0.5rem !important;
    }
    
    .sidebar-menu {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.5rem;
        padding: 0.5rem 0;
        justify-content: center;
        border-bottom: none;
        flex: none !important;
    }
    
    .menu-item {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }
    
    .sidebar-footer {
        border-top: none;
        padding: 0.5rem 0 0 0;
    }
    
    body:not(.login-active) .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 1rem;
    }
    
    .users-settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr 1fr;
        gap: 0.75rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .glass-card {
        padding: 1rem;
        border-radius: 10px;
    }
    
    .btn {
        width: 100%;
        margin-bottom: 0.25rem;
    }
    
    .sidebar-menu .menu-item {
        width: 100%;
    }
}
