/* ============================================
   Vectis — Styles
   Premium Modern Professional Design System
   ============================================ */

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

/* ---------- Color Tokens & Variables ---------- */
:root {
    --bg-primary: #f5f5f7;
    --bg-secondary: #f9fafb;
    --card-bg: rgba(255, 255, 255, 0.72);
    --card-bg-solid: #ffffff;
    --card-border: rgba(0, 0, 0, 0.06);
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.04), 0 4px 16px rgba(0, 0, 0, 0.03);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.06), 0 12px 40px rgba(0, 0, 0, 0.05);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent-color: #0f172a;
    --accent-hover: #1e293b;
    --accent-green: #167946;
    --accent-green-light: rgba(22, 121, 70, 0.08);
    --input-bg: #ffffff;
    --input-border: rgba(15, 23, 42, 0.12);
    --input-focus: rgba(22, 121, 70, 0.12);
    --sidebar-bg: linear-gradient(180deg, #fefefe 0%, #f8f9fb 100%);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    /* Shared page gutters — every interface (user + admin dashboards and the top
       bar) uses these so margins stay identical and scale fluidly with the
       viewport. Fluid clamp() means no fixed-pixel breakpoints are needed for
       the gutters themselves; media queries below only tighten the floor. */
    --page-pad-x: clamp(1.25rem, 4vw, 3rem);   /* ~20px → 48px */
    --page-pad-y: clamp(1.5rem, 3vw, 2.5rem);  /* ~24px → 40px */
}

/* ---------- Reset & Base ---------- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow: hidden;
    text-rendering: optimizeLegibility;
}

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

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(15, 23, 42, 0.12);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(15, 23, 42, 0.22);
}

/* ---------- Page Entry Animation ---------- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

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

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.96);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes subtleGlow {

    0%,
    100% {
        opacity: 0.5;
    }

    50% {
        opacity: 0.8;
    }
}

/* ================================
   LOGIN PAGE — Premium Split Layout
   ================================ */

@keyframes floatOrb {

    0%,
    100% {
        transform: translateY(0px) scale(1);
    }

    50% {
        transform: translateY(-28px) scale(1.05);
    }
}

@keyframes floatOrb2 {

    0%,
    100% {
        transform: translateY(0px) scale(1);
    }

    50% {
        transform: translateY(22px) scale(0.96);
    }
}

@keyframes shimmer {
    0% {
        background-position: -400px 0;
    }

    100% {
        background-position: 400px 0;
    }
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

#login-screen {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: #ffffff;
    perspective: 1400px;
}

/* ── Left brand panel (light geospatial theme) ── */
.login-brand-panel {
    flex: 0 0 56%;
    position: relative;
    background:
        radial-gradient(ellipse at 15% 20%, rgba(5, 150, 105, 0.10) 0%, transparent 55%),
        radial-gradient(ellipse at 85% 15%, rgba(16, 185, 129, 0.08) 0%, transparent 50%),
        linear-gradient(160deg, #f4faf6 0%, #eef7f1 45%, #e6f3ec 100%);
    display: flex;
    flex-direction: column;
    justify-content: center;
    overflow: hidden;
    padding: 64px 72px;
    transform-style: preserve-3d;
}

/* Subtle contour-grid texture */
.login-brand-panel::before {
    content: '';
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(5, 150, 105, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(5, 150, 105, 0.04) 1px, transparent 1px);
    background-size: 52px 52px;
    mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 85%);
    -webkit-mask-image: radial-gradient(ellipse at 40% 40%, #000 30%, transparent 85%);
    pointer-events: none;
}

/* Floating ambient blobs (parallax depth) */
.login-blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    pointer-events: none;
    will-change: transform;
}

.login-blob-1 {
    width: 360px;
    height: 360px;
    background: radial-gradient(circle, rgba(5, 150, 105, 0.28) 0%, transparent 70%);
    top: -90px;
    left: -70px;
    animation: floatOrb 9s ease-in-out infinite;
}

.login-blob-2 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(52, 211, 153, 0.24) 0%, transparent 70%);
    top: 30%;
    right: -60px;
    animation: floatOrb2 11s ease-in-out infinite;
}

.login-blob-3 {
    width: 220px;
    height: 220px;
    background: radial-gradient(circle, rgba(110, 231, 183, 0.22) 0%, transparent 70%);
    bottom: 18%;
    left: 22%;
    animation: floatOrb 14s ease-in-out infinite 2s;
}

/* Brand content */
.login-brand-content {
    position: relative;
    z-index: 3;
    text-align: left;
    max-width: 460px;
    transform-style: preserve-3d;
}

.login-brand-logo {
    height: 46px;
    margin-bottom: 54px;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    filter: drop-shadow(0 6px 14px rgba(5, 150, 105, 0.18));
    will-change: transform;
}

.login-brand-logo:hover {
    transform: scale(1.05) translateZ(30px);
}

/* Eyebrow pill */
.login-eyebrow-pill {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: rgba(22, 121, 70, 0.10);
    border: 1px solid rgba(22, 121, 70, 0.18);
    border-radius: 100px;
    font-size: 13px;
    font-weight: 700;
    color: #167946;
    margin-bottom: 26px;
    will-change: transform;
    box-shadow: 0 6px 18px rgba(22, 121, 70, 0.10);
}

.login-eyebrow-dash {
    width: 18px;
    height: 2px;
    border-radius: 2px;
    background: #167946;
}

.login-brand-headline {
    font-size: 52px;
    font-weight: 800;
    color: #0f2a1d;
    line-height: 1.08;
    letter-spacing: -1.5px;
    margin-bottom: 22px;
    will-change: transform;
}

.login-brand-headline span {
    background: linear-gradient(120deg, #167946 0%, #1da560 45%, #48c586 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    background-size: 200% 100%;
    animation: gradientShift 5s ease-in-out infinite;
}

.login-brand-divider {
    width: 64px;
    height: 4px;
    background: linear-gradient(90deg, #167946, #48c586);
    border-radius: 4px;
    margin-bottom: 26px;
}

.login-brand-desc {
    font-size: 16px;
    color: #4b6b5c;
    line-height: 1.7;
    max-width: 400px;
    margin: 0 0 40px;
    font-weight: 400;
    will-change: transform;
}

/* Feature list */
.login-features {
    display: flex;
    flex-direction: column;
    gap: 22px;
    will-change: transform;
}

.login-feature {
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-feature:hover {
    transform: translateX(6px) translateZ(24px);
}

.login-feature-icon {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #167946;
    background: #ffffff;
    box-shadow: 0 8px 20px rgba(22, 121, 70, 0.14), inset 0 0 0 1px rgba(22, 121, 70, 0.10);
    transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.35s ease;
}

.login-feature:hover .login-feature-icon {
    transform: translateZ(30px) rotate(-6deg);
    box-shadow: 0 14px 28px rgba(22, 121, 70, 0.22);
}

.login-feature-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.login-feature-text strong {
    font-size: 15px;
    font-weight: 700;
    color: #10241a;
}

.login-feature-text span {
    font-size: 13px;
    color: #5c7a6b;
}

/* Layered mountain scenery (parallax) */
.login-scenery {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 42%;
    z-index: 1;
    pointer-events: none;
}

.login-mtn {
    position: absolute;
    left: -4%;
    bottom: 0;
    width: 108%;
    height: 100%;
    will-change: transform;
}

.login-mtn-1 path {
    fill: rgba(5, 150, 105, 0.30);
}

.login-mtn-2 path {
    fill: rgba(16, 185, 129, 0.18);
}

.login-mtn-3 path {
    fill: rgba(52, 211, 153, 0.12);
}

/* ── Right form panel ── */
.login-form-panel {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    padding: 48px 44px;
    overflow-y: auto;
}

.login-card {
    width: 100%;
    max-width: 400px;
    padding: 40px 38px;
    background: #ffffff;
    border: 1px solid rgba(5, 150, 105, 0.10);
    border-radius: 22px;
    box-shadow: 0 30px 70px rgba(6, 40, 28, 0.12), 0 8px 24px rgba(6, 40, 28, 0.06);
    animation: loginCardIn 0.7s cubic-bezier(0.16, 1, 0.3, 1);
    transform-style: preserve-3d;
    transition: box-shadow 0.4s ease, transform 0.15s ease-out;
    will-change: transform;
}

.login-card>* {
    transform: translateZ(24px);
}

@keyframes loginCardIn {
    from {
        opacity: 0;
        transform: perspective(1400px) rotateY(-12deg) translateY(24px);
    }
    to {
        opacity: 1;
        transform: perspective(1400px) rotateY(0) translateY(0);
    }
}

/* Welcome text */
.login-welcome {
    margin-bottom: 30px;
    text-align: center;
}

.login-welcome h2 {
    font-size: 25px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.5px;
    margin-bottom: 8px;
    line-height: 1.2;
}

.login-welcome p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* Input with leading icon + password eye */
.login-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.login-input-icon {
    position: absolute;
    left: 14px;
    display: flex;
    color: var(--text-muted);
    pointer-events: none;
    transition: color 0.25s ease;
    z-index: 2;
}

.login-input-wrap:focus-within .login-input-icon {
    color: var(--accent-green);
}

.login-card .form-group .login-input-wrap input {
    padding-left: 42px;
    padding-right: 44px;
}

.login-eye {
    position: absolute;
    right: 8px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: 8px;
    transition: color 0.2s ease, background 0.2s ease;
    z-index: 2;
}

.login-eye:hover {
    color: var(--accent-green);
    background: rgba(5, 150, 105, 0.08);
}

/* Options row: remember me + forgot */
.login-options {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: -4px 0 20px;
}

.login-remember {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13px;
    color: var(--text-secondary);
    cursor: pointer;
    user-select: none;
}

.login-remember input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.login-checkbox {
    width: 18px;
    height: 18px;
    border-radius: 6px;
    border: 1.5px solid rgba(15, 23, 42, 0.22);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-spring);
    flex-shrink: 0;
}

.login-remember input:checked+.login-checkbox {
    background: var(--accent-green);
    border-color: var(--accent-green);
    box-shadow: 0 4px 10px rgba(22, 121, 70, 0.30);
}

.login-remember input:checked+.login-checkbox::after {
    content: '';
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg) translateY(-1px);
}

.login-forgot {
    font-size: 13px;
    font-weight: 600;
    color: var(--accent-green);
    text-decoration: none;
    transition: color 0.2s ease;
}

.login-forgot:hover {
    color: #115c35;
    text-decoration: underline;
    text-underline-offset: 3px;
}

/* Role selector — top-right compact pill */
#role-selector {
    position: absolute;
    top: 0;
    right: 0;
    display: flex;
    background: var(--bg-primary);
    border-radius: var(--radius-sm);
    padding: 3px;
    gap: 2px;
    z-index: 5;
}

