/* ==========================================================================
   WRdoc Enterprise UI System
   Premium navy / cobalt language for high-trust document operations
   ========================================================================== */

:root {
    --primary: #3867e8;
    --primary-hover: #2b54ca;
    --primary-deep: #23429e;
    --primary-light: #eef3ff;
    --primary-soft: #f5f7ff;
    --success: #159a77;
    --success-light: #eaf8f3;
    --info: #1686b7;
    --info-light: #eaf7fc;
    --warning: #c98722;
    --warning-light: #fff7e7;
    --danger: #cf4f5e;
    --danger-light: #fff0f2;

    --surface: #ffffff;
    --surface-subtle: #f8faff;
    --background: #f3f6fb;
    --background-deep: #e9eef7;
    --border: #e3e9f2;
    --border-strong: #d5deec;
    --text-main: #17233d;
    --text-body: #394966;
    --text-muted: #74819a;
    --nav-bg: #0c1730;
    --nav-bg-2: #142244;

    --radius-xs: 8px;
    --radius-sm: 10px;
    --radius-md: 14px;
    --radius-lg: 18px;
    --radius-xl: 24px;

    --shadow-xs: 0 1px 2px rgba(24, 39, 75, 0.03);
    --shadow-sm: 0 6px 18px rgba(24, 39, 75, 0.045);
    --shadow-md: 0 12px 30px rgba(24, 39, 75, 0.065);
    --shadow-lg: 0 20px 48px rgba(24, 39, 75, 0.12);
    --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

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

html { scroll-behavior: smooth; }

body {
    min-height: 100vh;
    margin: 0;
    color: var(--text-main);
    background:
        radial-gradient(circle at 92% 0%, rgba(56, 103, 232, 0.055), transparent 24rem),
        linear-gradient(180deg, #f7f9fd 0%, var(--background) 46%, #f0f4fa 100%);
    font-family: 'Noto Sans Thai', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 0.95rem;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

body::before {
    content: '';
    position: fixed;
    z-index: -1;
    inset: 0 auto auto 0;
    width: 100%;
    height: 280px;
    pointer-events: none;
    background: linear-gradient(180deg, rgba(255,255,255,0.6), transparent);
}

a { color: inherit; }

button, input, select, textarea { font: inherit; }

/* --------------------------------------------------------------------------
   Boot / authentication
   -------------------------------------------------------------------------- */
#boot-loader {
    position: fixed;
    z-index: 2000;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 50% 30%, #1f3569 0%, var(--nav-bg) 48%, #080f22 100%);
    transition: opacity 220ms var(--ease-out), visibility 220ms var(--ease-out);
}

#boot-loader::before {
    content: 'WRdoc';
    position: absolute;
    top: calc(50% - 64px);
    color: rgba(255,255,255,0.92);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

#boot-loader.is-hidden { opacity: 0; visibility: hidden; pointer-events: none; }

#boot-loader .boot-spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255,255,255,0.2);
    border-top-color: #9eb6ff;
    border-radius: 50%;
    animation: boot-spin 720ms linear infinite;
}

@keyframes boot-spin { to { transform: rotate(360deg); } }

#login-card, #content-card { opacity: 0; transition: opacity 260ms var(--ease-out); }
#login-card.is-ready, #content-card.is-ready { opacity: 1; }

#login-card {
    overflow: hidden;
    max-width: 460px !important;
    margin-top: 8vh;
    border: 1px solid rgba(255,255,255,0.75) !important;
    border-radius: var(--radius-xl) !important;
    background: rgba(255,255,255,0.92);
    box-shadow: 0 30px 80px rgba(17, 34, 74, 0.18) !important;
    backdrop-filter: blur(18px);
}

.login-top {
    position: relative;
    padding: 3rem 2.5rem 2.6rem;
    overflow: hidden;
    text-align: center;
    background:
        radial-gradient(circle at 90% 10%, rgba(110, 145, 255, 0.32), transparent 14rem),
        linear-gradient(135deg, var(--nav-bg) 0%, var(--nav-bg-2) 100%);
}

.login-top::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.16;
    background-image: linear-gradient(rgba(255,255,255,0.14) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.14) 1px, transparent 1px);
    background-size: 28px 28px;
    mask-image: linear-gradient(135deg, black, transparent 78%);
}

.login-top::after {
    content: '';
    position: absolute;
    bottom: -22px;
    left: -4%;
    width: 108%;
    height: 42px;
    border-radius: 50% 50% 0 0;
    background: var(--surface);
}

