:root {
    color-scheme:light;
    --ink:#292d25;
    --muted:#616658;
    --paper:#f6f2e8;
    --panel:#fffefa;
    --line:#e1d9c8;
    --nav:#242a23;
    --navtext:#f6f0e1;
    --accent:#eed295;
    --gold:#725623;
    --danger:#9d352d;
    --radius:12px;
    --header-height:66px;
    font:16px/1.5 "Segoe UI",system-ui,sans-serif;
}

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

body {
    margin:0;
    background:var(--paper);
    color:var(--ink);
}

a {
    color:#674814;
}

a:hover {
    text-decoration:none;
}

button,input,textarea,select {
    font:inherit;
}

button {
    cursor:pointer;
}

button:focus-visible,a:focus-visible,input:focus-visible,textarea:focus-visible,select:focus-visible,.tablewrap:focus-visible {
    outline:3px solid #98743a;
    outline-offset:3px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    gap: 12px;
    height: var(--header-height);
    padding: 0 clamp(1rem, 3vw, 2rem);
    background: var(--panel);
    border-bottom: 1px solid var(--line);
}

.brand {
    color: var(--ink);
    font: 700 clamp(1rem, 3vw, 1.3rem)/1.15 Georgia, serif;
    text-decoration: none;
}

.top-link {
    flex: none;
    margin-left: auto;
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 .7rem;
    font-weight: 650;
    font-size: .84rem;
    text-decoration: none;
}

.top-link:hover {
    background: var(--paper);
}

.shell {
    display: grid;
    grid-template-columns: 250px minmax(0, 1fr);
    min-height: calc(100vh - var(--header-height));
}

.sidebar {
    position: sticky;
    top: var(--header-height);
    align-self: start;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height));
    height: calc(100dvh - var(--header-height));
    min-height: 0;
    background: var(--nav);
    color: var(--navtext);
}

.sidebar-header {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: 1.15rem 1.35rem;
    border-bottom: 1px solid #666850;
    color: var(--accent);
}

.sidebar-menu {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    scrollbar-gutter: stable;
    padding: .65rem .8rem 1rem;
}

.sidebar details {
    margin: .45rem 0;
}

.sidebar summary,
.sidebar a {
    padding: .65rem .75rem;
    border-radius: 8px;
    overflow-wrap: anywhere;
}

.sidebar summary {
    cursor: pointer;
    color: var(--accent);
    font-weight: 700;
    font-size: .85rem;
}

.sidebar a {
    display: block;
    color: var(--navtext);
    text-decoration: none;
    font-size: .92rem;
}

.sidebar a:hover,
.sidebar a[aria-current="page"] {
    background: var(--accent);
    color: var(--ink);
}

.nav-toggle,
.nav-close,
.nav-overlay {
    display: none;
}

.guest-form .topbar {
    justify-content: center;
    position: static;
}

.guest-form .shell {
    display: block;
}

.guest-form .main {
    display: grid;
    align-content: safe center;
    min-height: calc(100vh - var(--header-height));
    min-height: calc(100dvh - var(--header-height));
    max-width: 500px;
    padding: 1.5rem 1rem;
}

.sign-in-card {
    padding: clamp(1.2rem, 5vw, 2rem);
    border: 1px solid var(--line);
    border-radius: 16px;
    background: var(--panel);
    box-shadow: 0 12px 40px #3029140d;
}

.sign-in-card h1 {
    margin: 0 0 1.25rem;
    font: 700 clamp(1.65rem, 4vw, 2.15rem)/1.15 Georgia, serif;
}

.sign-in-card input:not([type="submit"]) {
    min-height: 46px;
    font-size: 1rem;
}

.sign-in-card .sign-in-button {
    width: 100%;
    min-height: 46px;
    margin: .45rem 0 0;
    background: var(--nav);
    border-color: var(--nav);
    color: var(--navtext);
}

.sign-in-card .sign-in-button:hover {
    background: #3d4536;
}

.main {
    min-width:0;
    width:100%;
    max-width:1480px;
    padding:clamp(1rem,3.8vw,3.5rem);
    margin:0 auto;
}

.page-heading {
    margin:.2rem 0 1.1rem;
    font:700 clamp(1.95rem,4vw,3.15rem)/1.12 Georgia,serif;
    overflow-wrap:anywhere;
}

