:root {
    --bg: #f8f9fa;
    --bg-secondary: #ffffff;
    --surface: #ffffff;
    --surface2: #f1f3f5;
    --surface3: #e9ecef;
    --border: #dee2e6;
    --border-light: #ced4da;

    --primary: #F54B64;
    --primary2: #F78361;
    --primary-hover: #ff5e78;
    --primary-rgb: 245, 75, 100;

    --text: #212529;
    --text-secondary: #495057;
    --text-muted: #6c757d;

    --success: #10b981;
    --success-light: rgba(16, 185, 129, 0.1);
    --warning: #f59e0b;
    --warning-light: rgba(245, 158, 11, 0.1);
    --danger: #ef4444;
    --danger-light: rgba(239, 68, 68, 0.1);
    --info: #3b82f6;
    --info-light: rgba(59, 130, 246, 0.1);

    --gradient-primary: linear-gradient(135deg, var(--primary), var(--primary2));
    --gradient-overlay: linear-gradient(180deg, transparent, rgba(0, 0, 0, 0.05));

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 4px 12px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 420px;
    padding: 48px 40px;
}

.login-logo {
    text-align: center;
    margin-bottom: 24px;
}

.login-logo .material-symbols-outlined {
    font-size: 64px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-title {
    text-align: center;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
}

.text-sec {
    color: var(--text-secondary);
}

.text-small {
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea,
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--surface2);
    border-color: var(--border-light);
}

.btn-icon {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-icon:hover {
    background: var(--surface2);
    color: var(--primary);
}

.btn-table-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 86px;
    height: 34px;
    padding: 0 12px;
    border: 1px solid var(--danger);
    border-radius: var(--radius-sm);
    background: var(--danger-light);
    color: var(--danger);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.btn-table-delete:hover {
    background: var(--danger);
    color: #fff;
}

.admin-layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 280px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
}

.sidebar-logo .material-symbols-outlined {
    font-size: 28px;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    font-family: inherit;
}

.nav-item .material-symbols-outlined {
    font-size: 20px;
}

.nav-item:hover {
    background: var(--surface2);
    color: var(--text);
}

.nav-item.active {
    background: rgba(var(--primary-rgb), 0.1);
    color: var(--primary);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--surface2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
}

.sidebar-user-info {
    flex: 1;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-logout {
    padding: 8px;
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger-light);
}

.main-content {
    flex: 1 1 auto;
    padding: 32px;
    width: auto;
    max-width: calc(100vw - 280px);
    min-width: 0;
}

.content-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.page-subtitle {
    font-size: 14px;
}

.header-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.content-area {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 24px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-lg);
    border-color: var(--border-light);
}

.stat-icon {
    width: 64px;
    height: 64px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon .material-symbols-outlined {
    font-size: 32px;
    color: white;
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text);
}

.stat-change {
    font-size: 12px;
    margin-top: 4px;
}

.stat-change.positive {
    color: var(--success);
}

.stat-change.warning {
    color: var(--warning);
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 24px;
    min-width: 0;
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.card-title .material-symbols-outlined {
    font-size: 22px;
    color: var(--primary);
}

.quick-action-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 20px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 14px;
}

.quick-action-btn:hover {
    background: var(--surface3);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.quick-action-btn .material-symbols-outlined {
    font-size: 28px;
    color: var(--primary);
}

.param-row-inline {
    display: grid;
    grid-template-columns: 200px 1fr 1fr;
    gap: 16px;
    align-items: center;
    padding: 12px;
    margin-bottom: 8px;
    background: var(--surface2);
    border-radius: var(--radius-sm);
}

.param-label {
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.comment-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
}

.comment-icon {
    font-size: 18px;
    color: var(--text-muted);
}

.param-comment {
    flex: 1;
    font-size: 13px;
    font-style: italic;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.checkbox-label:hover {
    background: var(--surface3);
    border-color: var(--border-light);
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.param-row {
    margin-bottom: 16px;
}

.param-grid {
    display: grid;
    gap: 12px;
    align-items: center;
    margin-bottom: 12px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.tag-remove {
    padding: 2px;
    background: transparent;
    border: none;
    color: var(--danger);
    cursor: pointer;
    display: flex;
    align-items: center;
    border-radius: 4px;
    transition: all 0.2s;
}

.tag-remove:hover {
    background: var(--danger-light);
}

.tag-remove .material-symbols-outlined {
    font-size: 16px;
}

.filters {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
    padding: 20px;
    background: var(--surface2);
    border-radius: var(--radius-sm);
}

.users-column-panel {
    grid-template-columns: 220px minmax(0, 1fr);
    align-items: start;
    max-height: 360px;
    overflow: hidden;
}

.column-panel-title {
    font-weight: 600;
    color: var(--text);
    padding: 8px 0;
}

.column-toggle-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 10px;
    max-height: 310px;
    overflow: auto;
    padding-right: 4px;
}

.column-toggle {
    min-width: 0;
    padding: 8px 12px;
    white-space: nowrap;
}

.column-toggle span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

#users-grid,
#logs-grid {
    margin-top: 20px;
    min-width: 0;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--surface3);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 500;
}

.badge-warning {
    background: var(--warning-light);
    border-color: var(--warning);
    color: var(--warning);
}

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.modal-wide {
    max-width: 800px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px 20px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.success {
    border-left-color: var(--success);
}

.toast.error {
    border-left-color: var(--danger);
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast.success .toast-icon {
    color: var(--success);
}

.toast.error .toast-icon {
    color: var(--danger);
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text);
}

@media (max-width: 1024px) {
    .admin-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: static;
    }

    .main-content {
        padding: 20px;
        max-width: 100%;
    }

    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }

    .param-row-inline {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .content-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .header-actions {
        width: 100%;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 32px 24px;
    }

    .toast-container {
        left: 20px;
        right: 20px;
    }

    .toast {
        min-width: auto;
    }

    .filters {
        grid-template-columns: 1fr;
    }

    .users-column-panel {
        grid-template-columns: 1fr;
        max-height: 430px;
    }

    .column-toggle-list {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }
}

.jse-theme-dark {
    height: 400px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}

.gridjs-wrapper {
    font-size: 13px;
    overflow-x: auto !important;
    overflow-y: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    max-width: 100%;
}

.gridjs-table {
    table-layout: fixed;
    width: max-content !important;
    min-width: 100%;
}

.gridjs-th,
.gridjs-td {
    padding: 8px 12px;
    max-width: 420px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
    border-color: var(--border) !important;
}

.gridjs-th {
    font-size: 12px;
    font-weight: 600;
    position: relative;
    user-select: none;
}

.gridjs-td {
    font-size: 13px;
}

.gridjs-resizable {
    width: 8px !important;
    right: -4px !important;
    background: transparent;
    cursor: col-resize;
}

.gridjs-resizable::after {
    content: "";
    position: absolute;
    top: 25%;
    bottom: 25%;
    left: 3px;
    width: 2px;
    border-radius: 2px;
    background: transparent;
}

.gridjs-th:hover .gridjs-resizable::after,
.gridjs-resizable:hover::after {
    background: var(--primary);
}
