:root {
    --refsys-bg: #f5f7fb;
    --refsys-panel: #ffffff;
    --refsys-border: #e5e9f2;
    --refsys-text: #172033;
    --refsys-muted: #697386;
    --refsys-primary: #3147ff;
    --refsys-primary-dark: #2433bd;
    --refsys-success: #0f9f6e;
    --refsys-warning: #b7791f;
    --refsys-danger: #dc2626;
    --refsys-shadow: 0 18px 50px rgba(15, 23, 42, .08);
}

body.refsys-body {
    background: radial-gradient(circle at top left, rgba(49,71,255,.10), transparent 34rem), var(--refsys-bg);
    color: var(--refsys-text);
    font-family: var(--refsys-font-family), Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.refsys-login-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem;
}

.refsys-login-card {
    width: min(100%, 440px);
    background: rgba(255,255,255,.92);
    backdrop-filter: blur(14px);
    border: 1px solid rgba(255,255,255,.65);
    border-radius: 28px;
    box-shadow: var(--refsys-shadow);
    padding: 2rem;
}

.refsys-brand-mark {
    width: 48px;
    height: 48px;
    display: inline-grid;
    place-items: center;
    border-radius: 16px;
    color: #fff;
    background: linear-gradient(135deg, var(--refsys-primary), #14b8a6);
    box-shadow: 0 12px 30px rgba(49,71,255,.28);
}

.refsys-shell {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    min-height: 100vh;
}

.refsys-sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.25rem;
    background: #0f172a;
    color: #e5e7eb;
    overflow-y: auto;
}

.refsys-sidebar .nav-link {
    color: #cbd5e1;
    border-radius: 14px;
    padding: .75rem .9rem;
    margin-bottom: .25rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 600;
}

.refsys-sidebar .nav-link:hover,
.refsys-sidebar .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,.10);
}

.refsys-main {
    min-width: 0;
    padding: 1.25rem 1.5rem 3rem;
}

.refsys-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    margin: -1.25rem -1.5rem 1.5rem;
    padding: 1rem 1.5rem;
    background: rgba(245,247,251,.82);
    backdrop-filter: blur(16px);
    border-bottom: 1px solid rgba(229,233,242,.85);
}

.refsys-page-title {
    font-size: 1.55rem;
    font-weight: 800;
    margin: 0;
    letter-spacing: -.03em;
}

.refsys-card {
    background: rgba(255,255,255,.94);
    border: 1px solid var(--refsys-border);
    border-radius: 22px;
    box-shadow: 0 10px 35px rgba(15, 23, 42, .05);
}

.refsys-stat {
    position: relative;
    overflow: hidden;
}

.refsys-stat::after {
    content: "";
    position: absolute;
    inset: auto -30px -45px auto;
    width: 110px;
    height: 110px;
    border-radius: 999px;
    background: rgba(49,71,255,.08);
}

.refsys-stat-value {
    font-size: 2rem;
    font-weight: 850;
    letter-spacing: -.04em;
}

.refsys-muted { color: var(--refsys-muted); }

.refsys-table {
    margin-bottom: 0;
}
.refsys-table th {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--refsys-muted);
    border-bottom: 1px solid var(--refsys-border);
}
.refsys-table td { vertical-align: middle; }

