/* Claymorphism theme on top of Bootstrap: soft puffy surfaces, pressed-in fields, raised buttons. */

:root {
    --clay-bg: #e9e6fb;
    --clay-surface: #f6f4ff;
    --clay-field: #ffffff;
    --clay-text: #29234d;
    --clay-muted: #59537f;
    --clay-primary: #5a47c9;
    --clay-primary-dark: #453597;
    --clay-danger: #b42343;
    --clay-border: #a9a1d6;
    --clay-shade: rgba(96, 82, 164, .24);
    --clay-shade-soft: rgba(96, 82, 164, .16);
    --clay-light: rgba(255, 255, 255, .95);

    --clay-raised:
        8px 10px 22px var(--clay-shade),
        inset -5px -5px 10px var(--clay-shade-soft),
        inset 5px 5px 10px var(--clay-light);
    --clay-button:
        4px 5px 10px var(--clay-shade),
        inset -3px -3px 6px var(--clay-shade-soft),
        inset 3px 3px 6px var(--clay-light);
    --clay-pressed:
        inset 3px 3px 7px var(--clay-shade),
        inset -3px -3px 7px var(--clay-light);

    --bs-body-color: var(--clay-text);
    --bs-body-bg: var(--clay-bg);
    --bs-secondary-color: var(--clay-muted);
    --bs-link-color: var(--clay-primary-dark);
    --bs-link-color-rgb: 69, 53, 151;
}

body {
    background: var(--clay-bg);
    color: var(--clay-text);
    font-family: "Nunito", "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, sans-serif;
    min-height: 100vh;
}

h1, h2, h3, .h3, .h4, .h5, .h6 {
    font-weight: 700;
}

.text-muted, .form-text {
    color: var(--clay-muted) !important;
}

/* ---------- surfaces ---------- */

.clay-card {
    background: var(--clay-surface);
    border: 0;
    border-radius: 28px;
    box-shadow: var(--clay-raised);
}

.clay-nav {
    padding-block: .75rem;
}

.navbar-brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 800;
    color: var(--clay-text);
}

.brand-logo {
    width: 2.5rem;
    height: 2.5rem;
    filter: drop-shadow(2px 3px 4px var(--clay-shade));
}

.auth-logo { filter: drop-shadow(4px 6px 8px var(--clay-shade)); }

.auth-company {
    color: #0d2f66;
    font-weight: 800;
    letter-spacing: .02em;
}

.navbar .nav-link {
    border-radius: 999px;
    padding: .45rem .95rem;
    color: var(--clay-text);
    font-weight: 600;
}

.navbar .nav-link.active {
    box-shadow: var(--clay-pressed);
    background: var(--clay-bg);
    color: var(--clay-primary-dark);
}

.navbar-toggler {
    border: 0;
    border-radius: 16px;
    box-shadow: var(--clay-button);
}

.auth-wrap {
    max-width: 26rem;
    margin: 2rem auto;
}

/* ---------- buttons ---------- */

.btn {
    border-radius: 999px;
    font-weight: 700;
    border: 1.5px solid transparent;
    transition: transform .08s ease, box-shadow .08s ease;
}

.btn-clay {
    background: var(--clay-surface);
    color: var(--clay-text);
    border-color: var(--clay-border);
    box-shadow: var(--clay-button);
}

.btn-clay:hover {
    background: #fff;
    color: var(--clay-text);
    border-color: var(--clay-primary);
}

.btn-clay-primary, .btn-clay-danger {
    color: #fff;
    box-shadow: 4px 6px 12px var(--clay-shade),
        inset -3px -3px 7px rgba(0, 0, 0, .25),
        inset 3px 3px 7px rgba(255, 255, 255, .28);
}

