/*
   Kisii University Vice Chancellor Portal
   Admin Dashboard specific CSS Stylesheet
*/

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

:root {
    --admin-sidebar-bg: #1e293b;
    --admin-sidebar-hover: #334155;
    --admin-primary: #0b3c5d;
    --admin-secondary: #f5b041;
    --admin-text-dark: #0f172a;
    --admin-bg-light: #f8fafc;
    --admin-border: #e2e8f0;
    --admin-success: #10b981;
    --admin-danger: #ef4444;
    --admin-warning: #f59e0b;
    --font-sans: 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-sans);
    font-size: 0.95rem;
    color: var(--admin-text-dark);
    background-color: var(--admin-bg-light);
    display: flex;
    min-height: 100vh;
}

/* Auth Layout */
.auth-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100vw;
    height: 100vh;
    background: linear-gradient(135deg, #0b3c5d 0%, #061726 100%);
    padding: 1.5rem;
}

.auth-card {
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 8px;
    width: 100%;
    max-width: 420px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    text-align: center;
}

.auth-logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--admin-primary);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
}

.auth-logo-mark {
    width: 76px;
    height: 76px;
    margin: 0 auto 1rem auto;
    padding: 0.45rem;
    border-radius: 12px;
    border: 1px solid var(--admin-border);
    background-color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 8px 18px rgba(11, 60, 93, 0.12);
}

.auth-logo-mark img {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
}

.auth-subtitle {
    font-size: 0.85rem;
    color: #64748b;
    margin-bottom: 2rem;
    font-weight: 500;
}

.auth-form {
    text-align: left;
}

/* Panel Layout */
.admin-sidebar {
    width: 260px;
    background-color: var(--admin-sidebar-bg);
    color: #94a3b8;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #334155;
    text-align: center;
}

.sidebar-logo {
    color: #ffffff;
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.sidebar-logo span {
    color: var(--admin-secondary);
    display: block;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 1px;
}

.sidebar-logo-mark {
    background: #ffffff;
    border-radius: 10px;
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 0.75rem auto;
    padding: 0.35rem;
    box-shadow: 0 6px 14px rgba(0,0,0,0.18);
}

.sidebar-logo-mark img {
    max-height: 100%;
    max-width: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.sidebar-menu {
    list-style: none;
    padding: 1rem 0;
    flex-grow: 1;
    overflow-y: auto;
}

.sidebar-menu a {
    display: flex;
    align-items: center;
    padding: 0.85rem 1.5rem;
    color: #94a3b8;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
    gap: 0.75rem;
}

.sidebar-menu a:hover,
.sidebar-menu li.active a {
    color: #ffffff;
    background-color: var(--admin-sidebar-hover);
}

.sidebar-menu li.active a {
    border-left: 4px solid var(--admin-secondary);
    padding-left: calc(1.5rem - 4px);
}

.sidebar-icon {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #334155;
    font-size: 0.8rem;
}

.admin-main {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

.admin-header {
    height: 70px;
    background-color: #ffffff;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.admin-header-title {
    font-size: 1.25rem;
    font-weight: 700;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.admin-user {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--admin-primary);
}

.admin-content {
    padding: 2rem;
    flex-grow: 1;
    overflow-y: auto;
}

/* Dashboard Widgets */
.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: #ffffff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--admin-border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.stat-details h3 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--admin-primary);
    margin-bottom: 0.25rem;
}

.stat-details p {
    color: #64748b;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: #f1f5f9;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.35rem;
    color: var(--admin-primary);
}

.stat-icon.primary { background-color: rgba(11, 60, 93, 0.1); color: var(--admin-primary); }
.stat-icon.warning { background-color: rgba(245, 176, 65, 0.1); color: #d97706; }
.stat-icon.success { background-color: rgba(16, 185, 129, 0.1); color: var(--admin-success); }
.stat-icon.danger { background-color: rgba(239, 68, 68, 0.1); color: var(--admin-danger); }

/* Panels and Cards */
.admin-card {
    background-color: #ffffff;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.02);
    margin-bottom: 2rem;
}

.admin-card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.admin-card-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--admin-primary);
}

.admin-card-body {
    padding: 1.5rem;
}

/* Forms & UI Controls */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: #334155;
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 0.65rem 0.85rem;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-size: 0.9rem;
    background-color: #ffffff;
    color: var(--admin-text-dark);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 2px rgba(11, 60, 93, 0.15);
}

textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
    margin-top: 1.5rem;
    border-top: 1px solid var(--admin-border);
    padding-top: 1.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.55rem 1.25rem;
    border-radius: 4px;
    font-family: var(--font-sans);
    font-weight: 600;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.15s ease;
    border: none;
    text-decoration: none;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--admin-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: #082d46;
}

.btn-secondary {
    background-color: #64748b;
    color: #ffffff;
}

.btn-secondary:hover {
    background-color: #475569;
}

.btn-success {
    background-color: var(--admin-success);
    color: #ffffff;
}

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

.btn-danger {
    background-color: var(--admin-danger);
    color: #ffffff;
}

.btn-danger:hover {
    background-color: #dc2626;
}

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

/* Tables */
.admin-table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.admin-table th {
    background-color: #f1f5f9;
    padding: 0.85rem 1rem;
    font-weight: 600;
    color: #475569;
    border-bottom: 2px solid var(--admin-border);
}

