/*
	New interface of the customers area.
	Light theme only. Brand from thegreendoctors.it (DM Sans, green, pill buttons, rounded cards), management-tool density.
	Radius rule: interactive controls are pills, cards and dialogs 16px, inputs 10px.
*/

:root {
    --bg: #f3f7f2;
    --surface: #ffffff;
    --surface-2: #eaf5eb;
    --line: #dde7dc;
    --line-strong: #b9c9b7;
    --ink: #1d2b20;
    --body: #3a563e;
    --muted: #586b5b;
    --brand: #269938;
    --brand-strong: #1b7a2b;
    --brand-soft: #e1f2e3;
    --on-brand: #ffffff;
    --danger: #b42318;
    --danger-soft: #fdecea;
    --warn: #8a5a00;
    --warn-soft: #fff4d6;
    --focus: #269938;
    --shadow: 0 1px 2px rgba(29, 43, 32, .06), 0 8px 24px rgba(29, 43, 32, .07);
    --shadow-bar: 0 4px 15px rgba(29, 43, 32, .12);

    --r-card: 16px;
    --r-input: 10px;
    --r-pill: 999px;
    --font: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
    color-scheme: light;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* the sticky top bar must not cover focused elements */
    scroll-padding-top: 96px;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--body);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

h1,
h2,
h3 {
    color: var(--ink);
    line-height: 1.2;
    margin: 0;
    text-wrap: balance;
}

h1 {
    font-size: clamp(24px, 3vw, 30px);
    font-weight: 700;
    letter-spacing: -0.02em;
}

h2 {
    font-size: 18px;
    font-weight: 700;
}

p {
    margin: 0;
}

a {
    color: var(--brand-strong);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
    text-underline-offset: 3px;
}

:focus-visible {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
    border-radius: 6px;
}

.ti {
    font-size: 18px;
    line-height: 1;
}

.skip {
    position: absolute;
    left: 16px;
    top: -60px;
    z-index: 100;
    background: var(--surface);
    padding: 8px 14px;
    border-radius: var(--r-pill);
}

.skip:focus {
    top: 12px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

/* top bar, same floating pill as the public site */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    padding: 12px 16px 0;
}

.topbar-inner {
    max-width: 1240px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--r-pill);
    box-shadow: var(--shadow-bar);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 8px 10px 8px 22px;
    min-height: 60px;
}

.brand img {
    display: block;
    height: 40px;
    width: auto;
}

.mainnav {
    display: flex;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.mainnav a,
.tabs a {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    color: var(--body);
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color .15s ease, color .15s ease;
}

.mainnav a:hover,
.tabs a:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.mainnav a[aria-current],
.tabs a[aria-current] {
    background: var(--brand-soft);
    color: var(--brand-strong);
    font-weight: 600;
}

.mainnav-only-mobile {
    display: none !important;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-strong);
    color: var(--body);
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
}

.switch:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.usermenu {
    position: relative;
}

.usermenu summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: var(--r-pill);
    cursor: pointer;
    color: var(--ink);
    font-weight: 500;
}

.usermenu summary::-webkit-details-marker {
    display: none;
}

.usermenu summary:hover {
    background: var(--surface-2);
}

.usermenu-name {
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    display: grid;
    place-items: center;
    font-weight: 700;
    font-size: 13px;
}

.menu {
    position: absolute;
    right: 0;
    top: calc(100% + 8px);
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow-bar);
    padding: 6px;
    min-width: 190px;
    z-index: 30;
}

.menu a,
.menu button {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    color: var(--ink);
    background: none;
    border: 0;
    font: inherit;
    text-align: left;
    cursor: pointer;
}

.menu a:hover,
.menu button:hover {
    background: var(--surface-2);
    text-decoration: none;
}

.menu .danger,
.menu .danger .ti {
    color: var(--danger);
}

.menu-toggle {
    display: none;
}

@media (max-width: 1080px) {
    .usermenu-name {
        display: none;
    }
}

@media (max-width: 900px) {
    .topbar-inner {
        border-radius: 20px;
        flex-wrap: wrap;
        padding: 8px 8px 8px 16px;
    }

    .switch span {
        display: none;
    }

    .switch {
        padding: 9px;
    }

    .usermenu {
        display: none;
    }

    .menu-toggle {
        display: grid;
        place-items: center;
        width: 44px;
        height: 44px;
        border-radius: 50%;
        border: 0;
        background: var(--surface-2);
        color: var(--ink);
        cursor: pointer;
    }

    .mainnav {
        display: none;
        order: 3;
        flex-basis: 100%;
        flex-direction: column;
        padding: 6px 0 4px;
        border-top: 1px solid var(--line);
    }

    .topbar.open .mainnav {
        display: flex;
    }

    .mainnav a {
        padding: 12px 14px;
    }

    .mainnav-only-mobile {
        display: inline-flex !important;
    }
}