.login-top .brand-icon-xl {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 68px;
    height: 68px;
    margin-bottom: 1.25rem;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 20px;
    background: linear-gradient(145deg, #5b85ff, #315bd6);
    box-shadow: 0 14px 30px rgba(40, 81, 194, 0.4);
}

.login-top h1, .login-top p { position: relative; z-index: 1; }
.login-top h1 { margin: 0; color: #fff; font-size: 1.42rem; font-weight: 700; letter-spacing: -0.02em; }
.login-top p { margin: 0.45rem 0 0; color: #a8b6d4; font-size: 0.9rem; }
#login-card .card-body { padding: 1.65rem 2.5rem 2.8rem; }

/* --------------------------------------------------------------------------
   Global navigation
   -------------------------------------------------------------------------- */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 76px;
    padding: 0.65rem clamp(1rem, 3vw, 2.75rem);
    border-bottom: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(100deg, var(--nav-bg) 0%, #101d3a 55%, #162958 100%) !important;
    box-shadow: 0 10px 28px rgba(12, 23, 48, 0.14);
}

.navbar .container-fluid, #navbar > .navbar .container-fluid { max-width: 1540px; margin: 0 auto; }

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 0.72rem;
    margin-right: 1.8rem;
    color: #fff !important;
    font-size: 1.15rem;
    font-weight: 750;
    letter-spacing: -0.025em;
}

.brand-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    overflow: hidden;
    border: 1px solid rgba(255,255,255,0.18);
    border-radius: 12px;
    background: linear-gradient(145deg, #eaf0ff, #bfd0ff);
    box-shadow: 0 6px 18px rgba(40, 78, 183, 0.36);
}

.brand-mark img { width: 28px; height: 28px; object-fit: contain; }

.navbar .nav-link {
    position: relative;
    margin: 0 0.12rem;
    padding: 0.62rem 0.86rem !important;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: #aab7d0 !important;
    font-size: 0.86rem;
    font-weight: 600;
    transition: color 160ms var(--ease-out), background 160ms var(--ease-out), border-color 160ms var(--ease-out), transform 160ms var(--ease-out);
}

.navbar .nav-link:hover, .navbar .nav-link:focus-visible {
    color: #fff !important;
    border-color: rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.075);
}

.navbar .nav-link.active {
    color: #fff !important;
    border-color: rgba(137, 164, 255, 0.25);
    background: linear-gradient(135deg, rgba(90, 127, 240, 0.27), rgba(65, 96, 197, 0.16));
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}

.navbar .nav-link.active::after {
    content: '';
    position: absolute;
    right: 0.75rem;
    bottom: -0.68rem;
    left: 0.75rem;
    height: 2px;
    border-radius: 999px;
    background: #91aaff;
}

#user-display {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #d5def0;
    font-size: 0.84rem;
    font-weight: 600;
}

#user-display::before {
    content: "\f007";
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid rgba(255,255,255,0.13);
    border-radius: 50%;
    color: #a9bcff;
    font-family: 'Font Awesome 6 Free';
    font-weight: 400;
    background: rgba(255,255,255,0.07);
}

#btn-logout {
    padding: 0.45rem 0.9rem;
    border: 1px solid rgba(255,255,255,0.16);
    border-radius: var(--radius-sm);
    color: #c9d4e9;
    background: rgba(255,255,255,0.04);
    font-size: 0.81rem;
    font-weight: 700;
    transition: all 160ms var(--ease-out);
}

#btn-logout:hover { border-color: rgba(255, 171, 184, 0.42); color: #ffd9df; background: rgba(207, 79, 94, 0.16); }
.navbar-toggler:focus { box-shadow: 0 0 0 3px rgba(145,170,255,0.25); }

/* --------------------------------------------------------------------------
   Layout and hierarchy
   -------------------------------------------------------------------------- */
.page-wrapper {
    width: min(100%, 1540px);
    margin: 0 auto;
    padding: clamp(1.5rem, 3.6vw, 3.25rem) clamp(1rem, 3vw, 2.75rem) 4rem;
}