.admin-table td {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--admin-border);
    color: #334155;
    vertical-align: middle;
}

.admin-table tbody tr:hover {
    background-color: #f8fafc;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-success { background-color: #d1fae5; color: #065f46; }
.badge-warning { background-color: #fef3c7; color: #92400e; }
.badge-danger { background-color: #fee2e2; color: #991b1b; }
.badge-info { background-color: #e0f2fe; color: #075985; }

/* Dashboard Columns */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 1.5rem;
}

/* Image previewer */
.image-preview-box {
    width: 120px;
    height: 120px;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    overflow: hidden;
    margin-top: 0.5rem;
    background-color: #f1f5f9;
}

.image-preview-box.has-smart-preview {
    position: relative;
    background:
        linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
        linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
    background-color: #f8fafc;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
}

.image-preview-box.has-multiple-preview {
    padding: 0.75rem;
}

.multi-image-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
    gap: 0.5rem;
    width: 100%;
    height: calc(100% - 2rem);
    overflow: auto;
}

.multi-image-preview-grid img,
.multi-image-preview-more {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 5px;
    object-fit: cover;
    background-color: #ffffff;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.15);
}

.multi-image-preview-more {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    background-color: rgba(15, 23, 42, 0.78);
    font-weight: 800;
}

.image-preview-box img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.image-preview-box img.smart-preview-image {
    object-fit: contain;
    background-color: rgba(255,255,255,0.72);
}

.image-preview-meta {
    position: absolute;
    left: 0.5rem;
    right: 0.5rem;
    bottom: 0.5rem;
    padding: 0.35rem 0.5rem;
    border-radius: 4px;
    background-color: rgba(15, 23, 42, 0.78);
    color: #ffffff;
    font-size: 0.72rem;
    line-height: 1.2;
    text-align: center;
    pointer-events: none;
}

.logo-preview-box {
    width: 150px;
    height: 110px;
    padding: 0.5rem;
    background-color: #ffffff;
}

.logo-preview-box img {
    object-fit: contain;
}

.page-photo-preview {
    width: 100%;
    height: 240px;
    background-color: #eef2f7;
}

.page-photo-preview img,
.portrait-preview-box img {
    object-fit: contain;
    background-color: #eef2f7;
}

.social-icon-preview-box {
    width: 56px;
    height: 56px;
    padding: 0.55rem;
    background-color: #0b1d2d;
}

.social-icon-preview-box img {
    object-fit: contain;
}

.social-account-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 0.9rem;
}

.social-account-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    gap: 0.8rem;
    padding: 0.85rem;
    border: 1px solid #dbe4ee;
    border-radius: 6px;
    background-color: #f8fafc;
}

.social-account-fields label,
.social-account-icon-cell label {
    margin-top: 0;
}

.social-account-fields input + label {
    margin-top: 0.65rem;
}

.social-account-icon-cell {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.45rem;
}

.social-account-icon-cell .paste-image-target-small {
    margin-top: 0;
}

.social-account-icon-cell .social-icon-preview-box {
    margin-top: 0;
}

.remove-social-account {
    width: 100%;
}

.paste-image-target {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 38px;
    margin-top: 0.55rem;
    padding: 0.55rem 0.75rem;
    border: 1px dashed var(--admin-primary);
    border-radius: 6px;
    background-color: #f8fafc;
    color: var(--admin-primary);
    font-weight: 700;
    font-size: 0.82rem;
    cursor: text;
}

.paste-image-target:focus {
    outline: none;
    border-style: solid;
    box-shadow: 0 0 0 2px rgba(11, 60, 93, 0.15);
    background-color: #ffffff;
}

.paste-image-target-small {
    width: auto;
    min-height: 30px;
    padding: 0.35rem 0.65rem;
    font-size: 0.75rem;
}

.gallery-image-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(74px, 1fr));
    gap: 0.5rem;
    max-height: 172px;
    overflow: auto;
    padding: 0.55rem;
    margin-top: 0.35rem;
    border: 1px solid var(--admin-border);
    border-radius: 6px;
    background-color: #f8fafc;
}

.gallery-image-choice {
    position: relative;
    display: block;
    aspect-ratio: 1;
    border: 2px solid transparent;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    background-color: #ffffff;
}

.gallery-image-choice input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.gallery-image-choice img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    background-color: #ffffff;
}

.gallery-image-choice:has(input:checked) {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 2px rgba(11, 60, 93, 0.16);
}

.gallery-image-choice-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.45rem;
    text-align: center;
    font-size: 0.7rem;
    line-height: 1.2;
    color: #475569;
    border-style: dashed;
}

.landing-template-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
}

