/*
 * 1st PNUNIC 2027
 * Custom Theme: Teal (#006C6C) + Gold Accent
 * Version: 1.0.0
 */

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

/* ===== CSS Custom Properties ===== */
:root {
    /* Primary - Teal */
    --primary: #006C6C;
    --primary-light: #008B8B;
    --primary-lighter: #00AEAE;
    --primary-dark: #004F4F;
    --primary-darker: #003838;

    /* Gold Accent */
    --gold: #C5A55A;
    --gold-light: #D4BA7A;
    --gold-lighter: #E8D5A3;
    --gold-dark: #A68B3E;

    /* Neutrals */
    --bg-body: #F0F4F4;
    --bg-card: #FFFFFF;
    --bg-sidebar: #003838;
    --bg-sidebar-hover: #004F4F;
    --text-primary: #1A2E2E;
    --text-secondary: #4A6363;
    --text-muted: #7A9494;
    --text-on-primary: #FFFFFF;
    --text-on-sidebar: #B8D4D4;
    --border-color: #D4E0E0;
    --border-light: #E8F0F0;

    /* Status Colors */
    --status-draft: #6C757D;
    --status-submitted: #0D6EFD;
    --status-review: #FFC107;
    --status-accepted: #198754;
    --status-rejected: #DC3545;
    --status-revise: #FD7E14;
    --status-paid: #20C997;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 108, 108, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 108, 108, 0.1);
    --shadow-lg: 0 8px 30px rgba(0, 108, 108, 0.12);
    --shadow-xl: 0 16px 50px rgba(0, 108, 108, 0.15);

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transition */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;

    /* Sidebar Width */
    --sidebar-width: 260px;
}

/* ===== Base Styles ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', 'Noto Sans Thai', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-body);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 14px;
    overflow-x: hidden;
}

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

a:hover {
    color: var(--primary-light);
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-body);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-lighter);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
}

/* ===== Auth Layout (Login/Register) ===== */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary-darker) 0%, var(--primary) 50%, var(--primary-light) 100%);
    position: relative;
    overflow: hidden;
}

.auth-wrapper::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -50%;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle, rgba(184, 150, 90, 0.15) 0%, transparent 70%);
    animation: floatBg 15s ease-in-out infinite;
}

.auth-wrapper::after {
    content: '';
    position: absolute;
    bottom: -30%;
    left: -30%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(74, 111, 165, 0.12) 0%, transparent 70%);
    animation: floatBg 20s ease-in-out infinite reverse;
}

@keyframes floatBg {

    0%,
    100% {
        transform: translate(0, 0) rotate(0deg);
    }

    33% {
        transform: translate(30px, -20px) rotate(2deg);
    }

    66% {
        transform: translate(-20px, 20px) rotate(-2deg);
    }
}

.auth-card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    border-radius: var(--radius-xl);
    padding: 48px;
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(255, 255, 255, 0.3);
    animation: slideUp 0.6s ease-out;
}

.auth-card.wide {
    max-width: 680px;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo h1 {
    font-size: 28px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary) 0%, var(--gold) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.auth-logo p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 6px;
}

/* ===== Form Styles ===== */
.form-label {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    margin-bottom: 6px;
    letter-spacing: 0.3px;
}

.form-control,
.form-select {
    border: 2px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 14px;
    transition: all var(--transition-fast);
    font-family: inherit;
    background-color: #FAFAFC;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 108, 108, 0.12);
    background-color: #FFFFFF;
}

.form-control::placeholder {
    color: var(--text-muted);
}

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

/* ===== Buttons ===== */
.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    border: none;
    color: white;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(27, 42, 74, 0.25);
    letter-spacing: 0.3px;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(27, 42, 74, 0.35);
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--primary-lighter) 100%);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-gold {
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    border: none;
    color: #1A2E2E;
    font-weight: 600;
    padding: 10px 24px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
    box-shadow: 0 4px 15px rgba(184, 150, 90, 0.3);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(184, 150, 90, 0.4);
    color: #1A2E2E;
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    background: transparent;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--transition-normal);
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-1px);
}