#role-selector button {
    padding: 5px 14px;
    font-size: 11.5px;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: var(--transition-spring);
    font-family: inherit;
    letter-spacing: 0.2px;
    background: transparent;
    color: var(--text-muted);
}

#role-selector button.role-btn-active {
    background: var(--text-primary);
    color: #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

#role-selector button:not(.role-btn-active):hover {
    color: var(--text-secondary);
    background: rgba(15, 23, 42, 0.04);
}

/* Sign In / Sign Up toggle text */
.login-toggle-text {
    text-align: center;
    margin-top: 22px;
    font-size: 13px;
    color: var(--text-muted);
}

.login-toggle-text a {
    color: var(--accent-green);
    font-weight: 600;
    text-decoration: none;
    transition: var(--transition-smooth);
}

.login-toggle-text a:hover {
    color: #115c35;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.login-card .logo-area {
    display: none;
}

/* Form inputs */
.login-card .form-group {
    margin-bottom: 20px;
    text-align: left;
}

.login-card .form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.login-card .form-group input {
    width: 100%;
    padding: 13px 16px;
    border: 1.5px solid rgba(15, 23, 42, 0.1);
    border-radius: var(--radius-md);
    font-size: 14px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--bg-primary);
    transition: var(--transition-spring);
}

.login-card .form-group input::placeholder {
    color: var(--text-muted);
}

.login-card .form-group input:focus {
    outline: none;
    border-color: var(--accent-green);
    background: #fff;
    box-shadow: 0 0 0 4px var(--input-focus);
}

/* Sign In button */
.login-card .btn-login {
    width: 100%;
    padding: 14px;
    background: #167946;
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-spring);
    margin-top: 4px;
    letter-spacing: 0.3px;
    box-shadow: 0 8px 22px rgba(22, 121, 70, 0.30), 0 1px 3px rgba(22, 121, 70, 0.15);
    position: relative;
    overflow: hidden;
}

.login-card .btn-login::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.14) 0%, transparent 55%);
    pointer-events: none;
}

.login-card .btn-login:hover {
    background: #136a3d;
    transform: translateY(-2px) translateZ(24px);
    box-shadow: 0 14px 34px rgba(22, 121, 70, 0.38), 0 3px 8px rgba(22, 121, 70, 0.18);
}

.login-card .btn-login:active {
    transform: translateY(0) scale(0.985);
    box-shadow: 0 4px 12px rgba(22, 121, 70, 0.25);
}

/* Premium loading state while signing in (covers network latency) */
.login-card .btn-login .btn-login-label {
    display: inline-block;
    transition: opacity 0.2s ease;
}

.login-card .btn-login .btn-login-loader {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    gap: 7px;
    z-index: 2;
}

.login-card .btn-login .btn-login-loader span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.6);
    animation: btnDotWave 1.1s ease-in-out infinite;
}

.login-card .btn-login .btn-login-loader span:nth-child(2) {
    animation-delay: 0.16s;
}

.login-card .btn-login .btn-login-loader span:nth-child(3) {
    animation-delay: 0.32s;
}

.login-card .btn-login.loading {
    pointer-events: none;
    transform: none;
}

.login-card .btn-login.loading .btn-login-label {
    opacity: 0;
}

.login-card .btn-login.loading .btn-login-loader {
    display: flex;
}

/* Light sweep across the button surface while loading */
.login-card .btn-login.loading::after {
    background: linear-gradient(110deg,
            transparent 25%,
            rgba(255, 255, 255, 0.18) 50%,
            transparent 75%);
    background-size: 220% 100%;
    animation: btnShimmer 1.6s ease-in-out infinite;
}

@keyframes btnDotWave {
    0%, 65%, 100% {
        transform: translateY(0) scale(0.85);
        opacity: 0.45;
    }
    32% {
        transform: translateY(-7px) scale(1);
        opacity: 1;
    }
}

@keyframes btnShimmer {
    0% {
        background-position: 220% 0;
    }
    100% {
        background-position: -220% 0;
    }
}

/* User tab strip inside user panel */
#panel-user>div:first-child {
    border-bottom-color: rgba(15, 23, 42, 0.08) !important;
}

.login-error {
    color: #dc2626;
    font-size: 12.5px;
    margin-top: 12px;
    display: none;
    font-weight: 500;
    padding: 8px 12px;
    background: rgba(220, 38, 38, 0.06);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(220, 38, 38, 0.1);
}

/* Footer note */
.login-footer-note {
    margin-top: 32px;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
    letter-spacing: 0.2px;
}

.login-footer-note a {
    color: var(--text-secondary);
    font-weight: 600;
    text-decoration: none;
}

.login-footer-note a:hover {
    color: var(--text-primary);
}

/* Responsive: stack on small screens */
@media (max-width: 768px) {
    .login-brand-panel {
        display: none;
    }

    .login-form-panel {
        padding: 32px 24px;
    }
}

/* ================================
   APP LAYOUT
   ================================ */
#app-wrapper {
    display: none;
    height: 100vh;
    background: var(--bg-primary);
}

#app-wrapper.active {
    display: flex;
}

/* ---------- Sidebar ---------- */
.sidebar {
    width: 254px;
    min-width: 254px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(16px);
    box-shadow: 1px 0 0 rgba(0, 0, 0, 0.02);
}

.sidebar-header {
    padding: 24px 24px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-header img {
    height: 57px;
    opacity: 0.95;
    transition: var(--transition-smooth);
}

.sidebar-logo-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    border-radius: 8px;
}

.sidebar-logo-link:hover img {
    opacity: 1;
    transform: scale(1.02);
}

.sidebar-logo-link:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 3px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav .nav-section-title {
    font-size: 10px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    padding: 20px 24px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 24px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition-smooth);
    border-left: 3px solid transparent;
    margin: 1px 0;
    position: relative;
}

.nav-item:hover {
    background: rgba(15, 23, 42, 0.03);
    color: var(--text-primary);
}

/* USA has a single Quotation and Invoice — never show the domestic/international
   flyout sub-menus in USA mode. The selectors below must out-specify the
   hover-open rule (#nav-qu-wrap:hover > #nav-qu-menu) further down this file. */
body.branch-us #nav-qu-menu,
body.branch-us #nav-inv-menu,
body.branch-us #nav-qu-wrap:hover > #nav-qu-menu,
body.branch-us #nav-inv-wrap:hover > #nav-inv-menu {
    display: none !important;
}

.nav-item.active {
    background: var(--accent-green-light);
    color: var(--accent-green);
    font-weight: 600;
    border-left-color: var(--accent-green);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    background: var(--accent-green);
    border-radius: 3px 0 0 3px;
    opacity: 0.4;
}

.sidebar-system-nav {
    border-top: 1px solid rgba(15, 23, 42, 0.05);
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.btn-sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 11px 14px;
    background: rgba(15, 23, 42, 0.02);
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: inherit;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.btn-sidebar-footer:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
    border-color: rgba(15, 23, 42, 0.12);
}

.btn-sidebar-footer.active {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
    font-weight: 600;
    border-color: var(--text-primary);
}

/* ---------- Main Content ---------- */
.main-content {
    /* Full-width column under the top bar. Responsive flex container. */
    margin-left: 0;
    flex: 1;
    height: 100vh;
    overflow-y: auto;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    width: 100%;
}

.page-section {
    display: none;
    padding: var(--page-pad-y) var(--page-pad-x);
    width: 100%;
    box-sizing: border-box;
}

.page-section.active {
    display: flex;
    flex-direction: column;
    flex: 1;
    width: 100%;
    min-height: calc(100vh - 80px);
    box-sizing: border-box;
    animation: fadeInUp 0.45s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 36px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -0.8px;
    line-height: 1.2;
}

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

/* ================================
   DASHBOARD
   ================================ */
.stats-grid {
    display: grid;
    /* auto-fit keeps the cards balanced at any count (4 sit 4-up on wide,
       2-up on medium) instead of orphaning the 4th card on its own row. */
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 36px;
}

.stat-card {
    background: var(--card-bg-solid);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 28px 30px;
    transition: var(--transition-spring);
    backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-green), #818cf8);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(15, 23, 42, 0.12);
    box-shadow: var(--card-shadow-hover);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card .stat-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-card .stat-value {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-primary);
    margin-top: 10px;
    letter-spacing: -1px;
    line-height: 1;
}

/* Recent Documents */
.recent-section {
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.recent-section h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    letter-spacing: -0.3px;
}

.recent-table {
    width: 100%;
    background: var(--card-bg-solid);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    flex: 1;
    display: flex;
    flex-direction: column;
}

.recent-table table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

/* Don't let the date/amount columns break onto multiple lines. */
.recent-table th,
.recent-table td {
    white-space: nowrap;
}

.recent-table th {
    text-align: left;
    padding: 14px 20px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 1px solid var(--card-border);
    background: rgba(15, 23, 42, 0.02);
}

.recent-table td {
    padding: 14px 20px;
    font-size: 13.5px;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
}

.recent-table tr:last-child td {
    border-bottom: none;
}

.recent-table tr {
    transition: background 0.2s ease;
}

.recent-table tr:hover td {
    background: rgba(5, 150, 105, 0.03);
}

.badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 600;
    letter-spacing: 0.3px;
}

.badge-po {
    background: rgba(15, 23, 42, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(15, 23, 42, 0.1);
}

.badge-qu {
    background: rgba(99, 102, 241, 0.06);
    color: #6366f1;
    border: 1px solid rgba(99, 102, 241, 0.12);
}

.badge-inv {
    background: var(--accent-green-light);
    color: var(--accent-green);
    border: 1px solid rgba(5, 150, 105, 0.18);
}

.btn-redownload {
    padding: 6px 14px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-family: inherit;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition-smooth);
    font-weight: 500;
}