.landing-template-option {
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    padding: 1rem;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.landing-template-option:hover,
.landing-template-option.selected {
    border-color: var(--admin-primary);
    box-shadow: 0 0 0 2px rgba(11, 60, 93, 0.12);
}

.landing-template-option input {
    width: auto;
}

.landing-template-option strong {
    color: var(--admin-primary);
}

.landing-template-option small {
    color: #64748b;
    line-height: 1.45;
}

.landing-template-preview {
    height: 140px;
    border-radius: 6px;
    border: 1px solid var(--admin-border);
    background-color: #f8fafc;
    position: relative;
    overflow: hidden;
    display: block;
}

.classic-preview {
    background: linear-gradient(135deg, #0b3c5d 0%, #062235 100%);
}

.classic-preview span:nth-child(1) {
    position: absolute;
    left: 1rem;
    top: 2rem;
    width: 45%;
    height: 12px;
    background-color: #ffffff;
    border-radius: 2px;
}

.classic-preview span:nth-child(2) {
    position: absolute;
    left: 1rem;
    top: 3.4rem;
    width: 34%;
    height: 8px;
    background-color: #cbd5e1;
    border-radius: 2px;
}

.classic-preview span:nth-child(3) {
    position: absolute;
    right: 1rem;
    bottom: 1rem;
    width: 32%;
    height: 88px;
    background-color: #dbeafe;
    border-radius: 6px;
}

.executive-preview {
    background-color: #f1f2f6;
}

.executive-preview span:nth-child(1) {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 26px;
    background-color: #233f91;
}

.executive-preview span:nth-child(2) {
    position: absolute;
    top: 8px;
    left: 50%;
    width: 48px;
    height: 48px;
    transform: translateX(-50%);
    border-radius: 50%;
    background-color: #ffffff;
    border: 4px solid #f8fafc;
}

.executive-preview span:nth-child(3) {
    position: absolute;
    left: 1rem;
    bottom: 0;
    width: 34%;
    height: 82px;
    background-color: #bfdbfe;
    border-radius: 5px 5px 0 0;
}

/* Alert States */
.alert {
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}

.alert-success {
    background-color: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background-color: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* Responsiveness */
@media (max-width: 1024px) {
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
    }
    .social-account-row {
        grid-template-columns: 1fr;
    }
    .admin-sidebar {
        width: 100%;
        height: auto;
    }
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    .landing-template-grid {
        grid-template-columns: 1fr;
    }
}

/* Built-in image editor */
.image-editor-launch {
    margin-top: 0.65rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.image-editor-launch[hidden] {
    display: none !important;
}

.image-editor-launch.image-editor-complete {
    border-color: var(--admin-success);
    color: #047857;
    background: #ecfdf5;
}

body.image-editor-open {
    overflow: hidden;
}

.image-editor-modal {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: rgba(2, 6, 23, 0.82);
    backdrop-filter: blur(4px);
}

.image-editor-modal.is-open {
    display: flex;
}

.image-editor-dialog {
    width: min(1180px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 24px 70px rgba(0, 0, 0, 0.42);
}

.image-editor-header,
.image-editor-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--admin-border);
}

.image-editor-header strong {
    display: block;
    font-size: 1.05rem;
    color: var(--admin-primary);
}

.image-editor-header small {
    display: block;
    margin-top: 0.15rem;
    color: #64748b;
}

.image-editor-footer {
    justify-content: flex-end;
    border-top: 1px solid var(--admin-border);
    border-bottom: 0;
}

.image-editor-close {
    width: 38px;
    height: 38px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: #0f172a;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.image-editor-close:hover {
    background: #e2e8f0;
}

.image-editor-body {
    min-height: 0;
    overflow: auto;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 260px;
    gap: 1rem;
    padding: 1rem;
    background: #f8fafc;
}

.image-editor-stage-shell {
    min-height: 300px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    border-radius: 8px;
    background:
        linear-gradient(45deg, #dbe3ec 25%, transparent 25%),
        linear-gradient(-45deg, #dbe3ec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #dbe3ec 75%),
        linear-gradient(-45deg, transparent 75%, #dbe3ec 75%),
        #eef2f7;
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    padding: 1rem;
}

.image-editor-stage {
    position: relative;
    flex: 0 0 auto;
    line-height: 0;
    overflow: hidden;
    box-shadow: 0 10px 26px rgba(15, 23, 42, 0.2);
}

.image-editor-canvas {
    display: block;
    max-width: none;
    background: transparent;
}

.image-editor-crop-box {
    position: absolute;
    z-index: 3;
    cursor: move;
    border: 2px solid #ffffff;
    outline: 1px solid rgba(15, 23, 42, 0.75);
    box-shadow: 0 0 0 9999px rgba(2, 6, 23, 0.58);
    touch-action: none;
}

.image-editor-crop-box::before,
.image-editor-crop-box::after {
    content: '';
    position: absolute;
    pointer-events: none;
}

.image-editor-crop-box::before {
    left: 33.333%;
    right: 33.333%;
    top: 0;
    bottom: 0;
    border-left: 1px solid rgba(255,255,255,0.58);
    border-right: 1px solid rgba(255,255,255,0.58);
}

.image-editor-crop-box::after {
    top: 33.333%;
    bottom: 33.333%;
    left: 0;
    right: 0;
    border-top: 1px solid rgba(255,255,255,0.58);
    border-bottom: 1px solid rgba(255,255,255,0.58);
}

.crop-handle {
    position: absolute;
    z-index: 4;
    width: 16px;
    height: 16px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: var(--admin-secondary);
    box-shadow: 0 1px 4px rgba(0,0,0,0.4);
}

.crop-handle-nw { left: -9px; top: -9px; cursor: nwse-resize; }
.crop-handle-ne { right: -9px; top: -9px; cursor: nesw-resize; }
.crop-handle-sw { left: -9px; bottom: -9px; cursor: nesw-resize; }
.crop-handle-se { right: -9px; bottom: -9px; cursor: nwse-resize; }

.image-editor-controls {
    align-self: start;
    padding: 1rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #ffffff;
}

.image-editor-control-group {
    margin-bottom: 1rem;
}

.image-editor-control-group select {
    width: 100%;
}

.image-editor-tool-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

.image-editor-tool-grid button {
    width: 100%;
    padding: 0.65rem 0.75rem;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    background: #ffffff;
    color: #0f172a;
    text-align: left;
    font-weight: 600;
    cursor: pointer;
}

.image-editor-tool-grid button:hover {
    border-color: var(--admin-primary);
    color: var(--admin-primary);
    background: #f8fafc;
}

.image-editor-help,
.image-editor-status {
    margin-top: 1rem;
    font-size: 0.78rem;
    line-height: 1.45;
    color: #64748b;
}

.image-editor-status {
    min-height: 1.2rem;
    font-weight: 600;
    color: var(--admin-primary);
}

@media (max-width: 860px) {
    .image-editor-dialog {
        max-height: calc(100vh - 1rem);
    }

    .image-editor-body {
        grid-template-columns: 1fr;
    }

    .image-editor-controls {
        width: 100%;
    }

    .image-editor-tool-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .image-editor-stage-shell {
        min-height: 240px;
    }
}

@media (max-width: 520px) {
    .image-editor-modal {
        padding: 0.35rem;
    }

    .image-editor-header,
    .image-editor-footer {
        padding: 0.8rem;
    }

    .image-editor-body {
        padding: 0.6rem;
    }

    .image-editor-tool-grid {
        grid-template-columns: 1fr;
    }

    .image-editor-footer .btn {
        flex: 1;
    }
}

/* Fixed save control for long content-editing forms */
.admin-content.has-floating-save {
    padding-bottom: 7.5rem;
}

.floating-save-panel {
    position: fixed;
    right: 1.5rem;
    bottom: 1.5rem;
    z-index: 1200;
    min-width: 300px;
    padding: 0.75rem;
    border: 1px solid rgba(148, 163, 184, 0.55);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.97);
    box-shadow: 0 14px 38px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.85rem;
}

.floating-save-state {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 700;
    white-space: nowrap;
}

.floating-save-dot {
    width: 9px;
    height: 9px;
    flex: 0 0 9px;
    border-radius: 50%;
    background: #94a3b8;
    box-shadow: 0 0 0 4px rgba(148, 163, 184, 0.15);
}

.floating-save-panel[data-state="dirty"] .floating-save-dot {
    background: #f59e0b;
    box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.16);
}

.floating-save-panel[data-state="saving"] .floating-save-dot {
    background: #0b3c5d;
    box-shadow: 0 0 0 4px rgba(11, 60, 93, 0.16);
    animation: floating-save-pulse 1s ease-in-out infinite;
}

.floating-save-panel[data-state="saved"] .floating-save-dot,
.floating-save-panel[data-state="clean"] .floating-save-dot {
    background: #10b981;
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.16);
}

.floating-save-panel[data-state="error"] .floating-save-dot {
    background: #ef4444;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.16);
}

.floating-save-button {
    min-width: 165px;
    white-space: nowrap;
    box-shadow: 0 7px 18px rgba(11, 60, 93, 0.22);
}

@keyframes floating-save-pulse {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.2); opacity: 0.6; }
}