/* ===== Navbar ===== */
.top-navbar {
    background: white;
    border-bottom: 1px solid var(--border-light);
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: fixed;
    top: 0;
    left: var(--sidebar-width);
    right: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.top-navbar .navbar-brand {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
}

.top-navbar .nav-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.lang-toggle {
    display: flex;
    align-items: center;
    gap: 4px;
    background: var(--bg-body);
    border-radius: 20px;
    padding: 4px;
}

.lang-toggle a {
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all var(--transition-fast);
}

.lang-toggle a.active {
    background: var(--primary);
    color: white;
}

.lang-toggle a:hover:not(.active) {
    background: var(--border-light);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-body);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary) 0%, var(--gold) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: 14px;
}

.user-info {
    text-align: right;
}

.user-info .name {
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
}

.user-info .role {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background: linear-gradient(180deg, var(--primary-darker) 0%, var(--bg-sidebar) 100%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal);
    overflow-y: auto;
}

.sidebar-logo {
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--gold) 0%, var(--gold-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 800;
    color: var(--primary-darker);
    flex-shrink: 0;
}

.sidebar-logo-text {
    color: white;
}

.sidebar-logo-text h2 {
    font-size: 16px;
    font-weight: 700;
    line-height: 1.2;
    color: #ffffff;
}

.sidebar-logo-text small {
    font-size: 10px;
    color: var(--text-on-sidebar);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-on-sidebar);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    padding: 0 12px;
    margin-bottom: 8px;
    opacity: 0.6;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-on-sidebar);
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

.sidebar-link:hover {
    background: var(--bg-sidebar-hover);
    color: white;
}

.sidebar-link.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(27, 42, 74, 0.4);
}

.sidebar-link .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
    opacity: 0.8;
}

.sidebar-link.active .icon {
    opacity: 1;
}