.btn-redownload:hover {
    background: var(--text-primary);
    color: #fff;
    border-color: var(--text-primary);
}

.empty-state {
    text-align: center;
    padding: 72px 24px;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    width: 100%;
    min-height: 280px;
    box-sizing: border-box;
}

.empty-state p {
    font-size: 14px;
}

/* ================================
   FORMS
   ================================ */
.form-container {
    background: var(--card-bg-solid);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--card-shadow);
    transition: var(--transition-smooth);
    width: 100%;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

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

.form-section-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    display: flex;
    align-items: center;
    gap: 8px;
    letter-spacing: -0.1px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 18px;
}

.form-row.three-col {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row.single {
    grid-template-columns: 1fr;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 11px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: var(--transition-spring);
}

.form-group select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 4px var(--input-focus);
    background: #fff;
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group input[type="file"] {
    padding: 10px;
    font-size: 12px;
    background: rgba(15, 23, 42, 0.01);
}

/* ---------- Dynamic Items Table ---------- */
.items-table-wrapper {
    overflow: visible;
    margin-top: 10px;
}

.items-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 950px;
    table-layout: fixed;
}

.items-table th {
    text-align: left;
    padding: 12px 14px;
    font-size: 10.5px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    border-bottom: 2px solid rgba(15, 23, 42, 0.06);
    background: rgba(15, 23, 42, 0.015);
    white-space: nowrap;
}

.items-table th.col-sno,
.items-table th.col-uom,
.items-table th.col-qty,
.items-table th.col-hours {
    text-align: center !important;
}

.items-table th.col-rate,
.items-table th.col-discount,
.items-table th.col-amount {
    text-align: right !important;
}

.items-table td {
    padding: 8px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.04);
    vertical-align: top;
}

.items-table td input,
.items-table td select,
.items-table td textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: var(--transition-smooth);
}

.items-table td textarea {
    min-height: 38px;
    resize: vertical;
}

.items-table td input:focus,
.items-table td select:focus,
.items-table td textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--input-focus);
}

/* ---------- Custom Select Dropdown ---------- */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    width: 100%;
}

.custom-select-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 12px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 13px;
    background: var(--input-bg);
    cursor: pointer;
    transition: var(--transition-spring);
    height: 38px;
    color: var(--text-primary);
}

.custom-select-trigger:hover {
    border-color: var(--accent-green);
    background: #fff;
}

.custom-select-trigger .arrow {
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 4px solid var(--text-muted);
    transition: transform 0.2s;
    margin-left: 6px;
}

.custom-select-wrapper.open .custom-select-trigger .arrow {
    transform: rotate(180deg);
}

.custom-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: var(--radius-sm);
    margin-top: 4px;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.1);
    display: none;
    z-index: 1000;
    max-height: 250px;
    overflow-y: auto;
    overflow-x: hidden;
}

.custom-select-wrapper.open .custom-options {
    display: block;
    animation: fadeInUp 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.custom-option {
    display: block;
    padding: 9px 14px;
    font-size: 13px;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.15s;
    text-align: left;
}

.custom-option:hover {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.custom-option.selected {
    background: var(--accent-green-light);
    font-weight: 600;
    color: var(--accent-green);
}

/* Ensure row/cell/card containing open dropdown stack on top */
.items-table tr:has(.custom-select-wrapper.open),
.items-table td:has(.custom-select-wrapper.open),
.form-container:has(.custom-select-wrapper.open) {
    position: relative;
    z-index: 1005;
}




.items-table .col-sno {
    width: 50px;
}

.items-table .col-name {
    width: 216px;
}

/* Increased by 20% (180px -> 216px) */
.items-table .col-desc {
    width: 300px;
}

/* Decreased by 25% compared to baseline wide layout */
.items-table .col-uom {
    width: 100px;
}

.items-table .col-qty {
    width: 100px;
}

.items-table .col-hours {
    width: 100px;
}

.items-table .col-rate {
    width: 140px;
}

.items-table .col-discount {
    width: 110px;
}

.items-table .col-amount {
    width: 130px;
}

.items-table .col-actions {
    width: 44px;
}

.items-table .amount-display {
    padding: 9px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.015);
    border: 1px solid rgba(15, 23, 42, 0.04);
    border-radius: 6px;
    text-align: right;
    min-height: 36px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
}

.items-table .sno-display {
    padding: 9px 0;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.total-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 16px;
    padding: 18px 12px;
    border-top: 2px solid rgba(15, 23, 42, 0.06);
    margin-top: 6px;
}

/* Group CGST and SGST rows together visually by removing middle border */
#po-cgst-row, #qu-cgst-row, #inv-cgst-row {
    padding-bottom: 6px;
}
#po-sgst-row, #qu-sgst-row, #inv-sgst-row {
    border-top: none;
    margin-top: 0;
    padding-top: 6px;
}
#po-subtotal-row, #qu-subtotal-row, #inv-subtotal-row {
    border-top: none;
    margin-top: 0;
    padding-top: 6px;
    padding-bottom: 6px;
}

.total-row .total-label {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
}

.total-row .total-value {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    min-width: 150px;
    text-align: right;
    letter-spacing: -0.3px;
}

.amount-words {
    padding: 14px 18px;
    background: var(--accent-green-light);
    border: 1px solid rgba(5, 150, 105, 0.12);
    border-radius: var(--radius-sm);
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 10px;
}

/* ---------- Dynamic Lists (Terms, Conditions) ---------- */
.dynamic-list {
    margin-top: 10px;
}

.dynamic-list-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 10px;
}

.dynamic-list-item span.list-number {
    min-width: 24px;
    padding-top: 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}

.dynamic-list-item input,
.dynamic-list-item textarea {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    color: var(--text-primary);
    background: var(--input-bg);
    transition: var(--transition-smooth);
}

.dynamic-list-item textarea {
    min-height: 40px;
    resize: vertical;
}

.dynamic-list-item input:focus,
.dynamic-list-item textarea:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--input-focus);
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-spring);
    border: none;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-add {
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(15, 23, 42, 0.08);
    color: var(--text-primary);
}

.btn-add:hover {
    background: rgba(15, 23, 42, 0.06);
    border-color: rgba(15, 23, 42, 0.15);
}

.btn-add.active {
    background: var(--accent-green-light);
    border-color: rgba(5, 150, 105, 0.25);
    color: var(--accent-green);
}

.btn-remove {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 10px;
    border-radius: 6px;
    transition: var(--transition-smooth);
    line-height: 1;
}

.btn-remove:hover {
    color: #dc2626;
    background: rgba(220, 38, 38, 0.06);
}

.btn-generate {
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    color: #fff;
    padding: 14px 36px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 16px rgba(15, 23, 42, 0.15);
    border-radius: var(--radius-md);
}

.btn-generate:hover {
    background: linear-gradient(135deg, #1e293b 0%, #334155 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 24px rgba(15, 23, 42, 0.2);
}

.btn-generate:active {
    transform: translateY(0) scale(0.98);
}

.btn-danger {
    background: linear-gradient(135deg, #dc2626 0%, #ef4444 100%);
    color: #fff;
    padding: 14px 36px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(220, 38, 38, 0.2);
    border-radius: var(--radius-md);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #b91c1c 0%, #dc2626 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(220, 38, 38, 0.25);
}

.btn-danger:active {
    transform: translateY(0) scale(0.98);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid rgba(15, 23, 42, 0.12);
    padding: 14px 30px;
    font-size: 14px;
    border-radius: var(--radius-md);
}

.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.2);
}

.btn-secondary:disabled,
.btn-secondary[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    background: rgba(15, 23, 42, 0.02);
}

.btn-secondary:disabled:hover,
.btn-secondary[disabled]:hover {
    background: rgba(15, 23, 42, 0.02);
    border-color: rgba(15, 23, 42, 0.12);
}

.form-actions {
    display: flex;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid rgba(15, 23, 42, 0.06);
}

/* ---------- Image Preview ---------- */
.image-preview-area {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-top: 10px;
}

.image-preview {
    width: 100px;
    height: 100px;
    border: 1.5px dashed rgba(15, 23, 42, 0.12);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: rgba(15, 23, 42, 0.01);
    transition: var(--transition-smooth);
}

.image-preview:hover {
    border-color: var(--accent-green);
    background: var(--accent-green-light);
}

.image-preview img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    opacity: 0.85;
}

.image-preview .placeholder-text {
    font-size: 11px;
    color: var(--text-muted);
    text-align: center;
}

/* ---------- Settings & Profile Section Grid Layouts ---------- */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    align-items: stretch;
}

.settings-grid .form-container {
    min-height: 274px;
    height: auto;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 22px 24px;
}

.profile-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: start;
}

.profile-col {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ---------- Toast Notification ---------- */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--card-bg-solid);
    color: var(--text-primary);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 500;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.12), 0 2px 8px rgba(15, 23, 42, 0.06);
    border: 1px solid var(--card-border);
    z-index: 99999;
    transform: translateY(20px);
    opacity: 0;
    transition: var(--transition-spring);
    display: flex;
    align-items: center;
    gap: 10px;
    backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    border-left: 4px solid var(--accent-green);
}

.toast.error {
    border-left: 4px solid #dc2626;
}

.toast.welcome {
    border-left: 4px solid var(--accent-green);
}

.toast.warning {
    border-left: 4px solid #f59e0b;
}

.toast.info {
    border-left: 4px solid #3b82f6;
}

/* ---------- Loading Overlay ---------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255, 255, 255, 0.88);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    flex-direction: column;
    gap: 20px;
    backdrop-filter: blur(12px);
}

.loading-overlay.show {
    display: flex;
}

.loading-anim {
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-anim lottie-player {
    width: 150px;
    height: 150px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(15, 23, 42, 0.06);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

/* To-Marvel file upload spinner */
.tm-upload-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(15, 23, 42, 0.12);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.loading-overlay p {
    font-size: 14px;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.3px;
}