@media (max-width: 720px) {
    .admin-content.has-floating-save {
        padding-bottom: 8.5rem;
    }

    .floating-save-panel {
        left: 0.75rem;
        right: 0.75rem;
        bottom: 0.75rem;
        min-width: 0;
    }

    .floating-save-button {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 440px) {
    .floating-save-panel {
        align-items: stretch;
        flex-direction: column;
        gap: 0.55rem;
    }

    .floating-save-state {
        justify-content: center;
    }

    .floating-save-button {
        width: 100%;
    }
}

/* User accounts and granular permissions */
.sidebar-message-link {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.sidebar-menu-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

.sidebar-count {
    margin-left: 0.5rem;
    font-size: 0.7rem;
    padding: 0.15rem 0.4rem;
}

.sidebar-role {
    display: block;
    margin-top: 0.35rem;
    color: #94a3b8;
    font-size: 0.7rem;
    font-weight: 600;
}

.permission-fieldset {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
}

.permission-fieldset[disabled] {
    opacity: 0.78;
}

.permission-fieldset[disabled] input,
.permission-fieldset[disabled] textarea,
.permission-fieldset[disabled] select,
.permission-fieldset[disabled] button {
    cursor: not-allowed;
}

.permission-mode-notice {
    margin-bottom: 1.25rem;
}

.admin-card-subtitle {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
    font-weight: 400;
}

.empty-state {
    color: #64748b;
    text-align: center;
    padding: 2rem 0;
}

.table-muted {
    color: #64748b;
    font-size: 0.78rem;
}

.table-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.inline-form {
    display: inline;
    margin: 0;
}

.permission-summary-cell {
    min-width: 260px;
    max-width: 520px;
    font-size: 0.82rem;
    line-height: 1.55;
    color: #475569;
}

.user-editor-card {
    scroll-margin-top: 1rem;
}

.user-account-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 1.5rem;
}

.user-active-control {
    display: flex;
    flex-direction: column;
}

.toggle-check,
.permission-check {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    min-height: 44px;
    cursor: pointer;
}

.toggle-check input,
.permission-check input {
    width: 18px;
    height: 18px;
    accent-color: var(--admin-primary);
}

.permissions-editor {
    margin-top: 1.25rem;
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    overflow: hidden;
}

.permissions-editor-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--admin-border);
}

