:root {
    --bg: #f6f8fc;
    --card: #ffffff;
    --line: #e6eaf2;
    --text: #333;
    --muted: #64748b;
    --primary: #222;
    --danger: #dc2626;
    --dark: #0b1220;
    --soft: #f1f5f9;
    --radius: 6px;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Arial, "Noto Sans";
    color: var(--text);
    background: var(--bg);
}

.docType {
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: center;
    margin-top: 10px;
    flex-wrap: wrap;
    font-size: 20px;
    font-weight: 600;
    color: #ff0000;
}


.container {
    width: min(980px, 100%);
    margin: 0 auto;
    padding: 28px 16px 60px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.title {
    font-size: 24px;
    font-weight: 900;
    letter-spacing: 1px;
    margin: 0;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(2, 6, 23, .06);
    overflow: hidden;
}

.section {
    padding: 16px;
    border-top: 1px solid var(--line);
}

.section:first-child {
    border-top: 0;
}

.sectionHead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.sectionHead h2 {
    margin: 0;
    font-size: 14px;
    color: #111827;
    font-weight: 900;
}

.btn {
    border: 0;
    padding: 10px 12px;
    border-radius: 10px;
    font-weight: 900;
    font-size: 13px;
    cursor: pointer;
    transition: transform .05s ease, opacity .15s ease;
}

.btn:active {
    transform: translateY(1px);
}

.btnDark {
    background: var(--dark);
    color: #fff;
}

.btnPrimary {
    background: var(--primary);
    color: #fff;
}

.btnSoft {
    background: #fff;
    border: 1px solid var(--line);
    color: #0f172a;
}

.btnDanger {
    background: var(--danger);
    color: #fff;
}

.btnGhost {
    background: transparent;
    border: 1px solid var(--line);
    color: #0f172a;
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 720px) {
    .grid2 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 720px) {
    .grid3 {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

.rowSpan2 {
    grid-column: 1 / -1;
}

.field label {
    display: block;
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
    margin-bottom: 6px;
}

.field input,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
}

.field input:focus,
.field textarea:focus {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
    border-color: rgba(37, 99, 235, .45);
}

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

.logoPreview {
    display: flex;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px dashed var(--line);
    border-radius: 12px;
    background: #fff;
    margin-top: 10px;
}

.logoThumb {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    border: 1px solid var(--line);
    overflow: hidden;
    display: grid;
    place-items: center;
    background: #fff;
    flex: 0 0 auto;
}

.logoThumb img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
}

.logoEmpty {
    font-weight: 900;
    color: #94a3b8;
}

.logoHint {
    font-size: 12px;
    color: var(--muted);
    line-height: 1.4;
}

.tableWrap {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: auto;
    background: #fff;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 780px;
}

th,
td {
    border-top: 1px solid var(--line);
    padding: 10px 10px;
    text-align: left;
    font-size: 13px;
    vertical-align: middle;
}

th {
    border-top: 0;
    background: var(--soft);
    font-size: 12px;
    letter-spacing: .02em;
    color: #334155;
    font-weight: 950;
}

.tInput {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 8px 10px;
    outline: none;
    font-size: 13px;
}

.tInput:focus {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, .12);
    border-color: rgba(37, 99, 235, .45);
}

.summaryBox {
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 14px;
    font-size: 13px;
}

.sumRow {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    color: #0f172a;
}

.sumRow strong {
    font-weight: 950;
}

.sumRow.muted {
    color: var(--muted);
}

.sumRow.total {
    border-top: 1px solid var(--line);
    margin-top: 8px;
    padding-top: 10px;
    font-size: 14px;
}

.actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid var(--line);
    background: #fff;
}

.toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.toggle span {
    font-size: 12px;
    font-weight: 900;
    color: var(--muted);
}

.toggle input {
    width: 16px;
    height: 16px;
}

/* Small helpers */
.mt12 {
    margin-top: 12px;
}

.mt14 {
    margin-top: 14px;
}

.mt8 {
    margin-top: 8px;
}

.mb6 {
    margin-bottom: 6px;
}

.flexRow {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

.hint {
    font-size: 12px;
    color: var(--muted);
}

/* ------- PRINT VIEW ------- */
.hidden {
    display: none !important;
}

.toolbar {
    display: flex;
    gap: 10px;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.toolbar .leftTools {
    display: flex;
    gap: 10px;
}

.printSheet {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(2, 6, 23, .06);
    overflow: hidden;
    padding: 10px;
}

.printHead {
    padding: 18px 18px 0;
}

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

@media (min-width: 720px) {
    .printTop {
        flex-direction: row;
        justify-content: space-between;
        align-items: flex-start;
    }
}

.brandRow {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logoBox {
    width: 150px;
    height: auto;
    border-radius: 5px;
    border: 1px solid var(--line);
    background: #ccc;
    display: grid;
    place-items: center;
    overflow: hidden;
    flex: 0 0 auto;
}

.logoBox img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    padding: 5px;
}

.logoFallback {
    width: 100px;
    height: 100px;
    border-radius: 5px;
    display: grid;
    place-items: center;
    color: #fff;
    font-weight: 700;
    letter-spacing: .02em;
    background: #ccc;
}

.brandName {
    font-weight: 900;
    font-size: 22px;
    letter-spacing: 1px;
    margin: 0;
}

.smallText {
    margin: 5px 0 0;
    font-size: 16px;
    color: #666;
    line-height: 1.5;
}

.invoiceTitle {
    text-align: left;
}

@media (min-width: 720px) {
    .invoiceTitle {
        text-align: right;
    }
}

.invoiceTitle h1 {
    margin: 0;
    font-size: 34px;
    letter-spacing: -0.02em;
    font-weight: 1000;
    color: var(--primary);
}

.invoiceMeta {
    margin-top: 6px;
    font-size: 14px;
    color: #0f172a;
    line-height: 1.6;
}

.infoGrid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 18px;
    padding: 18px;
}

@media (min-width: 720px) {
    .infoGrid {
        grid-template-columns: 1fr 1fr;
    }
}

.infoCard h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 1000;
    color: var(--primary);
    letter-spacing: .01em;
}

.infoCard .lines {
    margin-top: 8px;
    font-size: 13px;
    color: #111827;
    line-height: 1.7;
}

.infoCard .lines b {
    color: #0f172a;
}

.printSection {
    padding: 0 18px 18px;
}

.printLabel {
    font-size: 13px;
    font-weight: 1000;
    color: #111827;
    margin: 10px 0 8px;
}

.printTable {
    border: 1px solid var(--line);
    border-radius: 12px;
    overflow: hidden;
}

.printTable table {
    min-width: 0;
}

.tr {
    text-align: right;
}

.strong {
    font-weight: 950;
}

.big {
    font-size: 15px;
}

.prewrap {
    white-space: pre-wrap;
    color: #334155;
}

.printFooter {
    border-top: 1px solid var(--line);
    padding: 14px 18px;
    text-align: center;
    font-size: 12px;
    color: var(--muted);
    line-height: 1.6;
}

.footerStrong {
    font-weight: 950;
    color: #0f172a;
}

@media print {
    body {
        background: #fff;
    }

    .noPrint {
        display: none !important;
    }

    .container {
        padding: 0;
        margin: 0;
        width: 100%;
    }

    .printSheet {
        border: 0;
        box-shadow: none;
        border-radius: 0;
    }
}