.page-content { animation: fade-slide-up 320ms var(--ease-out); }
@keyframes fade-slide-up { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.dashboard-intro {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 1.5rem;
    margin-bottom: 1.75rem;
}

.eyebrow {
    display: inline-flex;
    align-items: center;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.dashboard-title { margin: 0.35rem 0 0.25rem; color: var(--text-main); font-size: clamp(1.5rem, 2.4vw, 2.08rem); font-weight: 750; letter-spacing: -0.035em; }
.dashboard-subtitle { max-width: 670px; margin: 0; color: var(--text-muted); font-size: 0.92rem; }
.dashboard-status { display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.85rem; border: 1px solid #d6eee5; border-radius: 999px; color: #177d62; background: #f3fcf8; font-size: 0.78rem; font-weight: 700; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #27b58c; box-shadow: 0 0 0 4px rgba(39,181,140,0.14); }

/* --------------------------------------------------------------------------
   Cards and data surfaces
   -------------------------------------------------------------------------- */
.card {
    overflow: hidden;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-lg) !important;
    background: rgba(255,255,255,0.95);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
    padding: 1.1rem 1.4rem;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text-main);
    background: rgba(255,255,255,0.82) !important;
    font-size: 0.99rem;
    font-weight: 750;
}

.card-header-meta { color: var(--text-muted); font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; }
.card-body { padding: 1.4rem; }
.section-title { color: var(--text-main); font-size: 0.98rem; font-weight: 750; }

.stat-card {
    position: relative;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 100%;
    min-height: 118px;
    padding: 1.25rem 1.35rem;
    overflow: hidden;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    box-shadow: var(--shadow-xs);
    transition: transform 180ms var(--ease-out), box-shadow 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.stat-card::after { content: ''; position: absolute; right: -22px; bottom: -34px; width: 92px; height: 92px; border-radius: 50%; background: rgba(56,103,232,0.035); }
.stat-card:hover { transform: translateY(-3px); border-color: #cfdaef; box-shadow: var(--shadow-md); }
.stat-icon { display: flex; align-items: center; justify-content: center; width: 48px; height: 48px; flex: 0 0 auto; border-radius: 15px; font-size: 1.12rem; }
.si-blue { color: var(--primary); background: var(--primary-light); }
.si-green { color: var(--success); background: var(--success-light); }
.si-teal { color: var(--info); background: var(--info-light); }
.si-amber { color: var(--warning); background: var(--warning-light); }
.stat-info { min-width: 0; }
.stat-info .stat-label { margin-bottom: 0.25rem; color: var(--text-muted); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase; }
.stat-info .stat-val { color: var(--text-main); font-size: 2rem; font-weight: 780; line-height: 1; letter-spacing: -0.045em; }

/* --------------------------------------------------------------------------
   Forms and buttons
   -------------------------------------------------------------------------- */
.form-label { margin-bottom: 0.42rem; color: #45536c; font-size: 0.82rem; font-weight: 750; }
.form-control, .form-select {
    min-height: 44px;
    padding: 0.62rem 0.88rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    background-color: #fbfcff;
    font-size: 0.88rem;
    transition: border-color 160ms var(--ease-out), box-shadow 160ms var(--ease-out), background-color 160ms var(--ease-out);
}

textarea.form-control { min-height: auto; }
.form-control::placeholder { color: #a2adbf; }
.form-control:focus, .form-select:focus { border-color: #7290ee; outline: none; background: #fff; box-shadow: 0 0 0 4px rgba(56,103,232,0.12); }
.form-check-input:checked { border-color: var(--primary); background-color: var(--primary); }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.42rem;
    min-height: 42px;
    padding: 0.58rem 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.84rem;
    font-weight: 750;
    transition: transform 150ms var(--ease-out), box-shadow 150ms var(--ease-out), border-color 150ms var(--ease-out), background 150ms var(--ease-out);
}

.btn:active { transform: scale(0.97); }
.btn-primary { border-color: var(--primary); background: linear-gradient(135deg, #4775ef, var(--primary)); box-shadow: 0 6px 14px rgba(56,103,232,0.2); }
.btn-primary:hover, .btn-primary:focus-visible { border-color: var(--primary-hover); background: linear-gradient(135deg, #3d6ce4, var(--primary-hover)); box-shadow: 0 9px 18px rgba(56,103,232,0.26); transform: translateY(-1px); }
.btn-success { border-color: var(--success); background: linear-gradient(135deg, #23aa87, var(--success)); box-shadow: 0 6px 14px rgba(21,154,119,0.18); }
.btn-success:hover { border-color: #0d765b; background: #0f8768; transform: translateY(-1px); }
.btn-sm { min-height: 34px; padding: 0.4rem 0.74rem; font-size: 0.77rem; }
.btn-outline-primary { border-color: #b9c9f7; color: var(--primary); background: #fff; }
.btn-outline-primary:hover { border-color: var(--primary); color: var(--primary-deep); background: var(--primary-light); }
.btn-outline-secondary { border-color: var(--border-strong); color: #5b6a83; background: #fff; }
.btn-outline-secondary:hover { border-color: #b8c4d7; color: var(--text-main); background: #f5f7fb; }
.btn-outline-success { border-color: #b9e3d6; color: #168363; background: #fff; }
.btn-outline-success:hover { border-color: var(--success); color: #0f6e54; background: var(--success-light); }
.btn-outline-danger { border-color: #f0c5cc; color: var(--danger); background: #fff; }
.btn-outline-danger:hover { border-color: var(--danger); color: #a83d4c; background: var(--danger-light); }

/* --------------------------------------------------------------------------
   Alerts, search, tables
   -------------------------------------------------------------------------- */
.alert { display: flex; align-items: center; gap: 0.7rem; padding: 0.9rem 1rem; border: 1px solid transparent; border-radius: var(--radius-md); box-shadow: var(--shadow-xs); font-size: 0.86rem; }

.search-bar-wrapper { padding: 1.15rem 1.35rem; border-bottom: 1px solid var(--border); background: linear-gradient(180deg, #fbfcff, #f8faff); }
.search-bar-wrapper .input-group { overflow: hidden; border-radius: var(--radius-sm); box-shadow: 0 2px 10px rgba(28, 48, 93, 0.04); }
.search-bar-wrapper .input-group-text { display: inline-flex; align-items: center; padding-inline: 0.9rem; border-color: var(--border-strong); color: #8b98ad; background: #fff; }
.search-bar-wrapper .form-control { border-color: var(--border-strong); background: #fff; }
.search-bar-wrapper .input-group:focus-within { box-shadow: 0 0 0 4px rgba(56,103,232,0.10); }
.search-bar-wrapper .input-group:focus-within .input-group-text, .search-bar-wrapper .input-group:focus-within .form-control { border-color: #7290ee; }
.search-bar-wrapper .form-control:focus { box-shadow: none; }
.search-bar-wrapper .btn { height: 44px; min-height: 44px; border-left: 0; }

.table { margin-bottom: 0; color: var(--text-body); font-size: 0.84rem; }
.table > :not(caption) > * > * { vertical-align: middle; }
.table thead th { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); color: #8491a7; background: #f7f9fd; font-size: 0.68rem; font-weight: 800; letter-spacing: 0.07em; text-transform: uppercase; white-space: nowrap; }
.table tbody td { padding: 0.9rem 1rem; border-bottom: 1px solid #edf1f6; color: var(--text-body); }
.table-hover tbody tr { transition: background 150ms var(--ease-out); }
.table-hover tbody tr:hover td { background: #f7f9ff; }
.table tbody tr:last-child td { border-bottom: 0; }
.log-scroll { max-height: 380px; overflow-y: auto; }
.log-scroll::-webkit-scrollbar { width: 6px; height: 6px; }
.log-scroll::-webkit-scrollbar-thumb { border-radius: 999px; background: #cbd5e4; }
.log-scroll::-webkit-scrollbar-track { background: transparent; }

/* Tabulator */
.tabulator { overflow: hidden; border: 0 !important; border-radius: 0; background: transparent !important; color: var(--text-body) !important; font-family: inherit !important; font-size: 0.84rem !important; }
.tabulator-header { border-bottom: 1px solid var(--border) !important; background: #f7f9fd !important; color: #8491a7 !important; font-size: 0.68rem !important; font-weight: 800 !important; letter-spacing: 0.07em; text-transform: uppercase; }
.tabulator .tabulator-header .tabulator-col { padding: 0.75rem 0.8rem !important; border-right: 0 !important; background: transparent !important; }
.tabulator-row { border-bottom: 1px solid #edf1f6 !important; background: #fff !important; transition: background 150ms var(--ease-out) !important; }
.tabulator-row:hover { background: #f7f9ff !important; }
.tabulator-row .tabulator-cell { padding: 0.9rem 0.8rem !important; border-right: 0 !important; vertical-align: middle !important; }
.tabulator .tabulator-footer { padding: 0.9rem 1.2rem !important; border-top: 1px solid var(--border) !important; background: #fff !important; }
.tabulator-page { margin: 0 2px !important; padding: 0.3rem 0.68rem !important; border: 1px solid var(--border-strong) !important; border-radius: var(--radius-xs) !important; color: var(--text-body) !important; background: #fff !important; font-size: 0.76rem !important; font-weight: 700 !important; }
.tabulator-page.active { border-color: var(--primary) !important; color: #fff !important; background: var(--primary) !important; }

/* Document list rows */
.doc-list .tabulator-header { display: none !important; }
.doc-list .tabulator-row { background: #fff !important; }
.doc-list .tabulator-row:nth-child(even) { background: #fbfcff !important; }
.doc-list .tabulator-row:hover { background: var(--primary-light) !important; }
.doc-list .tabulator-row .tabulator-cell { padding: 0 !important; white-space: normal !important; }
.doc-row { display: flex; align-items: flex-start; gap: 0.85rem; padding: 1rem 1.25rem; cursor: pointer; }
.doc-row-icon { display: flex; align-items: center; justify-content: center; width: 40px; height: 40px; flex: 0 0 auto; margin-top: 1px; border: 1px solid #dce5ff; border-radius: 12px; color: var(--primary); background: #f1f5ff; font-size: 0.92rem; }
.doc-row-body { min-width: 0; flex: 1; }
.doc-row-title { margin-bottom: 0.38rem; color: var(--text-main); font-size: 0.88rem; font-weight: 750; line-height: 1.5; word-break: break-word; }
.doc-row-meta { display: flex; align-items: center; gap: 0.45rem; color: var(--text-muted); font-size: 0.73rem; }
.doc-row-meta-info { display: flex; flex: 1; min-width: 0; flex-wrap: wrap; align-items: center; gap: 0.45rem; }
.doc-row-meta .meta-item { display: inline-flex; align-items: center; gap: 0.28rem; white-space: nowrap; }
.doc-row-meta .meta-item i { color: #9aa6b9; font-size: 0.72rem; }
.doc-row-meta .meta-sep { color: #d2d9e4; }
.doc-row-actions { display: flex; flex: 0 0 auto; align-items: center; gap: 0.18rem; margin-top: -0.15rem; }
.doc-row-actions .btn { min-height: 32px; padding: 0.35rem 0.56rem; }
.doc-row-actions-mobile { display: none; }

#quota-display { display: inline-flex; align-items: center; gap: 0.25rem; padding: 0.42rem 0.76rem; border: 1px solid #cddaff; border-radius: 999px; color: var(--primary) !important; background: var(--primary-light) !important; font-size: 0.76rem; font-weight: 750; }

/* --------------------------------------------------------------------------
   Badges and utility surfaces
   -------------------------------------------------------------------------- */
.category-badge { display: inline-flex; align-items: center; gap: 0.3rem; padding: 0.27rem 0.58rem; border-radius: 999px; font-size: 0.7rem; font-weight: 750; line-height: 1.2; white-space: nowrap; }
.badge-category-blue { color: #315fc9; background: #eaf0ff; }
.badge-category-green { color: #167a61; background: #e8f7f1; }
.badge-category-purple { color: #7750ba; background: #f0eaff; }
.badge-category-orange { color: #b56d18; background: #fff2df; }
.badge-category-red { color: #b53c4d; background: #ffeaee; }
.badge-category-cyan { color: #0a789e; background: #e6f7fc; }
.badge-category-pink { color: #b74379; background: #fdebf4; }
.badge-category-teal { color: #147f72; background: #e5f6f3; }
.badge-category-default { color: #647189; background: #eef1f5; }

/* --------------------------------------------------------------------------
   Modals, settings, tracking detail
   -------------------------------------------------------------------------- */
.modal-backdrop.show { opacity: 0.58; background: #0e1a35; }
.modal-content { overflow: hidden; border: 1px solid rgba(255,255,255,0.72) !important; border-radius: var(--radius-xl) !important; box-shadow: 0 28px 70px rgba(11, 25, 58, 0.22); }
.modal-header { min-height: 66px; padding: 1.15rem 1.5rem; border-bottom: 1px solid var(--border); background: #f9fbff; }
.modal-title { color: var(--text-main); font-size: 1.02rem; font-weight: 780; }
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); background: #f9fbff; }
.modal .table-bordered > :not(caption) > * { border-color: var(--border); }
.modal .table-bordered thead th { background: #f6f8fc !important; }
.modal hr { border-color: var(--border); opacity: 1; }

#trackingItemModal .modal-body, #trackingViewModal .modal-body { background: #fff; }
#trackingItemModal .modal-body > .row { padding: 0.25rem 0; }
.trk-setting-list { max-height: 320px; overflow-y: auto; }
.trk-setting-list .list-group-item { padding: 0.72rem 0.85rem; border-color: #edf1f6; color: var(--text-body); font-size: 0.82rem; }
.trk-setting-list .list-group-item:hover { background: #f7f9ff; }
.list-group-item { border-color: #edf1f6; }
.progress { overflow: hidden; border-radius: 999px; background: #e9eef7; }
.progress-bar { background: linear-gradient(90deg, #547cf0, var(--primary)); }

/* --------------------------------------------------------------------------
   Document category tabs + category management page
   -------------------------------------------------------------------------- */
.doc-cat-tab-wrapper { padding: 1rem 1.35rem 0; background: linear-gradient(180deg, #fbfcff, #f8faff); border-bottom: 1px solid var(--border); }
#doc-cat-tabbar { border-bottom: none; gap: 0.25rem; }
#doc-cat-tabbar .nav-link { padding: 0.55rem 1rem; border: 1px solid transparent; border-radius: 10px 10px 0 0; color: #5b6a84; font-size: 0.86rem; font-weight: 600; background: transparent; }
#doc-cat-tabbar .nav-link:hover { color: var(--primary); background: rgba(84, 124, 240, 0.07); }
#doc-cat-tabbar .nav-link.active { color: var(--primary); background: #fff; border-color: var(--border) var(--border) #fff; }

.cat-group-card { border: 1px solid var(--border); border-radius: var(--radius-sm, 12px); background: #fff; overflow: hidden; }
.cat-group-header { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.7rem 0.95rem; background: #f8faff; border-bottom: 1px solid var(--border); }
.cat-group-title { display: flex; align-items: center; gap: 0.55rem; min-width: 0; }
.cat-group-title .cat-count { font-size: 0.68rem; background: #e8eefc; color: #4456c9; }
.cat-sub-list { max-height: 340px; overflow-y: auto; }
.cat-sub-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; padding: 0.55rem 0.95rem; }
.cat-sub-row:hover { background: #f7f9ff; }
.cat-sub-info { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.cat-sub-name { font-size: 0.86rem; color: var(--text-body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cat-sub-actions { display: flex; align-items: center; gap: 0.45rem; }
.cat-sub-actions .cat-switch .form-check-input { cursor: pointer; }
.cat-sub-actions .cat-move-select { min-width: 150px; font-size: 0.78rem; }
.cat-add-sub-row { padding: 0.55rem 0.95rem; background: #fbfcff; }
@media (max-width: 575.98px) {
    .cat-sub-row { flex-direction: column; align-items: stretch; }
    .cat-sub-actions { justify-content: flex-end; }
    .cat-sub-actions .cat-move-select { flex: 1; }
}

/* --------------------------------------------------------------------------
   Public procurement landing page
   -------------------------------------------------------------------------- */
.procurement-header {
    position: relative;
    padding: clamp(1.25rem, 3vw, 2.25rem);
    overflow: hidden;
    border: 1px solid rgba(151, 174, 228, 0.38);
    border-radius: var(--radius-xl);
    background:
        radial-gradient(circle at 90% 8%, rgba(110, 147, 255, 0.22), transparent 15rem),
        linear-gradient(135deg, #ffffff 0%, #f1f5ff 56%, #edf5fb 100%);
    box-shadow: var(--shadow-sm);
}
.procurement-header::after { content: ''; position: absolute; right: -70px; bottom: -90px; width: 240px; height: 240px; border: 28px solid rgba(56,103,232,0.06); border-radius: 50%; }
.procurement-brand { position: relative; z-index: 1; display: flex; align-items: center; gap: 1.1rem; }
.procurement-logo { width: 64px; height: 64px; flex: 0 0 auto; object-fit: contain; filter: drop-shadow(0 8px 10px rgba(36, 66, 151, 0.12)); }
.procurement-kicker { color: var(--primary); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
.procurement-title { margin-top: 0.22rem; color: var(--text-main); font-size: clamp(1.45rem, 3vw, 2rem); font-weight: 780; letter-spacing: -0.035em; }
.procurement-header p { color: var(--text-muted) !important; font-size: 0.9rem; }
.procurement-header-meta { display: flex; flex-wrap: wrap; gap: 0.55rem 1.15rem; margin-top: 1rem; color: #6e7d98; font-size: 0.72rem; font-weight: 700; }
.procurement-header-meta span { display: inline-flex; align-items: center; }
.procurement-header-meta i { color: var(--success); }
.procurement-footer-note { margin-top: 1.25rem; padding: 0.85rem 1rem; border: 1px solid #e1e8f2; border-radius: var(--radius-md); color: var(--text-muted); background: rgba(255,255,255,0.72); font-size: 0.74rem; text-align: center; }
.procurement-card { position: relative; overflow: hidden; border-color: var(--border) !important; color: inherit; transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out), border-color 200ms var(--ease-out); }
.procurement-card::after { content: ''; position: absolute; right: -52px; bottom: -66px; width: 180px; height: 180px; border-radius: 50%; background: rgba(56,103,232,0.035); }
.procurement-card:hover { transform: translateY(-5px); border-color: #c7d4f4 !important; box-shadow: var(--shadow-lg); }
.procurement-card .card-body { position: relative; z-index: 1; min-height: 245px; padding: 1.65rem !important; }
.procurement-card-icon { display: inline-flex; align-items: center; width: fit-content; min-height: 30px; padding: 0.33rem 0.62rem; border-radius: 999px; font-size: 0.7rem; font-weight: 800; letter-spacing: 0.06em; }
.procurement-card .card-title { margin-bottom: 0.5rem; color: var(--text-main) !important; font-size: 1.08rem; font-weight: 780; }
.procurement-card .card-text { max-width: 31rem; color: var(--text-muted) !important; font-size: 0.86rem; line-height: 1.75; }
.procurement-card .btn { align-self: flex-start; margin-top: 0.9rem; }

/* --------------------------------------------------------------------------
   Public tracking page
   -------------------------------------------------------------------------- */
.trk-navbar { min-height: 64px; }
.trk-hero {
    position: relative;
    margin-bottom: -30px;
    padding: 2.6rem 0 3.65rem;
    overflow: hidden;
    color: #fff;
    background:
        radial-gradient(circle at 78% 18%, rgba(105, 139, 255, 0.24), transparent 18rem),
        linear-gradient(135deg, #0a1530 0%, #14254d 62%, #1b3470 100%);
}
.trk-hero::before { content: ''; position: absolute; inset: 0; opacity: 0.12; background-image: linear-gradient(rgba(255,255,255,0.16) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,0.16) 1px, transparent 1px); background-size: 30px 30px; mask-image: linear-gradient(115deg, black, transparent 76%); }
.trk-hero .container { position: relative; z-index: 1; }
.trk-hero-kicker { position: relative; z-index: 1; margin-bottom: 0.65rem; color: #a9bcff; font-size: 0.66rem; font-weight: 800; letter-spacing: 0.16em; text-transform: uppercase; }
.trk-hero h1 { margin-bottom: 0.35rem; color: #fff; font-size: clamp(1.35rem, 3vw, 1.8rem); font-weight: 780; letter-spacing: -0.03em; }
.trk-hero p { margin-bottom: 0; color: #adbad5; font-size: 0.87rem; }
.content-lift { padding-top: 46px; padding-bottom: 2rem; }
.tracking-filter-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.15rem 1.35rem 0.95rem; }
.tracking-filter-header strong { display: block; color: var(--text-main); font-size: 0.92rem; font-weight: 780; }
.tracking-filter-header span:not(.tracking-data-badge) { display: block; margin-top: 0.15rem; color: var(--text-muted); font-size: 0.75rem; }
.tracking-data-badge { display: inline-flex; align-items: center; padding: 0.4rem 0.7rem; border: 1px solid #d6eee5; border-radius: 999px; color: #177d62; background: #f3fcf8; font-size: 0.7rem; font-weight: 750; white-space: nowrap; }
.trk-pub-title { word-break: break-word; color: var(--text-main); font-weight: 700; }
.pub-detail-row > td { background: #f7f9ff !important; box-shadow: inset 5px 0 0 var(--primary); }
.amount-strong { color: var(--primary); font-weight: 800; white-space: nowrap; }
.lock-hint { color: var(--text-muted); font-size: 0.77rem; }
.footer-note { padding: 1.6rem 0 2.6rem; color: var(--text-muted); font-size: 0.76rem; text-align: center; }
.timeline { position: relative; margin: 0; padding-left: 1.8rem; list-style: none; }
.timeline::before { content: ''; position: absolute; top: 4px; bottom: 4px; left: 7px; width: 2px; background: #d8e1f1; }
.timeline > li { position: relative; padding: 0 0 1.15rem 0.8rem; }
.timeline > li::before { content: ''; position: absolute; top: 5px; left: -24px; width: 12px; height: 12px; border: 3px solid #fff; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 2px #b7c8f7; }
.timeline-date { color: var(--text-muted); font-size: 0.76rem; }
.history-old { color: #b34c5b; text-decoration: line-through; }
.history-new { color: #147559; font-weight: 700; }
.toolbar .form-control, .toolbar .form-select { max-width: 220px; }
.procurement-card .bg-primary-subtle { color: #315fc9 !important; background: #eaf0ff !important; }
.procurement-card .bg-success-subtle { color: #167a61 !important; background: #e8f7f1 !important; }

/* --------------------------------------------------------------------------
   Responsive behavior
   -------------------------------------------------------------------------- */
@media (max-width: 991.98px) {
    .navbar .nav-link.active::after { display: none; }
    .navbar-collapse { padding: 0.75rem 0 0.35rem; }
    .navbar .nav-link { margin: 0.1rem 0; }
    .navbar .d-flex.align-items-center.gap-3 { align-items: stretch !important; padding-top: 0.6rem; border-top: 1px solid rgba(255,255,255,0.1); }
}

@media (max-width: 767.98px) {
    .dashboard-intro { align-items: flex-start; flex-direction: column; margin-bottom: 1.35rem; }
    .dashboard-status { align-self: flex-start; }
    .card-header { align-items: flex-start; min-height: 58px; padding: 1rem 1.05rem; }
    .card-body { padding: 1.05rem; }
    .search-bar-wrapper { padding: 0.9rem 1rem; }
    .table-responsive { margin-inline: 0; }
    .table thead th, .table tbody td { padding-inline: 0.78rem; }
    .doc-row { gap: 0.68rem; padding: 0.9rem 0.95rem; }
    .doc-row-icon { width: 34px; height: 34px; border-radius: 10px; font-size: 0.8rem; }
    .doc-row-title { font-size: 0.83rem; }
    .doc-row-meta { align-items: flex-start; }
    .doc-row-actions-desktop { display: none; }
    .doc-row-actions-mobile { display: flex; flex: 0 0 auto; margin-left: auto; padding-left: 0.3rem; }
    .doc-row-actions-mobile .btn { min-width: 31px; padding-inline: 0.45rem; }
    .modal-dialog { margin: 0.75rem; }
    .modal-body { padding: 1.1rem; }
    .modal-footer { padding: 0.9rem 1.1rem; }
    .procurement-card .card-body { min-height: 0; }
}

@media (max-width: 575.98px) {
    body { font-size: 0.9rem; }
    .page-wrapper { padding-top: 1.2rem; }
    .dashboard-title { font-size: 1.45rem; }
    .dashboard-subtitle { font-size: 0.84rem; }
    .stat-card { min-height: 100px; padding: 1rem; }
    .stat-icon { width: 42px; height: 42px; border-radius: 12px; font-size: 0.98rem; }
    .stat-info .stat-val { font-size: 1.72rem; }
    .stat-info .stat-label { font-size: 0.64rem; letter-spacing: 0.03em; }
    .card-header-meta { font-size: 0.62rem; }
    .procurement-brand { align-items: flex-start; gap: 0.8rem; }
    .procurement-logo { width: 50px; height: 50px; }
    .procurement-kicker { font-size: 0.66rem; }
    .procurement-title { font-size: 1.36rem; }
    .procurement-header p { font-size: 0.8rem; }
    .procurement-header-meta { gap: 0.35rem 0.75rem; font-size: 0.65rem; }
    .procurement-footer-note { font-size: 0.68rem; line-height: 1.65; }
    .tracking-filter-header { align-items: flex-start; flex-direction: column; padding: 1rem 1rem 0.75rem; }
    .tracking-data-badge { align-self: flex-start; }
    .trk-hero { padding-top: 2rem; }
    .content-lift { padding-top: 40px; }
    .footer-note { font-size: 0.7rem; line-height: 1.7; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}

:focus-visible { outline: 3px solid rgba(56,103,232,0.35); outline-offset: 2px; }