.permissions-editor-head h4 {
    margin: 0 0 0.25rem;
    color: var(--admin-primary);
}

.permissions-editor-head p {
    margin: 0;
    color: #64748b;
    font-size: 0.8rem;
}

.permission-presets {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
}

.permission-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1fr) 130px 130px;
    align-items: stretch;
}

.permission-grid > * {
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--admin-border);
}

.permission-grid > *:nth-last-child(-n+3) {
    border-bottom: 0;
}

.permission-grid-header {
    background: #eef2f7;
    color: #334155;
    font-size: 0.75rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.permission-module {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.permission-module strong {
    color: #1e293b;
    font-size: 0.88rem;
}

.permission-module span {
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.4;
}

.permission-check {
    justify-content: center;
    border-left: 1px solid var(--admin-border);
    font-weight: 700;
    color: #334155;
}

.settings-layout {
    display: grid;
    grid-template-columns: minmax(0, 600px) minmax(300px, 420px);
    align-items: start;
    gap: 1.5rem;
}

.account-type-panel {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: #f8fafc;
    color: #64748b;
    font-size: 0.82rem;
}

.account-type-panel strong {
    color: var(--admin-primary);
}

.form-divider {
    border: 0;
    border-top: 1px solid var(--admin-border);
    margin: 2rem 0;
}

.form-section-title {
    margin-bottom: 0.45rem;
    color: var(--admin-primary);
}

.form-help {
    color: #64748b;
    font-size: 0.83rem;
    line-height: 1.55;
    margin-bottom: 1.25rem;
}

.user-management-promo .admin-card-body {
    text-align: center;
    padding: 2rem;
}

.promo-icon,
.restricted-welcome-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.user-management-promo h4,
.restricted-welcome-card h3 {
    margin: 0 0 0.65rem;
    color: var(--admin-primary);
}

.user-management-promo p,
.restricted-welcome-card p {
    color: #64748b;
    line-height: 1.6;
    margin: 0 0 1.25rem;
}

.restricted-welcome-card .admin-card-body {
    text-align: center;
    padding: 3rem 1.5rem;
}

.dashboard-actions {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.dashboard-actions .btn {
    justify-content: flex-start;
    text-align: left;
    width: 100%;
}

@media (max-width: 1050px) {
    .settings-layout {
        grid-template-columns: 1fr;
    }

    .account-settings-card,
    .user-management-promo {
        max-width: none;
    }
}

@media (max-width: 780px) {
    .user-account-grid {
        grid-template-columns: 1fr;
    }

    .permissions-editor-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .permission-grid {
        grid-template-columns: minmax(170px, 1fr) 82px 82px;
    }

    .permission-grid > * {
        padding: 0.75rem 0.6rem;
    }

    .permission-check {
        flex-direction: column;
        gap: 0.25rem;
        font-size: 0.72rem;
    }
}

@media (max-width: 520px) {
    .permission-grid {
        grid-template-columns: minmax(130px, 1fr) 68px 68px;
    }

    .permission-module span {
        display: none;
    }

    .permission-presets {
        width: 100%;
    }

    .permission-presets .btn {
        flex: 1;
    }
}

/* Non-blocking upload warnings: text/database changes were committed while the old file was kept. */
.alert-warning {
    background: #fff7ed;
    border: 1px solid #fdba74;
    color: #9a3412;
}

/* Inquiry workflow: category filters, email replies, and recycle bin. */
.inquiry-filter-bar {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

.inquiry-filter-tab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 62px;
    padding: 0.9rem 1rem;
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    background: #ffffff;
    color: #475569;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.03);
    transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.inquiry-filter-tab:hover {
    transform: translateY(-1px);
    border-color: #94a3b8;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.07);
}

.inquiry-filter-tab strong {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 34px;
    height: 28px;
    padding: 0 0.55rem;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--admin-primary);
    font-size: 0.82rem;
}

.inquiry-filter-tab.active {
    border-color: var(--admin-primary);
    background: var(--admin-primary);
    color: #ffffff;
}

.inquiry-filter-tab.active strong {
    background: #ffffff;
    color: var(--admin-primary);
}

.inquiry-card-heading {
    align-items: flex-start;
    gap: 1rem;
}

.inquiry-card-help {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.82rem;
    line-height: 1.5;
}

.inline-action-form {
    display: inline-flex;
    margin: 0;
}

.inquiry-table-wrapper {
    overflow: visible;
}

.inquiry-table {
    table-layout: auto;
}

.inquiry-summary-row {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.inquiry-summary-row.is-unread {
    background: #fffbeb;
    font-weight: 600;
}

.inquiry-summary-row.is-trashed {
    background: #fff7f7;
    color: #64748b;
}

.inquiry-summary-row.is-open {
    outline: 2px solid rgba(11, 60, 93, 0.12);
    outline-offset: -2px;
}

.inquiry-email {
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    text-decoration: none;
    word-break: break-all;
}

.inquiry-email:hover {
    color: var(--admin-primary);
    text-decoration: underline;
}

.inquiry-reference {
    display: block;
    margin-top: 0.25rem;
    color: #64748b;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.deleted-time {
    display: block;
    margin-top: 0.25rem;
    color: #b91c1c;
    font-size: 0.72rem;
}

.reply-count-badge {
    display: inline-flex;
    margin-top: 0.35rem;
    padding: 0.2rem 0.5rem;
    border-radius: 999px;
    background: #ede9fe;
    color: #6d28d9;
    font-size: 0.68rem;
    font-weight: 800;
    white-space: nowrap;
}

.inquiry-row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem;
}

.message-detail-row > td {
    padding: 0 !important;
    background: #f8fafc;
}

.inquiry-detail-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.9fr);
    gap: 1.25rem;
    padding: 1.5rem;
}

.inquiry-message-panel,
.inquiry-reply-panel,
.inquiry-reply-history {
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    background: #ffffff;
}

.inquiry-message-panel,
.inquiry-reply-panel {
    padding: 1.25rem;
}

.inquiry-detail-title-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1rem;
}