/* page */

.page {
    flex: 1;
    width: 100%;
    max-width: 1240px;
    margin: 0 auto;
    padding: 28px 16px 48px;
}

.pagehead {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
}

.pagehead-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.crumb {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--muted);
    margin-bottom: 6px;
}

.crumb .ti {
    font-size: 16px;
}

.meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 18px;
    margin-top: 8px;
    font-size: 14px;
    color: var(--muted);
}

.meta a,
.meta span {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    overflow-wrap: anywhere;
}

.meta a:hover {
    color: var(--brand-strong);
}

.meta .ti {
    font-size: 16px;
}

.lead {
    color: var(--muted);
    margin-top: 6px;
    max-width: 65ch;
}

.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    overflow-x: auto;
    padding-bottom: 2px;
    scrollbar-width: thin;
}

.section {
    margin-top: 32px;
}

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

/* buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 9px 20px;
    border-radius: var(--r-pill);
    border: 1px solid transparent;
    font: inherit;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    text-decoration: none !important;
    transition: background-color .15s ease, transform .1s ease;
}

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

.btn-primary {
    background: var(--brand-strong);
    color: var(--on-brand);
}

.btn-primary:hover {
    background: var(--brand);
}

.btn-ghost {
    background: var(--surface);
    border-color: var(--line-strong);
    color: var(--ink);
}

.btn-ghost:hover {
    background: var(--surface-2);
}

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

.btn-link {
    background: none;
    border: 0;
    color: var(--brand-strong);
    padding: 0;
    min-height: 0;
    font-weight: 600;
}

.btn[disabled],
.btn.is-loading {
    opacity: .6;
    pointer-events: none;
}

.btn-icon {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    color: var(--body);
    border: 0;
    background: none;
    cursor: pointer;
    text-decoration: none !important;
}

.btn-icon span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
}

.btn-icon:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.btn-icon.danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

/* tooltip on icon buttons (desktop only) */
@media (hover: hover) {
    .btn-icon:hover::after {
        content: attr(aria-label);
        position: absolute;
        bottom: calc(100% + 6px);
        left: 50%;
        transform: translateX(-50%);
        background: var(--ink);
        color: var(--bg);
        font-size: 12px;
        font-weight: 500;
        padding: 4px 8px;
        border-radius: 6px;
        white-space: nowrap;
        pointer-events: none;
        z-index: 5;
    }
}

/* cards and stats */

.card {
    background: var(--surface);
    border-radius: var(--r-card);
    box-shadow: var(--shadow);
}

