:root {
    --ink: #173042;
    --muted: #60717f;
    --accent: #315da8;
    --border: #dce5eb
}

* {
    box-sizing: border-box
}

body {
    margin: 0;
    background: #f2f6f8;
    color: var(--ink);
    font: 16px/1.5 system-ui, Segoe UI, sans-serif
}

header {
    background: #172e43;
    color: white;
    padding: 16px 4%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px
}

.brand {
    display: flex;
    align-items: center;
    gap: 15px
}

.brand img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 50%;
    background: white
}

.brand strong {
    font-size: 25px
}

.brand small {
    display: block;
    color: #cbd9e5
}

main {
    max-width: 1500px;
    margin: 28px auto;
    padding: 0 24px
}

nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 25px
}

button {
    font: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    padding: 10px 16px;
    cursor: pointer
}

button:hover {
    border-color: var(--accent);
    background: #edf2fa
}

button.primary,
nav .selected {
    background: var(--accent);
    color: white;
    border-color: var(--accent)
}

button:disabled {
    opacity: .5;
    cursor: not-allowed
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 24px;
    margin-bottom: 20px
}

h1 {
    font-size: 30px;
    margin: 0 0 18px
}

h2 {
    font-size: 21px;
    margin: 0 0 16px
}

.heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 18px
}

.heading h1 {
    margin: 0
}

.grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px
}

.three {
    grid-template-columns: repeat(3, 1fr)
}

.split {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px
}

label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 14px
}

input,
select,
textarea {
    font: inherit;
    width: 100%;
    display: block;
    border: 1px solid #c9d6df;
    border-radius: 7px;
    padding: 10px;
    margin-top: 6px;
    background: white;
    color: var(--ink)
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #8faee0;
    outline-offset: 1px
}

input[readonly] {
    background: #edf2f6
}

.check {
    display: flex;
    align-items: center;
    gap: 10px
}

.check input {
    width: 20px;
    margin: 0
}

.tablewrap {
    overflow-x: auto
}

table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0 20px;
    font-size: 14px
}

th {
    text-align: left;
    color: var(--muted);
    font-size: 12px;
    background: #f5f8fa;
    padding: 12px 8px;
    white-space: nowrap
}

td {
    padding: 10px 8px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle
}

td button {
    padding: 6px 10px;
    margin: 2px;
    font-size: 13px
}

.totals {
    display: flex;
    gap: 30px;
    justify-content: flex-end;
    align-items: center;
    flex-wrap: wrap;
    margin: 20px 0
}

.totals span {
    color: var(--muted)
}

.totals strong {
    display: block;
    font-size: 26px;
    color: var(--accent)
}

.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center
}

.notice {
    background: #e9f0fa;
    border-left: 4px solid var(--accent);
    padding: 12px 18px;
    border-radius: 6px;
    font-size: 14px
}

.warning {
    background: #fff5de;
    border-color: #d7a21a
}

.success {
    background: #e6f4ee;
    border-color: #23936b
}

.muted {
    color: var(--muted);
    font-size: 13px
}

.login {
    max-width: 480px;
    margin: 50px auto
}

.login .actions {
    margin-top: 16px
}

#toast {
    position: fixed;
    right: 20px;
    top: 20px;
    z-index: 100;
    background: #173042;
    color: white;
    padding: 16px 22px;
    border-radius: 10px;
    max-width: 520px;
    box-shadow: 0 6px 30px #0003
}

#toast.error {
    background: #a42e35
}

.customerItem {
    padding: 16px 0;
    border-bottom: 1px solid var(--border)
}

.customerItem strong {
    display: block
}

.customerItem .actions {
    margin-top: 10px
}

dialog {
    width: min(1100px, 96vw);
    border: 0;
    border-radius: 14px;
    padding: 28px;
    max-height: 92vh;
    overflow: auto
}

dialog::backdrop {
    background: #112c3e88
}

#receipt {
    margin-top: 25px
}

#receipt p {
    white-space: pre-wrap
}

.receiptHeader {
    display: flex;
    align-items: center;
    gap: 20px
}

.receiptHeader img {
    width: 80px;
    height: 80px;
    object-fit: contain
}

.sitefooter {
    text-align: center;
    color: var(--muted);
    font-size: 12px;
    margin: 40px;
    line-height: 1.7
}

.sitefooter a {
    color: inherit
}

hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: 24px 0
}

[hidden] {
    display: none !important
}

.language-control {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    color: white
}

.language-control select {
    width: auto;
    margin: 0;
    padding: 6px 10px
}

@media(max-width:800px) {
    main {
        padding: 0 12px
    }

    .grid,
    .three,
    .split {
        grid-template-columns: 1fr
    }

    .card {
        padding: 16px
    }

    .heading,
    header {
        align-items: flex-start;
        flex-direction: column
    }

    h1 {
        font-size: 26px
    }

    .totals {
        justify-content: flex-start
    }

    nav button {
        font-size: 14px;
        padding: 9px 12px
    }

    .sitefooter {
        margin: 24px 16px
    }
}

@media print {
    body {
        background: white;
        font-size: 11px
    }

    body>header,
    body>main,
    body>footer,
    #toast,
    .noPrint {
        display: none !important
    }

    dialog {
        position: static;
        display: block !important;
        max-height: none;
        width: 100%;
        padding: 0;
        margin: 0;
        border: 0;
        overflow: visible
    }

    dialog:not([open]) {
        display: none !important
    }

    #receipt {
        margin: 0
    }

    #receipt table {
        font-size: 10px
    }

    #receipt th,
    #receipt td {
        padding: 6px 4px
    }

    #receipt h1 {
        font-size: 25px
    }

    @page {
        size: A4 landscape;
        margin: 15mm
    }
}
button.danger { background:#a42e35; color:white; border-color:#a42e35 }
button.danger:hover { background:#85242a; border-color:#85242a }
#userList select { min-width:150px; margin:0; padding:7px }