.btn-clay-primary { background: var(--clay-primary); }
.btn-clay-primary:hover { background: var(--clay-primary-dark); color: #fff; }
.btn-clay-danger { background: var(--clay-danger); }
.btn-clay-danger:hover { background: #8f1a34; color: #fff; }
.btn-danger-text, .btn-danger-text:hover { color: var(--clay-danger); }

.btn:active, .btn-clay.active {
    transform: translateY(1px);
    box-shadow: var(--clay-pressed);
}

.btn-clay.active {
    background: var(--clay-bg);
    color: var(--clay-primary-dark);
    border-color: var(--clay-primary);
}

.btn:disabled {
    box-shadow: none;
}

.btn[aria-busy="true"] {
    opacity: .65;
    cursor: progress;
}

/* ---------- fields ---------- */

.form-label {
    font-weight: 700;
    font-size: .9rem;
}

.form-control, .form-select {
    background-color: var(--clay-field);
    color: var(--clay-text);
    border: 1.5px solid var(--clay-border);
    border-radius: 16px;
    box-shadow: var(--clay-pressed);
    min-height: 2.75rem;
}

.form-control:focus, .form-select:focus {
    background-color: var(--clay-field);
    color: var(--clay-text);
    border-color: var(--clay-primary);
    box-shadow: var(--clay-pressed), 0 0 0 .22rem rgba(90, 71, 201, .35);
}

.btn:focus-visible, .nav-link:focus-visible, a:focus-visible {
    outline: 3px solid var(--clay-primary);
    outline-offset: 2px;
}

.form-control.text-uppercase::placeholder {
    text-transform: none;
}

.form-control.is-invalid {
    border-color: var(--clay-danger);
}

.form-check-input {
    border-color: var(--clay-border);
}

.form-check-input:checked {
    background-color: var(--clay-primary);
    border-color: var(--clay-primary);
}

.validation-box.validation-summary-errors {
    background: #ffe9ee;
    color: #7e1630;
    border-radius: 18px;
    padding: .75rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--clay-pressed);
}

.validation-box.validation-summary-errors ul {
    margin: 0;
    padding-left: 1.1rem;
}

.validation-box.validation-summary-valid {
    display: none;
}

.clay-alert {
    border: 0;
    border-radius: 20px;
    box-shadow: var(--clay-button);
}

/* ---------- page furniture ---------- */

.page-head {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.25rem;
}

.actions, .tabs, .search-bar, .send-bar, .pager {
    display: flex;
    flex-wrap: wrap;
    gap: .6rem;
}

.tabs { margin-bottom: 1.25rem; }
.search-bar { margin-bottom: 1.25rem; }
.search-bar .form-control, .send-bar .form-control { flex: 1 1 14rem; width: auto; }
.pager { justify-content: center; align-items: center; margin-top: 1.25rem; }

.empty {
    text-align: center;
    color: var(--clay-muted);
    padding: 2rem 0;
    margin: 0;
}

.chip {
    display: inline-block;
    border-radius: 999px;
    padding: .15rem .75rem;
    font-size: .8rem;
    font-weight: 700;
    box-shadow: inset -2px -2px 4px rgba(0, 0, 0, .08), inset 2px 2px 4px rgba(255, 255, 255, .7);
}

.chip-ok { background: #c8f1da; color: #14562f; }
.chip-off { background: #ffd5de; color: #7e1630; }

.pre-line { white-space: pre-line; }

.token-list {
    display: flex;
    flex-wrap: wrap;
    gap: .35rem 1.25rem;
    padding: 0;
    list-style: none;
}

.email-log li {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: .35rem .75rem;
    padding-block: .4rem;
}

.image-well {
    display: grid;
    place-items: center;
    height: 9rem;
    margin-bottom: 1rem;
    border-radius: 20px;
    background: var(--clay-field);
    box-shadow: var(--clay-pressed);
    padding: .75rem;
}

.image-well img {
    max-width: 100%;
    max-height: 7.5rem;
}

/* ---------- suggestions while typing ---------- */

.suggest-anchor { position: relative; }

.suggest {
    position: absolute;
    z-index: 30;
    max-width: min(32rem, 100%);
    max-height: 17rem;
    overflow-y: auto;
    margin: 0;
    padding: .35rem;
    list-style: none;
    background: var(--clay-field);
    border: 1.5px solid var(--clay-border);
    border-radius: 18px;
    box-shadow: 8px 12px 24px var(--clay-shade);
}

.suggest li {
    padding: .45rem .75rem;
    border-radius: 12px;
    cursor: pointer;
}

.suggest li span { display: block; font-weight: 700; overflow-wrap: anywhere; }
.suggest li small { display: block; color: var(--clay-muted); }
.suggest li:hover, .suggest li[aria-selected="true"] { background: var(--clay-bg); }
.suggest li[aria-selected="true"] { box-shadow: var(--clay-pressed); }

/* ---------- tables ---------- */

.table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--clay-text);
    --bs-table-border-color: #d6d1f2;
}

.table td { overflow-wrap: anywhere; }
.table td.amount, .table th { white-space: nowrap; }
.row-actions .btn { margin: .15rem 0 .15rem .25rem; }

/* ---------- totals ---------- */

.totals > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-block: .25rem;
}