/* ---------- Toggle Switch ---------- */
.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 22px;
    user-select: none;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(15, 23, 42, 0.08);
    transition: background-color 0.18s ease;
    border-radius: 22px;
    border: 1px solid rgba(15, 23, 42, 0.05);
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: #ffffff;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform;
    border-radius: 50%;
    box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.switch input:checked+.slider {
    background-color: var(--accent-green);
}

.switch input:checked+.slider:before {
    transform: translateX(20px);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
    /* Tighten the shared gutters on small screens — still variable-driven so the
       top bar and every dashboard stay aligned. (The old sidebar-era
       margin-left / fixed sidebar width rules were dropped: the layout is now a
       full-width top bar, not a left rail.) */
    :root {
        --page-pad-x: clamp(1rem, 3.5vw, 1.5rem);
        --page-pad-y: clamp(1.25rem, 3vw, 1.5rem);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .profile-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .form-row.three-col {
        grid-template-columns: 1fr;
    }

    .items-table-wrapper {
        overflow-x: auto;
    }
}

/* ---------- Rate & Currency Single Box Input ---------- */
.rate-currency-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    height: 38px;
    transition: var(--transition-spring);
    overflow: visible;
    position: relative;
    width: 100%;
}

.rate-currency-box:focus-within {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--input-focus);
    background: #fff;
}

.rate-currency-box input.item-rate,
.rate-currency-box input.item-price {
    flex: 1;
    border: none !important;
    background: transparent !important;
    height: 100% !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
    color: var(--text-primary) !important;
    min-width: 0 !important;
    box-shadow: none !important;
}

.rate-currency-box input.item-rate:focus,
.rate-currency-box input.item-price:focus {
    outline: none !important;
    box-shadow: none !important;
}

.rate-currency-box .currency-select {
    width: 87px;
    height: 100%;
    flex-shrink: 0;
    position: relative;
}

.rate-currency-box .currency-select .custom-select-trigger {
    border: none !important;
    background: transparent !important;
    height: 100% !important;
    padding: 0 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-left: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 0 !important;
}

.rate-currency-box .currency-select .custom-options {
    right: 0;
    left: auto;
    width: 120px;
    max-height: 200px;
    overflow-y: auto;
}

/* UOM combined box: 70% numeric input + 30% unit list */
.uom-box {
    display: flex;
    align-items: center;
    border: 1px solid var(--input-border);
    border-radius: 6px;
    background: var(--input-bg);
    height: 38px;
    transition: var(--transition-spring);
    overflow: visible;
    position: relative;
    width: 100%;
}

.uom-box:focus-within {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--input-focus);
    background: #fff;
}

.uom-box > input[type=number] {
    flex: 0 0 70%;
    width: 70%;
    border: none !important;
    background: transparent !important;
    height: 100% !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
    color: var(--text-primary) !important;
    min-width: 0 !important;
    box-shadow: none !important;
}

.uom-box > input[type=number]:focus {
    outline: none !important;
    box-shadow: none !important;
}

.uom-box .uom-select {
    flex: 0 0 30%;
    width: 30%;
    height: 100%;
    flex-shrink: 0;
    position: relative;
}

.uom-box .uom-select .custom-select-trigger {
    border: none !important;
    background: transparent !important;
    height: 100% !important;
    padding: 0 6px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    border-left: 1px solid rgba(15, 23, 42, 0.08) !important;
    border-radius: 0 !important;
    justify-content: center;
}

.uom-box .uom-select .custom-options {
    right: 0;
    left: auto;
    width: 90px;
    max-height: 200px;
    overflow-y: auto;
}

/* Cap the UOM dropdown height so a long custom list scrolls instead of
   overflowing the page (applies to standalone Quotation/PO dropdowns too). */
.uom-select .custom-options {
    max-height: 220px;
    overflow-y: auto;
}

/* "+ Add UOM" entry sits at the bottom of every UOM dropdown */
.custom-option.uom-add-option:hover {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

/* Invoice UOM column needs room for the combined box */
#inv-items-table .col-hours {
    width: 150px;
}

/* Hide number input spinners (up and down arrows) */
input[type=number]::-webkit-outer-spin-button,
input[type=number]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

input[type=number] {
    -moz-appearance: textfield;
}

/* ---------- Dashboard Actions Buttons ---------- */
.btn-action-view,
.btn-action-revise,
.btn-action-edit,
.btn-action-download,
.btn-action-delete {
    padding: 6px 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-left: 4px;
    letter-spacing: 0.1px;
}

.btn-action-view,
.btn-action-revise,
.btn-action-edit {
    background: rgba(15, 23, 42, 0.02);
    color: var(--text-secondary);
}

.btn-action-view:hover,
.btn-action-revise:hover,
.btn-action-edit:hover {
    background: var(--accent-green-light);
    color: var(--accent-green);
    border-color: rgba(5, 150, 105, 0.25);
}

.btn-action-download {
    background: linear-gradient(135deg, #0f172a, #1e293b);
    color: #fff;
    border-color: #0f172a;
}

.btn-action-download:hover {
    background: linear-gradient(135deg, #1e293b, #334155);
    border-color: #1e293b;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.15);
}

.btn-action-delete {
    background: transparent;
    color: #dc2626;
    border-color: rgba(220, 38, 38, 0.15);
}

.btn-action-delete:hover {
    background: rgba(220, 38, 38, 0.06);
    border-color: #dc2626;
}

/* ============================================
   ROW ACTIONS — single kebab button + popup menu
   ============================================ */
.btn-row-actions {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    width: 34px;
    height: 32px;
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
    color: var(--text-secondary);
    transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}
.btn-row-actions:hover {
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-primary);
    border-color: rgba(15, 23, 42, 0.18);
}

.row-actions-popup {
    position: fixed;
    /* Above the stat-card document popup (z-index 15000) so the ⋮ menu opened from
       a row inside that popup isn't hidden behind it; still below confirm/prompt
       dialogs (20000). */
    z-index: 16000;
    min-width: 152px;
    background: #ffffff;
    border: 1px solid var(--card-border);
    border-radius: 10px;
    box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16);
    padding: 6px;
    display: flex;
    flex-direction: column;
    animation: scaleIn 0.14s cubic-bezier(0.16, 1, 0.3, 1);
}
.row-actions-popup button {
    text-align: left;
    background: transparent;
    border: none;
    padding: 9px 12px;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-primary);
    cursor: pointer;
    transition: background 0.12s ease, color 0.12s ease;
}
.row-actions-popup button:hover {
    background: rgba(0, 77, 44, 0.08);
    color: #004d2c;
}
.row-actions-popup button.danger {
    color: #dc2626;
}
.row-actions-popup button.danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

.btn-action-generate {
    padding: 6px 12px;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: var(--transition-smooth);
    margin-left: 4px;
    letter-spacing: 0.1px;
    background: rgba(15, 23, 42, 0.02);
    color: var(--text-secondary);
}

.btn-action-generate:hover {
    background: var(--accent-green-light);
    color: var(--accent-green);
    border-color: rgba(5, 150, 105, 0.25);
}

/* ---------- PO Column Visibility Settings ---------- */
.btn-settings-icon {
    background: var(--card-bg-solid);
    border: 1px solid var(--card-border);
    padding: 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    transition: var(--transition-smooth);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(12px);
}

.btn-settings-icon:hover {
    color: var(--accent-green);
    border-color: rgba(5, 150, 105, 0.25);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.10);
}

/* Hide Table Columns via parent class on table */
#po-items-table.hide-col-sno .col-sno,
#qu-items-table.hide-col-sno .col-sno,
#po-items-table.hide-col-name .col-name,
#po-items-table.hide-col-desc .col-desc,
#qu-items-table.hide-col-desc .col-desc,
#po-items-table.hide-col-uom .col-uom,
#qu-items-table.hide-col-uom .col-uom,
#po-items-table.hide-col-qty .col-qty,
#qu-items-table.hide-col-qty .col-qty,
#inv-items-table.hide-col-qty .col-qty,
#inv-items-table.hide-col-hours .col-hours,
#po-items-table.hide-col-rate .col-rate,
#qu-items-table.hide-col-rate .col-rate,
#inv-items-table.hide-col-rate .col-rate,
#po-items-table.hide-col-discount .col-discount,
#qu-items-table.hide-col-discount .col-discount,
#po-items-table.hide-col-amount .col-amount,
#qu-items-table.hide-col-amount .col-amount {
    display: none;
}

/* ---------- Discount Custom Select & Input Styles ---------- */
.discount-trigger {
    padding: 0 !important;
    position: relative;
    cursor: text;
}

.discount-trigger input.item-discount-input {
    width: 100%;
    height: 100%;
    border: none !important;
    background: transparent !important;
    padding: 9px 12px !important;
    font-size: 13px !important;
    color: var(--text-primary) !important;
    text-align: left;
}

.discount-trigger input.item-discount-input:focus {
    outline: none !important;
    box-shadow: none !important;
}

/* ---------- Dashboard Filters ---------- */
.dashboard-filters {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
}

.dashboard-filter-input {
    padding: 9px 14px;
    border: 1px solid var(--input-border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-family: inherit;
    outline: none;
    background: var(--input-bg);
    color: var(--text-primary);
    transition: var(--transition-spring);
    height: 38px;
    box-sizing: border-box;
}

.dashboard-filter-input:focus {
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px var(--input-focus);
    background: #fff;
}

/* ---------- Server Connection Status Indicator ---------- */
#server-status-indicator.status-online {
    background: var(--accent-green-light);
    border: 1px solid rgba(5, 150, 105, 0.18);
    color: var(--accent-green);
}

#server-status-indicator.status-offline {
    background: rgba(220, 38, 38, 0.06);
    border: 1px solid rgba(220, 38, 38, 0.12);
    color: #dc2626;
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: currentColor;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% {
        opacity: 0.5;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.5;
    }
}

/* ================================
   ADMIN PANEL
   ================================ */

/* Admin Panel Tabs */
.admin-panel-tabs {
    display: flex;
    gap: 4px;
    background: rgba(15, 23, 42, 0.04);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 28px;
    width: fit-content;
}