.refsys-btn-primary,
.btn.refsys-btn-primary {
    background: linear-gradient(135deg, var(--refsys-primary), #14b8a6);
    border: 0;
    color: #fff;
    font-weight: 700;
    box-shadow: 0 12px 24px rgba(49,71,255,.20);
}
.refsys-btn-primary:hover { color: #fff; filter: brightness(.97); }

.refsys-pill {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border-radius: 999px;
    padding: .35rem .65rem;
    font-size: .78rem;
    font-weight: 700;
    background: #eef2ff;
    color: #3730a3;
}

.refsys-pill.status-submitted, .refsys-pill.status-completed { background: #d1fae5; color: #065f46; }
.refsys-pill.status-sent, .refsys-pill.status-opened, .refsys-pill.status-in_progress { background: #dbeafe; color: #1e40af; }
.refsys-pill.status-queued, .refsys-pill.status-queued_for_email, .refsys-pill.status-awaiting_references { background: #fef3c7; color: #92400e; }
.refsys-pill.status-email_failed, .refsys-pill.status-expired, .refsys-pill.status-cancelled { background: #fee2e2; color: #991b1b; }

.refsys-form-section {
    border: 1px solid var(--refsys-border);
    border-radius: 18px;
    padding: 1rem;
    background: #fff;
}

.refsys-question-card {
    border: 1px solid #edf0f6;
    border-radius: 16px;
    padding: .9rem;
    background: #fbfcff;
}

.refsys-toast-wrap {
    position: fixed;
    right: 1rem;
    bottom: 1rem;
    z-index: 1090;
    display: grid;
    gap: .75rem;
}
.refsys-toast {
    min-width: 290px;
    max-width: 420px;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,.65);
    box-shadow: var(--refsys-shadow);
    padding: .9rem 1rem;
    background: #fff;
    display: flex;
    gap: .75rem;
    align-items: flex-start;
}
.refsys-toast.success i { color: var(--refsys-success); }
.refsys-toast.error i { color: var(--refsys-danger); }
.refsys-toast.warning i { color: var(--refsys-warning); }

.refsys-loading {
    opacity: .65;
    pointer-events: none;
}

.refsys-referee-hero {
    border-radius: 28px;
    padding: 2rem;
    color: #fff;
    background: linear-gradient(135deg, #0f172a, #3147ff 55%, #14b8a6);
    box-shadow: var(--refsys-shadow);
}

@media (max-width: 991px) {
    .refsys-shell { grid-template-columns: 1fr; }
    .refsys-sidebar { position: relative; height: auto; }
    .refsys-sidebar .nav { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: .25rem; }
    .refsys-main { padding: 1rem; }
    .refsys-topbar { margin: -1rem -1rem 1rem; padding: 1rem; }
}

@media print {
    .refsys-sidebar, .refsys-topbar, .no-print { display: none !important; }
    .refsys-shell { display: block; }
    body { background: #fff !important; }
    .refsys-card { box-shadow: none; border: 1px solid #ddd; }
}

.refsys-input-group .input-group-text {
    border-radius: 16px 0 0 16px;
    border-color: var(--refsys-border);
    background: #f8fafc;
    color: var(--refsys-primary);
    min-width: 46px;
    justify-content: center;
}
.refsys-input-group .form-control,
.refsys-input-group .form-select {
    border-radius: 0 16px 16px 0;
    border-color: var(--refsys-border);
    min-height: 44px;
}
.refsys-input-group .form-control:focus,
.refsys-input-group .form-select:focus {
    box-shadow: 0 0 0 .2rem rgba(49,71,255,.10);
    border-color: var(--refsys-primary);
}
.refsys-section-title {
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    font-weight: 800;
    color: #172033;
    letter-spacing: -.01em;
}
.refsys-section-title i { color: var(--refsys-primary); }
.refsys-icon-chip {
    width: 44px;
    height: 44px;
    display: inline-grid;
    place-items: center;
    border-radius: 14px;
    background: #eef2ff;
    color: var(--refsys-primary);
}
.refsys-footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    border-top: 1px solid var(--refsys-border);
    margin-top: 2rem;
    padding-top: 1rem;
}
.refsys-main-menu .nav-link span { min-width: 0; }
@media (max-width: 767px) {
    .refsys-footer { flex-direction: column; align-items: flex-start; }
}

/* Pagination: force Laravel/Tailwind or Bootstrap pagination to stay compact inside RefSys cards. */
.refsys-main nav[role="navigation"],
.refsys-card nav[role="navigation"] {
    margin-top: 1rem;
}
.refsys-main nav[role="navigation"] svg,
.refsys-card nav[role="navigation"] svg,
.refsys-main .pagination svg,
.refsys-card .pagination svg {
    width: 1rem !important;
    height: 1rem !important;
    max-width: 1rem !important;
    max-height: 1rem !important;
    display: inline-block;
    vertical-align: -.125em;
}
.refsys-main .pagination,
.refsys-card .pagination {
    gap: .35rem;
    flex-wrap: wrap;
    margin-bottom: 0;
}
.refsys-main .page-link,
.refsys-card .page-link {
    border: 1px solid var(--refsys-border);
    border-radius: 999px !important;
    color: var(--refsys-text);
    min-width: 2.25rem;
    height: 2.25rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    box-shadow: 0 8px 20px rgba(15, 23, 42, .04);
}
.refsys-main .page-item.active .page-link,
.refsys-card .page-item.active .page-link {
    background: var(--refsys-primary);
    border-color: var(--refsys-primary);
    color: #fff;
}
.refsys-main .page-item.disabled .page-link,
.refsys-card .page-item.disabled .page-link {
    color: #94a3b8;
    background: #f8fafc;
    box-shadow: none;
}
/* Safety net for Laravel's default Tailwind pagination markup when Bootstrap pagination view is not used. */
.refsys-main nav[role="navigation"] .relative,
.refsys-card nav[role="navigation"] .relative {
    max-width: 100%;
}
.refsys-main nav[role="navigation"] a,
.refsys-main nav[role="navigation"] span,
.refsys-card nav[role="navigation"] a,
.refsys-card nav[role="navigation"] span {
    line-height: 1.25;
}
.refsys-main nav[role="navigation"] .hidden,
.refsys-card nav[role="navigation"] .hidden {
    display: none !important;
}
.refsys-main nav[role="navigation"] > div,
.refsys-card nav[role="navigation"] > div {
    max-width: 100%;
}

.refsys-font-preview {
    border: 1px solid var(--refsys-border);
    border-radius: 20px;
    background: linear-gradient(135deg, #ffffff, #f8fafc);
    padding: 1.25rem;
    box-shadow: 0 12px 32px rgba(15, 23, 42, .04);
}
.refsys-font-preview-text {
    font-size: clamp(1.5rem, 4vw, 2.4rem);
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -.04em;
    color: var(--refsys-text);
    word-break: break-word;
}
.refsys-font-preview-meta {
    color: var(--refsys-muted);
    font-size: .9rem;
    font-weight: 700;
}

.refsys-menu-group {
    border-radius: 16px;
    margin-bottom: .35rem;
}
.refsys-menu-group-title {
    color: #e2e8f0;
    border-radius: 14px;
    padding: .75rem .9rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-weight: 800;
    background: rgba(255,255,255,.045);
}
.refsys-menu-group.active .refsys-menu-group-title,
.refsys-menu-group-title:hover {
    background: rgba(255,255,255,.10);
    color: #fff;
}
.refsys-menu-chevron {
    font-size: .75rem;
    opacity: .75;
}
.refsys-submenu {
    margin: .35rem 0 .55rem 1.35rem;
    padding-left: .65rem;
    border-left: 1px solid rgba(255,255,255,.14);
}
.refsys-sidebar .refsys-submenu-link {
    font-size: .92rem;
    padding: .55rem .7rem;
    border-radius: 12px;
    margin-bottom: .15rem;
}
.refsys-sidebar .refsys-submenu-link i {
    width: 1.1rem;
    text-align: center;
}
.refsys-cms-editor {
    min-height: 260px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
}
.refsys-content-block-preview {
    border: 1px dashed var(--refsys-border);
    border-radius: 16px;
    background: #fff;
    padding: 1rem;
}
.refsys-content-block-body {
    color: var(--refsys-text);
}
.refsys-content-block-body p:last-child { margin-bottom: 0; }

@media (max-width: 991px) {
    .refsys-sidebar .nav { display: block; }
    .refsys-submenu { margin-left: .65rem; }
}

/* v5 sidebar and Bootstrap accordion menu refinements */
.refsys-main-menu {
    gap: .2rem;
}
.refsys-sidebar .refsys-menu-link,
.refsys-sidebar .refsys-menu-group-title {
    width: 100%;
    color: #cbd5e1;
    border: 0;
    border-radius: 14px;
    padding: .7rem .85rem;
    margin-bottom: .2rem;
    display: flex;
    align-items: center;
    gap: .75rem;
    font-size: 12px;
    line-height: 1.2;
    font-weight: 700;
    text-align: left;
    text-decoration: none;
    background: transparent;
}
.refsys-sidebar .refsys-menu-link i,
.refsys-sidebar .refsys-menu-group-title i:not(.refsys-menu-chevron) {
    width: 18px;
    text-align: center;
    font-size: 12px;
}
.refsys-sidebar .refsys-menu-link:hover,
.refsys-sidebar .refsys-menu-link.active,
.refsys-sidebar .refsys-menu-group.active > .refsys-menu-group-title,
.refsys-sidebar .refsys-menu-group-title:hover {
    color: #fff;
    background: rgba(255,255,255,.10);
}
.refsys-menu-chevron {
    font-size: 10px;
    transition: transform .2s ease;
}
.refsys-menu-group-title:not(.collapsed) .refsys-menu-chevron {
    transform: rotate(180deg);
}
.refsys-submenu {
    padding: .15rem 0 .45rem 1.25rem;
}
.refsys-sidebar .refsys-submenu-link,
.refsys-sidebar .nav-link.refsys-submenu-link {
    color: #b6c2d4;
    padding: .52rem .75rem;
    margin-bottom: .12rem;
    border-radius: 12px;
    font-size: 11px;
    line-height: 1.2;
    font-weight: 400;
    gap: .55rem;
}
.refsys-sidebar .refsys-submenu-link i {
    width: 14px;
    text-align: center;
    font-size: 10px;
}
.refsys-sidebar .refsys-submenu-link:hover,
.refsys-sidebar .refsys-submenu-link.active {
    color: #fff;
    background: rgba(255,255,255,.08);
}

/* v5 CMS editor */
.refsys-cms-route-preview {
    font-size: .82rem;
    color: var(--refsys-muted);
    margin-top: -.4rem;
    margin-bottom: .85rem;
}
.refsys-editor-shell {
    border: 1px solid var(--refsys-border);
    border-radius: 18px;
    background: #fff;
    overflow: hidden;
}
.refsys-editor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem;
    padding: .65rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--refsys-border);
}
.refsys-editor-toolbar .btn {
    border-radius: 999px;
    font-size: .78rem;
    padding: .35rem .62rem;
}
.refsys-editor-area {
    min-height: 430px;
    padding: 1rem;
    outline: 0;
    overflow: auto;
}
.refsys-editor-area:focus {
    box-shadow: inset 0 0 0 2px rgba(49,71,255,.18);
}
.refsys-editor-code {
    min-height: 430px;
    border: 0;
    border-radius: 0;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .9rem;
    resize: vertical;
}
.refsys-editor-assets {
    padding: .75rem;
    border-top: 1px solid var(--refsys-border);
    background: #fbfcff;
}
.refsys-editor-assets .form-control {
    max-width: 520px;
}
.refsys-existing-pages-table td {
    vertical-align: middle;
}
.refsys-public-page {
    min-height: 100vh;
    background: radial-gradient(circle at top right, rgba(49,71,255,.10), transparent 36rem), var(--refsys-bg);
}
.refsys-public-page-wrap {
    width: min(100%, 980px);
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}
.refsys-public-content img,
.refsys-editor-area img {
    max-width: 100%;
    height: auto;
    border-radius: 14px;
}
.refsys-public-content video,
.refsys-editor-area video {
    max-width: 100%;
    border-radius: 14px;
}

@media (max-width: 991px) {
    .refsys-sidebar .nav { display: flex; }
    .refsys-submenu { padding-left: .6rem; }
}
.refsys-editor-area:empty::before {
    content: attr(data-placeholder);
    color: #94a3b8;
}

/* v6 brand logo support */
.refsys-sidebar-brand {
    min-height: 54px;
    display: flex;
    align-items: center;
}
.refsys-brand-logo {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: contain;
}
.refsys-brand-logo-sidebar {
    max-height: 78px;
}
.refsys-brand-logo-login,
.refsys-brand-logo-placeholder {
    max-height: 120px;
}
.refsys-brand-logo-public {
    max-height: 86px;
}
.refsys-public-brand-link {
    min-height: 56px;
}
.refsys-logo-preview {
    border: 1px dashed var(--refsys-border);
    border-radius: 16px;
    background: #fbfcff;
    min-height: 82px;
    padding: .75rem;
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.refsys-logo-preview img {
    max-width: 100%;
    max-height: 110px;
    height: auto;
    object-fit: contain;
    display: block;
}
.refsys-logo-preview-empty {
    color: var(--refsys-muted);
    font-size: .9rem;
    font-weight: 600;
}


/* v6.1 public header clearance */
.refsys-public-header {
    padding: .9rem 1rem;
    margin: .75rem 0 1.5rem;
    min-height: 72px;
}
.refsys-public-header .refsys-public-brand-link {
    display: inline-flex;
}
@media (max-width: 767px) {
    .refsys-public-header {
        padding: .75rem;
        margin-top: .5rem;
    }
}

/* v7 CMS headers, footers and shortcodes */
.refsys-editor-shortcode-help {
    padding: .6rem .9rem;
    background: #f8fafc;
    border-bottom: 1px solid var(--refsys-border);
    color: var(--refsys-muted);
    font-size: .78rem;
}
.refsys-editor-shortcode-help code {
    background: #eef2ff;
    color: #2537d5;
    border-radius: 999px;
    padding: .15rem .45rem;
    white-space: nowrap;
}
.refsys-cms-header,
.refsys-cms-footer {
    background: rgba(255,255,255,.86);
    border: 1px solid rgba(226,232,240,.92);
    border-radius: 22px;
    box-shadow: 0 18px 45px rgba(15,23,42,.08);
    margin: .75rem 0 1.5rem;
    overflow: hidden;
}
.refsys-cms-header-inner,
.refsys-cms-footer-inner {
    padding: 1rem 1.25rem;
}
.refsys-cms-logo-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}
.refsys-cms-footer {
    margin: 1.5rem 0 .75rem;
}
.refsys-cms-footer-inner {
    color: var(--refsys-muted);
    font-size: .9rem;
}
.refsys-cms-footer-inner p:last-child,
.refsys-cms-header-inner p:last-child {
    margin-bottom: 0;
}
.refsys-shortcode-brand-logo {
    display: inline-block;
    vertical-align: middle;
}
.refsys-shortcode-brand-logo-fallback {
    font-weight: 900;
    color: var(--refsys-text);
    line-height: 1.1;
}
.refsys-public-content .refsys-shortcode-brand-logo,
.refsys-editor-area .refsys-shortcode-brand-logo {
    border-radius: 0;
}
@media (max-width: 767px) {
    .refsys-cms-header-inner,
    .refsys-cms-footer-inner {
        padding: .85rem;
    }
}

/* v10 admin profile and dashboard avatar */
.refsys-admin-chip {
    display: inline-flex;
    align-items: center;
    gap: .6rem;
    color: var(--refsys-muted);
    text-decoration: none;
    font-size: .86rem;
}
.refsys-admin-chip:hover {
    color: var(--refsys-text);
}
.refsys-admin-avatar,
.refsys-profile-avatar-preview {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: inline-grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
    background: linear-gradient(135deg, var(--refsys-primary), #14b8a6);
    color: #fff;
    font-weight: 900;
    box-shadow: 0 10px 24px rgba(15,23,42,.14);
}
.refsys-admin-avatar img,
.refsys-profile-avatar-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.refsys-admin-avatar span,
.refsys-profile-avatar-preview span {
    line-height: 1;
}
.refsys-admin-avatar-lg,
.refsys-profile-avatar-preview {
    width: 78px;
    height: 78px;
    font-size: 1.25rem;
}
