/* ============================================================
    ERP System — Main Stylesheet v1.0
   Soft, professional ERP look. No external framework.
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
    --sidebar-w:      240px;
    --topbar-h:       56px;
    --bg-page:        #f5f6f8;
    --bg-white:       #ffffff;
    --brand:          #22c55e;
    --brand-dark:     #16a34a;
    --brand-light:    #f0fdf4;
    --nav-bg:         #1f2937;
    --nav-border:     rgba(255,255,255,.06);
    --nav-text:       #9ca3af;
    --nav-hover:      rgba(255,255,255,.07);
    --nav-active-bg:  rgba(34,197,94,.13);
    --nav-active-txt: #22c55e;
    --text-main:      #374151;
    --text-muted:     #6b7280;
    --text-light:     #9ca3af;
    --border:         #e5e7eb;
    --border-light:   #f1f5f9;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.06);
    --shadow-md:      0 4px 14px rgba(0,0,0,.09);
    --radius:         8px;
    --radius-sm:      6px;
    --radius-full:    9999px;
    --font:           'Inter', system-ui, -apple-system, sans-serif;
    --transition:     .14s ease;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
    font-family: var(--font);
    background: var(--bg-page);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}
a { text-decoration: none; color: inherit; }
button { font-family: var(--font); }
img    { max-width: 100%; display: block; }

/* ── App Shell ──────────────────────────────────────────────── */
.app-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
    background: var(--bg-page);
}

.app-shell.sidebar-collapsed .sidebar {
    margin-left: calc(-1 * var(--sidebar-w));
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--nav-bg);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
    transition: margin-left .25s ease, transform .25s ease;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--nav-border);
}
.brand-icon {
    width: 44px;
    height: 44px;
    background: var(--nav-active-bg);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand);
    font-size: 1.2rem;
    flex-shrink: 0;
}
.sidebar-logo-img {
    width: 30px;
    height: 30px;
    object-fit: contain;
}
.brand-name {
    font-weight: 700;
    font-size: .9rem;
    color: #f3f4f6;
    letter-spacing: .01em;
}

.sidebar-nav { flex: 1; padding: 8px 0; }

.nav-section-label {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #4b5563;
    padding: 14px 20px 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 12px;
    margin: 1px 8px;
    border-radius: var(--radius-sm);
    color: var(--nav-text);
    font-size: .85rem;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--transition), color var(--transition);
}
.nav-item i { font-size: .95rem; width: 18px; flex-shrink: 0; }
.nav-item:hover  { background: var(--nav-hover); color: #e5e7eb; }
.nav-item.active { background: var(--nav-active-bg); color: var(--nav-active-txt); font-weight: 600; }

/* Sidebar accordion groups */
.nav-group { margin: 2px 0; }
.nav-group-toggle { justify-content: space-between; }
.nav-group-toggle .bi-chevron-down {
    width: auto;
    font-size: .72rem;
    opacity: .8;
    transition: transform .28s ease-in-out, opacity .2s ease;
}
.nav-group.is-open .nav-group-toggle .bi-chevron-down {
    transform: rotate(180deg);
    opacity: 1;
}

.nav-item-main {
    display: inline-flex;
    align-items: center;
    gap: 9px;
}

.sidebar-nav .nav-item {
    position: relative;
    overflow: hidden;
    box-shadow: inset 0 0 0 0 var(--brand);
    transition: color .28s ease-in-out, background .28s ease-in-out, box-shadow .28s ease-in-out;
}

.sidebar-nav .nav-item::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(90deg, rgba(34,197,94,.22) 0%, rgba(255,255,255,.06) 62%, transparent 100%);
    transform: scaleX(0);
    transform-origin: left center;
    transition: transform .28s ease-in-out;
    z-index: 0;
}

.sidebar-nav .nav-item > * {
    position: relative;
    z-index: 1;
}

.sidebar-nav .nav-item:hover {
    color: #f3f4f6;
    box-shadow: inset 4px 0 0 0 var(--brand);
}

.sidebar-nav .nav-item:hover::after,
.sidebar-nav .nav-group.is-open > .nav-item::after {
    transform: scaleX(1);
}

.sidebar-nav .nav-item.active,
.sidebar-nav .nav-group.is-open > .nav-item {
    color: #bbf7d0;
    background: rgba(34,197,94,.12);
    box-shadow: inset 4px 0 0 0 var(--brand);
    font-weight: 600;
}

.nav-sub {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin: 0 8px 0 24px;
    padding-left: 12px;
    border-left: 2px solid rgba(34,197,94,.30);
    transition: max-height .30s ease-in-out, opacity .26s ease-in-out, margin-top .26s ease-in-out;
}

