/* ==========================================================================
   LankaAds Support — Production Mobile-First Stylesheet
   Zero External Dependencies | Tested at 360px, 390px, 768px, 1024px, 1440px
   ========================================================================== */

:root {
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-accent-soft: #eff6ff;
    --bg-internal-note: #fffbeb;
    --border-color: #e2e8f0;
    --border-strong: #cbd5e1;
    --border-internal: #fcd34d;

    --text-main: #0f172a;
    --text-secondary: #334155;
    --text-muted: #475569;

    --primary: #1d4ed8;
    --primary-hover: #1e40af;
    --primary-contrast: #ffffff;

    --secondary-bg: #f1f5f9;
    --secondary-hover: #e2e8f0;
    --secondary-text: #0f172a;

    --status-open-bg: #dbeafe;
    --status-open-text: #1e40af;
    --status-staff-bg: #fef3c7;
    --status-staff-text: #92400e;
    --status-customer-bg: #e0e7ff;
    --status-customer-text: #3730a3;
    --status-resolved-bg: #dcfce7;
    --status-resolved-text: #166534;

    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    --danger-border: #fca5a5;

    --warning-bg: #fffbeb;
    --warning-text: #92400e;
    --warning-border: #fde68a;

    --bg-canvas: var(--bg-body);
    --danger-color: #dc2626;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.06);

    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="dark"] {
    --bg-body: #0b1120;
    --bg-card: #0f172a;
    --bg-subtle: #1e293b;
    --bg-accent-soft: rgba(59, 130, 246, 0.15);
    --bg-internal-note: #261f0d;
    --border-color: #334155;
    --border-strong: #475569;
    --border-internal: #78350f;

    --text-main: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-contrast: #ffffff;

    --secondary-bg: #1e293b;
    --secondary-hover: #334155;
    --secondary-text: #f8fafc;

    --status-open-bg: rgba(59, 130, 246, 0.22);
    --status-open-text: #93c5fd;
    --status-staff-bg: rgba(245, 158, 11, 0.22);
    --status-staff-text: #fde68a;
    --status-customer-bg: rgba(99, 102, 241, 0.22);
    --status-customer-text: #c7d2fe;
    --status-resolved-bg: rgba(34, 197, 94, 0.22);
    --status-resolved-text: #86efac;

    --danger-bg: rgba(239, 68, 68, 0.2);
    --danger-text: #fca5a5;
    --danger-border: #7f1d1d;
    --danger-color: #ef4444;

    --warning-bg: rgba(245, 158, 11, 0.18);
    --warning-text: #fde68a;
    --warning-border: #78350f;

    --bg-canvas: var(--bg-body);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.45);
    --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.55);
}

*, *::before, *::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