h2 {
    font-size:1.15rem;
    margin:0 0 .65rem;
}

.card {
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:var(--radius);
    padding:clamp(.9rem,2vw,1.45rem);
    margin:0 0 1rem;
    min-width:0;
}

.tiles {
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(min(100%,235px),1fr));
    gap:1rem;
    margin:1rem 0;
}

.tile {
    display:flex;
    flex-direction:column;
    justify-content:center;
    min-height:105px;
    padding:1.1rem;
    background:var(--panel);
    border:1px solid var(--line);
    border-radius:var(--radius);
    text-decoration:none;
    color:var(--ink);
    font-weight:700;
}

.tile:hover {
    border-color:#a78747;
}

.tile span {
    color:var(--muted);
    font-size:.86rem;
    font-weight:400;
    margin-top:.35rem;
}

.tile b {
    color:var(--gold);
    font-size:1.28rem;
}

.notice {
    display:block;
    color:var(--danger);
    margin:.5rem 0;
    overflow-wrap:anywhere;
}

.notice:empty {
    display:none;
}

.notice.ok {
    color:#31583c;
}

.muted {
    color:var(--muted);
    font-size:.9rem;
}

.fields {
    display:grid;
    grid-template-columns:repeat(auto-fit,minmax(min(100%,200px),1fr));
    gap:.85rem 1rem;
}

.field {
    min-width:0;
    margin-bottom:.7rem;
}

.field label {
    display:block;
    font-weight:650;
    margin-bottom:.25rem;
}

.field input:not([type=checkbox]),.field select,.field textarea,.stack input {
    display:block;
    width:100%;
    max-width:100%;
    min-width:0;
    border:1px solid #bcb5a6;
    border-radius:7px;
    background:white;
    padding:.54rem .65rem;
    color:var(--ink);
}

.field textarea {
    resize:vertical;
}

.field input[type=checkbox] {
    margin-right:.45rem;
}

.field input:disabled,.field input[readonly] {
    background:#f5f1e8;
}

.btn {
    display:inline-block;
    border:1px solid #a98b51;
    border-radius:7px;
    padding:.47rem .78rem;
    color:var(--ink);
    background:var(--accent);
    font-weight:650;
    text-decoration:none;
    margin:.2rem .35rem .2rem 0;
    white-space:normal;
    cursor:pointer;
}

.btn:hover {
    background:#e7c77f;
    text-decoration:none;
}

.btn.secondary {
    background:#fffefa;
    border-color:#b6ad98;
}

.btn.danger {
    color:#8d2e27;
}

.btn:disabled {
    opacity:.5;
    cursor:default;
}

.tablewrap {
    overflow-x:auto;
    max-width:100%;
    overscroll-behavior-x:contain;
    margin:1rem 0 .75rem;
    border:1px solid var(--line);
    border-radius:8px;
}

.grid {
    border-collapse:collapse;
    width:100%;
    min-width:640px;
    background:var(--panel);
    text-align:left;
    font-size:.91rem;
}

.grid th,.grid td {
    padding:.65rem .72rem;
    border-bottom:1px solid var(--line);
    vertical-align:middle;
}

.grid th {
    background:#f1eadb;
    color:var(--gold);
    font-weight:700;
    white-space:nowrap;
}

.grid td:last-child {
    min-width:145px;
}

.grid td:not(:last-child) {
    max-width:30ch;
    overflow-wrap:break-word;
}

.grid td .btn {
    padding:.35rem .65rem;
    white-space:nowrap;
}

.grid tr:nth-child(even) td {
    background:#f9f6ef;
}

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

.grid tr:hover td {
    background:#fbf7ec;
}

.report-card {
    scroll-margin-top:calc(var(--header-height) + 1rem);
}

.report-filters {
    margin-top:.75rem;
}

.report-filter-actions,.report-footer,.report-pages {
    display:flex;
    flex-wrap:wrap;
    align-items:center;
    gap:.4rem .7rem;
}

.report-footer {
    justify-content:space-between;
}

.report-pages {
    font-size:.9rem;
}

.report-link {
    font-weight:650;
    text-decoration:none;
}

.report-link:hover {
    color:var(--ink);
}

.editor {
    display:grid;
    grid-template-columns:minmax(0,1fr) minmax(230px,320px);
    gap:1rem;
    align-items:start;
}