/* One line per tax and rate, added by the form script or the details page. */
.totals > .tax-rows { display: block; padding-block: 0; }
.tax-rows > div {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding-block: .25rem;
}

.totals dt { font-weight: 600; }
.totals dd { margin: 0; font-variant-numeric: tabular-nums; }

.totals .grand {
    margin-top: .5rem;
    padding: .6rem 1rem;
    border-radius: 18px;
    background: var(--clay-bg);
    box-shadow: var(--clay-pressed);
    font-size: 1.2rem;
}

.totals .grand dt, .totals .grand dd { font-weight: 800; }

/* ---------- item rows ---------- */

.line-head, .line-row {
    display: grid;
    grid-template-columns: minmax(0, 2.8fr) minmax(0, 1.1fr) minmax(0, 1.75fr) minmax(0, 1.3fr)
        minmax(0, 1.3fr) minmax(0, .85fr) minmax(0, 1.2fr) 2.4rem;
    gap: .5rem;
    align-items: start;
}

.line-head {
    font-weight: 700;
    font-size: .85rem;
    padding: 0 .25rem .5rem;
}

.line-row { margin-bottom: .6rem; }
.line-row .form-control { padding-inline: .5rem; }

/* Quantity and its unit read as one field. */
.qty-group { flex-wrap: nowrap; }
.qty-group > .form-control { min-width: 0; }
.qty-group > .form-control:first-child { flex: 3 1 0; }
.qty-group > .form-control:last-child { flex: 2 1 0; }

/* The spin buttons take room that narrow number columns need. */
.line-row input[type="number"] { appearance: textfield; }
.line-row input[type="number"]::-webkit-inner-spin-button { appearance: none; margin: 0; }
.line-label, .remove-text { display: none; }

/* Shown the way it prints on the PDF; the hint stays plain. */
.serial-input { margin-top: .4rem; font-weight: 700; font-style: italic; }
.serial-input::placeholder { font-weight: 400; font-style: normal; }

.line-amount output {
    display: block;
    line-height: 2.75rem;
    text-align: right;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    overflow-wrap: anywhere;
}

.line-remove .btn { width: 2.4rem; height: 2.4rem; padding: 0; margin-top: .17rem; }

/* Item rows become cards before the columns get too narrow to type in. */
@media (max-width: 991.98px) {
    .line-head { display: none; }

    .line-row {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 22px;
        background: var(--clay-bg);
        box-shadow: var(--clay-button);
    }

    .line-description, .line-remove { grid-column: 1 / -1; }

    .line-label {
        display: block;
        font-weight: 700;
        font-size: .8rem;
        margin-bottom: .2rem;
    }

    .line-amount { grid-column: 1 / -1; }
    .line-amount output { text-align: left; font-size: 1.15rem; line-height: 1.5; }
    .serial-input { margin-top: 0; }
    .line-remove .btn { width: 100%; }
    .remove-text { display: inline; }
}

/* ---------- phones ---------- */

@media (max-width: 767.98px) {
    .clay-card { border-radius: 22px; }

    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }

    .table-stack tr {
        border-radius: 20px;
        background: var(--clay-bg);
        box-shadow: var(--clay-button);
        padding: .6rem 1rem;
        margin-bottom: 1rem;
    }

    .table-stack td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        text-align: right;
        border: 0;
        padding: .25rem 0;
    }

    .table-stack td::before {
        content: attr(data-label);
        font-weight: 700;
        text-align: left;
        flex: 0 0 auto;
    }

    .table-stack td.row-actions { justify-content: flex-end; padding-top: .6rem; }
    .table-stack td.row-actions::before { content: none; }
    .row-actions .btn { flex: 1; }

    .page-head > .btn, .page-head > .actions { width: 100%; }
    .actions > .btn { flex: 1 1 8rem; }
    .send-bar .btn, .search-bar .btn { flex: 1 1 auto; }
    .send-bar .form-control, .search-bar .form-control { flex-basis: 100%; }
    .tabs .btn { flex: 1 1 auto; }
    form > .btn-clay-primary { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
    .btn { transition: none; }
}