/* --- Readability: menus are read in Thai, so no wide tracking or tiny caps --- */
.sidebar-section-title {
    font-size: 11.5px;
    opacity: 0.85;
}
html[lang="th"] .sidebar-section-title {
    text-transform: none;
    letter-spacing: 0.02em;
    font-size: 12.5px;
}
.sidebar-link {
    font-size: 14px;
    line-height: 1.35;
}
.sidebar-link-label { flex: 1; min-width: 0; }
.sidebar-link:focus-visible,
.sidebar-group > summary:focus-visible,
.sidebar-search input:focus-visible {
    outline: 2px solid var(--gold, #C5A55A);
    outline-offset: 2px;
}
.sidebar-ext { font-size: 11px; opacity: 0.6; }

/* --- Collapsible groups (long staff menus) --- */
.sidebar-group { margin-bottom: 6px; }
.sidebar-group > summary {
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    margin-bottom: 2px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    user-select: none;
}
.sidebar-group > summary::-webkit-details-marker { display: none; }
.sidebar-group > summary:hover { background: var(--bg-sidebar-hover); opacity: 1; color: #fff; }
.sidebar-chevron { font-size: 11px; transition: transform var(--transition-fast); }
.sidebar-group:not([open]) .sidebar-chevron { transform: rotate(-90deg); }
.sidebar-group[data-has-active] > summary { color: #fff; opacity: 1; }
.sidebar-group-links { padding-bottom: 8px; }

/* --- Menu filter --- */
.sidebar-search {
    position: relative;
    margin: 0 0 14px;
}
.sidebar-search .bi-search {
    position: absolute; left: 12px; top: 50%; transform: translateY(-50%);
    color: var(--text-on-sidebar); font-size: 13px; pointer-events: none;
}
.sidebar-search input {
    width: 100%;
    padding: 9px 34px 9px 34px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 13.5px;
}
.sidebar-search input::placeholder { color: var(--text-on-sidebar); opacity: 0.8; }
.sidebar-search kbd {
    position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
    padding: 1px 6px; font-size: 11px; border-radius: 4px;
    background: rgba(255, 255, 255, 0.12); color: var(--text-on-sidebar);
}
.sidebar-search input:focus + kbd,
.sidebar-search input:not(:placeholder-shown) + kbd { display: none; }
.sidebar-search-empty { color: var(--text-on-sidebar); font-size: 13px; padding: 4px 12px 12px; margin: 0; }

.top-navbar .navbar-brand {
    margin: 0;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mobile-toggle:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

@media (max-width: 768px) {
    .top-navbar { padding: 0 12px; gap: 8px; }
    .top-navbar > .d-flex { min-width: 0; flex: 1; }
    .top-navbar .navbar-brand { font-size: 15px; }
    .top-navbar .nav-actions { gap: 10px; flex-shrink: 0; }
    /* Comfortable tap targets on phones */
    .sidebar-link { padding: 12px; }
    .sidebar-group > summary { padding: 11px 12px; }
}

.sidebar-badge {
    margin-left: auto;
    background: var(--gold);
    color: var(--primary-darker);
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ===== Main Content ===== */
.main-content {
    margin-left: var(--sidebar-width);
    padding-top: 64px;
    min-height: 100vh;
}

.page-content {
    padding: 24px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border-light);
    padding: 16px 20px;
    font-weight: 600;
    font-size: 15px;
}

.card-body {
    padding: 20px;
}

/* ===== Stat Cards ===== */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-normal);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    border-radius: 4px 0 0 4px;
}

.stat-card.teal::before {
    background: var(--primary);
}

.stat-card.gold::before {
    background: var(--gold);
}

.stat-card.green::before {
    background: var(--status-accepted);
}

.stat-card.blue::before {
    background: var(--status-submitted);
}

.stat-card.orange::before {
    background: var(--status-revise);
}

.stat-card.red::before {
    background: var(--status-rejected);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    margin-bottom: 12px;
}

.stat-card.teal .stat-icon {
    background: rgba(0, 108, 108, 0.08);
    color: var(--primary);
}

.stat-card.gold .stat-icon {
    background: rgba(184, 150, 90, 0.12);
    color: var(--gold-dark);
}

.stat-card.green .stat-icon {
    background: rgba(25, 135, 84, 0.1);
    color: var(--status-accepted);
}

.stat-card.blue .stat-icon {
    background: rgba(59, 107, 202, 0.1);
    color: var(--status-submitted);
}

.stat-card.orange .stat-icon {
    background: rgba(253, 126, 20, 0.1);
    color: var(--status-revise);
}

.stat-card.red .stat-icon {
    background: rgba(220, 53, 69, 0.1);
    color: var(--status-rejected);
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1;
}

.stat-card .stat-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ===== Status Badges ===== */
.badge-status {
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.badge-status::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
    display: inline-block;
}

.badge-draft {
    background: rgba(108, 117, 125, 0.1);
    color: var(--status-draft);
}

.badge-draft::before {
    background: var(--status-draft);
}

.badge-submitted {
    background: rgba(13, 110, 253, 0.1);
    color: var(--status-submitted);
}

.badge-submitted::before {
    background: var(--status-submitted);
}

.badge-under_review {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
}

.badge-under_review::before {
    background: var(--status-review);
}

.badge-accepted {
    background: rgba(25, 135, 84, 0.1);
    color: var(--status-accepted);
}

.badge-accepted::before {
    background: var(--status-accepted);
}

.badge-rejected {
    background: rgba(220, 53, 69, 0.1);
    color: var(--status-rejected);
}

.badge-rejected::before {
    background: var(--status-rejected);
}

.badge-revise {
    background: rgba(253, 126, 20, 0.1);
    color: var(--status-revise);
}

.badge-revise::before {
    background: var(--status-revise);
}

.badge-admin_revision,
.badge-committee_revision,
.badge-reviewer_revision {
    background: rgba(253, 126, 20, 0.1);
    color: var(--status-revise);
}

.badge-admin_revision::before,
.badge-committee_revision::before,
.badge-reviewer_revision::before {
    background: var(--status-revise);
}

.badge-committee_decision,
.badge-final_committee_check,
.badge-chair_final_check {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
}

.badge-committee_decision::before,
.badge-final_committee_check::before,
.badge-chair_final_check::before {
    background: var(--status-review);
}

/* ===== Per-submission progress stepper (views/partials/submission-progress.php) =====
   Laid out VERTICALLY on purpose. A horizontal track cannot hold five Thai stage
   labels side by side once the card is narrow (two-up on a laptop, or any phone),
   and Thai has no spaces to wrap on — so the labels used to collide with the
   connector lines. Stacking makes every label readable at any width. */
.sub-progress-track {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sub-progress-step {
    position: relative;
    padding: 0 0 9px 24px;
    min-height: 20px;
}

.sub-progress-step:last-child { padding-bottom: 0; }

/* Connector: a vertical line from under this dot down to the next one. */
.sub-progress-step:not(:last-child)::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 16px;
    bottom: -2px;
    width: 2px;
    background: var(--border-color, #dee2e6);
}

.sub-progress-step.is-done::before,
.sub-progress-step.is-current::before {
    background: var(--status-accepted, #198754);
}

.sub-progress-step.is-failed::before {
    background: rgba(220, 53, 69, 0.35);
}

.sub-progress-dot {
    position: absolute;
    left: 0;
    top: 4px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--border-color, #dee2e6);
    box-sizing: border-box;
}

.sub-progress-step.is-done .sub-progress-dot {
    background: var(--status-accepted, #198754);
    border-color: var(--status-accepted, #198754);
}

.sub-progress-step.is-current .sub-progress-dot {
    background: #fff;
    border-color: var(--status-revise, #fd7e14);
    box-shadow: 0 0 0 3px rgba(253, 126, 20, 0.2);
}

.sub-progress-step.is-failed .sub-progress-dot {
    background: var(--status-rejected, #dc3545);
    border-color: var(--status-rejected, #dc3545);
}

.sub-progress-label {
    display: block;
    font-size: 12.5px;
    line-height: 1.55;
    color: var(--text-muted, #6c757d);
}

.sub-progress-step.is-done .sub-progress-label { color: var(--status-accepted, #198754); }
.sub-progress-step.is-current .sub-progress-label { color: var(--status-revise, #fd7e14); font-weight: 600; }
.sub-progress-step.is-failed .sub-progress-label { color: var(--status-rejected, #dc3545); font-weight: 600; }

.sub-progress-caption {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
    padding-top: 9px;
    border-top: 1px solid var(--border-color, #dee2e6);
    font-size: 12px;
    line-height: 1.4;
}

.sub-progress-count {
    font-weight: 600;
    color: var(--text-muted, #6c757d);
}

.sub-progress-todo { font-size: 10px; padding: 2px 6px; }

.sub-progress-note {
    margin: 6px 0 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--text-muted, #6c757d);
}

.sub-progress-note.is-action { color: var(--status-revise, #fd7e14); font-weight: 500; }

/* ===== Per-role user guide (views/guide/mine.php) ===== */
.guide-steps {
    list-style: none;
    counter-reset: guide-step;
    margin: 0;
    padding: 0;
}

.guide-step {
    counter-increment: guide-step;
    position: relative;
    padding: 0 0 18px 44px;
}

.guide-step:last-child { padding-bottom: 0; }

/* Numbered badge, with a line running down to the next step. */
.guide-step::before {
    content: counter(guide-step);
    position: absolute;
    left: 0;
    top: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--primary, #006C6C);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.guide-step:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 14px;
    top: 34px;
    bottom: 4px;
    width: 2px;
    background: var(--border-color, #dee2e6);
}

.guide-step-title {
    font-weight: 700;
    font-size: 15px;
    padding-top: 4px;
    margin-bottom: 4px;
}

.guide-step-body {
    font-size: 14px;
    line-height: 1.8;
    color: var(--text-muted, #6c757d);
}

.guide-tips {
    margin-top: 22px;
    padding: 14px 16px;
    border-left: 4px solid var(--gold, #C5A55A);
    background: #FDF6EC;
    border-radius: 8px;
}

.guide-tips-title {
    font-weight: 700;
    font-size: 14px;
    color: #8A6D1F;
    margin-bottom: 6px;
}

.guide-tips ul {
    padding-left: 20px;
    font-size: 13.5px;
    line-height: 1.8;
    color: #6E5717;
}

/* ===== Collapsible payment details (views/finance/dashboard.php) =====
   Keeps the verify dialog focused on the decision; the transfer times and the
   slip open on demand. <details>/<summary>, so no JavaScript is involved. */
.fin-details {
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 8px;
    background: #fff;
}

.fin-details[open] { border-color: var(--primary, #006C6C); }

.fin-details-head {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    font-size: 13px;
    list-style: none;          /* hide the default triangle (Firefox) */
    user-select: none;
}

.fin-details-head::-webkit-details-marker { display: none; }  /* ...and WebKit */

.fin-details-head:hover { background: rgba(0, 0, 0, 0.02); }
.fin-details[open] .fin-details-head { border-bottom: 1px solid var(--border-color, #dee2e6); }

.fin-details-chevron {
    flex-shrink: 0;
    color: var(--text-muted, #6c757d);
    transition: transform 0.15s ease;
}

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

.fin-details-body { padding: 12px; }
.fin-details-body .table { margin-bottom: 0; }

/* ===== Collapsible progress rows (views/partials/submission-progress-list.php) =====
   Built on <details>/<summary> so open/close needs no JavaScript. */
.sub-acc {
    border: 1px solid var(--border-color, #dee2e6);
    border-radius: 10px;
    margin-bottom: 10px;
    background: #fff;
}

.sub-acc:last-child { margin-bottom: 0; }
.sub-acc[open] { border-color: var(--primary, #006C6C); }

.sub-acc-head {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 11px 14px;
    cursor: pointer;
    list-style: none;          /* hide the default disclosure triangle (Firefox) */
    user-select: none;
}

.sub-acc-head::-webkit-details-marker { display: none; }  /* ...and WebKit */

.sub-acc-head:hover { background: rgba(0, 0, 0, 0.02); }
.sub-acc[open] .sub-acc-head { border-bottom: 1px solid var(--border-color, #dee2e6); }

.sub-acc-chevron {
    flex-shrink: 0;
    color: var(--text-muted, #6c757d);
    transition: transform 0.15s ease;
}

.sub-acc[open] .sub-acc-chevron { transform: rotate(90deg); }

.sub-acc-title {
    font-weight: 600;
    font-size: 14px;
    /* Takes the slack so the step label and badges sit to the right, but is
       allowed to shrink and ellipsise instead of pushing them off the row. */
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sub-acc-step {
    font-size: 12px;
    color: var(--text-muted, #6c757d);
    flex-shrink: 0;
}

.sub-acc-body { padding: 14px; }

.sub-acc-link {
    display: inline-block;
    margin-top: 12px;
    font-size: 12.5px;
    font-weight: 600;
    text-decoration: none;
}

/* Horizontal variant — opt in with .sub-progress--horizontal, and only where the
   card spans the full page width (the submission detail page). Deliberately
   gated at >=992px: below that it stays vertical, because five Thai labels in a
   row is exactly what used to collide with the connector lines. The track also
   wraps rather than overflowing, so it degrades instead of overlapping. */
@media (min-width: 992px) {
    .sub-progress--horizontal .sub-progress-track {
        display: flex;
        align-items: center;
        flex-wrap: wrap;
        row-gap: 10px;
    }

    .sub-progress--horizontal .sub-progress-step {
        display: flex;
        align-items: center;
        gap: 7px;
        padding: 0;
        min-height: 0;
        flex: 1 1 auto;
        min-width: 0;
    }

    /* The dot leaves the left gutter and joins the row... */
    .sub-progress--horizontal .sub-progress-dot {
        position: static;
        flex-shrink: 0;
    }

    /* ...and the connector turns into a bar drawn AFTER this step's label
       (order:3), so it sits between two steps instead of through the text. */
    .sub-progress--horizontal .sub-progress-step:not(:last-child)::before {
        position: static;
        order: 3;
        left: auto;
        top: auto;
        bottom: auto;
        width: auto;
        height: 2px;
        flex: 1 1 16px;
        min-width: 16px;
        margin: 0 2px;
    }

    .sub-progress--horizontal .sub-progress-step:last-child { flex: 0 0 auto; }

    .sub-progress--horizontal .sub-progress-label { white-space: nowrap; }
}

/* Cleared by the committee, held until the fee is paid and finance verifies —
   the author has something to do, so it reads like the revision states, not
   like the passive "waiting on someone else" ones above. */
.badge-awaiting_payment {
    background: rgba(253, 126, 20, 0.1);
    color: var(--status-revise);
}

.badge-awaiting_payment::before {
    background: var(--status-revise);
}

.badge-pending {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
}

.badge-pending::before {
    background: var(--status-review);
}

.badge-verified {
    background: rgba(32, 201, 151, 0.1);
    color: #0d8065;
}

.badge-verified::before {
    background: var(--status-paid);
}

/* ===== Timeline ===== */
.timeline {
    position: relative;
    padding-left: 32px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 24px;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -26px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--border-color);
    border: 3px solid var(--bg-body);
    z-index: 1;
}

.timeline-item.active::before {
    background: var(--primary);
    box-shadow: 0 0 0 4px rgba(0, 108, 108, 0.2);
}

.timeline-item.completed::before {
    background: var(--status-accepted);
}

.timeline-item .timeline-title {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.timeline-item .timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ===== Tables ===== */
.table {
    font-size: 13px;
}

.table thead th {
    background: var(--bg-body);
    font-weight: 600;
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-color);
    padding: 12px 16px;
    white-space: nowrap;
}

.table tbody td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-light);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: rgba(0, 108, 108, 0.03);
}

/* ===== Step Wizard ===== */
.step-wizard {
    display: flex;
    justify-content: center;
    margin-bottom: 32px;
    gap: 0;
}

.step-wizard .step {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    position: relative;
    opacity: 0.5;
    transition: all var(--transition-normal);
}

.step-wizard .step.active {
    opacity: 1;
}

.step-wizard .step.completed {
    opacity: 1;
}

.step-wizard .step .step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-normal);
}

.step-wizard .step.active .step-number {
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(27, 42, 74, 0.3);
}

.step-wizard .step.completed .step-number {
    background: var(--status-accepted);
    color: white;
}

.step-wizard .step .step-text {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    white-space: nowrap;
}

.step-wizard .step.active .step-text {
    color: var(--primary);
}

.step-wizard .step-line {
    width: 40px;
    height: 2px;
    background: var(--border-color);
    align-self: center;
}

.step-wizard .step-line.completed {
    background: var(--status-accepted);
}

/* ===== Word Counter ===== */
.word-counter {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 6px;
    font-size: 12px;
}

.word-counter .count {
    font-weight: 600;
    color: var(--text-secondary);
}

.word-counter .count.over-limit {
    color: var(--status-rejected);
}

.word-counter .limit {
    color: var(--text-muted);
}

/* ===== Alert Flash Messages ===== */
.alert-flash {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.alert-flash.alert-success {
    background: rgba(25, 135, 84, 0.1);
    color: var(--status-accepted);
    border-left: 4px solid var(--status-accepted);
}

.alert-flash.alert-danger {
    background: rgba(220, 53, 69, 0.1);
    color: var(--status-rejected);
    border-left: 4px solid var(--status-rejected);
}

.alert-flash.alert-warning {
    background: rgba(255, 193, 7, 0.15);
    color: #997404;
    border-left: 4px solid var(--status-review);
}

.alert-flash.alert-info {
    background: rgba(27, 42, 74, 0.06);
    color: var(--primary);
    border-left: 4px solid var(--primary);
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 48px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h4 {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

/* ===== Score Stars ===== */
.score-input {
    display: flex;
    gap: 4px;
}

.score-input .star {
    font-size: 24px;
    cursor: pointer;
    color: var(--border-color);
    transition: color var(--transition-fast);
}

.score-input .star.active {
    color: var(--gold);
}

.score-input .star:hover {
    color: var(--gold-light);
}

/* ===== File Upload ===== */
.file-upload-zone {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    padding: 32px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition-normal);
    background: var(--bg-body);
}

.file-upload-zone:hover {
    border-color: var(--primary);
    background: rgba(0, 108, 108, 0.03);
}

.file-upload-zone.dragover {
    border-color: var(--primary);
    background: rgba(0, 108, 108, 0.05);
    transform: scale(1.01);
}

.file-upload-zone .upload-icon {
    font-size: 36px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.file-upload-zone p {
    color: var(--text-secondary);
    font-size: 14px;
}

.file-upload-zone .file-info {
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

/* ===== PDPA Checkbox ===== */
.pdpa-box {
    background: rgba(0, 108, 108, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-top: 16px;
}

.pdpa-box h5 {
    font-size: 15px;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 12px;
}

.pdpa-box p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
    margin-bottom: 16px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .top-navbar {
        left: 0;
    }

    .main-content {
        margin-left: 0;
    }

    .auth-card {
        margin: 16px;
        padding: 32px 24px;
    }

    .step-wizard {
        flex-wrap: wrap;
    }

    .step-wizard .step .step-text {
        display: none;
    }

    .stat-card .stat-value {
        font-size: 22px;
    }
}

/* ===== Mobile Menu Toggle ===== */
.mobile-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--primary);
    cursor: pointer;
    padding: 4px;
}

@media (max-width: 768px) {
    .mobile-toggle {
        display: block;
    }
}

/* ===== Sidebar Overlay (Mobile) ===== */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 150;
}

.sidebar-overlay.show {
    display: block;
}

/* ===== Print Styles ===== */
@media print {

    .sidebar,
    .top-navbar,
    .btn {
        display: none !important;
    }

    .main-content {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }
}

/* ===== Submission Grouping Filters (SubmissionGrouping::renderFilterBar) =====
   A row of dropdown filters (ระดับ / รูปแบบ / ภาษา / กลุ่มสาขา / ตีพิมพ์)
   above a single flat table; js/app.js hides non-matching <tr>s by their
   data-level/data-format/data-language/data-branch/data-publication
   attributes. Used by the Branch Group and Reviewer dashboards. */
.sg-filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--bg-body);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
}

.sg-filters .sg-filters-icon {
    font-size: 15px;
    color: var(--primary);
    margin-right: 2px;
    flex-shrink: 0;
}

.sg-filters select.form-select {
    width: auto;
    min-width: 168px;
    max-width: 100%;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    background-color: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 20px;
    padding: 7px 34px 7px 14px;
    background-position: right 14px center;
    background-size: 12px 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
    box-shadow: none;
}

.sg-filters select.form-select:hover {
    border-color: var(--primary-light);
    color: var(--primary);
}

.sg-filters select.form-select:focus {
    box-shadow: 0 0 0 3px rgba(0, 108, 108, 0.12);
    border-color: var(--primary);
    outline: none;
}

@media (max-width: 576px) {
    .sg-filters select.form-select {
        min-width: 0;
        flex: 1 1 auto;
    }
}