.card-pad {
    padding: 22px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.stat {
    padding: 18px 20px;
}

.stat dt {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.stat dd {
    margin: 4px 0 0;
    font-size: clamp(20px, 2.4vw, 26px);
    font-weight: 700;
    color: var(--ink);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.01em;
}

.stat-due {
    background: var(--brand-strong);
}

.stat-due dt,
.stat-due dd {
    color: var(--on-brand);
}

.stat-due.is-open {
    background: var(--warn-soft);
}

.stat-due.is-open dt,
.stat-due.is-open dd {
    color: var(--warn);
}

@media (max-width: 640px) {
    .stats {
        grid-template-columns: 1fr 1fr;
    }

    .stat-due {
        grid-column: 1 / -1;
    }
}

.note {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 16px;
    border-radius: 12px;
    background: var(--surface-2);
    color: var(--body);
    font-size: 14px;
    margin-bottom: 20px;
}

.note .ti {
    color: var(--brand-strong);
    margin-top: 2px;
}

/* toolbar with search */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 12px;
}

.search {
    position: relative;
    flex: 1 1 260px;
    max-width: 420px;
}

.search .ti {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.search input {
    padding-left: 40px !important;
    border-radius: var(--r-pill) !important;
}

.count {
    font-size: 14px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.toolbar .spacer {
    flex: 1;
}

.segmented {
    display: inline-flex;
    background: var(--surface-2);
    border-radius: var(--r-pill);
    padding: 4px;
    gap: 2px;
}

.segmented button {
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    color: var(--body);
    padding: 7px 16px;
    border-radius: var(--r-pill);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.segmented button[aria-selected="true"] {
    background: var(--surface);
    color: var(--ink);
    box-shadow: 0 1px 3px rgba(29, 43, 32, .12);
}

.segmented .pill-count {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

/* tables */

.table-card {
    overflow: hidden;
}

.table-scroll {
    overflow-x: auto;
}

table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

table.data th {
    text-align: left;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--muted);
    padding: 12px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    white-space: nowrap;
}

table.data td {
    padding: 11px 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--body);
}

table.data tbody tr:last-child td {
    border-bottom: 0;
}

table.data tbody tr:hover td {
    background: color-mix(in srgb, var(--surface-2) 55%, transparent);
}

table.data tr.is-selected td {
    background: var(--brand-soft);
}

table.data tr.is-inactive td {
    color: var(--muted);
}

table.data .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

table.data .nowrap {
    white-space: nowrap;
}

table.data .strong {
    color: var(--ink);
    font-weight: 600;
}

table.data .wrap {
    min-width: 160px;
    max-width: 420px;
    overflow-wrap: break-word;
}

table.data .actions {
    text-align: right;
    white-space: nowrap;
    width: 1%;
}

table.data .actions .sep {
    display: inline-block;
    width: 1px;
    height: 20px;
    background: var(--line);
    margin: 0 4px;
    vertical-align: middle;
}

.name-link {
    color: var(--ink);
    font-weight: 600;
}

.sub {
    display: block;
    font-size: 13px;
    color: var(--muted);
    font-weight: 400;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: var(--r-pill);
    background: var(--surface-2);
    color: var(--body);
    vertical-align: middle;
    white-space: nowrap;
}

.badge-brand {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.badge-muted {
    background: var(--surface-2);
    color: var(--muted);
}

.ext {
    font-family: ui-monospace, "SF Mono", Menlo, monospace;
    font-size: 12px;
    text-transform: uppercase;
    color: var(--muted);
}

.more {
    display: flex;
    justify-content: center;
    padding: 14px;
    border-top: 1px solid var(--line);
}

tr.filtered-out,
tr.paged-out {
    display: none;
}

.no-match td {
    text-align: center;
    color: var(--muted);
    padding: 28px 14px !important;
}

/* rows become cards on small screens */
@media (max-width: 720px) {
    table.data.stack thead {
        display: none;
    }

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

    table.data.stack tr {
        padding: 12px 16px;
        border-bottom: 1px solid var(--line);
    }

    table.data.stack tr.filtered-out,
    table.data.stack tr.paged-out {
        display: none;
    }

    table.data.stack tbody tr:last-child {
        border-bottom: 0;
    }

    table.data.stack td {
        border: 0;
        padding: 3px 0;
        display: flex;
        gap: 12px;
        justify-content: space-between;
        text-align: right;
        max-width: none;
        min-width: 0;
    }

    table.data.stack td[data-label]::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 13px;
        text-align: left;
        flex-shrink: 0;
    }

    table.data.stack td[data-label]:empty {
        display: none;
    }

    table.data.stack td.primary {
        display: block;
        font-size: 15px;
        text-align: left;
        padding-bottom: 6px;
    }

    table.data.stack td.primary::before {
        display: none;
    }

    table.data.stack td.actions {
        width: 100%;
        justify-content: flex-start;
        flex-wrap: wrap;
        gap: 4px;
        padding-top: 8px;
        white-space: normal;
    }

    table.data.stack td.actions::before {
        display: none;
    }

    table.data.stack .btn-icon {
        width: auto;
        height: 36px;
        border-radius: var(--r-pill);
        padding: 0 12px;
        display: inline-flex;
        gap: 6px;
        background: var(--surface-2);
        font-size: 13px;
        font-weight: 500;
    }

    table.data.stack .btn-icon span {
        position: static;
        width: auto;
        height: auto;
        clip: auto;
    }

    table.data.stack .btn-icon.danger {
        color: var(--danger);
        background: var(--danger-soft);
    }

    table.data.stack .actions .sep {
        display: none;
    }

    table.data.stack tbody tr:hover td {
        background: none;
    }

    .no-match td {
        justify-content: center !important;
    }
}

/* row menu for less used actions */

.rowmenu {
    position: relative;
    display: inline-block;
}

.rowmenu summary {
    list-style: none;
}

.rowmenu summary::-webkit-details-marker {
    display: none;
}

.rowmenu .menu {
    min-width: 220px;
    top: calc(100% + 4px);
}

@media (max-width: 720px) {
    .rowmenu .menu {
        left: 0;
        right: auto;
    }
}

/* empty state */

.empty {
    text-align: center;
    padding: 48px 20px;
}

.empty .ti {
    font-size: 32px;
    color: var(--brand);
}

.empty h2 {
    margin-top: 10px;
}

.empty p {
    color: var(--muted);
    margin: 6px auto 0;
    max-width: 46ch;
}

/* forms */

.form-card {
    max-width: 640px;
}

.form-grid {
    display: grid;
    gap: 18px;
}

.form-grid.two {
    grid-template-columns: 1fr 1fr;
}

@media (max-width: 640px) {
    .form-grid.two {
        grid-template-columns: 1fr;
    }
}

.field {
    display: grid;
    gap: 6px;
    min-width: 0;
}

.field>label,
.field-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.field .optional {
    font-weight: 400;
    color: var(--muted);
}

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

input[type=text],
input[type=email],
input[type=mail],
input[type=tel],
input[type=number],
input[type=date],
input[type=password],
input[type=search],
textarea,
select {
    width: 100%;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-input);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-size: 16px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
    min-height: 110px;
    resize: vertical;
}

input::placeholder,
textarea::placeholder {
    color: var(--muted);
    opacity: 1;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 25%, transparent);
}

input[readonly] {
    background: var(--surface-2);
    color: var(--muted);
}

.input-prefix {
    position: relative;
}

.input-prefix>span {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.input-prefix input {
    padding-left: 32px;
}

.check {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    color: var(--body);
}

.check input {
    width: 20px;
    height: 20px;
    margin: 1px 0 0;
    accent-color: var(--brand-strong);
    flex-shrink: 0;
}

.check b {
    color: var(--ink);
    font-weight: 600;
}

.form-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.inline-form {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 10px;
    align-items: end;
}

@media (max-width: 720px) {
    .inline-form {
        grid-template-columns: 1fr;
    }
}

.settings-row {
    display: grid;
    grid-template-columns: 1fr 120px;
    gap: 16px;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--line);
}

.settings-row:last-child {
    border-bottom: 0;
}

@media (max-width: 560px) {
    .settings-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }
}