.term-list {
    min-height:8rem;
}

.term-source[hidden],.term-checklist [hidden] {
    display:none;
}

.term-checklist {
    max-height:13rem;
    margin:.4rem 0 .2rem;
    overflow-y:auto;
    overscroll-behavior-y:contain;
    border:1px solid var(--line);
    border-radius:8px;
    background:white;
}

.term-checklist label {
    display:flex;
    align-items:center;
    gap:.45rem;
    min-height:38px;
    margin:0;
    padding:.35rem .65rem;
    font-weight:400;
    cursor:pointer;
}

.term-checklist label:hover,.term-checklist label:has(input:checked) {
    background:#f6f2e8;
}

.term-checklist input {
    flex:none;
    accent-color:var(--gold);
}

.term-checklist span {
    overflow-wrap:anywhere;
}

.term-empty {
    margin:.65rem;
}

.term-create {
    margin-bottom:1rem;
    padding-bottom:.75rem;
    border-bottom:1px solid var(--line);
}

.payment-image {
    display:block;
    max-width:min(100%,240px);
    max-height:260px;
    object-fit:contain;
    margin:.7rem 0;
}

.stack {
    max-width:520px;
}

.stack label {
    display:block;
    margin:.5rem 0;
}

@media (max-width: 840px) {
    :root {
        --header-height: 60px;
    }

    .topbar {
        padding-inline: .8rem;
        gap: .65rem;
    }

    .shell {
        display: block;
    }

    .icon-button {
        display: inline-grid;
        flex: none;
        place-items: center;
        width: 44px;
        height: 44px;
        background: var(--panel);
        color: var(--ink);
        border: 1px solid var(--line);
        border-radius: 8px;
        padding: 0;
    }

    .menu-icon,
    .menu-icon::before,
    .menu-icon::after {
        width: 17px;
        height: 2px;
        border-radius: 2px;
        background: currentColor;
    }

    .menu-icon {
        position: relative;
    }

    .menu-icon::before,
    .menu-icon::after {
        position: absolute;
        left: 0;
        content: "";
    }

    .menu-icon::before {
        top: -5px;
    }

    .menu-icon::after {
        top: 5px;
    }

    .nav-close {
        font-size: 1.5rem;
        line-height: 1;
    }

    .sidebar {
        display: none;
        position: fixed;
        inset: 0 auto 0 0;
        width: min(86vw, 320px);
        height: 100%;
        height: 100dvh;
        z-index: 30;
        background: var(--panel);
        color: var(--ink);
        box-shadow: 12px 0 32px #382d2333;
    }

    .sidebar-header {
        padding: max(.65rem, env(safe-area-inset-top)) 1rem .65rem;
        border-color: var(--line);
        color: var(--ink);
    }

    .sidebar-menu {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }

    .sidebar summary {
        color: var(--gold);
    }

    .sidebar a {
        display: flex;
        align-items: center;
        min-height: 44px;
        color: var(--ink);
    }

    .nav-overlay {
        position: fixed;
        inset: 0;
        z-index: 25;
        background: #231c1466;
    }

    .nav-open .sidebar {
        display: flex;
    }

    .nav-open .nav-overlay {
        display: block;
    }

    .nav-open {
        overflow: hidden;
    }

    .main {
        padding: 1rem;
    }

    .page-heading {
        font-size: clamp(1.65rem, 6vw, 2.25rem);
    }

    .editor {
        grid-template-columns: minmax(0, 1fr);
        gap: .75rem;
    }

    .tiles {
        gap: .75rem;
    }

    .tile {
        min-height: 90px;
    }

    .btn {
        min-height: 44px;
    }

    .grid td .btn {
        display:inline-flex;
        align-items:center;
    }
}

@media (max-width: 480px) {
    .fields {
        grid-template-columns: minmax(0, 1fr);
        gap: .2rem;
    }

    .guest-form .main {
        align-content: start;
        padding-top: clamp(2rem, 10vh, 4.5rem);
    }
}

.public-plans .topbar .top-link {
    margin-left: 0;
}

.public-plans .topbar .brand {
    margin-right: auto;
}

.public-plans .topbar {
    flex-wrap: wrap;
    height: auto;
    min-height: var(--header-height);
    padding-block: .6rem;
}

.public-plans .tiles article {
    align-self: start;
}