body.site-body {
    margin: 0;
    padding: 0;
    font-family: var(--font-sans);
    font-size: 1rem;
    line-height: 1.55;
    color: var(--text-main);
    background-color: var(--bg-body);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

img, svg, video, canvas {
    max-width: 100%;
    height: auto;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

code, pre {
    font-family: var(--font-mono);
    font-size: 0.875rem;
}

code {
    background: var(--bg-subtle);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.code-box {
    background: #0f172a;
    color: #f8fafc;
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    max-width: 100%;
    margin: 0;
}

.code-box code {
    background: transparent;
    color: inherit;
    padding: 0;
    white-space: pre;
    word-break: normal;
    overflow-wrap: normal;
}

.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    background: var(--primary);
    color: #fff;
    padding: 0.5rem 1rem;
    z-index: 1000;
}

.skip-link:focus {
    left: 0.5rem;
    top: 0.5rem;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* Layout Containers */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

@media (min-width: 768px) {
    .container {
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

.site-main {
    flex: 1 0 auto;
    width: 100%;
}

/* Typography & Utility Classes */
.h1, .h2, .h3, .h4 {
    margin: 0;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.25;
}

.h2 { font-size: 1.5rem; }
.h3 { font-size: 1.2rem; }
.h4 { font-size: 1.05rem; }

@media (min-width: 768px) {
    .h2 { font-size: 1.75rem; }
    .h3 { font-size: 1.3rem; }
}

.text-muted { color: var(--text-muted); margin-top: 0; }
.text-danger { color: var(--danger-text); }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.78rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.uppercase { text-transform: uppercase; letter-spacing: 0.04em; }
.font-semibold { font-weight: 600; }
.font-normal { font-weight: 400; }

.wrap-anywhere {
    overflow-wrap: anywhere;
    word-break: break-word;
}

.py-lg { padding-top: 1.5rem; padding-bottom: 1.5rem; }
.py-xl { padding-top: 2.25rem; padding-bottom: 2.25rem; }
.mb-xs { margin-bottom: 0.35rem; }
.mb-sm { margin-bottom: 0.75rem; }
.mb-md { margin-bottom: 1.15rem; }
.mb-lg { margin-bottom: 1.75rem; }
.mt-2xs { margin-top: 0.2rem; }
.mt-xs { margin-top: 0.45rem; }
.mt-sm { margin-top: 0.75rem; }
.mt-lg { margin-top: 1.75rem; }
.my-sm { margin-top: 0.75rem; margin-bottom: 0.75rem; }
.my-md { margin-top: 1.25rem; margin-bottom: 1.25rem; }
.ml-2xs { margin-left: 0.3rem; }
.pt-xs { padding-top: 0.5rem; }
.mx-auto { margin-left: auto; margin-right: auto; }
.max-w-md { max-width: 480px; }
.max-w-lg { max-width: 640px; }
.max-w-xl { max-width: 820px; }

.divider {
    border: 0;
    border-top: 1px solid var(--border-color);
}

/* Header & Navigation */
.site-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.brand-logo {
    display: inline-flex;
    align-items: center;
    gap: 0.65rem;
    color: var(--text-main);
    text-decoration: none;
    padding: 0.35rem 0;
    min-width: 0;
    order: 1;
}

.brand-logo:hover {
    text-decoration: none;
}

.brand-mark {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.brand-mark-admin {
    background: #0f172a;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.15;
    min-width: 0;
}

.brand-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text-main);
}

.brand-subtitle {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.header-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    order: 2;
    margin-left: auto;
}

.mobile-menu-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
}

/* Theme Toggle Button (Compact Sun / Moon) */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    color: var(--text-secondary);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
    flex-shrink: 0;
    box-sizing: border-box;
}

.theme-toggle-btn:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
    border-color: var(--border-strong);
}

.theme-toggle-btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.theme-toggle-btn:active {
    transform: scale(0.96);
}

.theme-toggle-btn .theme-icon-sun {
    display: none;
}

.theme-toggle-btn .theme-icon-moon {
    display: block;
}

[data-theme="dark"] .theme-toggle-btn .theme-icon-sun {
    display: block;
}

[data-theme="dark"] .theme-toggle-btn .theme-icon-moon {
    display: none;
}

[data-theme="dark"] .theme-toggle-btn {
    background: var(--bg-card);
    border-color: var(--border-color);
    color: #fde68a;
}

[data-theme="dark"] .theme-toggle-btn:hover {
    background: var(--bg-subtle);
    color: #fef08a;
    border-color: var(--border-strong);
}

/* Theme toggle inside Admin Topbar */
.admin-topbar .theme-toggle-btn {
    background: #1e293b;
    border-color: #334155;
    color: #cbd5e1;
}

.admin-topbar .theme-toggle-btn:hover {
    background: #334155;
    color: #ffffff;
    border-color: #475569;
}

[data-theme="dark"] .admin-topbar .theme-toggle-btn {
    background: #1e293b;
    border-color: #334155;
    color: #fde68a;
}

[data-theme="dark"] .admin-topbar .theme-toggle-btn:hover {
    background: #334155;
    color: #fef08a;
    border-color: #475569;
}

.site-nav {
    display: none;
    width: 100%;
    padding-bottom: 0.75rem;
    border-top: 1px solid var(--border-color);
    order: 3;
}

.site-nav.is-open {
    display: block;
}

.nav-list {
    list-style: none;
    margin: 0;
    padding: 0.5rem 0 0 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-link {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    text-decoration: none;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-subtle);
    color: var(--primary);
    text-decoration: none;
}

.nav-link-admin {
    color: #0f172a;
    font-weight: 600;
}

[data-theme="dark"] .nav-link-admin {
    color: #93c5fd;
}

.nav-action-item {
    padding-top: 0.25rem;
}

@media (min-width: 860px) {
    .mobile-menu-toggle {
        display: none;
    }

    .site-nav {
        display: block !important;
        width: auto;
        padding-bottom: 0;
        border-top: 0;
        order: 2;
        margin-left: auto;
    }

    .header-actions {
        order: 3;
        margin-left: 0.5rem;
    }

    .nav-list {
        flex-direction: row;
        align-items: center;
        padding: 0;
        gap: 0.35rem;
    }

    .nav-action-item {
        padding-top: 0;
        margin-left: 0.35rem;
    }
}

/* Buttons & Touch Targets */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    min-height: 44px;
    padding: 0.55rem 1.1rem;
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.2;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, border-color 0.15s ease;
    text-align: center;
}

.btn:hover {
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: var(--primary-contrast);
}

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

.btn-secondary {
    background: var(--secondary-bg);
    color: var(--secondary-text);
    border-color: var(--border-strong);
}

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

.btn-outline {
    background: var(--bg-card);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.btn-outline:hover {
    background: var(--bg-subtle);
    color: var(--text-main);
}

.btn-sm {
    min-height: 38px;
    padding: 0.4rem 0.8rem;
    font-size: 0.875rem;
}

.btn-xs {
    min-height: 32px;
    padding: 0.25rem 0.6rem;
    font-size: 0.8rem;
}

.btn-lg {
    min-height: 48px;
    padding: 0.7rem 1.35rem;
    font-size: 1rem;
}

.btn-block {
    width: 100%;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    align-items: center;
}

.justify-center {
    justify-content: center;
}

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

/* Cards */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    max-width: 100%;
}

.card-padded {
    padding: 1.15rem;
}

@media (min-width: 768px) {
    .card-padded {
        padding: 1.5rem;
    }
}

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

/* Hero Section (Public Homepage) */
.hero-section {
    padding: 1.5rem 0 1rem 0;
}

.hero-card {
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.5rem 1.15rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

@media (min-width: 768px) {
    .hero-card {
        padding: 2.5rem 2rem;
    }
}

.hero-badge {
    display: inline-block;
    background: var(--bg-accent-soft);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.3rem 0.75rem;
    border-radius: 999px;
    margin-bottom: 0.75rem;
}

.hero-title {
    margin: 0 0 0.5rem 0;
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--text-main);
}