/* upload */

.dropzone {
    display: grid;
    place-items: center;
    gap: 6px;
    text-align: center;
    padding: 26px 16px;
    border: 2px dashed var(--line-strong);
    border-radius: var(--r-card);
    background: var(--surface-2);
    cursor: pointer;
    transition: border-color .15s ease, background-color .15s ease;
}

.dropzone .ti {
    font-size: 30px;
    color: var(--brand);
}

.dropzone b {
    color: var(--ink);
}

.dropzone .hint {
    margin: 0;
}

.dropzone.is-over {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.dropzone input[type=file] {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
}

.dropzone:focus-within {
    outline: 3px solid var(--focus);
    outline-offset: 2px;
}

.filelist {
    list-style: none;
    margin: 0;
    padding: 0;
    font-size: 14px;
    display: grid;
    gap: 4px;
}

.filelist li {
    display: flex;
    gap: 8px;
    align-items: center;
    color: var(--ink);
    overflow-wrap: anywhere;
}

.filelist li.is-rejected {
    color: var(--danger);
}

.filelist li .ti {
    color: var(--muted);
}

.upload-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 18px;
    align-items: start;
}

@media (max-width: 760px) {
    .upload-grid {
        grid-template-columns: 1fr;
    }
}

.progress {
    display: none;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    color: var(--body);
}

.progress.is-on {
    display: flex;
}

