/* =============================================
   PROFESSIONAL ERP UI — style.css
   Top Navigation Layout
   ============================================= */

/* ---------- RESET & BASE ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --primary:        #2563eb;
    --primary-dark:   #1d4ed8;
    --primary-light:  #eff6ff;
    --navbar-bg:      #0f172a;
    --navbar-hover:   rgba(255,255,255,0.08);
    --navbar-active:  rgba(37,99,235,0.85);
    --navbar-border:  rgba(255,255,255,0.07);
    --topbar-bg:      #ffffff;
    --content-bg:     #f1f5f9;
    --card-bg:        #ffffff;
    --border:         #e2e8f0;
    --text-primary:   #0f172a;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;
    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --info:           #06b6d4;
    --radius:         8px;
    --radius-lg:      12px;
    --shadow-sm:      0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow:         0 4px 6px -1px rgba(0,0,0,0.08), 0 2px 4px -1px rgba(0,0,0,0.04);
    --shadow-lg:      0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
    --navbar-height:  56px;
    --font:           'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
}

html { font-size: 14px; }

body {
    font-family: var(--font);
    background: var(--content-bg);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: none; }


/* ---------- APP SHELL ---------- */
.app {
    min-height: 100vh;
}


/* =============================================
   TOP NAVBAR
   ============================================= */
.navbar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--navbar-height);
    background: var(--navbar-bg);
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 16px;
    gap: 4px;
    box-shadow: 0 1px 0 var(--navbar-border), 0 2px 8px rgba(0,0,0,0.18);
}

/* Brand */
.navbar-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    text-decoration: none;
    flex-shrink: 0;
    margin-right: 8px;
}

.brand-icon {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 15px;
    color: #fff;
    flex-shrink: 0;
}

.brand-name {
    font-size: 15px;
    font-weight: 700;
    color: #f8fafc;
    white-space: nowrap;
    letter-spacing: -0.01em;
}

/* Nav Menu (horizontal list) */
.nav-menu {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
    height: 100%;
    padding: 0;
    margin: 0;
}

/* Each nav item */
.nav-item {
    position: relative;
    height: 100%;
    display: flex;
    align-items: center;
}

/* Nav link */
.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 12px;
    height: 100%;
    color: #94a3b8;
    font-size: 13.5px;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: color 0.15s, background 0.15s;
    cursor: pointer;
    border-bottom: 3px solid transparent;
    margin-bottom: -1px;
}

.nav-link:hover {
    color: #f1f5f9;
    background: var(--navbar-hover);
    text-decoration: none;
}

.nav-link.active,
.nav-item.active > .nav-link {
    color: #fff;
    border-bottom-color: var(--primary);
    background: rgba(37,99,235,0.12);
}

.nav-link i:not(.nav-caret) {
    font-size: 14px;
    opacity: 0.8;
}

.nav-caret {
    font-size: 10px;
    opacity: 0.6;
    margin-left: 2px;
    transition: transform 0.2s;
}

.nav-dropdown.open > .nav-link .nav-caret {
    transform: rotate(180deg);
}

/* Dropdown submenu */
.nav-submenu {
    display: none;
    position: absolute;
    top: calc(100% + 0px);
    left: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
    list-style: none;
    padding: 6px 0;
    z-index: 1100;
    animation: dropIn 0.15s ease;
}

@keyframes dropIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.nav-dropdown.open .nav-submenu { display: block; }

.nav-submenu li a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: var(--text-secondary);
    font-size: 13.5px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}

.nav-submenu li a:hover {
    background: var(--content-bg);
    color: var(--primary);
    text-decoration: none;
}

.nav-submenu li a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}

.nav-submenu li a i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    opacity: 0.7;
}

.nav-submenu li a.active i { opacity: 1; }

/* Divider in submenu */
.nav-submenu .divider {
    height: 1px;
    background: var(--border);
    margin: 5px 0;
}