.nav-group.is-open > .nav-sub {
    max-height: 900px;
    opacity: 1;
    margin-top: 4px;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px 8px 14px;
    margin: 3px 0;
    border-radius: var(--radius-sm);
    color: #9fb1c2;
    font-size: .82rem;
    font-weight: 500;
    transition: color .22s ease, background .22s ease, padding-left .22s ease;
}

.nav-sub-item:hover {
    color: #f3f4f6;
    background: rgba(255,255,255,.10);
    padding-left: 18px;
}

.nav-sub-item.active {
    color: var(--nav-active-txt);
    background: rgba(34,197,94,.18);
    font-weight: 700;
    padding-left: 18px;
}

.nav-sub-nest {
    margin: 8px 0 2px;
}

.nav-sub-parent-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: #9fb1c2;
    font-size: .8rem;
    font-weight: 600;
    letter-spacing: .01em;
    text-transform: none;
    padding: 6px 10px 6px 14px;
    border-radius: var(--radius-sm);
    transition: background .2s ease, color .2s ease;
}

.nav-sub-parent-toggle i {
    width: auto;
    font-size: .68rem;
    opacity: .8;
    transition: transform .26s ease-in-out;
}

.nav-sub-nest.is-open > .nav-sub-parent-toggle {
    color: #bbf7d0;
    background: rgba(34,197,94,.12);
}

.nav-sub-nest.is-open > .nav-sub-parent-toggle i {
    transform: rotate(180deg);
}

.nav-sub-children {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-left: 12px;
    border-left: 1px dashed rgba(159,177,194,.35);
    padding-left: 6px;
    transition: max-height .28s ease-in-out, opacity .24s ease-in-out;
}

.nav-sub-nest.is-open > .nav-sub-children {
    max-height: 420px;
    opacity: 1;
}

.nav-sub-item.nav-sub-item-nested {
    margin-left: 10px;
    padding-left: 18px;
    font-size: .8rem;
}

.nav-sub-item.nav-sub-item-nested:hover,
.nav-sub-item.nav-sub-item-nested.active {
    padding-left: 22px;
}

.sidebar-footer {
    border-top: 1px solid var(--nav-border);
    padding: 8px;
}
.logout-link { color: #ef4444 !important; }
.logout-link:hover { background: rgba(239,68,68,.1) !important; }

/* ── Main Wrapper ───────────────────────────────────────────── */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Topbar ─────────────────────────────────────────────────── */
.app-top-strip {
    height: 10px;
    background: #050607;
    border-bottom: 1px solid #111827;
    position: relative;
    flex-shrink: 0;
}

.app-top-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #f59e0b;
    position: absolute;
    right: 12px;
    top: 2px;
}

.topbar {
    height: var(--topbar-h);
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 14px;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

#sidebarToggle { display: inline-flex; padding: 4px 8px; }

.topbar-left {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.topbar-brand {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
}

.topbar-brand-logo {
    width: 42px;
    height: 42px;
    object-fit: contain;
    border-radius: 4px;
}

.topbar-brand i {
    color: #64748b;
    font-size: 1.55rem;
}

.topbar-sep {
    width: 1px;
    height: 26px;
    background: #d1d5db;
    flex-shrink: 0;
}

.topbar-company {
    min-width: 0;
    line-height: 1.15;
}

.topbar-company small {
    display: block;
    font-size: .68rem;
    color: #9ca3af;
}

.topbar-company strong {
    display: inline-block;
    font-size: .86rem;
    color: #374151;
    font-weight: 600;
    white-space: nowrap;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    position: relative;
}

.topbar-datetime {
    font-size: .72rem;
    color: #6b7280;
    white-space: nowrap;
    margin-right: 6px;
}

.topbar-flag-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-right: 4px;
}

.topbar-flag {
    font-size: 1.05rem;
    line-height: 1;
    display: inline-block;
    animation: flagWave 1.9s ease-in-out infinite;
}

@keyframes flagWave {
    0% { transform: rotate(0deg) translateY(0); }
    25% { transform: rotate(-7deg) translateY(-1px); }
    50% { transform: rotate(0deg) translateY(0); }
    75% { transform: rotate(7deg) translateY(-1px); }
    100% { transform: rotate(0deg) translateY(0); }
}

.topbar-icon-btn {
    width: 26px;
    height: 26px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 6px;
    color: #6b7280;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.topbar-icon-btn:hover {
    background: #f3f4f6;
    color: #111827;
    border-color: #e5e7eb;
}

.topbar-notification-btn {
    position: relative;
}

#topbarMinimizeBtn {
    color: #475569;
}

#topbarMinimizeBtn:hover {
    color: #0f172a;
}

.topbar-notification-dot {
    position: absolute;
    right: 4px;
    top: 3px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #ef4444;
    box-shadow: 0 0 0 2px #ffffff;
}