@media (min-width: 768px) {
    .hero-title {
        font-size: 2.35rem;
    }
}

.hero-subtitle {
    margin: 0 auto 1.5rem auto;
    max-width: 640px;
    color: var(--text-muted);
    font-size: 1.02rem;
}

.hero-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
    max-width: 720px;
    margin: 0 auto 1.25rem auto;
}

@media (min-width: 640px) {
    .hero-actions {
        grid-template-columns: repeat(3, 1fr);
    }
}

.hero-btn {
    flex-direction: column;
    gap: 0.15rem;
    min-height: 54px;
}

.btn-substatus {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
}

.resource-status-banner {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    color: var(--text-secondary);
    max-width: 760px;
    margin: 0 auto 1.25rem auto;
    text-align: left;
}

.hero-account-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    padding-top: 0.75rem;
    border-top: 1px solid var(--border-color);
}

.dot-sep {
    color: var(--border-strong);
}

/* Feature Grid & FAQ */
.features-section {
    padding: 1rem 0;
}

.info-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 768px) {
    .info-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.faq-section {
    padding: 1.25rem 0 2.5rem 0;
}

.section-header {
    margin-bottom: 1.25rem;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.faq-question {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.15rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 48px;
    color: var(--text-main);
}

.faq-question::-webkit-details-marker {
    display: none;
}

.faq-chevron {
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: rotate(45deg);
    transition: transform 0.15s ease;
    flex-shrink: 0;
}

details[open] .faq-chevron {
    transform: rotate(-135deg);
}

.faq-answer {
    padding: 0 1.15rem 1.15rem 1.15rem;
    color: var(--text-secondary);
    border-top: 1px solid var(--bg-subtle);
    padding-top: 0.85rem;
    overflow-wrap: anywhere;
}

/* Forms & Validation */
.auth-card {
    max-width: 460px;
}

.auth-header {
    margin-bottom: 1.25rem;
}

.auth-footer {
    margin-top: 1.25rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
}

.stack-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .form-grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.form-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
}

.req { color: var(--danger-text); }
.opt { font-weight: 400; color: var(--text-muted); font-size: 0.82rem; }
.form-link { font-size: 0.85rem; }

.form-control {
    width: 100%;
    min-height: 44px;
    padding: 0.55rem 0.8rem;
    font-family: inherit;
    font-size: 1rem; /* Prevents mobile iOS/Android auto-zoom */
    color: var(--text-main);
    background-color: #ffffff;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    max-width: 100%;
}

.form-control:focus {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
    border-color: var(--primary);
}

.form-control:disabled,
.form-control[readonly] {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
}

.form-control-sm {
    min-height: 38px;
    padding: 0.4rem 0.65rem;
    font-size: 0.92rem;
}

.form-control-xs {
    min-height: 32px;
    width: 72px;
    padding: 0.25rem 0.5rem;
    font-size: 0.85rem;
    display: inline-block;
}

textarea.form-control {
    min-height: 110px;
    resize: vertical;
}

.form-control.is-invalid {
    border-color: var(--danger-text);
    background-color: #fffafa;
}

.field-error {
    color: var(--danger-text);
    font-size: 0.84rem;
    font-weight: 500;
}

.form-hint {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.checkbox-label {
    display: inline-flex;
    align-items: flex-start;
    gap: 0.55rem;
    cursor: pointer;
    line-height: 1.4;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
    flex-shrink: 0;
}

/* Alerts, Warnings & Badges */
.flash-container {
    padding-top: 1rem;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
    border: 1px solid transparent;
    font-weight: 500;
    overflow-wrap: anywhere;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
}

.alert-icon {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
    margin-top: 0.15rem;
}

.alert-content {
    flex: 1;
    min-width: 0;
}

.alert-success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
    border-left: 4px solid #10b981;
}

.alert-warning {
    background: #fffbeb;
    color: #92400e;
    border-color: #fde68a;
    border-left: 4px solid #d97706;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fca5a5;
    border-left: 4px solid #dc2626;
}

.alert-info {
    background: #f0fdfa;
    color: #115e59;
    border-color: #99f6e4;
    border-left: 4px solid #0d9488;
}

.security-warning-box {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-left: 4px solid #d97706;
    border-radius: var(--radius-sm);
    padding: 0.95rem 1.1rem;
    color: var(--warning-text);
}

.security-warning-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    margin-bottom: 0.25rem;
}

.security-warning-text {
    margin: 0;
    font-size: 0.9rem;
}

.security-warning-text p {
    margin: 0.45rem 0 0 0;
    line-height: 1.55;
}

.security-warning-text p:first-child {
    margin-top: 0;
}