/* Nested sub-groups inside a dropdown — flyout to the right */
.nav-sub-group {
    position: relative;
}
.nav-sub-group-toggle {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: var(--text-dark);
    font-size: 13.5px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
    width: 100%;
}
.nav-sub-group-toggle:hover {
    background: var(--content-bg);
    color: var(--primary);
    text-decoration: none;
}
.nav-sub-group-toggle.active {
    color: var(--primary);
}
.nav-sub-caret {
    font-size: 10px;
    opacity: 0.6;
    margin-left: auto;
    transition: transform 0.2s;
}
.nav-sub-group.open > .nav-sub-group-toggle .nav-sub-caret {
    transform: rotate(90deg);
}
/* Flyout panel — appears to the right of the toggle row */
.nav-sub-submenu {
    display: none;
    position: absolute;
    top: 0;
    left: 100%;
    min-width: 190px;
    list-style: none;
    padding: 6px 0;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 8px 24px rgba(0,0,0,0.12), 0 2px 6px rgba(0,0,0,0.06);
    z-index: 1300;
    animation: dropIn 0.15s ease;
}
.nav-sub-group.open > .nav-sub-submenu {
    display: block;
}
.nav-sub-submenu li a {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 9px 16px;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.12s, color 0.12s;
    white-space: nowrap;
}
.nav-sub-submenu li a:hover {
    background: var(--content-bg);
    color: var(--primary);
    text-decoration: none;
}
.nav-sub-submenu li a.active {
    color: var(--primary);
    background: var(--primary-light);
    font-weight: 600;
}
.nav-sub-submenu li a i {
    width: 16px;
    text-align: center;
    font-size: 13px;
    opacity: 0.7;
}
.nav-sub-submenu li a.active i { opacity: 1; }
.nav-sub-divider {
    height: 1px;
    background: var(--border);
    margin: 4px 0;
}

/* Right side of navbar */
.navbar-right {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
    flex-shrink: 0;
}

/* User chip */
.nav-user {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 10px;
    border-radius: 8px;
    cursor: default;
}

.nav-avatar {
    width: 30px; height: 30px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700; color: #fff;
    flex-shrink: 0;
}

.nav-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.nav-user-name {
    font-size: 13px;
    font-weight: 600;
    color: #f1f5f9;
    white-space: nowrap;
}

.nav-user-role {
    font-size: 11px;
    color: #64748b;
}

/* Logout button */
.nav-logout {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 6px 12px;
    border-radius: 7px;
    color: #94a3b8;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}

.nav-logout:hover {
    background: rgba(239,68,68,0.12);
    color: #f87171;
    text-decoration: none;
}

/* Mobile-only logout menu item — hidden on desktop */
.navbar-right-mobile { display: none; }
.nav-menu-logout { display: none; }

/* Mobile toggle button */
.nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    margin-left: auto;
}

.nav-toggle:hover { background: var(--navbar-hover); color: #fff; }

/* Mobile responsive */
@media (max-width: 900px) {
    .nav-toggle { display: flex; align-items: center; }
    .navbar-right { display: none; }
    .nav-menu-logout { display: block; }

    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        position: fixed;
        top: var(--navbar-height);
        left: 0; right: 0;
        background: var(--navbar-bg);
        border-top: 1px solid var(--navbar-border);
        padding: 8px;
        gap: 2px;
        height: auto;
        max-height: calc(100vh - var(--navbar-height));
        overflow-y: auto;
        box-shadow: 0 8px 16px rgba(0,0,0,0.3);
    }

    .nav-menu.open { display: flex; }

    .nav-item { height: auto; flex-direction: column; align-items: stretch; }

    .nav-link {
        height: auto;
        padding: 10px 12px;
        border-bottom: none;
        border-radius: 7px;
        margin-bottom: 0;
    }

    .nav-link.active,
    .nav-item.active > .nav-link {
        border-bottom: none;
        background: rgba(37,99,235,0.2);
    }

    .nav-submenu {
        position: static;
        box-shadow: none;
        border: none;
        border-radius: 0;
        background: rgba(255,255,255,0.04);
        padding: 4px 0 4px 20px;
        margin-top: 2px;
        animation: none;
    }

    .nav-submenu li a {
        color: #94a3b8;
        border-radius: 6px;
    }

    .nav-submenu li a:hover {
        background: var(--navbar-hover);
        color: #f1f5f9;
    }

    /* Sub-submenus: stack below instead of flyout right */
    .nav-sub-group { position: static !important; }

    .nav-sub-submenu {
        position: static !important;
        left: auto !important;
        top: auto !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        background: rgba(255,255,255,0.03) !important;
        padding: 4px 0 4px 16px !important;
        animation: none !important;
        min-width: unset !important;
        width: 100% !important;
    }

    .nav-sub-submenu li a {
        color: #94a3b8;
        border-radius: 6px;
        white-space: normal;
    }

    .nav-sub-submenu li a:hover {
        background: var(--navbar-hover);
        color: #f1f5f9;
    }
}


