/* Global Styles */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background: #0f1117;
    color: #e2e8f0;
    min-height: 100vh;
}

/* Navbar */
.navbar {
    background: rgba(255, 255, 255, 0.04);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding: 0.9rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
    backdrop-filter: blur(10px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
}

.brand-icon {
    font-size: 1.4rem;
}

.nav-user {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-role-badge {
    background: rgba(99, 102, 241, 0.25);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.4);
    border-radius: 20px;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 8px;
    padding: 0.4rem 0.9rem;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    font-weight: 500;
    transition: background 0.2s;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.3);
}

/* Layout & Containers */
.container {
    margin: 0 auto;
    padding: 2rem 4rem;
}

.edit-container,
.create-container {
    max-width: 600px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.75rem;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

.page-header h1 span {
    color: #818cf8;
}

.search-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.search-bar-form {
    width: 80% !important;
    /* Overriding default flex:1 if needed */
}

.search-select {
    padding: 0.55rem 1rem !important;
    width: auto !important;
    background: rgba(255, 255, 255, 0.08) !important;
}

.total-records-badge {
    font-size: 0.875rem;
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.55rem 1rem;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
}

/* Forms & Cards */
.card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

input::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

select option {
    background: #1e1e2e;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.75rem;
}

.hint {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
    margin-top: 0.35rem;
}

.username-display {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.95rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    border: none;
    border-radius: 10px;
    padding: 0.7rem 1.25rem;
    font-size: 0.95rem;
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s, transform 0.1s;
}

.btn:hover {
    opacity: 0.85;
    transform: translateY(-1px);
}

.btn-primary {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.btn-warning {
    background: rgba(251, 191, 36, 0.2);
    color: #fcd34d;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-info {
    background: rgba(56, 189, 248, 0.15);
    color: #7dd3fc;
    border: 1px solid rgba(56, 189, 248, 0.3);
}

.btn-unread {
    position: relative;
    border-color: #818cf8 !important;
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.3);
    animation: pulse-unread 2.5s infinite;
}

.btn-unread::after {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 9px;
    height: 9px;
    background: #ff0000;
    border: 2px solid #0f1117;
    border-radius: 50%;
    z-index: 2;
}

@keyframes pulse-unread {
    0% {
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0.4);
    }

    70% {
        box-shadow: 0 0 0 8px rgba(129, 140, 248, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(129, 140, 248, 0);
    }
}

.btn-sm {
    padding: 0.38rem 0.75rem;
    font-size: 0.8rem;
    border-radius: 7px;
    font-weight: 500;
}

/* Alerts */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

.alert-success {
    background: rgba(34, 197, 94, 0.15);
    border: 1px solid rgba(34, 197, 94, 0.3);
    color: #86efac;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

/* Tables */
.table-wrapper {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 16px;
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

thead tr {
    background: rgba(255, 255, 255, 0.05);
}

th {
    padding: 0.9rem 1.25rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(255, 255, 255, 0.4);
}

td {
    padding: 0.9rem 1.25rem;
    font-size: 0.9rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.03);
}

.actions {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}

.date-text {
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.8rem;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: rgba(255, 255, 255, 0.3);
}

/* Login Page Specific */
.login-body {
    background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: rgba(255, 255, 255, 0.07);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 20px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
}

.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.login-header .logo {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.login-header h1 {
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
}

.login-header p {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

.btn-login {
    width: 100%;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    margin-top: 0.5rem;
    transition: opacity 0.2s, transform 0.15s;
}

.btn-login:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-login:active {
    transform: translateY(0);
}

/* Nav Links */
.nav-links {
    width: 100%;
    padding: 0 3rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    margin: 0 1rem;
}

.nav-link {
    color: rgba(255, 255, 255, 0.55);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.4rem 0.75rem;
    border-radius: 8px;
    transition: background 0.2s, color 0.2s;
}

.nav-link:hover,
.nav-link.active {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

/* Header actions group */
.header-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

/* Textarea */
textarea {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

/* Form Grid (2 cols) */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem 1.25rem;
}

.form-group-full {
    grid-column: 1 / -1;
}

/* Search Bar */
.search-bar {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.search-bar input {
    flex: 1;
    max-width: 380px;
    padding: 0.55rem 1rem;
    font-size: 0.875rem;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    justify-content: center;
}

.pagination-numbers {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s;
}

.page-link:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: rgba(99, 102, 241, 0.4);
    color: #a5b4fc;
    transform: translateY(-1px);
}

.page-link.active {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.pagination-info {
    color: rgba(255, 255, 255, 0.35);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    z-index: 200;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.modal-overlay.show {
    display: flex;
}

.modal-dialog {
    background: #1a1f2e;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 18px;
    width: 100%;
    max-width: 540px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.6);
    animation: modalIn 0.2s ease-out;
}

.modal-lg {
    max-width: 820px;
}

@keyframes modalIn {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.97);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.modal-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.4);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.15s, color 0.15s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.modal-body {
    padding: 1.5rem;
}

.modal-loading,
.modal-error {
    text-align: center;
    padding: 2rem;
    color: rgba(255, 255, 255, 0.4);
    font-size: 0.9rem;
}

.modal-error {
    color: #fca5a5;
}

/* Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.detail-row {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-row-full {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: rgba(255, 255, 255, 0.35);
}

.detail-value {
    font-size: 0.9rem;
    color: #e2e8f0;
    word-break: break-all;
}

.monospace {
    font-family: 'Courier New', monospace;
    font-size: 0.82rem;
    color: #a5b4fc;
}

/* CSV Upload Panel */
.csv-upload-panel {
    background: rgba(99, 102, 241, 0.06);
    border: 1px dashed rgba(99, 102, 241, 0.3);
    border-radius: 12px;
    padding: 1rem 1.25rem;
    margin-bottom: 1.25rem;
}

.csv-upload-inner {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: center;
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
}

.csv-actions {
    display: flex;
    gap: 0.5rem;
}

/* CSV Preview */
.csv-summary {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.25rem;
}

.csv-stat {
    font-size: 0.875rem;
    color: rgba(255, 255, 255, 0.5);
}

.csv-stat-valid {
    color: #86efac;
}

.csv-stat-invalid {
    color: #fca5a5;
}

.csv-row-invalid td {
    background: rgba(239, 68, 68, 0.06) !important;
}

.csv-error-msg {
    color: #fca5a5;
    font-size: 0.8rem;
}

/* Permission Badges */
.perm-badge {
    display: inline-block;
    border-radius: 20px;
    padding: 0.2rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 600;
}

.perm-edit {
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    border: 1px solid rgba(99, 102, 241, 0.35);
}

.perm-view {
    background: rgba(148, 163, 184, 0.15);
    color: #cbd5e1;
    border: 1px solid rgba(148, 163, 184, 0.25);
}

/* Action Badges (History) */
.action-badge {
    display: inline-block;
    border-radius: 6px;
    padding: 0.2rem 0.6rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.action-CREATE {
    background: rgba(34, 197, 94, 0.15);
    color: #86efac;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.action-UPDATE {
    background: rgba(251, 191, 36, 0.15);
    color: #fcd34d;
    border: 1px solid rgba(251, 191, 36, 0.3);
}

.action-DELETE {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

/* Diff display */
.diff-list {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.diff-item {
    font-size: 0.78rem;
    display: flex;
    gap: 0.3rem;
    flex-wrap: wrap;
    align-items: center;
}

.diff-field {
    color: rgba(255, 255, 255, 0.4);
    font-weight: 600;
}

.diff-old {
    color: #fca5a5;
    text-decoration: line-through;
    word-break: break-all;
}

.diff-arrow {
    color: rgba(255, 255, 255, 0.3);
}

.diff-new {
    color: #86efac;
    word-break: break-all;
}

/* Snapshot box */
.snapshot-box {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.75rem;
    font-family: monospace;
    color: #a5b4fc;
    max-width: 340px;
    max-height: 200px;
    overflow: auto;
    margin-top: 0.4rem;
    white-space: pre;
}

input[type="date"] {
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    color: #fff;
    font-size: 0.95rem;
    font-family: 'Inter', sans-serif;
    outline: none;
    color-scheme: dark;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input[type="date"]:focus {
    border-color: #818cf8;
    box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.2);
}

.modal-footer {
    padding: 1rem;
}