.security-warning-inline {
    background: var(--warning-bg);
    border: 1px solid var(--warning-border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 0.85rem;
    font-size: 0.86rem;
    color: var(--warning-text);
}

.security-notice {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}

.clean-list {
    margin: 0;
    padding-left: 1.2rem;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.76rem;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
}

.badge-open { background: var(--status-open-bg); color: var(--status-open-text); }
.badge-awaiting-staff { background: var(--status-staff-bg); color: var(--status-staff-text); }
.badge-awaiting-customer { background: var(--status-customer-bg); color: var(--status-customer-text); }
.badge-resolved { background: var(--status-resolved-bg); color: var(--status-resolved-text); }
.badge-verified { background: var(--status-resolved-bg); color: var(--status-resolved-text); }
.badge-pending { background: var(--status-staff-bg); color: var(--status-staff-text); }
.badge-invalid { background: var(--danger-bg); color: var(--danger-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-info { background: #ccfbf1; color: #0f766e; }
.badge-neutral { background: var(--bg-subtle); color: var(--text-secondary); }

/* Navigation & Notification Indicators */
.nav-notif-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.4rem;
    border-radius: 999px;
    background: #e11d48;
    color: #ffffff;
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
    margin-left: 0.45rem;
    box-shadow: 0 1px 3px rgba(225, 29, 72, 0.35);
    flex-shrink: 0;
}

.notif-unread-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #e11d48;
    margin-right: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.ticket-table tr.is-unread-item td:first-child {
    border-left: 3px solid #e11d48;
}

.ticket-table tr.is-unread-item {
    background-color: rgba(254, 242, 242, 0.45);
}

.ticket-table tr.is-read-item {
    background-color: inherit;
    opacity: 0.96;
}

/* Page Headers & Filter Bars */
.page-header,
.admin-page-header {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
    margin-bottom: 1.25rem;
}

@media (min-width: 640px) {
    .page-header,
    .admin-page-header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.status-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-bottom: 1rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 40px;
    padding: 0.4rem 0.85rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
}

.status-pill:hover {
    background: var(--bg-subtle);
    text-decoration: none;
}

.status-pill.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.pill-count {
    background: rgba(15, 23, 42, 0.08);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.status-pill.active .pill-count {
    background: rgba(255, 255, 255, 0.22);
    color: #ffffff;
}

.filter-row {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

@media (min-width: 640px) {
    .filter-row {
        flex-direction: row;
        align-items: center;
    }
    .filter-input-wrap {
        flex: 1 1 auto;
    }
}

.filter-actions {
    display: flex;
    gap: 0.5rem;
}

.admin-filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 640px) {
    .admin-filter-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .admin-filter-grid {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

/* Responsive Ticket Table -> Mobile Cards (< 768px) */
.table-card {
    overflow: hidden;
}

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

.ticket-table th {
    background: var(--bg-subtle);
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.ticket-table td {
    padding: 0.9rem 1rem;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.92rem;
}

.ticket-table tr:last-child td {
    border-bottom: 0;
}

.ticket-num-link {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--primary);
    font-size: 0.88rem;
}

.ticket-subject-link {
    font-weight: 600;
    color: var(--text-main);
    display: block;
}

.ticket-meta-sub {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 0.15rem;
}

@media (max-width: 767.98px) {
    .responsive-table,
    .responsive-table tbody,
    .responsive-table tr,
    .responsive-table td {
        display: block;
        width: 100%;
    }

    .responsive-table thead {
        display: none;
    }

    .responsive-table tr {
        padding: 0.9rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    .responsive-table tr:last-child {
        border-bottom: 0;
    }

    .responsive-table td {
        padding: 0.35rem 0;
        border-bottom: 0;
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.75rem;
        text-align: right;
    }

    .responsive-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.78rem;
        color: var(--text-muted);
        text-transform: uppercase;
        text-align: left;
        flex-shrink: 0;
    }

    .responsive-table td[data-label="Subject"] {
        flex-direction: column;
        align-items: flex-start;
        text-align: left;
        gap: 0.2rem;
    }
}

/* Ticket Detail & Conversation View */
.ticket-header-bar {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding-bottom: 1.15rem;
    border-bottom: 1px solid var(--border-color);
}

@media (min-width: 768px) {
    .ticket-header-bar {
        flex-direction: row;
        align-items: flex-start;
        justify-content: space-between;
    }
}

.ticket-header-main {
    min-width: 0;
    flex: 1 1 auto;
}

.ticket-breadcrumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    font-size: 0.875rem;
}

.ticket-ref {
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--text-secondary);
}

.ticket-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    align-items: center;
}

.ticket-layout-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 960px) {
    .ticket-layout-grid {
        grid-template-columns: minmax(0, 1fr) 330px;
    }
}

.ticket-conversation-col,
.ticket-sidebar-col {
    min-width: 0;
}

.conversation-thread {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.message-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    min-width: 0;
}

.message-staff {
    border-left: 4px solid var(--primary);
}

.message-internal {
    background: var(--bg-internal-note);
    border-color: var(--border-internal);
    border-left: 4px solid #d97706;
}

.message-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding-bottom: 0.75rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.message-author {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
}

.author-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.avatar-customer { background: var(--bg-subtle); color: var(--text-secondary); }
.avatar-staff { background: var(--primary); color: #ffffff; }
.avatar-internal { background: #d97706; color: #ffffff; }

.author-name {
    display: inline-block;
    margin-right: 0.35rem;
    overflow-wrap: anywhere;
}

.role-pill {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
}

.role-customer { background: var(--bg-subtle); color: var(--text-muted); }
.role-staff { background: var(--status-open-bg); color: var(--status-open-text); }
.role-internal { background: #fde68a; color: #78350f; }

.message-time {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.message-body {
    font-size: 0.96rem;
    line-height: 1.6;
    color: var(--text-main);
}

/* Attachments */
.message-attachments {
    margin-top: 1rem;
    padding-top: 0.85rem;
    border-top: 1px dashed var(--border-strong);
}

.attachments-title {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    margin-bottom: 0.6rem;
}

.attachments-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.65rem;
}

@media (min-width: 540px) {
    .attachments-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

.attachment-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-body);
    min-width: 0;
}

.attachment-thumb-link {
    width: 52px;
    height: 52px;
    border-radius: 4px;
    overflow: hidden;
    flex-shrink: 0;
    background: #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.attachment-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.attachment-info {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.attachment-name {
    font-size: 0.84rem;
    font-weight: 600;
    color: var(--text-main);
}

.attachment-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.file-preview-list {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    margin-top: 0.35rem;
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Sidebar Meta List */
.meta-list {
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.meta-row {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.meta-row dt {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.meta-row dd {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-main);
}

.masked-code-box {
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.75rem;
}

.masked-code-val {
    display: block;
    margin-top: 0.2rem;
    font-size: 0.82rem;
    background: transparent;
    padding: 0;
}

/* Admin Shell & Sidebar */
.admin-topbar {
    background: #0f172a;
    color: #ffffff;
    border-bottom: 1px solid #1e293b;
    position: sticky;
    top: 0;
    z-index: 120;
}

.admin-topbar-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    min-height: 60px;
    padding: 0.45rem 1rem;
    gap: 0.5rem;
}

.admin-topbar-left,
.admin-topbar-right {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    min-width: 0;
}

.topbar-user-pill {
    display: none;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    color: #e2e8f0;
    background: #1e293b;
    border: 1px solid #334155;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
}

.topbar-role-tag {
    font-size: 0.72rem;
    font-weight: 700;
    color: #93c5fd;
    text-transform: uppercase;
}

@media (min-width: 768px) {
    .topbar-user-pill {
        display: inline-flex;
    }
}

@media (max-width: 420px) {
    .admin-topbar-inner {
        padding: 0.4rem 0.65rem;
    }
    .admin-topbar-right .btn-sm {
        padding: 0.3rem 0.55rem;
        font-size: 0.78rem;
        min-height: 34px;
    }
    .admin-topbar .theme-toggle-btn {
        width: 34px;
        height: 34px;
    }
    .admin-topbar .brand-mark {
        display: none;
    }
}

.admin-topbar .brand-title {
    color: #ffffff;
}

.admin-topbar .brand-subtitle {
    color: #94a3b8;
}

.admin-topbar .mobile-menu-toggle {
    background: #1e293b;
    border-color: #334155;
    color: #ffffff;
}

.admin-shell {
    display: flex;
    flex-direction: column;
    flex: 1 0 auto;
    width: 100%;
}

.admin-sidebar {
    display: none;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem;
}

.admin-sidebar.is-open {
    display: block;
}

.admin-nav {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.admin-nav-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    padding: 0 0.65rem;
    margin-bottom: 0.35rem;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    min-height: 42px;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.92rem;
    text-decoration: none;
}

.admin-nav-link:hover,
.admin-nav-link.active {
    background: var(--bg-accent-soft);
    color: var(--primary);
    text-decoration: none;
}

.admin-main {
    flex: 1 1 auto;
    padding: 1.25rem 1rem 2.5rem 1rem;
    min-width: 0;
    max-width: 100%;
}

@media (min-width: 960px) {
    .admin-topbar .mobile-menu-toggle {
        display: none;
    }

    .admin-shell {
        flex-direction: row;
        align-items: stretch;
    }

    .admin-sidebar {
        display: block !important;
        width: 240px;
        flex-shrink: 0;
        border-bottom: 0;
        border-right: 1px solid var(--border-color);
        padding: 1.25rem 0.85rem;
    }

    .admin-main {
        padding: 1.75rem 2rem 3rem 2rem;
    }
}

/* Admin Stats & Settings Grids */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.85rem;
}

@media (min-width: 540px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1.1rem 1.2rem;
    text-decoration: none;
    color: var(--text-main);
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-card:hover {
    border-color: var(--primary);
    text-decoration: none;
}

.stat-open { border-top: 3px solid #2563eb; }
.stat-awaiting-staff { border-top: 3px solid #d97706; }
.stat-awaiting-customer { border-top: 3px solid #4f46e5; }
.stat-resolved { border-top: 3px solid #16a34a; }

.stat-label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
}

.stat-value {
    font-size: 1.85rem;
    font-weight: 800;
    line-height: 1.1;
}

.stat-foot {
    font-size: 0.76rem;
    color: var(--text-muted);
}

.settings-grid,
.admin-composer-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.25rem;
    align-items: start;
}

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

.note-composer-card {
    background: #fffdf5;
    border-color: var(--border-internal);
}

.stack-list {
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.item-edit-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.9rem;
    background: var(--bg-body);
}

.item-edit-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    margin-top: 0.65rem;
}

.inline-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.85rem;
}

.flex-align-end {
    display: flex;
    align-items: flex-end;
}

.verification-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.65rem;
    padding: 0.75rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-subtle);
}

.timeline-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
}

.timeline-item {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.86rem;
    padding-bottom: 0.55rem;
    border-bottom: 1px solid var(--bg-subtle);
}

.timeline-item:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* Pagination & Empty States */
.pagination {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 1.25rem;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    min-height: 40px;
    padding: 0.35rem 0.7rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-weight: 600;
    text-decoration: none;
}

.page-link.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #ffffff;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
}

/* Footer */
.site-footer {
    background: var(--bg-card);
    border-top: 1px solid var(--border-color);
    margin-top: 2.5rem;
    padding: 1.5rem 0;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.footer-inner {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 768px) {
    .footer-inner {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.footer-note {
    margin: 0.2rem 0 0 0;
    font-size: 0.8rem;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 0.85rem;
}

/* ==========================================================================
   Extended Features: Role Badges, File Preview Grid, Lightbox, Satisfaction
   ========================================================================== */

.role-admin {
    background: #dbeafe;
    color: #1e40af;
}

.role-agent {
    background: #e0e7ff;
    color: #3730a3;
}

.text-danger {
    color: var(--danger-text) !important;
}

.btn-xs {
    min-height: 28px;
    padding: 0.2rem 0.55rem;
    font-size: 0.76rem;
}

/* Attachment Zoom Badge on Thumbnails */
.attachment-thumb-link {
    position: relative;
}

.attachment-zoom-badge {
    position: absolute;
    right: 2px;
    bottom: 2px;
    background: rgba(15, 23, 42, 0.78);
    color: #ffffff;
    font-size: 0.62rem;
    font-weight: 600;
    padding: 1px 4px;
    border-radius: 3px;
    line-height: 1.2;
    pointer-events: none;
}

/* Multi-Action File Uploader Preview Grid */
.file-preview-summary {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.65rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 0.45rem;
}

.file-preview-count {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-main);
}

.file-preview-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
}

@media (min-width: 540px) {
    .file-preview-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.file-preview-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.45rem 0.6rem;
    background: var(--bg-card);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    min-width: 0;
}

.file-preview-thumb-wrap {
    width: 46px;
    height: 46px;
    border-radius: 4px;
    overflow: hidden;
    background: var(--bg-subtle);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.file-preview-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.file-preview-meta {
    flex: 1 1 auto;
    min-width: 0;
}

.file-preview-name {
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--text-main);
    line-height: 1.25;
}

.file-preview-remove {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger-border);
    border-radius: var(--radius-sm);
    padding: 0.25rem 0.5rem;
    font-size: 0.76rem;
    font-weight: 600;
    cursor: pointer;
    flex-shrink: 0;
    min-height: 32px;
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
}

.file-preview-remove:hover {
    background: #fecaca;
}

/* Staff Permission Controls */
.perm-badges-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 0.3rem;
}

.perm-fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
    margin: 0;
    background: var(--bg-body);
}