/* =============================================
   MAIN CONTENT
   ============================================= */
.content {
    margin-top: var(--navbar-height);
    min-height: calc(100vh - var(--navbar-height));
    background: var(--content-bg);
}

.page-body {
    padding: 24px;
}

/* Legacy pages that still wrap in <div class="content"> */
.content .content {
    margin-top: 0 !important;
    min-height: auto !important;
    background: transparent !important;
    padding: 0 !important;
}


/* =============================================
   PAGE HEADER
   ============================================= */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2, .page-header h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.content h2 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.content h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}


/* =============================================
   BUTTONS
   ============================================= */
.btn, a.btn, button.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    border: none;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.15s ease;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:hover { text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary, a.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}
.btn-primary:hover, a.btn-primary:hover {
    background: var(--primary-dark);
    color: #fff;
    box-shadow: 0 4px 12px rgba(37,99,235,0.35);
}

.btn-success {
    background: var(--success);
    color: #fff;
    box-shadow: 0 1px 4px rgba(16,185,129,0.3);
}
.btn-success:hover {
    background: #059669;
    color: #fff;
    box-shadow: 0 4px 12px rgba(16,185,129,0.35);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
    box-shadow: 0 1px 4px rgba(239,68,68,0.3);
}
.btn-danger:hover { background: #dc2626; color: #fff; }

.btn-warning {
    background: var(--warning);
    color: #fff;
}
.btn-warning:hover { background: #d97706; color: #fff; }

.btn-secondary {
    background: #f1f5f9;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-secondary:hover {
    background: #e2e8f0;
    color: var(--text-primary);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-sm  { padding: 5px 10px; font-size: 12px; }
.btn-lg  { padding: 11px 22px; font-size: 15px; }
.btn-icon { padding: 7px 9px; }

/* Legacy bare <a> links styled as buttons */
.content > a:not(.btn):not(.report-card),
.page-body > a:not(.btn):not(.report-card) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    background: var(--primary);
    color: #fff;
    text-decoration: none;
    margin-bottom: 16px;
    transition: background 0.15s;
    box-shadow: 0 1px 4px rgba(37,99,235,0.3);
}
.content > a:not(.btn):not(.report-card):hover,
.page-body > a:not(.btn):not(.report-card):hover {
    background: var(--primary-dark);
    color: #fff;
}


/* =============================================
   CARDS (Dashboard)
   ============================================= */
.cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
}

.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }

.card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px; height: 100%;
    background: var(--primary);
}

.card:nth-child(2)::before { background: var(--success); }
.card:nth-child(3)::before { background: var(--warning); }
.card:nth-child(4)::before { background: var(--info); }

.card h3 {
    font-size: 30px;
    font-weight: 800;
    color: var(--text-primary);
    margin: 0 0 4px;
    line-height: 1;
}

.card p {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
    margin: 0;
}


/* =============================================
   PANEL / SECTION WRAPPER
   ============================================= */
.panel {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-bottom: 20px;
}