.spinner {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid var(--line-strong);
    border-top-color: var(--brand);
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* flash messages */

.flash {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 12px 12px 16px;
    border-radius: 12px;
    margin-bottom: 20px;
    font-weight: 500;
}

.flash p {
    flex: 1;
}

.flash-error {
    background: var(--danger-soft);
    color: var(--danger);
}

.flash-ok {
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.flash-close {
    border: 0;
    background: none;
    color: inherit;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
}

/* dialogs */

.dialog {
    border: 0;
    padding: 0;
    border-radius: 20px;
    background: var(--surface);
    color: var(--body);
    box-shadow: 0 24px 64px rgba(0, 0, 0, .25);
    width: min(460px, calc(100vw - 32px));
    overscroll-behavior: contain;
}

.dialog::backdrop {
    background: rgba(16, 23, 18, .45);
    backdrop-filter: blur(3px);
}

.dialog form {
    padding: 26px;
}

.dialog h2 {
    font-size: 20px;
    margin-bottom: 10px;
}

.dialog p {
    margin-bottom: 10px;
}

.dialog .check {
    margin-top: 16px;
    font-size: 14px;
}

.dialog-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.notice-icon {
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
    margin-bottom: 14px;
}

.notice-icon .ti {
    font-size: 24px;
}

/* stand alone confirm page (no javascript) */

.confirm-page {
    max-width: 480px;
    margin: 8vh auto 0;
}

/* footer */

.foot {
    text-align: center;
    padding: 18px 16px 24px;
    font-size: 13px;
}

.foot a {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation-duration: .01ms !important;
    }
}

/* file rows */

.filecell {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--ink);
    min-width: 200px;
}

.thumb {
    width: 40px;
    height: 40px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--surface-2);
}

.thumb-icon {
    display: grid;
    place-items: center;
    color: var(--brand-strong);
}

/* on phones the page actions stay compact, so the data starts higher */
@media (max-width: 640px) {
    .pagehead {
        margin-bottom: 14px;
    }

    .pagehead-actions {
        gap: 6px;
    }

    .pagehead-actions .btn {
        min-height: 38px;
        padding: 7px 14px;
        font-size: 14px;
    }
}

/* photo gallery (customers) */

.gallery-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-bottom: 8px;
}

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 38px;
    padding: 6px 14px;
    border-radius: var(--r-pill);
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--body);
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.chip span {
    font-weight: 500;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.chip:hover {
    background: var(--surface-2);
}

.chip[aria-pressed="true"] {
    background: var(--brand-strong);
    border-color: var(--brand-strong);
    color: var(--on-brand);
}

.chip[aria-pressed="true"] span {
    color: var(--on-brand);
    opacity: .85;
}

.gallery-day {
    margin-top: 24px;
}

.gallery-day h2 {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 4px 12px;
    font-size: 16px;
    margin-bottom: 10px;
    position: sticky;
    top: 84px;
    z-index: 2;
    background: var(--bg);
    padding: 8px 0;
}

.gallery-label {
    font-weight: 600;
    color: var(--brand-strong);
}

.gallery-count {
    font-size: 13px;
    font-weight: 500;
    color: var(--muted);
}

.tiles {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}

@media (max-width: 640px) {
    .tiles {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        gap: 4px;
    }

    .gallery-day h2 {
        top: 76px;
    }
}

.tile a {
    display: block;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: var(--surface-2);
    position: relative;
}

@media (max-width: 640px) {
    .tile a {
        border-radius: 6px;
    }
}

.tile .thumb,
.tile .thumb-icon {
    width: 100%;
    height: 100%;
    border-radius: 0;
    object-fit: cover;
    transition: transform .25s ease;
}

.tile a:hover .thumb {
    transform: scale(1.04);
}

.tile-file {
    display: grid;
    place-items: center;
    align-content: center;
    gap: 6px;
    width: 100%;
    height: 100%;
    color: var(--brand-strong);
}

.tile-file .ti {
    font-size: 32px;
}

.tile-video .tile-file {
    background: var(--ink);
    color: #fff;
}

.tile-video .tile-file .ext {
    color: rgba(255, 255, 255, .75);
}

.tile.paged-out,
.tile.kind-out,
.gallery-day.empty-day {
    display: none;
}

/* full screen viewer */

.viewer {
    border: 0;
    padding: 0;
    margin: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    max-height: none;
    background: #0d120e;
    color: #fff;
    overscroll-behavior: contain;
}

.viewer::backdrop {
    background: #0d120e;
}

.viewer[open] {
    display: grid;
    /* minmax(0, 1fr): the stage must not grow with the photo and push it down */
    grid-template-rows: auto minmax(0, 1fr);
}

.viewer-top {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 12px 10px 20px;
    padding-top: max(10px, env(safe-area-inset-top));
}

.viewer-info {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: rgba(255, 255, 255, .8);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#viewer-count {
    font-weight: 700;
    color: #fff;
    font-variant-numeric: tabular-nums;
    margin-right: 8px;
}

.viewer-btn,
.viewer-nav {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 0;
    background: none;
    color: #fff;
    cursor: pointer;
    text-decoration: none !important;
}

.viewer-btn:hover,
.viewer-nav:hover {
    background: rgba(255, 255, 255, .12);
}

.viewer .ti {
    font-size: 22px;
}

.viewer-stage {
    position: relative;
    display: grid;
    place-items: center;
    min-height: 0;
    overflow: hidden;
    padding: 0 8px max(12px, env(safe-area-inset-bottom));
    touch-action: pan-y pinch-zoom;
}

.viewer-stage img,
.viewer-stage video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
}

