:root {
    --bg-dark: #0f172a;
    --card-bg: #1e293b;
    --card-border: #334155;
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent-blue: #38bdf8;
    --accent-green: #22c55e;
    --accent-yellow: #eab308;
    --accent-red: #ef4444;
    --radius-md: 10px;
    --radius-lg: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    min-height: 100vh;
}

/* Login Overlay */
.login-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.92);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.login-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    width: 100%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.5);
}

.login-header i {
    font-size: 2.5rem;
    color: var(--accent-blue);
    margin-bottom: 12px;
}

.login-header h2 {
    font-size: 1.3rem;
    margin-bottom: 6px;
}

.login-header p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.login-input {
    text-align: center;
    font-size: 1.1rem;
    letter-spacing: 2px;
    margin-bottom: 16px;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 12px;
}

.login-error {
    margin-top: 14px;
    color: var(--accent-red);
    font-size: 0.85rem;
    font-weight: 600;
}

.btn-logout {
    background: rgba(239, 68, 68, 0.15) !important;
    color: var(--accent-red) !important;
    border-color: rgba(239, 68, 68, 0.3) !important;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--card-bg);
    border-bottom: 1px solid var(--card-border);
    padding: 16px 32px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
}

.logo i {
    font-size: 2rem;
    color: var(--accent-blue);
}

.logo h1 {
    font-size: 1.35rem;
    font-weight: 700;
}

.badge {
    background: var(--accent-blue);
    color: #0f172a;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 12px;
    font-weight: 700;
}

.logo p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.nav-links {
    display: flex;
    gap: 12px;
}

.nav-btn {
    background: transparent;
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    padding: 10px 18px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.nav-btn.active, .nav-btn:hover {
    background: var(--accent-blue);
    color: #0f172a;
    border-color: var(--accent-blue);
}

/* Layout */
.main-layout {
    max-width: 1200px;
    margin: 30px auto;
    padding: 0 20px;
}

.view-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.data-table, .items-edit-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td, .items-edit-table th, .items-edit-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--card-border);
}

.data-table th, .items-edit-table th {
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 0.85rem;
}

/* Form Styles */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section.full-width {
    grid-column: 1 / -1;
}

.form-section h3 {
    font-size: 1rem;
    color: var(--text-primary);
    border-bottom: 1px solid var(--card-border);
    padding-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-row {
    display: flex;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
}

.form-group.flex-2 { flex: 2; }
.form-group.flex-1 { flex: 1; }

.form-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.custom-input {
    background: #0f172a;
    border: 1px solid var(--card-border);
    color: var(--text-primary);
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.custom-input:focus {
    border-color: var(--accent-blue);
}

.section-title-with-btn {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Buttons */
.btn {
    padding: 10px 18px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-primary { background: var(--accent-blue); color: #0f172a; }
.btn-primary:hover { background: #0284c7; color: #fff; }

.btn-secondary { background: rgba(255, 255, 255, 0.08); color: var(--text-primary); border: 1px solid var(--card-border); }
.btn-secondary:hover { background: rgba(255, 255, 255, 0.15); }

.btn-success { background: var(--accent-green); color: #0f172a; }
.btn-success:hover { background: #16a34a; color: #fff; }

.btn-warning { background: var(--accent-yellow); color: #0f172a; }
.btn-danger { background: rgba(239, 68, 68, 0.15); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.3); }
.btn-danger:hover { background: var(--accent-red); color: #fff; }

.preview-toolbar {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 10px;
}

/* ==========================================================================
   PRINTABLE PAPER SHEET (EXACT bks64.pdf LAYOUT MATCH)
   ========================================================================== */
.invoice-paper {
    background: #ffffff;
    color: #000000;
    width: 210mm;
    min-height: 297mm;
    padding: 20mm 20mm;
    margin: 0 auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    font-family: 'Arial', sans-serif;
    font-size: 11pt;
    line-height: 1.4;
    position: relative;
    box-sizing: border-box;
}

.inv-header {
    margin-bottom: 25px;
}

.inv-company-name {
    font-size: 18pt;
    font-weight: bold;
    color: #000;
    margin-bottom: 4px;
}

.inv-company-address {
    font-size: 9.5pt;
    color: #333;
}

.inv-title-bar {
    text-align: left;
    margin-bottom: 25px;
}

.inv-title-bar h2 {
    font-size: 16pt;
    font-weight: bold;
    color: #000;
    letter-spacing: 1px;
}

/* Meta Grid */
.inv-meta-grid {
    display: flex;
    justify-content: space-between;
    margin-bottom: 25px;
}

.inv-client-box {
    width: 58%;
}

.inv-details-box {
    width: 38%;
}

.meta-line {
    margin-bottom: 4px;
    font-size: 10.5pt;
}

.address-line {
    margin-top: 4px;
    margin-bottom: 6px;
    white-space: pre-line;
}

.attn-line {
    margin-top: 8px;
}

/* Items Table */
.inv-items-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 25px;
}

.inv-items-table th {
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 8px 6px;
    text-align: left;
    font-weight: bold;
    font-size: 10.5pt;
}

.inv-items-table td {
    padding: 10px 6px;
    font-size: 10.5pt;
    vertical-align: top;
}

.inv-items-table tfoot tr td {
    border-top: 1px solid #000;
    border-bottom: 1px solid #000;
    padding: 8px 6px;
    font-size: 11pt;
}

.text-right { text-align: right; }
.bold { font-weight: bold; }

/* Footer Grid */
.inv-footer-grid {
    display: flex;
    justify-content: space-between;
    margin-top: 20px;
    margin-bottom: 40px;
}

.inv-payment-info {
    font-size: 10pt;
    line-height: 1.5;
}

.inv-signatory-box {
    text-align: right;
    font-size: 10.5pt;
    padding-right: 10px;
}

.sign-company {
    font-weight: bold;
    margin-top: 2px;
}

.sign-space {
    height: 60px;
}

.sign-name {
    font-size: 11pt;
}

.inv-bottom-tag {
    position: absolute;
    bottom: 15mm;
    left: 20mm;
    right: 20mm;
    border-top: 1px solid #ddd;
    padding-top: 8px;
    text-align: center;
    font-size: 9pt;
    color: #555;
}

/* ==========================================================================
   PRINT MEDIA RULES (For Printing / PDF Export)
   ========================================================================== */
@media print {
    body {
        background: #fff;
        color: #000;
    }

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

    .main-layout {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }

    .invoice-paper {
        box-shadow: none;
        margin: 0;
        padding: 10mm 15mm;
        width: 100%;
        min-height: auto;
    }
}