.topbar-notification-panel {
    position: absolute;
    top: 34px;
    right: 54px;
    width: 340px;
    max-height: 420px;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    box-shadow: 0 18px 40px rgba(15, 23, 42, .18);
    z-index: 1200;
    overflow: hidden;
}

.np-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid #eef2f7;
    background: #f8fafc;
}

.np-head strong {
    font-size: .78rem;
    letter-spacing: .03em;
    text-transform: uppercase;
    color: #334155;
}

.np-markall {
    border: none;
    background: transparent;
    color: #2563eb;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
}

.np-list {
    max-height: 360px;
    overflow-y: auto;
}

.np-item {
    border-bottom: 1px solid #f1f5f9;
    padding: 10px 12px;
    cursor: pointer;
}

.np-item:hover {
    background: #f8fafc;
}

.np-item-title {
    font-size: .76rem;
    font-weight: 700;
    color: #0f172a;
    margin-bottom: 4px;
}

.np-item-msg {
    font-size: .74rem;
    color: #475569;
    line-height: 1.35;
}

.np-item-time {
    margin-top: 6px;
    font-size: .66rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.np-empty {
    padding: 18px 12px;
    text-align: center;
    color: #94a3b8;
    font-size: .74rem;
    font-weight: 600;
}

@media (max-width: 900px) {
    .topbar-notification-panel {
        right: 8px;
        left: 8px;
        width: auto;
        top: 40px;
    }
}

.topbar-flag-image {
    width: 18px;
    height: 18px;
    object-fit: cover;
    border-radius: 50%;
}

body.erp-minimized {
    background: radial-gradient(circle at 18% 14%, #dbeafe 0%, #f5f6f8 45%, #eef2ff 100%);
}

body.erp-minimized .app-shell {
    display: none;
}

.erp-mini-home-screen {
    position: fixed;
    inset: 0;
    z-index: 2100;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background:
        radial-gradient(circle at 16% 12%, rgba(255, 255, 255, .8), rgba(255, 255, 255, 0) 44%),
        radial-gradient(circle at 84% 86%, rgba(56, 189, 248, .24), rgba(56, 189, 248, 0) 42%),
        linear-gradient(155deg, #dbeafe 0%, #f5f7ff 52%, #e2e8f0 100%);
}

body.erp-minimized .erp-mini-home-screen {
    display: flex;
}

.erp-mini-phone {
    width: min(340px, 92vw);
    min-height: 530px;
    border-radius: 28px;
    border: 1px solid rgba(15, 23, 42, .12);
    padding: 18px 14px 16px;
    background: linear-gradient(160deg, rgba(15, 23, 42, .86), rgba(2, 6, 23, .94));
    box-shadow: 0 24px 50px rgba(2, 6, 23, .35);
    color: #e2e8f0;
}

.erp-mini-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.erp-mini-time {
    font-size: 1.05rem;
    font-weight: 800;
    letter-spacing: .03em;
}

.erp-mini-badge {
    font-size: .64rem;
    font-weight: 700;
    color: #38bdf8;
    border: 1px solid rgba(56, 189, 248, .4);
    border-radius: 999px;
    padding: 5px 9px;
    text-transform: uppercase;
    letter-spacing: .06em;
}

.erp-mini-app-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
}

.erp-mini-app {
    height: 82px;
    border-radius: 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    letter-spacing: .02em;
    color: #e2e8f0;
    background: linear-gradient(165deg, rgba(30, 41, 59, .92), rgba(51, 65, 85, .88));
    border: 1px solid rgba(148, 163, 184, .24);
}

body.erp-restore-animating .app-shell {
    animation: erpShellRestore .24s cubic-bezier(.2, .8, .2, 1);
    transform-origin: center top;
    will-change: transform, opacity;
}

@keyframes erpShellRestore {
    0% {
        opacity: .92;
        transform: translateY(8px) scale(.992);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.erp-floating-widget {
    position: fixed;
    left: 16px;
    top: 120px;
    z-index: 2500;
    width: 92px;
    height: 92px;
    border: 0;
    border-radius: 50%;
    background: radial-gradient(circle at 30% 24%, #1e293b 0%, #0f172a 66%, #020617 100%);
    color: #f8fafc;
    box-shadow: 0 12px 30px rgba(2, 6, 23, .44);
    padding: 0;
    display: none;
    align-items: center;
    justify-content: center;
    overflow: visible;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.erp-floating-widget.is-visible {
    display: inline-flex;
}

.erp-floating-widget:active {
    transform: scale(.98);
}

.erp-floating-widget .erp-fw-core {
    position: relative;
    z-index: 2;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    pointer-events: none;
}

.erp-floating-widget .erp-fw-title {
    font-size: .78rem;
    font-weight: 800;
    letter-spacing: .03em;
    line-height: 1;
    color: #f8fafc;
}

.erp-floating-widget .erp-fw-open {
    font-size: .6rem;
    font-weight: 700;
    line-height: 1;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #22c55e;
}

.erp-floating-widget .erp-fw-live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #22c55e;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, .22);
    animation: erpLiveBlink 1.1s ease-in-out infinite;
}

.erp-floating-widget .erp-fw-orbit-wrap {
    position: absolute;
    inset: -16px;
    pointer-events: none;
    display: none;
    z-index: 0;
}

.erp-floating-widget.has-running-job .erp-fw-orbit-wrap {
    display: block;
}

.erp-floating-widget .erp-fw-orbit {
    width: 100%;
    height: 100%;
    display: block;
    transform-origin: 50% 50%;
    animation: erpOrbitSpin 8s linear infinite;
}

.erp-floating-widget .erp-fw-orbit-text {
    fill: #000000;
    font-size: 10px;
    letter-spacing: .9px;
    font-weight: 800;
    text-transform: uppercase;
}

.erp-floating-widget .erp-fw-timer {
    position: absolute;
    z-index: 3;
    left: 50%;
    bottom: 11px;
    transform: translateX(-50%);
    min-width: 66px;
    text-align: center;
    color: #ff3b3b;
    font-size: .66rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .03em;
    text-shadow: 0 0 10px rgba(255, 59, 59, .45);
    display: none;
    pointer-events: none;
}

.erp-floating-widget.has-running-job .erp-fw-timer {
    display: block;
}

@keyframes erpOrbitSpin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes erpLiveBlink {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: .45;
        transform: scale(.82);
    }
}

@media (prefers-reduced-motion: reduce) {
    body.erp-restore-animating .app-shell {
        animation: none;
    }

    .erp-floating-widget .erp-fw-orbit {
        animation: none;
    }

    .erp-fw-live-dot {
        animation: none;
    }
}

/* ── Page Content ───────────────────────────────────────────── */
.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scrollbar-width: thin;
}

/* ── App Footer ────────────────────────────────────────────── */
.app-footer {
    border-top: 1px solid var(--nav-border);
    background: var(--nav-bg);
    padding: 10px 18px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-footer-left,
.app-footer-right {
    font-size: .74rem;
    color: #d1d5db;
    line-height: 1.35;
    font-weight: 500;
    white-space: nowrap;
}

/* ── Settings Module ───────────────────────────────────────── */
.settings-card { overflow: hidden; }
.settings-modern {
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, .06);
}

.settings-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 12px 0;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.settings-tab {
    display: inline-flex;
    align-items: center;
    padding: 9px 12px;
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    color: #6b7280;
    font-size: .82rem;
    font-weight: 600;
}

.settings-tab:hover { background: #eef2f7; color: #1f2937; }

.settings-tab.active {
    background: #fff;
    border-color: var(--border);
    color: var(--text-main);
}

.settings-body { padding: 16px; }

.settings-static-banner {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    border: 1px solid #dbeafe;
    background: #eff6ff;
    color: #1e3a8a;
    border-radius: 10px;
    padding: 10px 12px;
    margin-bottom: 14px;
}

.settings-static-banner i { font-size: 1rem; margin-top: 1px; }
.settings-static-banner p { margin-top: 3px; font-size: .76rem; color: #334155; }

.form-grid-2 {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.library-upload-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    border: 1px solid var(--border);
    background: #f8fafc;
    padding: 10px;
    border-radius: 10px;
}

.library-category-pills {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.library-pill {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: #fff;
    color: #64748b;
    font-size: .74rem;
    font-weight: 600;
}

.library-pill.active {
    background: #ecfdf5;
    color: #166534;
    border-color: #86efac;
}

.settings-preview {
    width: 54px;
    height: 54px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    overflow: hidden;
}

.settings-preview img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.library-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    padding: 10px;
}

.library-card-modern {
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 8px 24px rgba(15, 23, 42, .05);
}

.library-chip {
    position: absolute;
    top: 12px;
    left: 12px;
    z-index: 2;
    background: rgba(15,23,42,.72);
    color: #f8fafc;
    font-size: .68rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 999px;
}

.library-thumb {
    width: 100%;
    height: 130px;
    border-radius: 6px;
    border: 1px solid var(--border-light);
    overflow: hidden;
    background: #f8fafc;
}

.library-card-modern .library-thumb { height: 150px; }

.library-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.library-meta { margin: 8px 0 10px; }
.library-name { font-size: .8rem; font-weight: 600; color: var(--text-main); }
.library-time { font-size: .72rem; color: #9ca3af; margin-top: 3px; }

.backup-banner {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    border: 1px solid #c7d2fe;
    background: #eef2ff;
    color: #312e81;
    border-radius: 10px;
    padding: 11px 12px;
}
.backup-banner i { font-size: 1rem; margin-top: 2px; }
.backup-banner p { margin-top: 3px; color: #3730a3; font-size: .76rem; }

.backup-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.backup-panel {
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 8px 22px rgba(15,23,42,.04);
    padding: 14px;
}

.backup-panel h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: .92rem;
    color: var(--text-main);
    margin-bottom: 6px;
}

.backup-panel p { color: var(--text-muted); font-size: .78rem; }

.backup-danger {
    border-color: #fecaca;
    background: #fff7f7;
}

.backup-danger h3 { color: #991b1b; }

/* Dark mode surface overrides */
body.theme-dark {
    --bg-page: #0f172a;
    --bg-white: #111827;
    --text-main: #e5e7eb;
    --text-muted: #9ca3af;
    --border: #1f2937;
    --border-light: #1f2937;
}

body.theme-dark .card,
body.theme-dark .table,
body.theme-dark .form-card,
body.theme-dark .settings-tab.active,
body.theme-dark .library-card,
body.theme-dark .topbar {
    background: #111827;
}

body.theme-dark .settings-static-banner {
    background: #172554;
    border-color: #1e3a8a;
    color: #bfdbfe;
}

body.theme-dark .settings-static-banner p { color: #cbd5e1; }
body.theme-dark .library-upload-bar { background: #0f172a; }
body.theme-dark .library-pill { background: #0f172a; color: #94a3b8; border-color: #1f2937; }
body.theme-dark .library-pill.active { background: #14532d; color: #dcfce7; border-color: #166534; }
body.theme-dark .backup-panel { background: #0f172a; border-color: #1f2937; }
body.theme-dark .backup-banner { background: #1e1b4b; border-color: #312e81; color: #c7d2fe; }
body.theme-dark .backup-banner p { color: #c4b5fd; }
body.theme-dark .backup-danger { background: #2b1215; border-color: #7f1d1d; }
body.theme-dark .backup-danger h3 { color: #fecaca; }

body.theme-dark .topbar-icon-btn:hover {
    background: #1f2937;
    color: #f3f4f6;
    border-color: #374151;
}

.app-footer-left {
    text-align: left;
    flex-shrink: 0;
}

.app-footer-right {
    text-align: right;
    margin-left: auto;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Page Header ────────────────────────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}
.page-header h1 { font-size: 1.3rem; font-weight: 700; color: var(--text-main); }
.page-header p  { font-size: .82rem; color: var(--text-muted); margin-top: 3px; }
.page-header-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Breadcrumb */
.breadcrumb {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}
.breadcrumb a     { color: var(--brand); }
.breadcrumb-sep   { color: #d1d5db; }

/* ── Stat Cards Grid ────────────────────────────────────────── */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px,1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.stat-card:hover { box-shadow: var(--shadow-md); }
.stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    flex-shrink: 0;
}
.stat-icon.green  { background: #f0fdf4; color: #16a34a; }
.stat-icon.blue   { background: #eff6ff; color: #2563eb; }
.stat-icon.amber  { background: #fffbeb; color: #d97706; }
.stat-icon.purple { background: #faf5ff; color: #7c3aed; }
.stat-icon.red    { background: #fef2f2; color: #dc2626; }
.stat-icon.teal   { background: #f0fdfa; color: #0d9488; }
.stat-value { font-size: 1.55rem; font-weight: 700; color: var(--text-main); line-height: 1; }
.stat-label { font-size: .73rem; color: var(--text-muted); margin-top: 4px; }

/* ── Card ───────────────────────────────────────────────────── */
.card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 13px 18px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.card-title { font-size: .875rem; font-weight: 600; color: var(--text-main); }
.card-body  { padding: 18px; }

/* Section grid (two columns) */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.three-col { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ── Table ──────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; border-radius: 0 0 var(--radius) var(--radius); }
table { width: 100%; border-collapse: collapse; }
th {
    background: #f8fafc;
    color: var(--text-muted);
    font-size: .67rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 700;
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 1;
}
td {
    padding: 10px 12px;
    font-size: .82rem;
    color: var(--text-main);
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
    white-space: nowrap;
}
tbody tr:nth-child(even)       { background: #fafbfc; }
tbody tr:hover                 { background: #eff6ff; }
tbody tr:nth-child(even):hover { background: #e8f4fd; }
.table-empty {
    text-align: center;
    color: var(--text-muted);
    padding: 40px 20px;
    font-size: .875rem;
}
.table-empty i { font-size: 2rem; display: block; margin-bottom: 8px; color: #d1d5db; }

/* Row actions */
.row-actions { display: flex; gap: 4px; }
.row-actions .btn { padding: 4px 7px; font-size: .72rem; }

/* ── Filter Bar ─────────────────────────────────────────────── */
.filter-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: flex-end;
    margin-bottom: 14px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; }
.filter-group label {
    font-size: .64rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-light);
    font-weight: 700;
}
.filter-group input,
.filter-group select {
    height: 33px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    font: inherit;
    font-size: .82rem;
    color: var(--text-main);
    min-width: 140px;
    outline: none;
    background: #fff;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.filter-group input:focus,
.filter-group select:focus {
    border-color: #86efac;
    box-shadow: 0 0 0 3px rgba(34,197,94,.1);
}

/* ── Forms ──────────────────────────────────────────────────── */
.form-grid   { display: grid; grid-template-columns: repeat(2, 1fr); gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.form-grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.col-span-2  { grid-column: span 2; }
.col-span-3  { grid-column: span 3; }
.col-span-full { grid-column: 1 / -1; }

.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group label {
    font-size: .68rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
}
.form-control {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    font: inherit;
    font-size: .875rem;
    color: var(--text-main);
    background: var(--bg-white);
    width: 100%;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    appearance: none;
    -webkit-appearance: none;
}
.form-control:focus {
    border-color: #86efac;
    box-shadow: 0 0 0 3px rgba(34,197,94,.1);
}
textarea.form-control { resize: vertical; min-height: 80px; }
.form-control[readonly]  { background: #f8fafc; color: var(--text-muted); cursor: default; }
.form-control[disabled]  { background: #f3f4f6; color: #9ca3af; cursor: not-allowed; }
.form-hint { font-size: .7rem; color: var(--text-light); }
.form-section-title {
    font-size: .78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-muted);
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 16px;
}

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    line-height: 1;
}
.btn-sm   { padding: 5px 10px; font-size: .75rem; }
.btn-full { width: 100%; justify-content: center; }

.btn-primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); box-shadow: 0 2px 8px rgba(34,197,94,.35); }

.btn-secondary { background: #f3f4f6; color: var(--text-main); border-color: var(--border); }
.btn-secondary:hover { background: #e9eaec; }

.btn-danger  { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.btn-danger:hover  { background: #fee2e2; border-color: #f87171; }

.btn-blue  { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.btn-blue:hover  { background: #dbeafe; }

.btn-amber  { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.btn-amber:hover  { background: #fef3c7; }

.btn-ghost  { background: transparent; color: var(--text-muted); border-color: var(--border); }
.btn-ghost:hover  { background: #f3f4f6; }

.btn-dark { background: #1f2937; color: #f9fafb; border-color: #1f2937; }
.btn-dark:hover { background: #111827; }

/* ── Badges / Status Pills ──────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 9px;
    border-radius: var(--radius-full);
    font-size: .68rem;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: .02em;
}
.badge-available    { background: #dcfce7; color: #166534; }
.badge-assigned     { background: #ede9fe; color: #5b21b6; }
.badge-consumed     { background: #f3f4f6; color: #6b7280; }
/* Paper stock — Firebase-aligned statuses */
.badge-main         { background: #f3e8ff; color: #7e22ce; }
.badge-stock        { background: #d1fae5; color: #065f46; }
.badge-slitting     { background: #ffedd5; color: #c2410c; }
.badge-job-assign   { background: #ffe4e6; color: #be123c; }
.badge-draft        { background: #f3f4f6; color: #6b7280; }
.badge-sent         { background: #eff6ff; color: #1d4ed8; }
.badge-approved     { background: #dcfce7; color: #166534; }
.badge-rejected     { background: #fef2f2; color: #991b1b; }
.badge-converted    { background: #faf5ff; color: #6d28d9; }
.badge-pending      { background: #fff7ed; color: #c2410c; }
.badge-in-production{ background: #eff6ff; color: #1d4ed8; }
.badge-completed    { background: #dcfce7; color: #166534; }
.badge-dispatched   { background: #f0fdf4; color: #15803d; }
.badge-cancelled    { background: #fef2f2; color: #991b1b; }
.badge-queued       { background: #f3f4f6; color: #4b5563; }
.badge-in-progress  { background: #eff6ff; color: #2563eb; }
.badge-on-hold      { background: #fff7ed; color: #b45309; }
.badge-urgent       { background: #fef2f2; color: #dc2626; }
.badge-high         { background: #fff7ed; color: #c2410c; }
.badge-normal       { background: #eff6ff; color: #1d4ed8; }
.badge-low          { background: #f3f4f6; color: #6b7280; }

/* Planning lifecycle: distinct color concept per status */
.badge-preparing-slitting     { background: #ffedd5; color: #c2410c; }
.badge-slitting-active        { background: #fff7ed; color: #9a3412; }
.badge-slitting-pause         { background: #fff1f2; color: #be123c; }
.badge-slitted                { background: #dcfce7; color: #166534; }
.badge-jumbo-slitting-preparing { background: #f5f3ff; color: #6d28d9; }
.badge-jumbo-slitting-active  { background: #312e81; color: #ffffff; }
.badge-jumbo-slitted          { background: #ecfdf5; color: #047857; }
.badge-pending-jumbo-slitting { background: #fdf4ff; color: #a21caf; }

.badge-pending-printing       { background: #eff6ff; color: #1d4ed8; }
.badge-printing-preparing     { background: #dbeafe; color: #1e40af; }
.badge-printing-active        { background: #bfdbfe; color: #1d4ed8; }
.badge-printing-pause         { background: #fee2e2; color: #991b1b; }
.badge-printed                { background: #dcfce7; color: #166534; }

.badge-pending-die-cutting    { background: #fef3c7; color: #92400e; }
.badge-die-cutting-preparing  { background: #fde68a; color: #92400e; }
.badge-die-cutting-active     { background: #fcd34d; color: #78350f; }
.badge-die-cutting-pause      { background: #fee2e2; color: #b91c1c; }
.badge-die-cutting-done       { background: #ecfccb; color: #3f6212; }

.badge-pending-barcode        { background: #f0fdfa; color: #0f766e; }
.badge-barcode-preparing      { background: #ccfbf1; color: #0f766e; }
.badge-barcode-active         { background: #99f6e4; color: #115e59; }
.badge-barcode-pause          { background: #ffe4e6; color: #be123c; }
.badge-barcode-done           { background: #a7f3d0; color: #047857; }

.badge-pending-label-slitting { background: #f5f3ff; color: #6d28d9; }
.badge-label-slitting-preparing { background: #ede9fe; color: #5b21b6; }
.badge-label-slitting-active  { background: #ddd6fe; color: #6d28d9; }
.badge-label-slitting-pause   { background: #fce7f3; color: #9d174d; }
.badge-label-slitting-done    { background: #ddd6fe; color: #6d28d9; }

.badge-pending-packing        { background: #e0f2fe; color: #0369a1; }
.badge-packing-preparing      { background: #bae6fd; color: #075985; }
.badge-packing-active         { background: #7dd3fc; color: #0c4a6e; }
.badge-packing-pause          { background: #fde68a; color: #92400e; }
.badge-packing-done           { background: #7dd3fc; color: #0c4a6e; }

/* ── Alerts / Flash ─────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
    font-size: .875rem;
    border: 1px solid transparent;
}
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error,
.alert-danger  { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-warning { background: #fffbeb; color: #92400e; border-color: #fde68a; }
.alert-info    { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.alert-close   { background: none; border: none; cursor: pointer; font-size: 1.1rem; color: inherit; opacity: .6; line-height: 1; }
.alert-close:hover { opacity: 1; }

/* ── Calc / Result boxes ────────────────────────────────────── */
.calc-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px,1fr));
    gap: 12px;
    padding: 14px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.calc-item small  { display: block; font-size: .64rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-light); margin-bottom: 4px; }
.calc-item strong { font-size: 1rem; font-weight: 700; color: var(--text-main); }
.calc-item strong.green { color: #16a34a; }
.calc-item strong.amber { color: #d97706; }

/* ── Pagination ─────────────────────────────────────────────── */
.pagination {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: flex-end;
    padding-top: 14px;
}
.page-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: .8rem;
    color: var(--text-muted);
    cursor: pointer;
}
.page-item:hover       { background: #f3f4f6; color: var(--text-main); }
.page-item.active      { background: var(--brand); color: #fff; border-color: var(--brand); font-weight: 700; }

/* ── Login ──────────────────────────────────────────────────── */
.login-body {
    background: linear-gradient(135deg, #f0fdf4 0%, #f5f6f8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-wrap { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 40px 36px;
    box-shadow: var(--shadow-md);
}
.login-logo {
    width: 132px;
    height: 132px;
    background: var(--brand-light);
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
    color: var(--brand);
    margin: 0 auto 16px;
}
.login-logo img {
    width: 100px;
    height: 100px;
    object-fit: contain;
}
.login-title { font-size: 1.35rem; font-weight: 700; color: var(--text-main); text-align: center; margin-bottom: 4px; }
.login-sub   { text-align: center; color: var(--text-muted); font-size: .85rem; margin-bottom: 28px; }
.login-form .form-group { margin-bottom: 14px; }

/* ── Utility Classes ────────────────────────────────────────── */
.text-muted  { color: var(--text-muted); }
.text-light  { color: var(--text-light); }
.text-green  { color: #16a34a; }
.text-red    { color: #dc2626; }
.text-amber  { color: #d97706; }
.text-blue   { color: #2563eb; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.d-flex      { display: flex; }
.flex-wrap   { flex-wrap: wrap; }
.align-center{ align-items: center; }
.justify-between { justify-content: space-between; }
.gap-4  { gap: 4px; }
.gap-8  { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.mt-8   { margin-top: 8px; }
.mt-12  { margin-top: 12px; }
.mt-16  { margin-top: 16px; }
.mt-20  { margin-top: 20px; }
.mb-8   { margin-bottom: 8px; }
.mb-12  { margin-bottom: 12px; }
.mb-16  { margin-bottom: 16px; }
.mb-20  { margin-bottom: 20px; }
.mb-24  { margin-bottom: 24px; }
.text-right  { text-align: right; }
.text-center { text-align: center; }
.text-sm     { font-size: .8rem; }

.empty-state { text-align: center; padding: 48px 20px; }
.empty-state i { font-size: 2.5rem; color: #d1d5db; display: block; margin-bottom: 10px; }
.empty-state p { color: var(--text-muted); }

/* Setup page */
.setup-wrap { max-width: 640px; margin: 60px auto; padding: 20px; }
.setup-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius); padding: 36px; box-shadow: var(--shadow-md); }
.setup-card h1 { font-size: 1.4rem; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.setup-card p  { color: var(--text-muted); margin-bottom: 24px; }
.setup-log { background: #1f2937; color: #a3e635; font-family: monospace; font-size: .8rem; padding: 14px; border-radius: var(--radius-sm); max-height: 260px; overflow-y: auto; margin: 16px 0; }
.setup-log .ok  { color: #4ade80; }
.setup-log .err { color: #f87171; }

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .app-shell.sidebar-collapsed .sidebar { margin-left: 0; }
    .sidebar {
        position: fixed;
        left: 0; top: 0; bottom: 0;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s ease;
    }
    .sidebar.is-open { transform: translateX(0); }
    .main-wrapper { margin-left: 0; }
    #sidebarToggle { display: inline-flex; }
    .topbar-sep { display: none; }
    .topbar-company small { display: none; }
    .topbar-company strong { max-width: 180px; font-size: .8rem; }
    .topbar-datetime { display: none; }
    .two-col, .three-col { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
    .page-content { padding: 16px; }
    .topbar { padding: 0 10px; }
    .topbar-brand span { display: none; }
    .topbar-right { gap: 2px; }
    .topbar-flag-wrap { width: 20px; height: 20px; margin-right: 2px; }
    .topbar-flag { font-size: .95rem; }
    .topbar-icon-btn { width: 24px; height: 24px; }
    .app-footer {
        padding: 9px 12px;
        flex-direction: column;
        align-items: flex-start;
        gap: 2px;
    }
    .app-footer-left,
    .app-footer-right {
        white-space: normal;
        font-size: .7rem;
    }
    .app-footer-right { text-align: left; margin-left: 0; }
    .form-grid-2 { grid-template-columns: 1fr; }
    .library-upload-bar { align-items: stretch; }
    .library-upload-bar input,
    .library-upload-bar select,
    .library-upload-bar button { width: 100%; }
    .settings-tabs { overflow-x: auto; white-space: nowrap; }
    .backup-grid { grid-template-columns: 1fr; }
    .form-grid, .form-grid-3, .form-grid-4 { grid-template-columns: 1fr; }
    .col-span-2, .col-span-3, .col-span-full { grid-column: 1; }
    .stat-cards { grid-template-columns: 1fr 1fr; }
    .filter-bar { flex-direction: column; align-items: stretch; }
    .filter-group input, .filter-group select { min-width: unset; width: 100%; }
    .login-card { padding: 28px 20px; }

    .erp-floating-widget {
        width: 82px;
        height: 82px;
    }

    .erp-floating-widget .erp-fw-title {
        font-size: .7rem;
    }

    .erp-floating-widget .erp-fw-open {
        font-size: .54rem;
    }

    .erp-floating-widget .erp-fw-live-dot {
        width: 5px;
        height: 5px;
    }

    .erp-floating-widget .erp-fw-orbit-wrap {
        inset: -14px;
    }

    .erp-floating-widget .erp-fw-orbit-text {
        font-size: 8.7px;
    }

    .erp-floating-widget .erp-fw-timer {
        font-size: .6rem;
        min-width: 54px;
        bottom: 8px;
    }
}
@media (max-width: 400px) {
    .stat-cards { grid-template-columns: 1fr; }
}