.perm-fieldset.is-admin-role {
    opacity: 0.65;
}

.perm-checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.86rem;
}

.perm-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.4rem 0.6rem;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    max-height: 240px;
    overflow-y: auto;
}

.perm-checkbox-row-compact {
    padding: 0.35rem 0.15rem;
    border-top: 1px solid var(--border-color);
    font-size: 0.82rem;
}

.perm-checkbox-group .perm-checkbox-row-compact:first-child {
    border-top: 0;
}

.status-pill.status-pill-danger {
    border-color: #fecdd3;
    color: #be123c;
    background: #fff1f2;
}

.status-pill.status-pill-danger:hover {
    background: #ffe4e6;
}

.status-pill.status-pill-danger.active {
    background: #e11d48;
    border-color: #e11d48;
    color: #ffffff;
}

.perm-checkbox-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-top: 0.15rem;
    flex-shrink: 0;
}

.block {
    display: block;
}

.is-hidden {
    display: none !important;
}

/* Customer Satisfaction Rating Widget & Historical Cards */
.satisfaction-card {
    border: 2px solid #93c5fd;
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

.satisfaction-message-card {
    border: 2px solid #93c5fd;
    background: linear-gradient(180deg, #f0f7ff 0%, #ffffff 100%);
    box-shadow: 0 4px 6px -1px rgba(37, 99, 235, 0.08), 0 2px 4px -2px rgba(37, 99, 235, 0.06);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    position: relative;
}

.feedback-submitted-header,
.feedback-request-header,
.feedback-edit-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.75rem;
}

.feedback-submitted-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.feedback-submitted-title-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.feedback-system-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 999px;
    font-size: 1rem;
    line-height: 1;
}