.admin-tab {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 10px 22px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition-spring);
    background: transparent;
    color: var(--text-muted);
    letter-spacing: 0.1px;
}

.admin-tab:hover {
    background: rgba(15, 23, 42, 0.04);
    color: var(--text-secondary);
}

.admin-tab.active {
    background: var(--card-bg-solid);
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
}

.admin-tab-chip {
    background: #dc2626;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 10px;
    padding: 1px 7px;
    line-height: 16px;
}

.admin-tab-content {
    display: none;
}

.admin-tab-content.active {
    display: block;
    animation: fadeInUp 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.admin-section-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

@media (max-width: 1024px) {
    .admin-section-grid {
        grid-template-columns: 1fr;
    }
}

/* Activity Log Entries */
.activity-log-entry {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.015);
    border: 1px solid rgba(15, 23, 42, 0.04);
    margin-bottom: 8px;
    transition: var(--transition-smooth);
}

.activity-log-entry:hover {
    background: rgba(15, 23, 42, 0.03);
    border-color: rgba(15, 23, 42, 0.08);
    transform: translateX(2px);
}

.activity-icon {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}

.activity-icon.login {
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
}

.activity-icon.file_generated {
    background: var(--accent-green-light);
    color: var(--accent-green);
}

.activity-icon.file_edited {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
}

.activity-icon.file_deleted {
    background: rgba(220, 38, 38, 0.06);
    color: #dc2626;
}

.activity-icon.settings_changed {
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
}

.activity-icon.user_action {
    background: rgba(6, 182, 212, 0.08);
    color: #06b6d4;
}

.activity-icon.logout {
    background: rgba(107, 114, 128, 0.08);
    color: #6b7280;
}

.activity-details {
    flex: 1;
    min-width: 0;
}

.activity-details .activity-title {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 2px;
}

.activity-details .activity-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.activity-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    flex-shrink: 0;
    gap: 4px;
}

.activity-time {
    font-size: 11.5px;
    color: var(--text-muted);
    font-weight: 500;
    white-space: nowrap;
}

.activity-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.activity-badge.login {
    background: rgba(59, 130, 246, 0.08);
    color: #3b82f6;
    border: 1px solid rgba(59, 130, 246, 0.12);
}

.activity-badge.file_generated {
    background: var(--accent-green-light);
    color: var(--accent-green);
    border: 1px solid rgba(5, 150, 105, 0.12);
}

.activity-badge.file_edited {
    background: rgba(245, 158, 11, 0.08);
    color: #f59e0b;
    border: 1px solid rgba(245, 158, 11, 0.12);
}

.activity-badge.file_deleted {
    background: rgba(220, 38, 38, 0.06);
    color: #dc2626;
    border: 1px solid rgba(220, 38, 38, 0.1);
}

.activity-badge.settings_changed {
    background: rgba(139, 92, 246, 0.08);
    color: #8b5cf6;
    border: 1px solid rgba(139, 92, 246, 0.12);
}

.activity-badge.user_action {
    background: rgba(6, 182, 212, 0.08);
    color: #06b6d4;
    border: 1px solid rgba(6, 182, 212, 0.12);
}

.activity-badge.logout {
    background: rgba(107, 114, 128, 0.08);
    color: #6b7280;
    border: 1px solid rgba(107, 114, 128, 0.12);
}

/* ============================================
   Professional Polish Layer (additive)
   Keyboard accessibility, motion safety, print
   ============================================ */

/* Crisp keyboard-only focus ring — visible for keyboard users,
   hidden for mouse users so it never clutters the premium look. */
a:focus-visible,
button:focus-visible,
[role="button"]:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid var(--accent-green);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* Remove the default focus ring only where focus-visible is supported,
   so we don't strip focus indication from older browsers. */
button:focus:not(:focus-visible),
a:focus:not(:focus-visible) {
    outline: none;
}

/* Respect users who prefer reduced motion (accessibility + pro polish). */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* Clean print output: drop the app chrome, print only content. */
@media print {

    #login-screen,
    .sidebar,
    .topbar,
    .app-header,
    .btn,
    button,
    .dashboard-filter-input,
    ::-webkit-scrollbar {
        display: none !important;
    }

    body {
        background: #fff !important;
        overflow: visible !important;
    }

    .main-content,
    .content-area {
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }

    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* ============================================
   PREMIUM THEME LAYER
   Brings the app chrome in line with the login
   page: dark navy brand surface + emerald glow.
   (Login page styles are intentionally untouched.)
   ============================================ */

/* ---- Navy brand sidebar (mirrors .login-brand-panel) ---- */
.sidebar {
    background: linear-gradient(180deg, #0a1628 0%, #0d1f35 55%, #081420 100%);
    border-right: none;
    /* Soft shadow the navy panel casts onto the light content, so the two
       surfaces blend instead of meeting at a hard line. */
    box-shadow:
        18px 0 40px -18px rgba(8, 20, 32, 0.55),
        inset -1px 0 0 rgba(255, 255, 255, 0.04);
    overflow: hidden;
}

/* Faint navy→transparent gradient seam on the content side, plus a thin
   emerald hairline, echoing the soft edge of the login brand panel. */
.main-content {
    background:
        linear-gradient(90deg, rgba(13, 31, 53, 0.06) 0%, rgba(13, 31, 53, 0.015) 48px, transparent 120px),
        var(--bg-secondary);
}

.main-content::before {
    content: '';
    position: fixed;
    top: 0;
    left: 254px;
    width: 1px;
    height: 100vh;
    background: linear-gradient(180deg,
        rgba(129, 140, 248, 0.35) 0%,
        rgba(129, 140, 248, 0.08) 30%,
        transparent 80%);
    pointer-events: none;
    z-index: 99;
}

/* Fine grid texture, like the login panel */
.sidebar::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.022) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.022) 1px, transparent 1px);
    background-size: 40px 40px;
}

/* Soft emerald glows in the corners */
.sidebar::after {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at 18% -5%, rgba(79, 70, 229, 0.16) 0%, transparent 45%),
        radial-gradient(circle at 85% 105%, rgba(99, 102, 241, 0.09) 0%, transparent 50%);
}

/* Keep real content above the decorative layers */
.sidebar > * {
    position: relative;
    z-index: 1;
}

.sidebar-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.sidebar-header img {
    filter: drop-shadow(0 4px 14px rgba(0, 0, 0, 0.45)) brightness(1.08);
    opacity: 1;
}

.sidebar-nav .nav-section-title {
    color: rgba(255, 255, 255, 0.34);
}

.nav-item {
    color: rgba(255, 255, 255, 0.64);
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(79, 70, 229, 0.2) 0%, rgba(79, 70, 229, 0.04) 100%);
    color: #ffffff;
    border-left-color: #818cf8;
}

.nav-item.active::after {
    background: #818cf8;
    opacity: 0.95;
    box-shadow: 0 0 12px rgba(129, 140, 248, 0.8);
}

/* System nav + footer buttons on the dark surface */
.sidebar-system-nav {
    border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.btn-sidebar-footer {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.7);
}

.btn-sidebar-footer:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    border-color: rgba(255, 255, 255, 0.16);
}

.btn-sidebar-footer.active {
    background: rgba(79, 70, 229, 0.16);
    color: #ffffff;
    border-color: rgba(129, 140, 248, 0.4);
}

/* ---- Content side: premium accents (stays light, like the form panel) ---- */

/* Eyebrow accent bar before each page title, echoing the login welcome.
   `.title-accent` exposes the same gradient + eyebrow look as a reusable class
   so any heading anywhere in the app can match the page titles. */
.page-header h1,
.title-accent {
    background: linear-gradient(120deg, #111827 0%, #111827 50%, #1b6b39 78%, #2e7d32 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    /* Shrink to the text width (not the full container) so the gradient maps
       across the heading itself — otherwise short titles like "Dashboard" sit in
       the dark left end of the gradient and look black. fit-content keeps the
       eyebrow bar and gradient painting consistently on every page. */
    display: block;
    width: -moz-fit-content;
    width: fit-content;
}

/* Region badges (IND/USA) and any inline tag inside a heading must show their own
   solid colour, not inherit the heading's transparent text fill. */
.page-header h1 > span,
.title-accent > span {
    -webkit-text-fill-color: initial;
    -webkit-background-clip: border-box;
    background-clip: border-box;
}

.page-header h1::before,
.title-accent::before {
    content: '';
    display: block;
    width: 38px;
    height: 3px;
    margin-bottom: 14px;
    border-radius: 3px;
    background: linear-gradient(90deg, #1b5e20, #2e7d32);
    box-shadow: 0 0 10px rgba(46, 125, 50, 0.4);
}

/* ---- Premium stat cards: icon tile + accent + clean type ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(212px, 1fr));
    gap: 22px;
    margin-bottom: 40px;
}

.stat-card {
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.07);
    border-radius: 18px;
    padding: 24px 24px 26px;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 12px 30px -18px rgba(15, 23, 42, 0.22);
    min-width: 0;
    overflow: hidden;
}

.stat-card::before {
    height: 3px;
    background: linear-gradient(90deg, var(--accent, #4f46e5), transparent 88%);
    opacity: 0.9;
}

.stat-card:hover {
    transform: translateY(-4px);
    border-color: color-mix(in srgb, var(--accent, #4f46e5) 30%, transparent);
    box-shadow:
        0 1px 2px rgba(15, 23, 42, 0.04),
        0 24px 48px -24px color-mix(in srgb, var(--accent, #4f46e5) 55%, rgba(15, 23, 42, 0.5));
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--accent-soft, rgba(79, 70, 229, 0.1));
    color: var(--accent, #4f46e5);
    margin-bottom: 20px;
    transition: var(--transition-spring);
}

.stat-card:hover .stat-icon {
    transform: scale(1.06);
}

.stat-card .stat-label {
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stat-card .stat-value {
    font-size: 34px;
    font-weight: 800;
    letter-spacing: -1.2px;
    color: var(--text-primary);
    margin-top: 7px;
    line-height: 1.05;
}

/* ============================================
   TOP NAVIGATION BAR
   Converts the left sidebar into a horizontal
   navy brand bar across the top (logo · nav ·
   account). Source order overrides the sidebar
   layout above, including the 900px breakpoint.
   ============================================ */

:root {
    --topbar-h: 70px;
}

/* Stack the bar on top, content below */
#app-wrapper.active {
    flex-direction: column;
}

.sidebar {
    width: 100%;
    min-width: 0;
    height: var(--topbar-h);
    flex-direction: row;
    align-items: center;
    top: 0;
    left: 0;
    right: 0;
    padding: 0 var(--page-pad-x);
    gap: 20px;
    border-right: none;
    box-shadow:
        0 16px 36px -20px rgba(8, 20, 32, 0.6),
        inset 0 -1px 0 rgba(255, 255, 255, 0.05);
}

/* Logo block on the left */
.sidebar-header {
    padding: 0;
    border-bottom: none;
    flex-shrink: 0;
    justify-content: flex-start;
    margin-right: 6px;
}

/* Section labels ("Menu" / "Generate") have no place in a top bar */
.sidebar-nav .nav-section-title {
    display: none;
}

/* Primary nav: horizontal row of pills, left-aligned next to the logo */
.sidebar-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    padding: 0;
    overflow: visible;
    justify-content: flex-start;
}

