@media print {
    body {
        font-family: sans-serif;
        margin: 0;
        padding: 0;
        background: white;
        color: black;
    }
    
    .container {
        width: 100%;
        margin: 0;
    }
    
    .print-area {
        padding: 20px;
    }
    
    .invoice-card {
        border: none;
        box-shadow: none;
        padding: 0;
    }
    
    .invoice-company h2 {
        font-size: 24px;
        margin: 0 0 10px 0;
    }
    
    .invoice-company div {
        margin: 5px 0;
        font-size: 14px;
    }
    
    .invoice-head {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        margin: 20px 0;
    }
    
    .invoice-head h1 {
        font-size: 28px;
        margin: 0;
    }
    
    .invoice-meta div {
        margin: 5px 0;
        font-size: 14px;
    }
    
    .invoice-party {
        margin: 20px 0;
        font-size: 14px;
    }
    
    .invoice-party div {
        margin: 5px 0;
    }
    
    .table-wrap table {
        width: 100%;
        border-collapse: collapse;
        margin: 20px 0;
    }
    
    .table-wrap th,
    .table-wrap td {
        border: 1px solid #000;
        padding: 8px;
        text-align: left;
        font-size: 12px;
    }
    
    .table-wrap th {
        background: #f0f0f0;
        font-weight: bold;
    }
    
    .invoice-total,
    .account-details,
    .tax-breakdown,
    .amount-words,
    .delivery-info,
    .signature {
        margin: 10px 0;
        font-size: 14px;
    }
    
    .account-details h3 {
        margin: 0 0 10px 0;
        font-size: 16px;
    }
    
    .signature {
        text-align: center;
        margin-top: 50px;
    }
    
    .no-print {
        display: none;
    }
}

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

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, sans-serif;
    background:
        radial-gradient(circle at 12% 20%, rgba(255, 214, 153, 0.25), transparent 35%),
        radial-gradient(circle at 88% 12%, rgba(186, 230, 253, 0.33), transparent 38%),
        #f4f6fb;
    color: #1b1f2a;
}

.container {
    width: min(1100px, 94%);
    margin: 0 auto;
}