.viewer-stage .viewer-doc {
    text-align: center;
    display: grid;
    gap: 14px;
    justify-items: center;
}

.viewer-stage .viewer-doc .ti {
    font-size: 48px;
}

.viewer-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, .35);
    width: 52px;
    height: 52px;
}

.viewer-prev {
    left: 12px;
}

.viewer-next {
    right: 12px;
}

.viewer-nav[disabled] {
    opacity: 0;
    pointer-events: none;
}

@media (hover: none) {
    .viewer-nav {
        display: none;
    }
}

.viewer-loading::after {
    content: "";
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 3px solid rgba(255, 255, 255, .25);
    border-top-color: #fff;
    animation: spin .8s linear infinite;
}

/* login and password recovery */

.auth-page {
    flex: 1;
    width: 100%;
    max-width: 1040px;
    margin: 0 auto;
    padding: clamp(24px, 6vh, 64px) 16px 40px;
}

.auth .switch span {
    display: inline;
}

.auth .switch {
    padding: 8px 14px;
}

.auth-grid {
    display: grid;
    grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
    gap: 24px;
    align-items: stretch;
}

.auth-grid-single {
    grid-template-columns: minmax(0, 440px);
    justify-content: center;
}

.auth-card {
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.auth-card .flash {
    margin: 0;
}

.auth-card .crumb {
    align-self: flex-start;
    margin: -8px 0 0;
}

.auth-sub {
    margin-top: -12px;
    color: var(--muted);
    text-wrap: pretty;
}

.auth-icon {
    display: grid;
    place-items: center;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: var(--brand-soft);
    color: var(--brand-strong);
}

.auth-icon .ti {
    font-size: 26px;
}

.auth-form {
    display: grid;
    gap: 18px;
}

.field-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
}

.field-row label {
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}

.field-row a {
    font-size: 14px;
    font-weight: 500;
}

.input-reveal {
    position: relative;
}

.input-reveal input {
    padding-right: 52px;
}

.reveal {
    position: absolute;
    top: 50%;
    right: 4px;
    transform: translateY(-50%);
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: none;
    color: var(--muted);
    cursor: pointer;
}

.reveal:hover {
    background: var(--surface-2);
    color: var(--ink);
}

.reveal .ti {
    font-size: 20px;
}

.btn-block {
    width: 100%;
    min-height: 46px;
}

.auth-help {
    padding-top: 18px;
    border-top: 1px solid var(--line);
    font-size: 14px;
    color: var(--muted);
}

.auth-help a {
    font-weight: 500;
    overflow-wrap: anywhere;
}

.auth-aside {
    position: relative;
    overflow: hidden;
    border-radius: var(--r-card);
    background: #2d4a33 url(/img/Back_in.jpg) center / cover no-repeat;
    color: #fff;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    gap: 18px;
    padding: 32px;
    min-height: 440px;
    isolation: isolate;
}

.auth-aside::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    background: linear-gradient(180deg, rgba(20, 36, 24, 0) 20%, rgba(20, 36, 24, .55) 50%, rgba(20, 36, 24, .9) 100%);
}

.auth-aside h2 {
    color: #fff;
    font-size: 22px;
    max-width: 22ch;
}

.auth-points {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 14px;
}

.auth-points li {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

.auth-points .ti {
    flex-shrink: 0;
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .16);
    font-size: 18px;
}

.auth-points b {
    color: #fff;
}

.auth-points p {
    font-size: 14px;
    color: rgba(255, 255, 255, .86);
}

@media (max-width: 820px) {
    .auth-grid {
        grid-template-columns: minmax(0, 1fr);
        max-width: 480px;
        margin: 0 auto;
    }

    .auth-aside {
        min-height: 0;
        padding: 140px 24px 24px;
    }
}

@media (max-width: 480px) {
    .auth-page {
        padding-top: 20px;
    }

    .auth-card {
        padding: 24px 20px;
    }
}