.feedback-submitted-body {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.85rem 1rem;
}

.feedback-stars-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.feedback-rating-label {
    font-size: 0.88rem;
    color: var(--text-main);
}

.feedback-submitted-message {
    color: var(--text-main);
    font-size: 0.93rem;
    line-height: 1.55;
}

.feedback-resolved-banner-badge {
    margin-bottom: 0.25rem;
}

.satisfaction-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.satisfaction-current-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--bg-accent-soft);
    padding: 0.35rem 0.7rem;
    border-radius: 999px;
}

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

.star-rating-options {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.5rem;
}

@media (min-width: 640px) {
    .star-rating-options {
        grid-template-columns: repeat(5, minmax(0, 1fr));
    }
}

.star-option-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.65rem 0.45rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: #ffffff;
    cursor: pointer;
    transition: border-color 0.15s ease, background-color 0.15s ease;
    position: relative;
    min-width: 0;
}

.star-option-card:hover {
    border-color: var(--primary);
    background: var(--bg-subtle);
}

.star-option-card.is-selected {
    border-color: var(--primary);
    background: var(--bg-accent-soft);
    box-shadow: 0 0 0 1px var(--primary);
}

.star-radio-input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}

.star-option-card:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.star-option-stars {
    color: #f59e0b;
    font-size: 1.05rem;
    letter-spacing: 1px;
    line-height: 1.2;
}

.star-option-num {
    font-weight: 700;
    font-size: 0.84rem;
    color: var(--text-main);
    margin-top: 0.15rem;
}