.panel-header {
    padding: 13px 18px;
    border-bottom: 1px solid #dde4ed;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: linear-gradient(to bottom, #f8fafc, #f1f5f9);
}

.panel-title {
    font-size: 13.5px;
    font-weight: 700;
    color: #1e293b;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.panel-body { padding: 20px; }


/* =============================================
   TABLES
   ============================================= */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    font-size: 13.5px;
}

table thead tr {
    background: linear-gradient(to bottom, #f1f5f9, #e8edf5);
    border-bottom: 2px solid #c9d3e0;
}

table th {
    padding: 11px 12px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    white-space: nowrap;
    background: transparent;
    border-bottom: 2px solid #c9d3e0;
    border-right: 1px solid #e5ebf2;
    border-left: none; border-top: none;
}
table th:last-child { border-right: none; }

table td {
    padding: 10px 12px;
    font-size: 13px;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    border-right: 1px solid #f0f4f8;
    border-left: none; border-top: none;
    vertical-align: middle;
    white-space: nowrap;
}
table td:last-child { border-right: none; }

table tbody tr:nth-child(even) { background: #fafbfd; }
table tbody tr:last-child td { border-bottom: none; }
table tbody tr:hover { background: #eff6ff !important; transition: background 0.1s; }

.table-wrapper, .list-table-wrapper {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow-x: auto;
    margin-top: 16px;
}

.content > table {
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    margin-top: 16px;
}

/* list-table (invoice / purchase line items) */
.list-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
    background: #fff;
}

.list-table th {
    background: linear-gradient(to bottom, #f1f5f9, #e8edf5);
    padding: 10px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #374151;
    border-bottom: 2px solid #c9d3e0;
    border-right: 1px solid #dde3ec;
    border-left: none; border-top: none;
    text-align: center;
}
.list-table th:last-child { border-right: none; }

.list-table td {
    padding: 7px 6px;
    border-bottom: 1px solid var(--border);
    border-right: 1px solid #f0f4f8;
    border-left: none; border-top: none;
    text-align: center;
    vertical-align: middle;
}
.list-table td:last-child { border-right: none; }

.list-table tbody tr:nth-child(even) { background: #fafbfd; }
.list-table tbody tr:hover { background: #eff6ff !important; transition: background 0.1s; }
.list-table tbody tr:last-child td { border-bottom: none; }

.list-table input,
.list-table select {
    width: 100%;
    box-sizing: border-box;
    font-size: 12px;
    padding: 5px 7px;
    border: 1px solid var(--border);
    border-radius: 5px;
    font-family: var(--font);
    background: #fff;
    transition: border-color 0.15s;
}

.list-table input:focus,
.list-table select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}

.list-table th:nth-child(1)  { width: 170px; }
.list-table th:nth-child(2)  { width: 120px; }
.list-table th:nth-child(3)  { width: 70px; }
.list-table th:nth-child(4)  { width: 70px; }
.list-table th:nth-child(5)  { width: 60px; }
.list-table th:nth-child(6)  { width: 110px; }
.list-table th:nth-child(7)  { width: 70px; }
.list-table th:nth-child(8)  { width: 75px; }
.list-table th:nth-child(9)  { width: 90px; }
.list-table th:nth-child(10) { width: 60px; }
.list-table th:nth-child(11) { width: 100px; }
.list-table th:nth-child(12) { width: 40px; }


/* =============================================
   FORMS
   ============================================= */
.form-group { margin-bottom: 16px; }

label, .form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

input[type="text"],
input[type="number"],
input[type="email"],
input[type="date"],
input[type="password"],
input[type="search"],
input[type="tel"],
select,
textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
    font-family: var(--font);
    color: var(--text-primary);
    background: #fff;
    transition: border-color 0.15s, box-shadow 0.15s;
    line-height: 1.4;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.12);
}

select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 28px;
}

textarea { resize: vertical; min-height: 80px; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-section {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}

.form-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.error, input.error, select.error {
    border-color: var(--danger) !important;
    background: #fff5f5;
}

.error-msg {
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

input[type="radio"], input[type="checkbox"] {
    width: auto;
    padding: 0;
    accent-color: var(--primary);
}


/* =============================================
   BADGES / STATUS CHIPS
   ============================================= */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.badge-success  { background: #d1fae5; color: #065f46; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-info     { background: #cffafe; color: #164e63; }
.badge-primary  { background: #dbeafe; color: #1e40af; }
.badge-gray     { background: #f1f5f9; color: #475569; }


/* =============================================
   ACTION BUTTONS IN TABLES
   ============================================= */
.action-links { display: flex; align-items: center; gap: 6px; }

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 6px;
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s, transform 0.1s;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
}

.action-btn:hover         { background: #f1f5f9; color: var(--text-primary); transform: scale(1.1); }

/* Edit — always blue */
.action-btn.edit          { color: var(--primary); }
.action-btn.edit:hover    { background: #dbeafe; color: #1d4ed8; }

/* Delete — always red */
.action-btn.delete        { color: var(--danger); }
.action-btn.delete:hover  { background: #fee2e2; color: #b91c1c; }

/* View — always green */
.action-btn.view          { color: var(--success); }
.action-btn.view:hover    { background: #d1fae5; color: #047857; }

/* Print — always amber */
.action-btn.print         { color: var(--warning); }
.action-btn.print:hover   { background: #fef3c7; color: #b45309; }

/* Return — always orange */
.action-btn.return        { color: #f97316; }
.action-btn.return:hover  { background: #ffedd5; color: #c2410c; }

/* Lock — always slate */
.action-btn.lock          { color: #64748b; }
.action-btn.lock:hover    { background: #f1f5f9; color: #334155; }


/* =============================================
   ALERTS / FLASH MESSAGES
   ============================================= */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 13.5px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid;
}

.alert-success { background: #f0fdf4; border-color: var(--success); color: #14532d; }
.alert-danger  { background: #fff5f5; border-color: var(--danger);  color: #7f1d1d; }
.alert-warning { background: #fffbeb; border-color: var(--warning); color: #78350f; }
.alert-info    { background: #f0f9ff; border-color: var(--info);    color: #0c4a6e; }


/* =============================================
   MODAL
   ============================================= */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,0.5);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(2px);
}

.modal-overlay.active { display: flex; }

.modal-box {
    background: #fff;
    width: 440px;
    max-width: 95vw;
    max-height: 90vh;
    overflow: auto;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.modal-close {
    cursor: pointer;
    font-size: 20px;
    color: var(--text-muted);
    line-height: 1;
    background: none;
    border: none;
    padding: 2px 6px;
    border-radius: 4px;
    transition: background 0.15s;
}
.modal-close:hover { background: #f1f5f9; color: var(--text-primary); }

.modal-toggle {
    padding: 12px 20px;
    border-bottom: 1px solid var(--border);
    background: #f8fafc;
}

.modal-body { padding: 20px; }

.modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: #f8fafc;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}


/* =============================================
   REPORTS PAGE
   ============================================= */
.report-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-top: 20px;
}

.report-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: block;
}

.report-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: var(--shadow);
    text-decoration: none;
    color: var(--text-primary);
}

.report-icon {
    font-size: 28px;
    margin-bottom: 12px;
    display: block;
}

.report-title {
    font-size: 15px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.report-desc {
    font-size: 12.5px;
    color: var(--text-secondary);
    line-height: 1.5;
}


/* =============================================
   PRODUCT CELL (invoice line items)
   ============================================= */
.product-cell { padding: 4px; vertical-align: top; }
.prod-name-wrap { width: 100%; }
.prod-desc-wrap { margin-top: 2px; }
.item-desc {
    width: 100%;
    height: 26px;
    font-size: 11px;
    resize: none;
    box-sizing: border-box;
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 3px 6px;
    font-family: var(--font);
}
.item-desc:focus { outline: none; border-color: var(--primary); }


/* =============================================
   MISCELLANEOUS UTILITIES
   ============================================= */
.text-muted   { color: var(--text-muted) !important; }
.text-success { color: var(--success) !important; }
.text-danger  { color: var(--danger) !important; }
.text-warning { color: var(--warning) !important; }
.text-primary-color { color: var(--primary) !important; }

.fw-bold   { font-weight: 700; }
.fw-medium { font-weight: 500; }
.text-right  { text-align: right; }
.text-center { text-align: center; }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.flex-1 { flex: 1; }

hr { border: none; border-top: 1px solid var(--border); margin: 16px 0; }


/* =============================================
   TOTALS BOX
   ============================================= */
.totals-box {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #dde4ed;
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    min-width: 300px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.totals-row {
    display: flex;
    justify-content: space-between;
    padding: 6px 0;
    font-size: 13.5px;
    color: var(--text-secondary);
    border-bottom: 1px solid #e8edf4;
}

.totals-row:last-child { border-bottom: none; }

.totals-row.grand-total {
    font-size: 16px;
    font-weight: 800;
    color: var(--text-primary);
    padding-top: 10px;
    margin-top: 4px;
    border-top: 2px solid #c9d3e0;
    border-bottom: none;
    background: linear-gradient(90deg, transparent, rgba(37,99,235,0.04));
    border-radius: 0 0 6px 6px;
    padding-left: 4px;
    padding-right: 4px;
}


/* =============================================
   LOGIN PAGE
   ============================================= */
body.login-page {
    background: linear-gradient(135deg, #0f172a 0%, #1e3a8a 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

@media (max-width: 480px) {
    body.login-page {
        align-items: flex-start;
        padding: 24px 16px;
    }
    .login-card {
        padding: 28px 20px;
        border-radius: 12px;
    }
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo-icon {
    width: 52px; height: 52px;
    background: var(--primary);
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px;
    color: #fff;
    margin: 0 auto 12px;
    box-shadow: 0 8px 20px rgba(37,99,235,0.35);
}

.login-logo h2 {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
}


/* =============================================
   SCROLLBAR (WebKit)
   ============================================= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }


/* =============================================
   FILTER / SEARCH BAR
   ============================================= */
.filter-panel {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: var(--shadow-sm);
}

.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    min-width: 150px;
}

.filter-group label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0;
}

.filter-group input,
.filter-group select {
    padding: 8px 10px;
    font-size: 13px;
    min-width: 150px;
}

.filter-actions {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-wrap: wrap;
    margin-left: auto;
}

.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
}

.search-bar input {
    min-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: var(--font);
}


/* =============================================
   SUMMARY STAT CARDS
   ============================================= */
.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--shadow-sm);
}

.stat-card-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-card-value {
    font-size: 17px;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
}


/* =============================================
   COLUMN FILTER BOX (stocks page)
   ============================================= */
.col-filter-box {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 16px;
    margin-bottom: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

.col-filter-box .col-filter-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-right: 4px;
    white-space: nowrap;
}

.col-filter-box label {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12.5px;
    color: var(--text-primary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 5px;
    transition: background 0.15s;
    text-transform: none;
    letter-spacing: 0;
    margin: 0;
    font-weight: 500;
    white-space: nowrap;
}

.col-filter-box label:hover { background: var(--content-bg); }


/* =============================================
   INFO TABLE (key-value display in view pages)
   ============================================= */
.info-table { width: 100%; border-collapse: collapse; margin-bottom: 0; }

.info-table th {
    width: 160px;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-muted);
    padding: 9px 14px;
    text-align: left;
    background: #f8fafc;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
    white-space: nowrap;
}

.info-table td {
    padding: 9px 14px;
    color: var(--text-primary);
    font-size: 13.5px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: top;
}

.info-table tr:last-child th,
.info-table tr:last-child td { border-bottom: none; }


/* =============================================
   SETTINGS PAGE
   ============================================= */
.settings-section-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-primary);
    padding: 14px 20px 0;
    border-top: 1px solid var(--border);
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-section-title:first-child { border-top: none; }
