@import url('https://fonts.googleapis.com/css2?family=Tinos:ital,wght@0,400;0,700;1,400;1,700&display=swap');

:root {
    --border-color: #000000;
    --border-width: 1.5px;
    --bg-gray: #f8f9fa;
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --font-times: 'Tinos', 'Times New Roman', Times, serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-times);
    background-color: #cbd5e1;
    color: #000;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* App Header UI */
.app-header {
    background-color: #0f172a;
    color: #fff;
    padding: 10px 20px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.15);
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: 'Inter', system-ui, sans-serif;
}

.header-container {
    max-width: 1480px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.brand {
    font-size: 1.15rem;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #38bdf8;
    letter-spacing: 0.5px;
}

.actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border-radius: 5px;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Inter', system-ui, sans-serif;
}

.btn-primary { background-color: #2563eb; color: white; }
.btn-primary:hover { background-color: #1d4ed8; }

.btn-save { background-color: #16a34a; color: white; }
.btn-save:hover { background-color: #15803d; }

.btn-saved-list { background-color: #0284c7; color: white; position: relative; }
.btn-saved-list:hover { background-color: #0369a1; }

.btn-saved-list .badge {
    background: #ef4444;
    color: white;
    font-size: 0.65rem;
    padding: 1px 5px;
    border-radius: 10px;
    margin-left: 3px;
}

.btn-corel { background-color: #8b5cf6; color: white; }
.btn-corel:hover { background-color: #7c3aed; }

.btn-secondary { background-color: #059669; color: white; }
.btn-secondary:hover { background-color: #047857; }

.btn-info { background-color: #64748b; color: white; }
.btn-info:hover { background-color: #475569; }

.btn-warning { background-color: #d97706; color: white; }
.btn-warning:hover { background-color: #b45309; }

/* Auth Status Box in Header */
.auth-box {
    margin-left: 4px;
    padding-left: 6px;
    border-left: 1px solid #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.user-badge {
    background: #1e293b;
    color: #4ade80;
    border: 1px solid #22c55e;
    padding: 4px 8px;
    border-radius: 5px;
    font-size: 0.775rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 5px;
}

.btn-logout {
    background: #ef4444;
    color: white;
    padding: 5px 10px;
}
.btn-logout:hover { background: #dc2626; }

/* -------------------------------------------------------------
   DUAL COLUMN STUDIO LAYOUT - ULTRA COMPACT HIGH DENSITY UI
   ------------------------------------------------------------- */
.studio-layout {
    display: flex;
    gap: 16px;
    max-width: 1480px;
    margin: 0 auto;
    padding: 12px;
    width: 100%;
    align-items: flex-start;
}

/* Left Sidebar Controls (Ultra Compact) */
.studio-sidebar {
    width: 380px;
    flex-shrink: 0;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
    border: 1px solid #cbd5e1;
    max-height: calc(100vh - 70px);
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: hidden;
    position: sticky;
    top: 60px;
    font-family: 'Inter', system-ui, sans-serif;
}

.sidebar-header {
    background: #0f172a;
    color: #38bdf8;
    padding: 8px 12px;
    font-weight: 800;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 6px;
    border-bottom: 1px solid #1e293b;
}

.sidebar-scroll {
    padding: 8px;
    overflow-y: auto;
    overflow-x: hidden;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-section {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 8px 10px;
    width: 100%;
}

.section-title {
    font-size: 0.7rem;
    font-weight: 800;
    color: #334155;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 5px;
    border-bottom: 1px solid #cbd5e1;
    padding-bottom: 4px;
}

.tool-group {
    margin-bottom: 5px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    width: 100%;
}

.tool-group:last-child {
    margin-bottom: 0;
}

.tool-group label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #475569;
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}

.label-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.value-badge {
    font-size: 0.725rem;
    font-weight: 800;
    color: #2563eb;
}

.tool-group select, 
.tool-group input[type="range"] {
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    font-size: 0.75rem;
    height: 26px;
    outline: none;
    background: #ffffff;
    color: #1e293b;
    font-weight: 600;
    width: 100%;
    box-sizing: border-box;
}

.tool-group select:focus {
    border-color: #2563eb;
}

/* 2-Column Controls Grid inside Sidebar */
.controls-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
    margin-top: 4px;
}

.full-width {
    width: 100%;
}

.align-buttons {
    display: flex;
    background: #ffffff;
    padding: 1px;
    border-radius: 5px;
    border: 1px solid #cbd5e1;
    width: 100%;
}

.btn-align {
    flex: 1;
    background: transparent;
    border: none;
    padding: 3px 6px;
    border-radius: 4px;
    cursor: pointer;
    color: #475569;
    font-size: 0.725rem;
    font-weight: 600;
    height: 24px;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
}

.btn-align.active,
.btn-align:hover {
    background: #2563eb;
    color: #ffffff;
}

.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 5px;
    border: 1px solid #cbd5e1;
    border-radius: 4px;
    padding: 2px 5px;
    background: #ffffff;
    height: 26px;
    width: 100%;
}

.color-picker-input {
    border: none;
    width: 22px;
    height: 20px;
    cursor: pointer;
    background: transparent;
    padding: 0;
}

.color-hex {
    font-size: 0.7rem;
    font-weight: 700;
    color: #334155;
}

.btn-toggle {
    padding: 3px 6px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #334155;
    cursor: pointer;
    font-size: 0.725rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    height: 26px;
    width: 100%;
    transition: all 0.15s ease;
}

.btn-toggle.active {
    background: #2563eb;
    color: #ffffff;
    border-color: #2563eb;
}

/* Quick Form Controls */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    width: 100%;
}

.input-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    width: 100%;
}

.full-span {
    grid-column: span 2;
}

.input-item label {
    font-size: 0.68rem;
    font-weight: 700;
    color: #475569;
}

.input-item input {
    padding: 3px 6px;
    font-size: 0.75rem;
    height: 26px;
    border-radius: 4px;
    border: 1px solid #cbd5e1;
    outline: none;
    font-weight: 600;
    color: #0f172a;
    width: 100%;
    box-sizing: border-box;
}

.input-item input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.15);
}

.sidebar-actions-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    width: 100%;
}

.sidebar-actions-grid .btn {
    padding: 5px 8px;
    font-size: 0.725rem;
    height: 26px;
}

/* Right Side Bill Preview */
.studio-preview {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: auto;
    padding-bottom: 20px;
}

/* Authentic Invoice Paper Box (Fixed Single Page A4) */
.invoice-box {
    background: #ffffff;
    width: 210mm;
    height: 297mm;
    padding: 0;
    margin: 0 auto;
    border: var(--border-width) solid var(--border-color);
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    position: relative;
    font-size: 13.5px;
    line-height: 1.3;
    color: #000000;
    overflow: hidden;
    font-family: var(--font-times);
}

/* Editable Elements Highlight on Hover */
[contenteditable="true"] {
    outline: none;
    transition: background-color 0.15s ease, box-shadow 0.15s ease;
    border-radius: 2px;
    min-width: 5px;
    font-family: var(--font-times);
}

[contenteditable="true"]:hover {
    background-color: rgba(37, 99, 235, 0.08);
}

[contenteditable="true"]:focus {
    background-color: rgba(37, 99, 235, 0.12);
    box-shadow: 0 0 0 1px #2563eb;
}

/* 1. Header Row */
.invoice-header-row {
    display: flex;
    border-bottom: var(--border-width) solid var(--border-color);
    width: 100%;
}

.supplier-info {
    width: 56%;
    padding: 12px 14px;
    border-right: var(--border-width) solid var(--border-color);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.company-title {
    font-family: Arial, 'Helvetica Neue', 'Inter', sans-serif;
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 2px;
    text-transform: uppercase;
    margin-bottom: 8px;
    line-height: 1.0;
    color: #000;
    text-align: center;
}

.company-tagline {
    font-family: var(--font-times);
    font-style: italic;
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 16px;
    color: #000;
    letter-spacing: 0.5px;
    text-align: center;
}

.contact-row {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 16px;
    font-family: var(--font-times);
    line-height: 1.3;
}

.contact-left {
    text-align: left;
}

.contact-right {
    text-align: right;
}

.address {
    text-align: center;
    font-weight: 700;
    font-size: 13.5px;
    line-height: 1.35;
    font-family: var(--font-times);
}

/* Right Meta Grid */
.meta-grid {
    width: 44%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-collapse: collapse;
}

.meta-cell {
    border-bottom: var(--border-width) solid var(--border-color);
    border-right: var(--border-width) solid var(--border-color);
    padding: 5px 8px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 42px;
    font-family: var(--font-times);
}

.meta-cell:nth-child(2n) {
    border-right: none;
}

.meta-cell:nth-last-child(1),
.meta-cell:nth-last-child(2) {
    border-bottom: none;
}

.meta-cell .label {
    font-size: 11.5px;
    font-weight: 700;
    color: #000;
}

.meta-cell .value {
    font-size: 13.5px;
    font-weight: 700;
    min-height: 16px;
}

.val-bold {
    font-weight: 700 !important;
}

/* 2. Middle Row: Buyer & Terms */
.invoice-middle-row {
    display: flex;
    border-bottom: var(--border-width) solid var(--border-color);
    min-height: 110px;
    width: 100%;
}

.buyer-info {
    width: 56%;
    border-right: var(--border-width) solid var(--border-color);
    padding: 16px 14px;
    display: flex;
    align-items: center;
}

.buyer-name {
    font-family: var(--font-times);
    font-size: 26px;
    font-weight: 700;
    line-height: 1.25;
    letter-spacing: 0.2px;
}

.terms-delivery {
    width: 44%;
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    font-family: var(--font-times);
}

.terms-delivery .label {
    font-size: 12px;
    font-weight: 700;
}

.terms-delivery .terms-text {
    flex: 1;
    font-size: 13.5px;
    padding-top: 4px;
}

/* 3. Items Table Section */
.invoice-table-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
}

.items-table {
    width: 100%;
    height: 100%;
    border-collapse: collapse;
    table-layout: fixed;
    font-family: var(--font-times);
}

.items-table th {
    border-bottom: var(--border-width) solid var(--border-color);
    border-right: var(--border-width) solid var(--border-color);
    padding: 6px 4px;
    font-size: 11.5px;
    font-weight: 700;
    text-align: center;
    vertical-align: middle;
    line-height: 1.15;
    background-color: #fff;
    color: #000;
    font-family: var(--font-times);
}

.items-table th:last-child {
    border-right: none;
}

.sub-th {
    font-size: 9.5px;
    font-weight: 600;
}

/* Column Width Percentages summing to 100% */
.col-sl { width: 5.5%; }
.col-desc { width: 43.5%; }
.col-qty { width: 7%; }
.col-uom { width: 7%; }
.col-sqft { width: 7%; }
.col-rate { width: 12%; }
.col-gst { width: 8%; }
.col-amount { width: 10%; }

.items-table td {
    border-right: var(--border-width) solid var(--border-color);
    padding: 8px 8px;
    font-size: 14px;
    vertical-align: top;
    line-height: 1.3;
    word-break: break-word;
    font-family: var(--font-times);
}

.items-table td:last-child {
    border-right: none;
}

.item-row {
    position: relative;
}

.item-row td {
    font-family: var(--font-times);
    font-size: 15px;
    font-weight: 700;
}

.text-center { text-align: center; }
.text-right { text-align: right; }

/* Floating Delete Button on Hover outside Table */
.btn-delete-row {
    position: absolute;
    right: -32px;
    top: 50%;
    transform: translateY(-50%);
    background: #ef4444;
    color: white;
    border: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 11px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.4;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.item-row:hover .btn-delete-row {
    opacity: 1;
}

.btn-delete-row:hover {
    background: #dc2626;
    transform: translateY(-50%) scale(1.1);
}

/* Table Footer / Totals */
.items-table tfoot tr {
    border-top: var(--border-width) solid var(--border-color);
}

.items-table tfoot td {
    padding: 6px 12px;
    font-weight: 700;
    font-size: 14px;
    font-family: var(--font-times);
}

.total-label {
    font-size: 14px;
    font-weight: 700;
}

.total-val {
    font-family: var(--font-times);
    font-size: 15px;
    font-weight: 700;
}

/* 4. Bottom Footer Section */
.invoice-footer-section {
    display: flex;
    border-top: var(--border-width) solid var(--border-color);
    margin-top: auto;
    width: 100%;
    font-family: var(--font-times);
}

.footer-left {
    width: 56%;
    border-right: var(--border-width) solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.amount-words-wrapper {
    padding: 6px 10px;
    border-bottom: var(--border-width) solid var(--border-color);
    position: relative;
    min-height: 48px;
}

.amount-words-wrapper .label {
    font-size: 11.5px;
    font-weight: 700;
}

.words-text {
    font-size: 15px;
    font-weight: 700;
    margin-top: 2px;
    font-family: var(--font-times);
}

.eoe {
    position: absolute;
    right: 10px;
    top: 6px;
    font-weight: 700;
    font-size: 12px;
}

.proprietor-section {
    padding: 8px 10px;
    font-weight: 700;
    font-size: 12.5px;
    line-height: 1.25;
}

.prop-name {
    margin-top: 1px;
}

.bank-details {
    padding: 8px 10px;
    font-size: 12.5px;
    line-height: 1.35;
    font-weight: 600;
}

.bank-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.declaration {
    padding: 8px 10px;
    font-size: 11px;
    line-height: 1.25;
}

.dec-title {
    font-weight: 700;
    margin-bottom: 2px;
}

.dec-text {
    font-size: 10.5px;
    font-weight: 500;
}

/* Footer Right (Signature Box) */
.footer-right {
    width: 44%;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding: 16px;
    position: relative;
}

.signature-box {
    text-align: right;
    margin-top: auto;
    padding-bottom: 4px;
    padding-right: 4px;
}

.sig-title {
    font-size: 13.5px;
    font-weight: 700;
    font-family: var(--font-times);
}

/* -------------------------------------------------------------
   MODAL DIALOGS & AUTH STYLES
   ------------------------------------------------------------- */
.hidden {
    display: none !important;
}

.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
    font-family: 'Inter', system-ui, sans-serif;
}

.modal-card {
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
    animation: modalSlideUp 0.25s ease-out forwards;
}

.modal-large {
    max-width: 860px !important;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-header {
    background: #0f172a;
    color: #ffffff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #38bdf8;
}

.modal-close-btn {
    background: transparent;
    border: none;
    color: #94a3b8;
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
    transition: color 0.15s ease;
}

.modal-close-btn:hover { color: #ffffff; }

.modal-body {
    padding: 24px;
}

.login-subtext {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 16px;
}

.login-error-msg {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
    padding: 10px 14px;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.form-group {
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-size: 0.825rem;
    font-weight: 700;
    color: #334155;
    display: flex;
    align-items: center;
    gap: 6px;
}

.form-group input {
    padding: 10px 14px;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.15s ease;
}

.form-group input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.modal-footer {
    padding-top: 8px;
}

.full-width {
    width: 100%;
}

/* Saved Bills Manager Table */
.search-bar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    gap: 16px;
}

.search-input-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

#saved-search-input {
    width: 100%;
    padding: 10px 14px 10px 38px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
    font-size: 0.875rem;
    outline: none;
}

#saved-search-input:focus {
    border-color: #2563eb;
}

.saved-total-info {
    font-size: 0.875rem;
    color: #475569;
}

.saved-bills-table-container {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.saved-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
    font-family: 'Inter', system-ui, sans-serif;
}

.saved-table th {
    background: #f8fafc;
    color: #334155;
    padding: 12px 14px;
    font-weight: 700;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.saved-table td {
    padding: 12px 14px;
    border-bottom: 1px solid #f1f5f9;
    color: #1e293b;
    vertical-align: middle;
}

.saved-table tr:hover td {
    background-color: #f8fafc;
}

.saved-table .action-btns {
    display: flex;
    justify-content: center;
    gap: 6px;
}

.btn-act {
    padding: 6px 10px;
    font-size: 0.775rem;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    transition: background 0.15s ease;
}

.btn-act-edit { background: #3b82f6; color: white; }
.btn-act-edit:hover { background: #2563eb; }

.btn-act-copy { background: #8b5cf6; color: white; }
.btn-act-copy:hover { background: #7c3aed; }

.btn-act-delete { background: #ef4444; color: white; }
.btn-act-delete:hover { background: #dc2626; }

.empty-saved-msg {
    text-align: center;
    padding: 40px 20px;
    color: #94a3b8;
    font-size: 0.95rem;
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: #ffffff;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
    font-size: 0.9rem;
    font-weight: 600;
    font-family: 'Inter', system-ui, sans-serif;
    z-index: 2000;
    display: flex;
    align-items: center;
    gap: 10px;
    border-left: 4px solid #22c55e;
    animation: toastIn 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toastIn {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* -------------------------------------------------------------
   MOBILE & TABLET RESPONSIVE STYLES (@media screen)
   ------------------------------------------------------------- */
@media screen and (max-width: 992px) {
    body {
        display: flex;
        flex-direction: column;
        padding: 0;
    }

    .app-header {
        position: sticky;
        top: 0;
        z-index: 1000;
        padding: 6px 10px;
        border-radius: 0;
        margin: 0;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    }

    .header-container {
        flex-direction: column;
        align-items: stretch;
        gap: 4px;
    }

    .brand {
        font-size: 0.95rem;
        justify-content: center;
    }

    .actions {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 2px;
        -webkit-overflow-scrolling: touch;
        justify-content: flex-start;
        width: 100%;
        scrollbar-width: thin;
    }

    .actions .btn {
        flex-shrink: 0;
        padding: 5px 10px;
        font-size: 0.775rem;
    }

    .auth-box {
        margin-left: 0;
        padding-left: 4px;
        flex-shrink: 0;
    }

    .studio-layout {
        display: flex;
        flex-direction: column;
        padding: 6px 4px;
        margin: 0;
        gap: 10px;
    }

    .studio-preview {
        order: 1;
        width: 100%;
        overflow: hidden;
        padding: 0;
        margin: 0;
        justify-content: center;
        align-items: flex-start;
        height: auto;
    }

    .studio-sidebar {
        order: 2;
        width: 100%;
        position: relative;
        top: 0;
        max-height: none;
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
        margin: 0;
    }

    .invoice-box {
        margin: 0 auto;
        flex-shrink: 0;
    }

    /* Modals for Mobile */
    .modal-card {
        max-width: 94%;
        margin: 0 12px;
    }

    .modal-large {
        max-width: 96% !important;
    }

    .saved-bills-table-container {
        max-height: 360px;
    }

    .saved-table th, .saved-table td {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .saved-table .action-btns {
        flex-direction: column;
        gap: 4px;
    }

    .btn-delete-row {
        opacity: 0.9;
        right: 2px;
    }
}

@media screen and (max-width: 576px) {
    .brand {
        font-size: 0.95rem;
    }

    .sidebar-header {
        font-size: 0.8rem;
        padding: 6px 10px;
    }

    .sidebar-section {
        padding: 6px 8px;
    }

    .controls-grid, .form-grid {
        grid-template-columns: 1fr 1fr;
        gap: 5px;
    }

    .toast {
        bottom: 12px;
        right: 12px;
        left: 12px;
        font-size: 0.825rem;
        padding: 10px 14px;
    }
}

/* Printing & PDF Specific CSS - Strictly 1 Page A4 */
@page {
    size: A4 portrait;
    margin: 0;
}

@media print {
    html, body {
        width: 210mm;
        height: 297mm;
        margin: 0 !important;
        padding: 0 !important;
        background: #ffffff !important;
        overflow: hidden !important;
        font-family: 'Times New Roman', Times, serif !important;
    }

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

    .studio-layout {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .studio-preview {
        padding: 0 !important;
        margin: 0 !important;
        display: block !important;
    }

    .invoice-box {
        box-shadow: none !important;
        border: var(--border-width) solid var(--border-color) !important;
        width: 210mm !important;
        height: 297mm !important;
        padding: 0 !important;
        margin: 0 !important;
        page-break-after: avoid !important;
        page-break-inside: avoid !important;
        font-family: 'Times New Roman', Times, serif !important;
    }

    [contenteditable="true"] {
        background-color: transparent !important;
        box-shadow: none !important;
    }
}