.star-option-label {
    font-size: 0.73rem;
    color: var(--text-muted);
    line-height: 1.2;
    margin-top: 0.1rem;
}

.star-rating-display {
    display: inline-flex;
    align-items: center;
    gap: 1px;
    font-size: 0.95rem;
    line-height: 1;
}

.star-filled {
    color: #f59e0b;
}

.star-empty {
    color: #cbd5e1;
}

.historical-rating-item {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    background: var(--bg-body);
}

.historical-rating-top {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.historical-rating-comment {
    font-size: 0.88rem;
    color: var(--text-secondary);
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.7rem;
}

/* Satisfaction Distribution Bars */
.rating-dist-list {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.rating-dist-row {
    display: grid;
    grid-template-columns: 120px 1fr 90px;
    align-items: center;
    gap: 0.65rem;
    font-size: 0.85rem;
}

@media (max-width: 480px) {
    .rating-dist-row {
        grid-template-columns: 95px 1fr 78px;
        gap: 0.45rem;
    }
}

.rating-dist-label {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.rating-dist-track {
    height: 12px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: 999px;
    overflow: hidden;
}

.rating-dist-fill {
    height: 100%;
    border-radius: 999px;
}

.dist-bar-positive { background: #16a34a; }
.dist-bar-neutral { background: #d97706; }
.dist-bar-negative { background: #dc2626; }

.rating-dist-meta {
    text-align: right;
    white-space: nowrap;
}

/* Accessible In-Page Screenshot Lightbox */
body.lightbox-open {
    overflow: hidden;
}

.lightbox-modal[hidden] {
    display: none !important;
}

.lightbox-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.92);
}

.lightbox-dialog {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    color: #ffffff;
    max-width: 100vw;
    max-height: 100vh;
}

.lightbox-topbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.65rem 1rem;
    background: rgba(15, 23, 42, 0.95);
    border-bottom: 1px solid #334155;
    z-index: 3;
}

.lightbox-title-group {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    min-width: 0;
    flex: 1 1 200px;
}

.lightbox-counter {
    background: #2563eb;
    color: #ffffff;
    font-size: 0.75rem;
    font-weight: 700;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    white-space: nowrap;
    flex-shrink: 0;
}

.lightbox-filename {
    font-size: 0.9rem;
    font-weight: 600;
    color: #f8fafc;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lightbox-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem;
}

.lightbox-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 36px;
    min-width: 36px;
    padding: 0.3rem 0.6rem;
    background: #1e293b;
    color: #f8fafc;
    border: 1px solid #475569;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.lightbox-btn:hover {
    background: #334155;
    color: #ffffff;
    text-decoration: none;
}

.lightbox-btn:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

.lightbox-close-btn {
    background: #dc2626;
    border-color: #ef4444;
    font-size: 1.15rem;
    line-height: 1;
}

.lightbox-close-btn:hover {
    background: #b91c1c;
}

.lightbox-zoom-level {
    font-family: var(--font-mono);
    font-size: 0.78rem;
    min-width: 48px;
    text-align: center;
    color: #cbd5e1;
}

.lightbox-stage {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    min-height: 0;
    user-select: none;
    padding: 0.75rem;
}

.lightbox-stage.is-zoomed {
    cursor: grab;
}

.lightbox-stage.is-dragging {
    cursor: grabbing;
}

.lightbox-img-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
}

.lightbox-image {
    display: block;
    transition: transform 0.08s ease-out;
    transform-origin: center center;
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.5);
    background: #0f172a;
}

.lightbox-image.is-fit-screen {
    max-width: calc(100vw - 96px);
    max-height: calc(100vh - 150px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.lightbox-image.is-actual-size {
    max-width: none;
    max-height: none;
}

@media (max-width: 639.98px) {
    .lightbox-image.is-fit-screen {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 190px);
    }
}

.lightbox-stage.is-dragging .lightbox-image {
    transition: none;
}

.lightbox-nav-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 4;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: rgba(15, 23, 42, 0.82);
    border: 1px solid #475569;
    color: #ffffff;
    font-size: 1.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.lightbox-nav-btn:hover:not(:disabled) {
    background: #2563eb;
    border-color: #60a5fa;
}

.lightbox-nav-btn.is-disabled,
.lightbox-nav-btn:disabled {
    opacity: 0.25;
    cursor: default;
}

.lightbox-prev {
    left: 0.75rem;
}

.lightbox-next {
    right: 0.75rem;
}

.lightbox-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.55rem 1rem;
    background: rgba(15, 23, 42, 0.95);
    border-top: 1px solid #334155;
    font-size: 0.78rem;
    color: #94a3b8;
    z-index: 3;
}

/* Generic Admin Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(2px);
    padding: 1rem;
}

.modal-overlay.is-hidden {
    display: none !important;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 520px;
    overflow: hidden;
    animation: modalFadeIn 0.18s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

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

.modal-header h3 {
    margin: 0;
    font-size: 1.15rem;
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    line-height: 1;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
}

.modal-close-btn:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 1.25rem;
}

/* ==========================================================================
   Dark Theme Component Refinements
   ========================================================================== */

/* Form controls in Dark Mode */
[data-theme="dark"] .form-control {
    background-color: #0b1120;
    color: var(--text-main);
    border-color: var(--border-color);
}

[data-theme="dark"] .form-control:focus {
    border-color: var(--primary);
    outline-color: var(--primary);
}