.topbar {
    background: linear-gradient(95deg, #0b2f45, #0e5c77 55%, #1389a6);
    color: #fff;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
    position: sticky;
    top: 0;
    z-index: 100;
}

.topbar-inner {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.brand {
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.brand-title {
    font-size: 1.15rem;
    font-weight: 700;
    display: block;
}

.brand-sub {
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #cde9f3;
    display: block;
}

.logo-img {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    flex: 0 0 auto;
}

.menu {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.menu-toggle {
    display: none;
    border: 0;
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    font-weight: 700;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
}

.menu-toggle:hover {
    background: rgba(255, 255, 255, 0.28);
}

.menu a {
    text-decoration: none;
}

.menu-home,
.menu-link,
.menu-logout {
    color: #e7f4fb;
    padding: 8px 10px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.92rem;
}

.menu-home:hover,
.menu-link:hover,
.menu-logout:hover {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
}

.menu-group {
    position: relative;
}

.menu-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    min-width: 210px;
    padding: 8px;
    border-radius: 10px;
    background: #fff;
    box-shadow: 0 14px 30px rgba(0, 0, 0, 0.15);
    display: none;
}

.menu-dropdown a {
    display: block;
    color: #214054;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 8px 10px;
    border-radius: 7px;
}

.menu-dropdown a:hover {
    background: #eef7fb;
}

.menu-divider,
.menu-section-toggle {
    margin: 6px 0;
    padding: 6px 10px;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6f7d8f;
    border-top: 1px solid #e2e8f1;
    background: transparent;
}

.menu-section-toggle {
    width: 100%;
    text-align: left;
    border: 0;
    cursor: pointer;
}

.menu-section {
    padding-left: 4px;
}

.menu-section.collapsed {
    display: none;
}

.menu-group:hover .menu-dropdown,
.menu-group:focus-within .menu-dropdown {
    display: block;
}

main.container {
    padding: 20px 0 32px;
}

.card {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
    padding: 18px;
    margin-bottom: 18px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    gap: 14px;
}

.stat {
    background: #fff;
    border-left: 6px solid #136f8b;
    border-radius: 10px;
    padding: 14px 16px;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

.stat .label {
    color: #4d5b72;
    font-size: 0.9rem;
}

.stat .value {
    margin-top: 6px;
    font-size: 1.6rem;
    font-weight: 700;
}

h1, h2, h3 {
    margin: 0 0 12px;
}

form .row {
    display: grid;
    grid-template-columns: repeat(2, minmax(180px, 1fr));
    gap: 12px;
}

.table-form .row {
    grid-template-columns: 1fr;
    gap: 6px;
}

.table-form label {
    font-size: 12px;
    margin-bottom: 2px;
}

.table-form .actions {
    margin-top: 6px;
    justify-content: flex-start;
}

label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
}

input:not([type="checkbox"]):not([type="radio"]):not(.choices__input):not(.choices__input--cloned),
select,
textarea,
button {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #c9d1df;
    padding: 10px 12px;
    font-size: 0.95rem;
}

input[type="checkbox"],
input[type="radio"] {
    width: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
}

a {
    color: #0d5f78;
}

textarea {
    resize: vertical;
    min-height: 90px;
}

button {
    cursor: pointer;
    background: #136f8b;
    color: #fff;
    border: 0;
    font-weight: 700;
}

button:hover {
    background: #0f5e76;
}

.btn-danger {
    background: #c62828;
}

.btn-danger:hover {
    background: #a91f1f;
}

.actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    flex-wrap: wrap;
}

.dashboard-actions {
    margin-bottom: 14px;
}

.actions form {
    margin: 0;
}

.actions button {
    width: auto;
}

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

.table-wrap-items {
    overflow: visible;
}

.permission-grid th,
.permission-grid td {
    vertical-align: middle;
}

.permission-grid td.center {
    text-align: center;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th, td {
    border-bottom: 1px solid #e5e9f2;
    padding: 10px;
    text-align: left;
    font-size: 0.92rem;
}

#salesItemsTable td,
#quotationItemsTable td,
#proformaItemsTable td,
#purchaseItemsTable td,
#poItemsTable td {
    vertical-align: top;
}

th {
    background: #f0f4fa;
}

.muted {
    color: #677389;
}

.alert {
    padding: 11px 12px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-weight: 600;
}

.alert.success {
    background: #e8f7ed;
    color: #1e7e34;
}

.alert.error {
    background: #fdeaea;
    color: #b12424;
}

.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    background:
        linear-gradient(rgba(0, 0, 0, 0.45), rgba(0, 0, 0, 0.45)),
        url("https://images.unsplash.com/photo-1470252649378-9c29740c9fa8?auto=format&fit=crop&w=1600&q=80")
        center / cover no-repeat fixed;
}

.login-card {
    width: min(420px, 92%);
    background: rgba(255, 255, 255, 0.95);
    border-radius: 14px;
    padding: 22px;
    box-shadow: 0 14px 36px rgba(0, 0, 0, 0.2);
}

.login-company {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px;
    border-radius: 10px;
    background: #f4fbff;
    margin-bottom: 12px;
}

.small-text {
    font-size: 0.8rem;
    line-height: 1.35;
}

.error-text {
    color: #b12424;
    min-height: 20px;
    margin-top: 4px;
    margin-bottom: 8px;
    font-size: 0.9rem;
}

.invoice-card {
    margin-top: 18px;
}

.invoice-company {
    display: flex;
    align-items: center;
    gap: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e5e9f2;
    margin-bottom: 12px;
}

.invoice-company h2 {
    margin: 0 0 4px;
}

.invoice-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.invoice-meta {
    text-align: right;
}

.invoice-party {
    margin: 14px 0;
    padding: 10px;
    background: #f7fafc;
    border-radius: 8px;
}

.invoice-total {
    margin-top: 14px;
    text-align: right;
    font-size: 1.08rem;
}

.invoice-note {
    margin-top: 10px;
}

.print-area {
    padding-bottom: 30px;
}

.master-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    gap: 14px;
}