.inquiry-detail-title-row h4,
.inquiry-reply-panel h4,
.inquiry-reply-history h4 {
    margin: 0;
    color: var(--admin-primary);
}

.detail-close-button {
    appearance: none;
    border: 0;
    background: transparent;
    color: #64748b;
    font-size: 1.7rem;
    line-height: 1;
    cursor: pointer;
}

.detail-close-button:hover {
    color: #0f172a;
}

.inquiry-meta-list {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
    margin: 0 0 1rem;
}

.inquiry-meta-list > div {
    padding: 0.7rem 0.8rem;
    border-radius: 8px;
    background: #f8fafc;
}

.inquiry-meta-list dt {
    margin-bottom: 0.25rem;
    color: #64748b;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.inquiry-meta-list dd {
    margin: 0;
    color: #1e293b;
    font-size: 0.8rem;
    line-height: 1.45;
    word-break: break-word;
}

.inquiry-original-message {
    padding: 1rem;
    border-left: 4px solid var(--admin-primary);
    border-radius: 0 8px 8px 0;
    background: #f8fafc;
    color: #334155;
    font-size: 0.92rem;
    line-height: 1.7;
    white-space: normal;
}

.inquiry-reply-panel > p {
    margin: 0.5rem 0 1rem;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.55;
}

.inquiry-reply-form textarea {
    resize: vertical;
    min-height: 150px;
}

.inquiry-send-reply-button {
    width: 100%;
    justify-content: center;
}

.inquiry-send-reply-button:disabled {
    opacity: 0.65;
    cursor: wait;
}

.view-only-note {
    padding: 0.8rem 1rem;
    border-radius: 8px;
    background: #f1f5f9;
    color: #475569 !important;
}

.inquiry-reply-history {
    margin: 0 1.5rem 1.5rem;
    overflow: hidden;
}

.reply-history-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--admin-border);
    background: #f8fafc;
}

.reply-history-heading span {
    color: #64748b;
    font-size: 0.75rem;
    font-weight: 700;
}

.reply-history-empty {
    margin: 0;
    padding: 1.2rem;
    color: #64748b;
    text-align: center;
}

.reply-history-item {
    padding: 1rem 1.15rem;
    border-bottom: 1px solid var(--admin-border);
}

.reply-history-item:last-child {
    border-bottom: 0;
}

.reply-history-item.is-sent {
    border-left: 4px solid var(--admin-success);
}

.reply-history-item.is-failed {
    border-left: 4px solid var(--admin-danger);
    background: #fff7f7;
}

.reply-history-meta {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
}

.reply-history-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0.5rem;
    flex-shrink: 0;
}

.reply-delete-form {
    margin: 0;
}

.reply-delete-button {
    white-space: nowrap;
}

.reply-history-to,
.reply-delivery-detail,
.reply-delivery-error {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.5;
}

.reply-history-body {
    margin-top: 0.8rem;
    color: #334155;
    font-size: 0.86rem;
    line-height: 1.6;
}

.reply-delivery-error {
    color: #b91c1c;
}

.inquiry-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    min-height: 190px;
    color: #64748b;
    text-align: center;
}

.inquiry-empty-icon {
    font-size: 2rem;
}