.nav-item {
    padding: 9px 16px;
    margin: 0;
    border-left: none !important;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    gap: 8px;
}

/* Active = soft emerald pill with an inset ring (no left bar / no underline) */
.nav-item.active {
    background: linear-gradient(135deg, rgba(79, 70, 229, 0.3) 0%, rgba(79, 70, 229, 0.14) 100%);
    color: #ffffff;
    border-left: none;
    box-shadow: inset 0 0 0 1px rgba(129, 140, 248, 0.38), 0 2px 12px -4px rgba(79, 70, 229, 0.5);
}

.nav-item.active::after {
    display: none;
}

/* Account cluster (Admin · Settings · Profile) pushed to the far right */
.sidebar-system-nav {
    flex-direction: row;
    align-items: center;
    gap: 4px;
    border-top: none;
    padding: 0;
    margin-left: auto;
    flex-shrink: 0;
}

/* Content now sits below the bar, full width */
.main-content {
    margin-left: 0;
    margin-top: var(--topbar-h);
    width: 100%;
    height: calc(100vh - var(--topbar-h));
    background:
        linear-gradient(180deg, rgba(13, 31, 53, 0.05) 0%, rgba(13, 31, 53, 0.012) 60px, transparent 130px),
        var(--bg-secondary);
}

/* Emerald hairline seam directly under the bar */
.main-content::before {
    top: var(--topbar-h);
    left: 0;
    right: 0;
    width: 100%;
    height: 1px;
    background: linear-gradient(90deg,
        rgba(129, 140, 248, 0.4) 0%,
        rgba(129, 140, 248, 0.12) 45%,
        transparent 92%);
}

/* The corner glows read better anchored to the bar's left/right edges */
.sidebar::after {
    background:
        radial-gradient(circle at 6% 50%, rgba(79, 70, 229, 0.18) 0%, transparent 38%),
        radial-gradient(circle at 96% 50%, rgba(99, 102, 241, 0.1) 0%, transparent 40%);
}

/* Tablet / narrow: let the nav scroll horizontally rather than wrap or clip */
@media (max-width: 1100px) {
    .sidebar {
        /* Keep the bar aligned to the shared page gutter; nav still scrolls. */
        padding: 0 var(--page-pad-x);
        gap: 10px;
    }

    .sidebar-nav {
        overflow-x: auto;
        overflow-y: hidden;
        scrollbar-width: none;
    }

    .sidebar-nav::-webkit-scrollbar {
        display: none;
    }

    .nav-item {
        padding: 8px 12px;
        font-size: 13px;
    }
}

/* ============================================
   WHITE BRAND NAV BAR + PROFILE POPUP
   Matches marvelgeospatial.com — white surface,
   forest-green accents. (Login page untouched:
   tokens are scoped to #app-wrapper only.)
   ============================================ */

#app-wrapper {
    --accent-green: #2e7d32;
    --accent-green-light: rgba(46, 125, 50, 0.1);
    --input-focus: rgba(46, 125, 50, 0.16);
}

.sidebar {
    background: #ffffff;
    overflow: visible;
    border-right: none;
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.07), 0 12px 30px -20px rgba(15, 23, 42, 0.22);
}

/* Drop the navy texture/glow on the white bar */
.sidebar::before,
.sidebar::after {
    display: none;
}

.sidebar-header img {
    filter: none;
}

/* Text nav links: forest green, soft-green hover/active pill */
.nav-item {
    color: #14532d;
    font-weight: 600;
}

.nav-item:hover {
    background: rgba(46, 125, 50, 0.08);
    color: #1b5e20;
}

/* Text nav links: underline indicator instead of a filled box */
.sidebar-nav .nav-item.active {
    background: transparent;
    color: #1b5e20;
    box-shadow: none;
}

.sidebar-nav .nav-item:hover {
    background: transparent;
    color: #1b5e20;
}

.sidebar-nav .nav-item.active::after,
.sidebar-nav .nav-item:hover::after {
    display: block;
    content: '';
    position: absolute;
    left: 16px;
    right: 16px;
    top: auto;
    bottom: 3px;
    width: auto;
    height: 2.5px;
    transform: none;
    border-radius: 3px;
    background: linear-gradient(90deg, #5fc06f, #81c784);
}

.sidebar-nav .nav-item.active::after {
    opacity: 1;
}

.sidebar-nav .nav-item:hover::after {
    opacity: 0.35;
    box-shadow: none;
}

/* Content: plain light surface, thin green seam under the bar */
.main-content {
    background: var(--bg-secondary);
}

.main-content::before {
    height: 2px;
    opacity: 0.7;
    background: linear-gradient(90deg,
        rgba(46, 125, 50, 0.45) 0%,
        rgba(46, 125, 50, 0.12) 45%,
        transparent 92%);
}

/* ---- Right-side icon buttons (Admin · Settings · Profile) ---- */
.topbar-icon-btn {
    width: 40px;
    height: 40px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 11px;
    background: transparent;
    color: #15502f;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: var(--transition-spring);
}

.topbar-icon-btn:hover {
    background: rgba(46, 125, 50, 0.1);
    color: #1b5e20;
}

.topbar-icon-btn.active {
    background: rgba(46, 125, 50, 0.12);
    color: #1b5e20;
    box-shadow: inset 0 0 0 1px rgba(46, 125, 50, 0.24);
}

.topbar-badge {
    position: absolute;
    top: 1px;
    right: 1px;
    min-width: 17px;
    height: 17px;
    padding: 0 4px;
    border-radius: 9px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
}

/* ---- Profile popup ---- */
.topbar-profile-wrapper {
    position: relative;
    display: inline-flex;
}

.profile-popup {
    display: none;
    position: absolute;
    top: calc(100% + 14px);
    right: 0;
    width: 252px;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 16px;
    box-shadow: 0 20px 48px -14px rgba(15, 23, 42, 0.26);
    padding: 8px;
    z-index: 1200;
    transform-origin: top right;
    animation: scaleIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.profile-popup.open {
    display: block;
}

.profile-popup::before {
    content: '';
    position: absolute;
    top: -6px;
    right: 15px;
    width: 12px;
    height: 12px;
    background: #ffffff;
    border-left: 1px solid rgba(15, 23, 42, 0.08);
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    transform: rotate(45deg);
}

.profile-popup-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.06);
    margin-bottom: 6px;
    min-width: 0;
}

.profile-popup-avatar {
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: linear-gradient(135deg, #2e7d32 0%, #1b5e20 100%);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 12px -2px rgba(46, 125, 50, 0.45);
}

.profile-popup-id {
    min-width: 0;
    overflow: hidden;
}

.profile-popup-name {
    font-size: 14.5px;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-popup-username {
    font-size: 11.5px;
    font-weight: 400;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-popup-role {
    font-size: 12px;
    font-weight: 600;
    color: #2e7d32;
    margin-top: 3px;
}

.profile-popup-menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.profile-popup-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    padding: 10px 12px;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.profile-popup-item svg {
    width: 17px;
    height: 17px;
    color: var(--text-secondary);
    flex-shrink: 0;
}

.profile-popup-item:hover {
    background: rgba(46, 125, 50, 0.08);
    color: #1b5e20;
}

.profile-popup-item:hover svg {
    color: #2e7d32;
}

.profile-popup-item.danger {
    color: #dc2626;
}

.profile-popup-item.danger svg {
    color: #dc2626;
}

.profile-popup-item.danger:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #b91c1c;
}

/* Page title accent + heading tie to the brand green */
/* ============================================
   CHANGE PASSWORD MODAL
   ============================================ */
.change-password-card {
    position: relative;
    background: #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.08);
    border-radius: 20px;
    padding: 30px 30px 28px;
    width: 420px;
    max-width: 92vw;
    box-shadow: 0 24px 60px -16px rgba(15, 23, 42, 0.3);
    animation: scaleIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.change-password-close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition-smooth);
}

.change-password-close:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

.change-password-head {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.change-password-icon {
    width: 48px;
    height: 48px;
    border-radius: 13px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(46, 125, 50, 0.1);
    color: #2e7d32;
}

.change-password-head h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.3px;
    line-height: 1.2;
}

.change-password-head p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 3px;
}

.change-password-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.change-password-actions .btn {
    padding: 11px 22px;
}

/* Inline loading optimization for login page refresh */
.no-loading #loading-overlay {
    display: none !important;
}
.no-loading #login-screen {
    display: flex;
}

/* ============================================
   TO MARVEL PREMIUM UPLOAD & MODE SELECTOR
   ============================================ */
.tm-upload-loader {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    max-width: 280px;
}

.tm-upload-loader-icon {
    width: 42px;
    height: 42px;
    border-radius: 13px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-green);
    background: rgba(5, 150, 105, 0.10);
    box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.30);
    animation: tm-upload-pulse 1.8s ease-in-out infinite;
}

.tm-upload-loader-icon svg {
    animation: tm-upload-bob 1.8s ease-in-out infinite;
}

.tm-upload-loader-text {
    text-align: center;
    min-width: 0;
    width: 100%;
}

