[hidden] {
    display: none !important;
}

body {
    display: flex;
    flex-direction: column;
    align-items: center;
}

h1 {
    text-align: center;
}

#inputTitle input {
    font-size: inherit;
    font-weight: inherit;
    padding: 2px 8px;
    width: 7em;
    text-align: center;
}

#dataEntry {
    width: 90vw;
}

#formatHint {
    margin: 0 0 6px;
    text-align: left;
    font-size: 16px;
    color: #555;
}

/* Textarea with a line-number gutter on the left (screen only, used to find errors) */
#editor {
    display: flex;
    height: 50vh;
    border: 1px solid #888;
}

/* Gutter and textarea must share font, line height and vertical padding to stay aligned */
#lineNumbers,
#editor textarea {
    margin: 0;
    padding: 6px 8px;
    font-family: monospace;
    font-size: 18px;
    line-height: 1.4;
}

#lineNumbers {
    overflow: hidden;
    min-width: 2ch;
    padding-bottom: 30px; /* room for the textarea's horizontal scrollbar when scrolled to the end */
    white-space: pre;
    text-align: right;
    color: #888;
    background: #f3f3f3;
    border-right: 1px solid #ccc;
    user-select: none;
}

#editor textarea {
    flex: 1;
    box-sizing: border-box;
    height: 100%;
    border: 0;
    resize: none;
}

#divButton {
    margin-top: 10px;
}

button {
    font-size: 18px;
    padding: 10px 24px;
}
#inputView {
    display: flex;
    flex-direction: column;
    align-items: center;
}

#tableView {
    width: 90vw;
}

#tableActions {
    display: flex;
    gap: 10px;
    margin: 10px 0;
}

/* Title shown only at the top of the first page */
.page-title {
    margin: 10px 0 20px;
    text-align: center;
    font-family: Arial, Helvetica, sans-serif;
    font-weight: bold;
    font-size: 20px;
}

.person {
    margin: 16px 0;
}

/*
 * Single thin black lines, compact rows, like the printed model.
 * Uses separate borders (each cell draws only its bottom and left line) instead of
 * border-collapse, because collapsed 1px borders randomly disappear when printing.
 */
.person table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    border: 2px solid black;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 15px;
}

.person td {
    border: 0;
    border-bottom: 1px solid black;
    padding: 1px 4px;
}

.person td + td {
    border-left: 1px solid black;
}

.person tr:last-child td {
    border-bottom: 0;
}

.value-highlight {
    color: #e00000;
    font-weight: bold;
}

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

.card-note td {
    text-align: center;
    padding: 6px 10px;
}

.card-header td {
    padding: 6px;
}

/* Header and note cells span both columns, so they must not take the 30%/70% column widths */
.person tr.card-header td,
.person tr.card-note td {
    width: auto;
}

.card-header-content {
    display: flex;
    align-items: center;
}

.card-title {
    flex: 1;
    text-align: center;
    font-weight: bold;
    font-size: 20px;
}

.card-logo {
    display: block;
    height: 40px;
}

.person td:first-child {
    width: 30%;
}

.person td:last-child {
    width: 70%;
}

.page-number {
    margin-top: 8px;
    text-align: right;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 12px;
}

.page-separator {
    margin: 20px 0;
    border: 1px dashed black;
}

/*
 * A4 with no page margin: this removes the browser's own print header and footer
 * (page title, file path, date, page numbers). The page padding below replaces the margin.
 */
@page {
    size: A4;
    margin: 0;
}

@media print {
    body {
        display: block;
        margin: 0;
    }

    /* Each page fills one A4 sheet (slightly less than 297mm to avoid a blank extra sheet) */
    .page {
        position: relative;
        box-sizing: border-box;
        height: 296mm;
        padding: 12mm 15mm;
    }

    /* Page number pinned to the bottom-right corner of the sheet */
    .page-number {
        position: absolute;
        right: 15mm;
        bottom: 10mm;
        margin: 0;
    }

    /* Never split a card between two sheets */
    .person {
        break-inside: avoid;
    }

    #tableView {
        width: auto;
    }

    #tableActions,
    #tableView hr {
        display: none;
    }

    .page {
        break-after: page;
    }

    .page:last-of-type {
        break-after: auto;
    }
}