@media (max-width: 1180px) {
    .inquiry-filter-bar {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .inquiry-detail-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .reply-history-meta {
        flex-direction: column;
        align-items: stretch;
    }

    .reply-history-actions {
        justify-content: flex-start;
    }
}

@media (max-width: 900px) {
    .inquiry-table thead {
        display: none;
    }

    .inquiry-table,
    .inquiry-table tbody,
    .inquiry-table tr,
    .inquiry-table td {
        display: block;
        width: 100%;
    }

    .inquiry-summary-row {
        margin-bottom: 0.9rem;
        border: 1px solid var(--admin-border);
        border-radius: 10px;
        overflow: hidden;
    }

    .inquiry-summary-row td {
        display: grid;
        grid-template-columns: 110px minmax(0, 1fr);
        gap: 0.75rem;
        align-items: start;
        border-bottom: 1px solid #eef2f7;
    }

    .inquiry-summary-row td:last-child {
        border-bottom: 0;
    }

    .inquiry-summary-row td::before {
        content: attr(data-label);
        color: #64748b;
        font-size: 0.7rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.04em;
    }

    .message-detail-row {
        margin: -0.45rem 0 1rem;
    }

    .message-detail-row > td {
        display: block;
        border: 0;
    }

    .inquiry-detail-grid {
        padding: 1rem;
    }

    .inquiry-reply-history {
        margin: 0 1rem 1rem;
    }
}

@media (max-width: 620px) {
    .inquiry-filter-bar {
        grid-template-columns: 1fr 1fr;
        gap: 0.55rem;
    }

    .inquiry-filter-tab {
        min-height: 54px;
        padding: 0.75rem;
        font-size: 0.78rem;
    }

    .inquiry-card-heading {
        flex-direction: column;
    }

    .inquiry-meta-list {
        grid-template-columns: 1fr;
    }

    .inquiry-summary-row td {
        grid-template-columns: 86px minmax(0, 1fr);
        padding: 0.75rem;
    }

    .inquiry-row-actions {
        align-items: stretch;
        flex-direction: column;
    }

    .inquiry-row-actions .inline-action-form,
    .inquiry-row-actions .btn {
        width: 100%;
    }

    .inquiry-row-actions .btn {
        justify-content: center;
    }

    .reply-history-meta {
        flex-direction: column;
        gap: 0.45rem;
    }
}

/* Reply delivery fallback for hosts that reject outgoing mail as spam. */
.host-mail-warning {
    margin: 0 0 18px;
    padding: 14px 16px;
    border: 1px solid #f1c27d;
    border-left: 4px solid #d97706;
    border-radius: 8px;
    background: #fff8eb;
    color: #713f12;
    line-height: 1.55;
}

.host-mail-warning strong {
    display: block;
    margin-bottom: 3px;
}

.reply-fallback-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.reply-fallback-actions .btn {
    text-decoration: none;
}

@media (max-width: 640px) {
    .reply-fallback-actions {
        flex-direction: column;
    }

    .reply-fallback-actions .btn {
        width: 100%;
        text-align: center;
    }
}

/* =========================================================
   Sticky portal navigation and header
   ========================================================= */
html {
    min-height: 100%;
}

body {
    align-items: flex-start;
}

.admin-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    min-height: 100vh;
    overflow: hidden;
    z-index: 300;
}

.sidebar-menu {
    min-height: 0;
    overscroll-behavior: contain;
}

.admin-main {
    min-width: 0;
}

.admin-header {
    position: sticky;
    top: 0;
    z-index: 250;
    box-shadow: 0 2px 12px rgba(15, 23, 42, 0.05);
}

@media (max-width: 768px) {
    body {
        align-items: stretch;
    }

    .admin-sidebar {
        position: relative;
        top: auto;
        width: 100%;
        height: auto;
        min-height: 0;
        overflow: visible;
    }

    .admin-header {
        top: 0;
    }
}

/* =========================================================
   My Portal themed dialogs
   ========================================================= */
body.portal-modal-open {
    overflow: hidden;
}

.portal-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.portal-modal.is-open {
    display: flex;
}

.portal-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.72);
    backdrop-filter: blur(5px);
    animation: portal-modal-fade 0.18s ease-out;
}

.portal-modal-dialog {
    position: relative;
    width: min(620px, 100%);
    max-height: calc(100vh - 2rem);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(148, 163, 184, 0.35);
    border-radius: 16px;
    background: #ffffff;
    box-shadow: 0 30px 90px rgba(2, 6, 23, 0.42);
    animation: portal-modal-rise 0.2s ease-out;
}