.tm-upload-loader-title {
    font-size: 14.5px;
    font-weight: 700;
    color: #004d2c;
    line-height: 1.2;
}

.tm-upload-loader-name {
    font-size: 12px;
    color: var(--text-secondary);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 4px;
}

.tm-upload-loader-bar {
    width: 100%;
    height: 4px;
    border-radius: 999px;
    background: rgba(5, 150, 105, 0.12);
    overflow: hidden;
    position: relative;
}

.tm-upload-loader-bar span {
    position: absolute;
    inset: 0;
    width: 40%;
    border-radius: 999px;
    background: linear-gradient(90deg, transparent, var(--accent-green), #0fae74);
    animation: tm-upload-slide 1.3s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes tm-upload-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(5, 150, 105, 0.28); }
    50% { box-shadow: 0 0 0 10px rgba(5, 150, 105, 0); }
}

@keyframes tm-upload-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

@keyframes tm-upload-slide {
    0% { left: -40%; }
    100% { left: 100%; }
}

.tm-mode-popup-card {
    position: relative;
    background:
        radial-gradient(120% 80% at 50% -10%, rgba(5, 150, 105, 0.06), transparent 60%),
        #ffffff;
    border: 1px solid rgba(15, 23, 42, 0.06);
    border-radius: 24px;
    padding: 34px 30px 26px;
    width: 440px;
    max-width: 92vw;
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.7) inset,
        0 32px 70px -24px rgba(15, 23, 42, 0.32),
        0 8px 24px -12px rgba(15, 23, 42, 0.18);
    animation: scaleIn 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    overflow: hidden;
}

/* Subtle gradient accent line across the top of the card. */
.tm-mode-popup-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-green), #2563eb);
    opacity: 0.9;
}

.tm-mode-popup-icon {
    width: 56px;
    height: 56px;
    border-radius: 16px;
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.14), rgba(5, 150, 105, 0.04));
    color: var(--accent-green);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    box-shadow:
        0 8px 18px -6px rgba(5, 150, 105, 0.28),
        0 0 0 1px rgba(5, 150, 105, 0.10) inset;
}

.tm-mode-popup-title {
    font-size: 21px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 22px;
    letter-spacing: -0.4px;
}

.tm-mode-popup-options {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
    margin-bottom: 18px;
}

.tm-mode-option-card {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 14px;
    padding: 15px 16px;
    background: #ffffff;
    border: 1.5px solid rgba(15, 23, 42, 0.07);
    border-radius: 16px;
    cursor: pointer;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.22s ease, border-color 0.22s ease, background 0.22s ease;
    width: 100%;
    position: relative;
    outline: none;
    --tm-accent: var(--accent-green);
    --tm-accent-soft: rgba(5, 150, 105, 0.08);
}

.tm-mode-international {
    --tm-accent: #2563eb;
    --tm-accent-soft: rgba(37, 99, 235, 0.08);
}

.tm-mode-option-card:hover {
    border-color: var(--tm-accent);
    background: linear-gradient(180deg, rgba(255, 255, 255, 0), var(--tm-accent-soft));
    transform: translateY(-2px);
    box-shadow: 0 12px 26px -12px color-mix(in srgb, var(--tm-accent) 45%, transparent);
}

.tm-mode-option-card:focus-visible {
    border-color: var(--tm-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tm-accent) 22%, transparent);
}

.tm-mode-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--tm-accent-soft);
    color: var(--tm-accent);
    flex-shrink: 0;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.tm-mode-option-card:hover .tm-mode-card-icon {
    transform: scale(1.06);
}

.tm-mode-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.tm-mode-card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}

.tm-mode-card-sub {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
}

.tm-mode-card-arrow {
    color: #cbd0d8;
    flex-shrink: 0;
    transition: transform 0.22s cubic-bezier(0.16, 1, 0.3, 1), color 0.22s ease;
}

.tm-mode-option-card:hover .tm-mode-card-arrow {
    color: var(--tm-accent);
    transform: translateX(4px);
}

.tm-mode-popup-cancel {
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    padding: 9px 18px;
    border-radius: 10px;
    transition: var(--transition-smooth);
    font-family: inherit;
}

.tm-mode-popup-cancel:hover {
    background: rgba(15, 23, 42, 0.05);
    color: var(--text-primary);
}

/* Premium drop zone micro-interactions */
#tm-drop-zone:hover {
    border-color: var(--accent-green) !important;
    background: rgba(5, 150, 105, 0.035) !important;
    box-shadow: 0 4px 20px rgba(5, 150, 105, 0.03);
}
#tm-drop-zone:hover .tm-upload-icon-container {
    transform: translateY(-2px) scale(1.04);
    background: rgba(5, 150, 105, 0.12) !important;
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.12);
}
#tm-drop-zone:hover .btn-tm-browse {
    background: #047857 !important;
    box-shadow: 0 6px 16px rgba(5, 150, 105, 0.3) !important;
}

/* ============================================
   NAV DROPDOWNS (Quotation / Invoice) — open on hover
   ============================================ */
#nav-inv-wrap:hover > #nav-inv-menu,
#nav-qu-wrap:hover > #nav-qu-menu {
    display: block !important;
}
/* Invisible bridge across the gap between the tab and its menu so moving the
   cursor down to the menu doesn't drop the hover and close it. */
#nav-inv-menu::before,
#nav-qu-menu::before {
    content: "";
    position: absolute;
    top: -10px;
    left: 0;
    right: 0;
    height: 10px;
}

/* ---------- Settings: premium menu tiles + detail pop-up ---------- */
.settings-tiles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 12px;
}
.settings-tile {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    text-align: left;
    background: linear-gradient(145deg, #ffffff 0%, #f8faf9 100%);
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 18px;
    padding: 26px 24px;
    cursor: pointer;
    transition: border-color .2s ease, box-shadow .25s ease, transform .25s cubic-bezier(0.16, 1, 0.3, 1);
    font-family: inherit;
    position: relative;
    overflow: hidden;
}
.settings-tile::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #2e7d32, #4caf50, #81c784);
    opacity: 0;
    transition: opacity .25s ease;
    border-radius: 18px 18px 0 0;
}
.settings-tile:hover {
    border-color: rgba(46, 125, 50, 0.25);
    box-shadow: 0 8px 30px rgba(46, 125, 50, 0.08), 0 2px 8px rgba(0, 0, 0, 0.04);
    transform: translateY(-4px);
}
.settings-tile:hover::before {
    opacity: 1;
}
.settings-tile:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(46, 125, 50, 0.06);
}
.settings-tile-icon {
    display: inline-flex;
    width: 52px;
    height: 52px;
    align-items: center;
    justify-content: center;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.1) 0%, rgba(46, 125, 50, 0.04) 100%);
    color: #2e7d32;
    margin-bottom: 4px;
    transition: background .2s ease, box-shadow .2s ease, transform .2s ease;
}
.settings-tile:hover .settings-tile-icon {
    background: linear-gradient(135deg, rgba(46, 125, 50, 0.16) 0%, rgba(46, 125, 50, 0.06) 100%);
    box-shadow: 0 4px 14px rgba(46, 125, 50, 0.12);
    transform: scale(1.05);
}
.settings-tile-icon svg {
    width: 22px;
    height: 22px;
}
.settings-tile-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.2px;
}
.settings-tile-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.settings-detail-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    z-index: 9300;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    overflow: auto;
}
.settings-detail-card {
    background: #fff;
    border-radius: 18px;
    width: 100%;
    max-width: 1512px;
    margin: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.16), 0 4px 16px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    max-height: 90vh;
}
.settings-detail-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.07);
}
.settings-detail-head h3 { margin: 0; font-size: 20px; font-weight: 700; color: #18181b; letter-spacing: -0.2px; }
.settings-detail-close {
    background: transparent;
    border: 1px solid rgba(0, 0, 0, 0.12);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    color: var(--text-primary);
    padding: 6px 14px;
    border-radius: 8px;
    line-height: 1;
    transition: all 0.15s ease;
}
.settings-detail-close:hover { background: rgba(0, 0, 0, 0.04); color: #18181b; }
.settings-detail-body { padding: 28px; overflow-y: auto; }
/* The moved card fills the modal body cleanly (the modal itself is the card). */
.settings-detail-body .form-container {
    border: none;
    box-shadow: none;
    padding: 0;
    margin: 0;
    background: transparent;
}

/* ---------- Unified wide modal width for all popups ---------- */
.modal-card-wide {
    width: 1512px !important;
    max-width: 95vw !important;
}

/* ---------- Premium Popup Layouts & Grids ---------- */
.modal-split-layout {
    display: grid;
    grid-template-columns: 380px 1fr;
    gap: 36px;
    margin-top: 18px;
}
@media (max-width: 992px) {
    .modal-split-layout {
        grid-template-columns: 1fr;
        gap: 24px;
    }
}

.modal-info-panel {
    background: linear-gradient(145deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid rgba(15, 23, 42, 0.04);
    border-radius: 16px;
    padding: 30px 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
}
.modal-info-panel h4 {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-info-panel p {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.55;
    margin: 0;
}
.modal-info-panel ul {
    list-style-type: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.modal-info-panel li {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: 8px;
    line-height: 1.45;
}
.modal-info-panel li svg {
    color: var(--accent-green);
    flex-shrink: 0;
    margin-top: 2px;
}

.modal-form-panel {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 20px;
}

.modal-form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 18px;
}
.modal-form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 18px;
}
@media (max-width: 768px) {
    .modal-form-grid-2, .modal-form-grid-3 {
        grid-template-columns: 1fr;
        gap: 14px;
    }
}

/* --- Region Picker Upgrade --- */
.region-selector-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 28px;
    width: 100%;
    max-width: 900px;
    margin: 24px auto 12px;
}
@media (max-width: 640px) {
    .region-selector-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
}
.region-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    padding: 36px 28px;
    background: #ffffff;
    border: 1.5px solid rgba(15, 23, 42, 0.08);
    border-radius: 18px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    width: 100%;
    outline: none;
}
.region-card:hover, .region-card:focus {
    border-color: var(--accent-green);
    transform: translateY(-5px);
    box-shadow: 0 12px 30px rgba(5, 150, 105, 0.08), 0 2px 8px rgba(0, 0, 0, 0.02);
}
.region-card svg {
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.3s ease;
}
.region-card:hover svg {
    transform: scale(1.06);
}
.region-card-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 4px 0 2px;
    text-align: center;
}
.region-card-branch {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin: 0;
    text-align: center;
    line-height: 1.45;
}
.region-card-desc {
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.55;
    text-align: center;
    margin: 6px 0 0 0;
}