.master-card {
    display: block;
    text-decoration: none;
    background: #fff;
    border-radius: 12px;
    padding: 16px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
}

.master-card:hover {
    background: #f4fbff;
}

.module-shell {
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.module-tabs {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #d9e2ee;
    background: #f7f9fd;
    flex-wrap: wrap;
}

.module-tab-btn {
    width: auto;
    padding: 8px 18px;
    background: #ecf1f8;
    color: #1d3f58;
    border: 1px solid #ccd8e8;
}

.module-tab-btn.active {
    background: #1d9ab5;
    color: #fff;
    border-color: #1d9ab5;
}

.module-search {
    margin-left: auto;
    width: min(320px, 100%);
}

.module-search input {
    background: #fff;
}

.module-panel {
    display: none;
    padding: 14px;
}

.module-panel.active {
    display: block;
}

.module-panel .card {
    margin-bottom: 0;
    box-shadow: none;
    border: 1px solid #e2e8f1;
}

.pagination {
    display: flex;
    gap: 6px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.page-link {
    display: inline-block;
    padding: 6px 10px;
    border: 1px solid #c8d4e3;
    border-radius: 6px;
    text-decoration: none;
    color: #1d4863;
    background: #fff;
    font-weight: 600;
    font-size: 0.88rem;
}

.page-link:hover {
    background: #edf5fb;
}

.page-link.active {
    background: #1d9ab5;
    color: #fff;
    border-color: #1d9ab5;
}

@media (max-width: 760px) {
    body {
        font-size: 15px;
    }

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

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

    .topbar-inner {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        padding: 10px 0;
    }

    .menu-toggle {
        display: inline-flex;
        align-items: center;
        gap: 6px;
    }

    .menu {
        width: 100%;
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
        display: none;
    }

    .menu-home,
    .menu-link,
    .menu-logout {
        background: rgba(255, 255, 255, 0.1);
        display: block;
        width: 100%;
    }

    .menu.menu-open {
        display: flex;
    }

    .menu-group {
        width: 100%;
    }

    .menu-dropdown {
        position: static;
        display: block;
        margin-top: 6px;
        min-width: 0;
        width: 100%;
        box-shadow: none;
        border: 1px solid #e2e8f1;
        background: #f7fbff;
    }

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

    .invoice-head {
        flex-direction: column;
    }

    .invoice-meta {
        text-align: left;
    }

    .module-tabs {
        gap: 6px;
        flex-direction: column;
        align-items: stretch;
    }

    .module-search {
        width: 100%;
        margin-left: 0;
    }

    .module-tab-btn {
        width: 100%;
        text-align: left;
    }

    th, td {
        font-size: 0.88rem;
        padding: 8px;
    }

    .table-wrap {
        -webkit-overflow-scrolling: touch;
    }

    .table-wrap table {
        min-width: 720px;
    }

    .table-wrap-items table {
        min-width: 0;
    }
}

@media (max-width: 520px) {
    .container {
        width: 94%;
    }

    .brand-title {
        font-size: 1rem;
    }

    .brand-sub {
        font-size: 0.68rem;
    }

    .logo-img {
        width: 36px;
        height: 36px;
    }

    .module-tab-btn {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    input, select, textarea, button {
        font-size: 0.9rem;
        padding: 9px 10px;
    }

    .invoice-total {
        text-align: left;
        font-size: 1rem;
    }

    .actions {
        flex-direction: column;
        align-items: stretch;
    }

    .actions button {
        width: 100%;
    }

    .table-wrap table {
        min-width: 640px;
    }

    .table-wrap-items table {
        min-width: 0;
    }
}

@media print {
    .no-print {
        display: none !important;
    }

    body {
        background: #fff;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