.portal-modal-accent {
    height: 6px;
    flex: 0 0 6px;
    background: linear-gradient(90deg, var(--admin-primary), #176b96, var(--admin-secondary));
}

.portal-modal-danger .portal-modal-accent {
    background: linear-gradient(90deg, #991b1b, var(--admin-danger), #fb7185);
}

.portal-modal-warning .portal-modal-accent {
    background: linear-gradient(90deg, #b45309, var(--admin-warning), #fcd34d);
}

.portal-modal-success .portal-modal-accent {
    background: linear-gradient(90deg, #047857, var(--admin-success), #6ee7b7);
}

.portal-modal-header {
    display: grid;
    grid-template-columns: 48px minmax(0, 1fr) 38px;
    align-items: start;
    gap: 0.9rem;
    padding: 1.25rem 1.3rem 1rem;
    border-bottom: 1px solid var(--admin-border);
}

.portal-modal-icon {
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(11, 60, 93, 0.11);
    color: var(--admin-primary);
    font-size: 1.2rem;
    font-weight: 900;
    box-shadow: inset 0 0 0 1px rgba(11, 60, 93, 0.12);
}

.portal-modal-danger .portal-modal-icon {
    background: #fee2e2;
    color: #b91c1c;
    box-shadow: inset 0 0 0 1px #fecaca;
}

.portal-modal-warning .portal-modal-icon {
    background: #fef3c7;
    color: #b45309;
    box-shadow: inset 0 0 0 1px #fde68a;
}

.portal-modal-success .portal-modal-icon {
    background: #d1fae5;
    color: #047857;
    box-shadow: inset 0 0 0 1px #a7f3d0;
}

.portal-modal-heading h3 {
    margin: 0;
    color: var(--admin-primary);
    font-size: 1.08rem;
    line-height: 1.35;
}

.portal-modal-danger .portal-modal-heading h3 {
    color: #991b1b;
}

.portal-modal-heading p {
    margin: 0.35rem 0 0;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.55;
}

.portal-modal-close {
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 50%;
    background: #f1f5f9;
    color: #334155;
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}

.portal-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.portal-modal-body {
    min-height: 0;
    overflow: auto;
    padding: 1.15rem 1.3rem;
    color: #334155;
    line-height: 1.6;
}

.portal-modal-body[hidden] {
    display: none;
}

.portal-modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.7rem;
    padding: 1rem 1.3rem 1.2rem;
    border-top: 1px solid var(--admin-border);
    background: #f8fafc;
}

.portal-modal-footer .btn {
    min-width: 112px;
}

.portal-copy-panel p {
    margin: 0 0 0.75rem;
    color: #64748b;
}

.portal-copy-area {
    width: 100%;
    min-height: 240px;
    resize: vertical;
    padding: 0.9rem;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    background: #f8fafc;
    color: #0f172a;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.82rem;
    line-height: 1.5;
}

@keyframes portal-modal-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes portal-modal-rise {
    from { opacity: 0; transform: translateY(14px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 560px) {
    .portal-modal {
        padding: 0.55rem;
    }

    .portal-modal-dialog {
        max-height: calc(100vh - 1.1rem);
        border-radius: 12px;
    }

    .portal-modal-header {
        grid-template-columns: 40px minmax(0, 1fr) 34px;
        gap: 0.7rem;
        padding: 1rem;
    }

    .portal-modal-icon {
        width: 40px;
        height: 40px;
    }

    .portal-modal-body {
        padding: 1rem;
    }

    .portal-modal-footer {
        padding: 0.85rem 1rem 1rem;
        flex-direction: column-reverse;
    }

    .portal-modal-footer .btn {
        width: 100%;
    }
}

/* =========================================================
   Audit log page
   ========================================================= */
.audit-summary-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.audit-summary-card {
    padding: 1.15rem 1.25rem;
    border: 1px solid var(--admin-border);
    border-radius: 10px;
    background: #ffffff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.audit-summary-card span {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.audit-summary-card strong {
    display: block;
    margin-top: 0.35rem;
    color: var(--admin-primary);
    font-size: 1.7rem;
}

.audit-filter-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.8fr) repeat(4, minmax(145px, 1fr)) repeat(2, minmax(145px, 1fr)) auto;
    align-items: end;
    gap: 0.8rem;
}

.audit-filter-form .form-group {
    margin-bottom: 0;
}

.audit-filter-actions {
    display: flex;
    align-items: flex-end;
}

.audit-filter-actions .btn {
    min-height: 40px;
    white-space: nowrap;
}

.audit-log-table {
    min-width: 1050px;
}

.audit-table-subtext {
    display: block;
    margin-top: 0.2rem;
    color: #64748b;
    font-size: 0.73rem;
}

.audit-action-badge,
.audit-status {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 800;
    white-space: nowrap;
}

.audit-action-badge {
    background: #e0f2fe;
    color: #075985;
}

.audit-status-success {
    background: #d1fae5;
    color: #065f46;
}

.audit-status-failed {
    background: #fee2e2;
    color: #991b1b;
}

.audit-status-warning {
    background: #fef3c7;
    color: #92400e;
}

.audit-description-cell {
    min-width: 280px;
    max-width: 480px;
    line-height: 1.45;
}

.audit-empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: #64748b;
}

.audit-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    margin-top: 1.25rem;
    color: #475569;
    font-weight: 700;
}

.audit-detail-template {
    width: 100%;
}

.audit-detail-meta-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.7rem;
}

.audit-detail-meta-grid > div {
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #f8fafc;
}

.audit-detail-meta-grid span {
    display: block;
    color: #64748b;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.audit-detail-meta-grid strong {
    display: block;
    margin-top: 0.15rem;
    color: #1e293b;
    font-size: 0.82rem;
    word-break: break-word;
}

.audit-detail-description,
.audit-user-agent {
    margin-top: 1rem;
    padding: 0.85rem;
    border-left: 4px solid var(--admin-primary);
    border-radius: 0 8px 8px 0;
    background: #f8fafc;
}

.audit-detail-description p,
.audit-user-agent p {
    margin: 0.35rem 0 0;
    word-break: break-word;
}

.audit-change-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

.audit-change-grid section {
    min-width: 0;
}

.audit-change-grid h4 {
    margin: 0 0 0.45rem;
    color: var(--admin-primary);
    font-size: 0.86rem;
}

.audit-change-grid pre {
    max-height: 300px;
    overflow: auto;
    margin: 0;
    padding: 0.8rem;
    border: 1px solid var(--admin-border);
    border-radius: 8px;
    background: #0f172a;
    color: #e2e8f0;
    font-family: Consolas, Monaco, monospace;
    font-size: 0.72rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.permission-readonly {
    cursor: default;
    color: #64748b;
    background: #f8fafc;
}

@media (max-width: 1300px) {
    .audit-filter-form {
        grid-template-columns: repeat(4, minmax(150px, 1fr));
    }

    .audit-search-field {
        grid-column: span 2;
    }
}

@media (max-width: 900px) {
    .audit-summary-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .audit-filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .audit-search-field {
        grid-column: span 2;
    }

    .audit-filter-actions {
        grid-column: span 2;
    }

    .audit-filter-actions .btn {
        width: 100%;
    }
}

@media (max-width: 560px) {
    .audit-summary-grid,
    .audit-filter-form,
    .audit-detail-meta-grid,
    .audit-change-grid {
        grid-template-columns: 1fr;
    }

    .audit-search-field,
    .audit-filter-actions {
        grid-column: auto;
    }
}

.portal-modal-dialog:has(.audit-detail-template) {
    width: min(1040px, 100%);
}