/* --- Custom Confirm Upgrade --- */
.confirm-split {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 28px;
    align-items: center;
    text-align: left;
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}
@media (max-width: 576px) {
    .confirm-split {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 20px;
    }
    .confirm-icon-wrap {
        margin: 0 auto;
    }
}
.confirm-icon-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(5, 150, 105, 0.1) 0%, rgba(5, 150, 105, 0.02) 100%);
    color: var(--accent-green);
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.06);
}
.confirm-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.confirm-warning-box {
    background: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 10px;
    padding: 12px 16px;
    margin-top: 4px;
    font-size: 12.5px;
    color: #92400e;
    line-height: 1.45;
    text-align: left;
}

/* --- Premium List Rows & Table layouts --- */
.premium-table-container {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.06);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.02);
}
.premium-table-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
    transition: background-color 0.15s ease;
    gap: 16px;
}
.premium-table-row:last-child {
    border-bottom: none;
}
.premium-table-row:hover {
    background-color: rgba(5, 150, 105, 0.01);
}
.premium-user-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, rgba(15, 23, 42, 0.08) 0%, rgba(15, 23, 42, 0.03) 100%);
    color: var(--text-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    flex-shrink: 0;
    border: 1px solid rgba(0, 0, 0, 0.04);
}
.audit-timeline {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.audit-row {
    display: grid;
    grid-template-columns: 170px 1fr auto;
    gap: 20px;
    align-items: center;
    padding: 14px 24px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.04);
    transition: background-color 0.15s ease;
}
.audit-row:hover {
    background-color: rgba(0, 0, 0, 0.005);
}
.audit-time {
    font-size: 12.5px;
    color: var(--text-muted);
    font-weight: 500;
}
.audit-desc {
    font-size: 13.5px;
    color: var(--text-primary);
    font-weight: 500;
    word-break: break-word;
}
.audit-badge {
    font-size: 9.5px;
    font-weight: 700;
    border-radius: 6px;
    padding: 3px 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

/* --- Pagination Controls --- */
.pagination-container {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid rgba(0, 0, 0, 0.06);
    flex-wrap: wrap;
    gap: 16px;
    font-family: 'Inter', -apple-system, sans-serif;
}
.pagination-left select.pagination-select {
    padding: 8px 32px 8px 12px;
    font-size: 13px;
    font-weight: 500;
    color: #27272a;
    background-color: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    cursor: pointer;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2371717a' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 14px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    transition: all 0.2s ease;
}
.pagination-left select.pagination-select:hover {
    border-color: rgba(5, 150, 105, 0.3);
    background-color: #fafafa;
}
.pagination-right {
    display: flex;
    align-items: center;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.02);
    background: #ffffff;
}
.pagination-btn {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 500;
    color: #27272a;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.pagination-btn:hover:not(:disabled) {
    background-color: rgba(0, 0, 0, 0.02);
}
.pagination-btn:disabled {
    color: #a1a1aa;
    cursor: not-allowed;
}
.pagination-page-indicator {
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    color: #0f172a;
    border-left: 1px solid rgba(0, 0, 0, 0.12);
    border-right: 1px solid rgba(0, 0, 0, 0.12);
    background: rgba(0, 0, 0, 0.01);
    min-width: 32px;
    text-align: center;
}

/* Page-size dropdown reuses the project's custom-select component. Because it
   sits at the bottom of a list, its options open upward to avoid being clipped. */
.pagination-left .pagination-select-wrapper .custom-options {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 6px;
}
.pagination-container:has(.custom-select-wrapper.open) {
    position: relative;
    z-index: 1005;
}

/* ============================================================
   UI POLISH & LOGO THEME  (appended last — intentionally
   overrides earlier rules). Logo palette: orange + green.
   ============================================================ */
:root {
    --logo-orange: #f47c20;
    --logo-orange-soft: rgba(244, 124, 32, 0.10);
    --logo-green: #2e8b2e;
    --logo-green-soft: rgba(46, 139, 46, 0.10);
    --shadow-3d: 0 10px 30px -12px rgba(15, 23, 42, 0.20), 0 2px 8px rgba(15, 23, 42, 0.05);
    --shadow-3d-hover: 0 24px 50px -16px rgba(15, 23, 42, 0.30), 0 8px 18px rgba(15, 23, 42, 0.08);
}

/* Smooth, consistent easing for interactive surfaces */
.stat-card, .nav-item, .btn, .recent-table tbody tr,
.custom-select-trigger, .modal-card, .tm-mode-option-card, .pagination-btn {
    transition: transform .28s cubic-bezier(.16, 1, .3, 1),
                box-shadow .28s cubic-bezier(.16, 1, .3, 1),
                background-color .2s ease, border-color .2s ease, color .2s ease;
}

/* --- Stat cards: 3D lift + logo green→orange accent bar --- */
.stat-card { box-shadow: var(--shadow-3d); }
.stat-card::before {
    background: linear-gradient(90deg, var(--logo-green), var(--logo-orange)) !important;
    height: 4px !important;
    opacity: 0;
}
.stat-card:hover {
    transform: translateY(-6px) scale(1.012);
    box-shadow: var(--shadow-3d-hover);
}
.stat-card:hover::before { opacity: 1; }
.stat-card:active { transform: translateY(-2px) scale(0.998); }

/* --- Active nav underline: tie in the logo orange (horizontal top-nav). Scoped
   to .sidebar-nav so it only restyles the underline's colour — it must NOT touch
   the bar's geometry, or the underline turns into a stray vertical line. --- */
.sidebar-nav .nav-item.active::after {
    background: linear-gradient(90deg, var(--logo-green), var(--logo-orange));
}

/* --- Buttons: tactile lift + press feedback --- */
.btn:hover, .btn-generate:hover, .btn-add:hover { transform: translateY(-1px); }
.btn:active, .btn-generate:active, .btn-add:active,
.btn-action-generate:active, .pagination-btn:active, .btn-row-actions:active {
    transform: scale(0.96);
}

/* --- Primary & Secondary Button Themes --- */
.btn-primary {
    background: #004d2c !important;
    background-color: #004d2c !important;
    color: #fff !important;
    border: 1px solid #004d2c !important;
    transition: var(--transition-smooth);
}
.btn-primary:hover {
    background: #003d22 !important;
    background-color: #003d22 !important;
    border-color: #003d22 !important;
}

.btn-secondary {
    background: transparent !important;
    background-color: transparent !important;
    color: var(--text-primary) !important;
    border: 1px solid rgba(15, 23, 42, 0.12) !important;
    transition: var(--transition-smooth);
}
.btn-secondary:hover {
    background: rgba(15, 23, 42, 0.03) !important;
    background-color: rgba(15, 23, 42, 0.03) !important;
    border-color: rgba(15, 23, 42, 0.2) !important;
}

/* --- Custom Select Dropdowns Polish --- */
.custom-select-trigger {
    background: var(--input-bg) !important;
    border: 1px solid var(--input-border) !important;
    color: var(--text-primary) !important;
    border-radius: 8px !important;
    padding: 9px 12px !important;
    transition: var(--transition-smooth) !important;
}
.custom-select-trigger:hover {
    border-color: var(--logo-green) !important;
    background: #fff !important;
}
.custom-options {
    background: #ffffff !important;
    border: 1px solid var(--card-border) !important;
    border-radius: var(--radius-sm) !important;
    box-shadow: 0 10px 40px rgba(15, 23, 42, 0.1) !important;
}
.custom-option {
    font-size: 13px !important;
    color: var(--text-primary) !important;
    padding: 9px 14px !important;
    transition: var(--transition-smooth) !important;
}
.custom-option:hover {
    background: var(--logo-green-soft) !important;
    color: var(--logo-green) !important;
}
.custom-option.selected {
    background: var(--logo-green-soft) !important;
    color: var(--logo-green) !important;
    font-weight: 600 !important;
}


/* --- Table rows: subtle hover depth with a logo-green edge. The edge is set on
   the first cell because box-shadow on a <tr> doesn't render under
   border-collapse: collapse (which these tables use). --- */
.recent-table tbody tr:hover { background: var(--logo-green-soft); }
.recent-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--logo-green); }

/* --- Modal entrance: gentle pop --- */
.modal-card { animation: modalPop 0.32s cubic-bezier(.16, 1, .3, 1); }
@keyframes modalPop {
    from { opacity: 0; transform: translateY(14px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* =========================================================
   GLOBAL FLEXBOX LAYOUT AUTO-ADJUSTMENT FOR TOTAL PROJECT
   ========================================================= */
.to-marvel-layout,
.dashboard-container,
.recent-section,
#dashboard-content,
#po-content,
#qu-content,
#inv-content,
#proforma-content,
#sales-content,
#receipts-content,
#sales-returns-content {
    width: 100% !important;
    max-width: 100% !important;
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    box-sizing: border-box !important;
}

#tm-list-card,
#tm-upload-card {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
}

#tm-list-card {
    flex: 1 1 auto !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 480px !important;
}

/* --- Region chooser option cards: lift + logo-tinted hover --- */
.tm-mode-option-card:hover { transform: translateY(-3px) scale(1.01); }

/* --- Brand logo: subtle float --- */
img[src*="marvel-logo"], img[src*="logo"] {
    animation: logoFloat 5.5s ease-in-out infinite;
}
@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-3px); }
}

/* Respect reduced-motion preferences */
@media (prefers-reduced-motion: reduce) {
    .stat-card, .nav-item, .btn, .modal-card, .tm-mode-option-card,
    img[src*="logo"] {
        animation: none !important;
        transition: background-color .2s ease, border-color .2s ease, color .2s ease !important;
    }
    .stat-card:hover, .nav-item:hover, .tm-mode-option-card:hover { transform: none; }
}