[data-theme="dark"] .form-control:disabled,
[data-theme="dark"] .form-control[readonly] {
    background-color: var(--bg-subtle);
    color: var(--text-muted);
}

[data-theme="dark"] .form-control.is-invalid {
    border-color: #ef4444;
    background-color: rgba(239, 68, 68, 0.12);
}

[data-theme="dark"] select.form-control option {
    background-color: #0f172a;
    color: var(--text-main);
}

/* Hero card gradient */
[data-theme="dark"] .hero-card {
    background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%);
}

/* Alerts in Dark Mode */
[data-theme="dark"] .alert-success {
    background: rgba(16, 185, 129, 0.16);
    color: #6ee7b7;
    border-color: #065f46;
    border-left: 4px solid #10b981;
}

[data-theme="dark"] .alert-warning {
    background: rgba(245, 158, 11, 0.16);
    color: #fde68a;
    border-color: #78350f;
    border-left: 4px solid #f59e0b;
}

[data-theme="dark"] .alert-error {
    background: rgba(239, 68, 68, 0.16);
    color: #fca5a5;
    border-color: #7f1d1d;
    border-left: 4px solid #ef4444;
}

[data-theme="dark"] .alert-info {
    background: rgba(13, 148, 136, 0.16);
    color: #5eead4;
    border-color: #115e59;
    border-left: 4px solid #14b8a6;
}

/* Security notices */
[data-theme="dark"] .security-warning-box,
[data-theme="dark"] .security-warning-inline {
    background: rgba(245, 158, 11, 0.12);
    border-color: #78350f;
    border-left: 4px solid #f59e0b;
    color: #fde68a;
}

[data-theme="dark"] .security-warning-inline[style*="#fef2f2"] {
    background: rgba(239, 68, 68, 0.16) !important;
    color: #fca5a5 !important;
    border-color: #7f1d1d !important;
    border-left-color: #ef4444 !important;
}

[data-theme="dark"] .card[style*="bg-canvas"] {
    background: var(--bg-body) !important;
    border-color: var(--border-color) !important;
}

/* Ticket table unread row */
[data-theme="dark"] .ticket-table tr.is-unread-item {
    background-color: rgba(225, 29, 72, 0.14);
}

/* Internal notes & composers */
[data-theme="dark"] .message-internal {
    background: var(--bg-internal-note);
    border-color: var(--border-internal);
    border-left: 4px solid #d97706;
}

[data-theme="dark"] .role-internal {
    background: rgba(245, 158, 11, 0.25);
    color: #fde68a;
}

[data-theme="dark"] .note-composer-card {
    background: #1c1708;
    border-color: #78350f;
}

/* Customer satisfaction rating card & historical ratings */
[data-theme="dark"] .satisfaction-card {
    border-color: #3b82f6;
    background: linear-gradient(180deg, #0f172a 0%, #0b1120 100%);
}

[data-theme="dark"] .satisfaction-message-card {
    border-color: #3b82f6;
    background: linear-gradient(180deg, #131c31 0%, #0f172a 100%);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.35);
}

[data-theme="dark"] .feedback-submitted-body {
    background: #0b1120;
    border-color: var(--border-color);
}

[data-theme="dark"] .feedback-system-icon {
    background: rgba(245, 158, 11, 0.2);
    color: #fde68a;
}

[data-theme="dark"] .star-option-card {
    background: #0f172a;
    border-color: var(--border-color);
}

[data-theme="dark"] .star-option-card:hover {
    background: var(--bg-subtle);
    border-color: var(--primary);
}

[data-theme="dark"] .star-option-card.is-selected {
    background: rgba(59, 130, 246, 0.2);
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

[data-theme="dark"] .star-empty {
    color: #475569;
}

[data-theme="dark"] .historical-rating-comment {
    background: #0b1120;
    border-color: var(--border-color);
    color: var(--text-secondary);
}

/* Attachments & previews */
[data-theme="dark"] .attachment-thumb-link {
    background: #1e293b;
}

[data-theme="dark"] .file-preview-thumb-wrap {
    background: #1e293b;
}

[data-theme="dark"] .file-preview-card {
    background: var(--bg-card);
    border-color: var(--border-strong);
}

/* Admin Topbar, Pills & Modals in Dark Mode */
[data-theme="dark"] .admin-topbar {
    background: #020617;
    border-bottom-color: #1e293b;
}

[data-theme="dark"] .topbar-user-pill {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.78);
}

[data-theme="dark"] .modal-card {
    background: var(--bg-card);
    border-color: var(--border-color);
}

[data-theme="dark"] .modal-close-btn:hover {
    color: var(--text-main);
}

/* Code box in Dark Mode */
[data-theme="dark"] .code-box {
    background: #020617;
    border: 1px solid var(--border-color);
}

/* Status pills danger */
[data-theme="dark"] .status-pill.status-pill-danger {
    border-color: #881337;
    color: #fda4af;
    background: rgba(225, 29, 72, 0.15);
}

[data-theme="dark"] .status-pill.status-pill-danger:hover {
    background: rgba(225, 29, 72, 0.25);
}

/* Strict Image & Logo Protection: Never invert or filter screenshots, uploaded images, or logos */
img, picture, svg.brand-mark, .brand-mark, .attachment-thumb, .lightbox-image, .file-preview-thumb {
    filter: none !important;
}

/* Accessibility: Respect Reduced Motion Preference */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

