:root {
    --bg-body: #f4f5f7;
    --bg-topbar: #1f2933;
    --bg-topbar-hover: #111827;
    --bg-dropdown: #ffffff;
    --bg-card: #ffffff;
    --border-subtle: #e1e4ea;
    --accent: #14699b;
    --accent-soft: rgba(20, 105, 155, 0.08);
    --text-main: #111827;
    --text-muted: #6b7280;
    --text-on-dark: #f9fafb;
    --danger: #dc2626;
    --shadow-soft: 0 8px 20px rgba(15, 23, 42, 0.10);
    --radius-lg: 14px;
    --radius-md: 10px;
    --radius-pill: 999px;
}

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

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* ========== TOP BAR ========== */

.topbar {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: var(--bg-topbar);
    color: var(--text-on-dark);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 1rem;
    gap: 1rem;
}

.topbar-logo {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding-right: 0.8rem;
    border-right: 1px solid rgba(156, 163, 175, 0.4);
}

.topbar-logo-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f46e5, #06b6d4);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 700;
}

.topbar-logo-text {
    display: flex;
    flex-direction: column;
}

.topbar-logo-text span:first-child {
    font-size: 0.9rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.topbar-logo-text span:last-child {
    font-size: 0.7rem;
    color: rgba(209, 213, 219, 0.9);
}

.top-nav-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.nav-main {
    display: flex;
    align-items: stretch;
    gap: 0.4rem;
}

.nav-item {
    position: relative;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-pill);
    font-size: 0.82rem;
    font-weight: 500;
    color: #e5e7eb;
    white-space: nowrap;
    transition: background 0.16s ease, color 0.16s ease, transform 0.08s ease;
}

.nav-link:hover {
    background: rgba(15, 118, 110, 0.18);
    color: #f9fafb;
    transform: translateY(-1px);
}

/* ACTIVE TOP MENU */
.nav-link.active {
    background: rgba(20, 105, 155, 0.20);
    color: #ffffff;
    border: 1px solid var(--accent);
    box-shadow: 0 0 0 2px rgba(20,105,155,0.12);
    font-weight: 600;
    transform: translateY(-1px);
}

.nav-link-icon {
    font-size: 1rem;
}

.nav-caret {
    font-size: 0.6rem;
    opacity: 0.7;
}

/* Dropdowns – 1st level */

.dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: -1px;
    min-width: 220px;
    background: var(--bg-dropdown);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 0.4rem 0;
    display: none;
    z-index: 2000;
}

.nav-item:hover > .dropdown {
    display: block;
}

.dropdown-group-title {
    padding: 0.4rem 0.9rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
}

.dropdown-item {
    position: relative;
}

.dropdown-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
    color: var(--text-main);
    transition: background 0.14s ease;
}

.dropdown-link-label {
    display: flex;
    flex-direction: column;
}

.dropdown-link-label span:first-child {
    font-weight: 500;
}

.dropdown-link-label span:last-child {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.dropdown-arrow {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
}

/* Submenu (2nd level) */

.dropdown-submenu {
    position: absolute;
    top: -4px;
    left: 100%;
    margin-left: -1px;
    min-width: 220px;
    background: var(--bg-dropdown);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 0.35rem 0;
    display: none;
    z-index: 2100;
}

.dropdown-item:hover > .dropdown-submenu {
    display: block;
}

.dropdown-submenu .dropdown-link {
    padding: 0.4rem 0.85rem;
}

/* ========== RIGHT PROFILE ========== */

.top-right {
    display: flex;
    align-items: center;
    gap: 0.7rem;
}

.profile-wrap {
    position: relative;
}

.profile-pill {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.25rem 0.7rem;
    border-radius: var(--radius-pill);
    background: rgba(17, 24, 39, 0.85);
    cursor: pointer;
}

.profile-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #10b981;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    font-weight: 600;
}

.profile-info {
    display: flex;
    flex-direction: column;
}

.profile-info span:first-child {
    font-size: 0.78rem;
    font-weight: 500;
}

.profile-info span:last-child {
    font-size: 0.68rem;
    color: #9ca3af;
}

.profile-caret {
    font-size: 0.65rem;
    color: #9ca3af;
}

.profile-menu {
    position: absolute;
    right: 0;
    top: 100%;
    min-width: 190px;
    background: var(--bg-dropdown);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-soft);
    padding: 0.35rem 0;
    display: none;
    z-index: 2300;
}

.profile-wrap:hover .profile-menu {
    display: block;
}

.profile-menu a {
    display: block;
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
    color: var(--text-main);
}

.profile-menu a:hover {
    background: #f3f4ff;
}

.profile-menu .danger {
    color: var(--danger);
}

/* ========== MAIN LAYOUT ========== */

.main-wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.9rem 1rem 2rem;
}

.breadcrumbs {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.breadcrumbs span + span::before {
    content: "›";
    margin: 0 0.3rem;
    color: #9ca3af;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.9rem;
    gap: 0.8rem;
}

.page-title-block {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 600;
}

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

.page-actions {
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

/* ===== BUTTONS ===== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-pill);
    border: 1px solid transparent;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    background: #ffffff;
    color: var(--text-main);
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.15s ease, color 0.15s ease,
                box-shadow 0.15s ease, border-color 0.15s ease,
                transform 0.05s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

/* primary blue – Add Menu, Search etc. */
.btn.primary {
    background: var(--accent);
    color: #ffffff;
}

/* soft blue – Back to List, View All, small actions */
.btn.soft-blue {
    background: rgba(20,105,155,0.06);
    color: var(--accent);
    border-color: rgba(20,105,155,0.2);
}

/* green – Save main actions */
.btn.success {
    background: #16a34a;
    border-color: #16a34a;
    color: #ffffff;
}

/* red – Delete */
.btn.danger {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

/* big CTA button */
.btn.lg {
    padding: 0.6rem 1.6rem;
    font-size: 0.9rem;
}

/* small pill label button (e.g. ACL) */
.btn.pill {
    padding-inline: 0.8rem;
    font-size: 0.75rem;
}

/* ===== FILTER BAR ===== */

.filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-bar .filter-search {
    flex: 1 1 260px;
}

.filter-bar .filter-field {
    min-width: 160px;
}

.filter-bar .filter-search input[type="text"] {
    border-radius: var(--radius-pill);
    padding-left: 14px;
    padding-right: 14px;
}

/* ===== FORM CONTROLS (GLOBAL) ===== */

input[type="text"],
input[type="password"],
input[type="number"],
input[type="email"],
select,
textarea {
    font-family: inherit;
    font-size: 0.85rem;
    color: var(--text-main);
    border: 1px solid var(--border-subtle);
    border-radius: 8px;
    padding: 6px 10px;
    background: #ffffff;
    width: 100%;
    outline: none;
    box-sizing: border-box;
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(20,105,155,0.09);
}

.form-row {
    margin-bottom: 0.8rem;
}

.form-row label {
    display: block;
    font-size: 0.78rem;
    margin-bottom: 2px;
    color: var(--text-muted);
}

/* ===== TABLES ===== */

.table-wrap {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-subtle);
    padding: 0.7rem 0.9rem 0.9rem;
}

.table-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.table-header-title {
    font-size: 0.9rem;
    font-weight: 600;
}

.table-header-subtitle {
    font-size: 0.76rem;
    color: var(--text-muted);
}

table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 0.4rem;
    font-size: 0.78rem;
}


.table-scroll {
    overflow-x: auto;
}


thead {
    background: #f9fafb;
}

th,
td {
    padding: 0.45rem 0.25rem;
    text-align: left;
}

th {
    font-weight: 600;
    color: #4b5563;
    border-bottom: 1px solid var(--border-subtle);
    font-size: 0.75rem;
}

tbody tr:nth-child(even) {
    background: #f9fafb;
}

tbody tr:hover {
    background: #eef2ff;
}

/* status badges */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.12rem 0.46rem;
    border-radius: var(--radius-pill);
    font-size: 0.7rem;
    font-weight: 500;
}

.badge.success {
    background: #ecfdf3;
    color: #15803d;
}

.badge.warn {
    background: #fffbeb;
    color: #b45309;
}

.badge.muted {
    background: #f3f4f6;
    color: #4b5563;
}

/* ===== FLASH MESSAGES ===== */

.flash {
    max-width: 1440px;
    margin: 0.8rem auto 0.4rem;
    padding: 0.55rem 0.9rem;
    border-radius: 999px;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
}

.flash-ok {
    background: #ecfdf3;
    border: 1px solid #bbf7d0;
    color: #166534;
}

/* ===== GLOBAL PAGE PRELOADER ===== */

.page-preloader {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

.page-preloader.active {
    display: flex;
}

.page-preloader-spinner {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 3px solid #e5e7eb;
    border-top-color: var(--accent);
    animation: preloader-spin 0.7s linear infinite;
}

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

/* ===== RESPONSIVE NAV TOGGLE (if needed later) ===== */

.nav-toggle {
    display: none;
    font-size: 1.4rem;
    cursor: pointer;
}

@media (max-width: 960px) {
    .topbar-inner {
        flex-wrap: wrap;
    }

    .topbar-logo {
        border-right: none;
    }

    .nav-main {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--bg-topbar);
        flex-direction: column;
        padding: 0.35rem 0.5rem 0.6rem;
        border-bottom: 1px solid rgba(31, 41, 55, 0.9);
        display: none;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        width: 100%;
        border-radius: 8px;
        padding: 0.5rem 0.7rem;
    }

    .nav-toggle {
        display: block;
        color: #e5e7eb;
    }
}
/* Menu filters – horizontal layout */
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filters-row .field {
    min-width: 220px;
}
.filters-row .field-actions {
    display: flex;
    gap: 8px;
}

/* Global preloader, shown when body.has class is-loading */
body.is-loading::before {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 9998;
}
body.is-loading::after {
    content: '';
    position: fixed;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    margin: -21px 0 0 -21px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.7);
    border-top-color: transparent;
    animation: spin 0.9s linear infinite;
    z-index: 9999;
}
@keyframes spin {
    to { transform: rotate(360deg); }
}
.filters-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}
.filters-row .field { min-width: 220px; }
.filters-row .field-actions {
    display: flex;
    gap: 8px;
}

/* Level-2 remark styling */
.dropdown .lvl2-remark {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* --- Level 2 Hover Blue Theme (Fix Text + Icon + Remark) --- */

.dropdown-item:hover > .dropdown-link {
    background: #14699b !important;
    color: #ffffff !important;
}

.dropdown-item:hover > .dropdown-link .lvl2-title {
    color: #ffffff !important;
}

.dropdown-item:hover > .dropdown-link .lvl2-remark {
    color: #e8f4ff !important;
}

.dropdown-item:hover > .dropdown-arrow {
    color: #ffffff !important;
}

/* submenu divider alignment */
.dropdown-item.has-submenu:hover {
    background: #14699b !important;
    color: #ffffff !important;
}

