:root {
    --bg: #f3efe6;
    --ink: #1c2418;
    --muted: #5c6756;
    --line: #d5ceb8;
    --card: #fffdf8;
    --accent: #2f5d3a;
    --accent-2: #c45c26;
    --danger: #8b2e2e;
    --ok: #2f5d3a;
    --shadow: 0 1px 0 rgba(28, 36, 24, 0.06);
    --font: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
    --sans: "Avenir Next", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background:
        radial-gradient(ellipse at top left, #e8f0e4 0%, transparent 45%),
        linear-gradient(180deg, #efe8d8 0%, var(--bg) 40%, #e7e0d0 100%);
    min-height: 100vh;
    font-family: var(--sans);
    line-height: 1.45;
}

a { color: var(--accent); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--accent-2); }

.wrap { width: min(1100px, calc(100% - 2rem)); margin-inline: auto; }

.site-header {
    border-bottom: 1px solid var(--line);
    background: rgba(255, 253, 248, 0.85);
    backdrop-filter: blur(8px);
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.85rem 0;
    flex-wrap: wrap;
}

.brand {
    font-family: var(--font);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--ink);
    text-decoration: none;
    letter-spacing: -0.02em;
}

nav {
    display: flex;
    gap: 0.85rem;
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.92rem;
}

.nav-email { color: var(--muted); font-size: 0.85rem; }

.site-footer {
    margin-top: 3rem;
    padding: 1.5rem 0 2rem;
    color: var(--muted);
    font-size: 0.85rem;
    border-top: 1px solid var(--line);
}

.site-footer p { margin: 0 0 0.35rem; }
.site-footer p:last-child { margin-bottom: 0; }

h1, h2 {
    font-family: var(--font);
    letter-spacing: -0.02em;
    font-weight: 700;
    line-height: 1.15;
}

h1 { font-size: clamp(1.6rem, 3vw, 2rem); margin: 1.4rem 0 0.6rem; }
h2 { font-size: 1.25rem; margin: 1.6rem 0 0.5rem; }

.lede { color: var(--muted); margin: 0 0 1.25rem; max-width: 38rem; }

.flash {
    margin: 1rem 0;
    padding: 0.75rem 0.9rem;
    border: 1px solid var(--line);
    background: var(--card);
    box-shadow: var(--shadow);
}
.flash-ok { border-color: #9cbc9f; }
.flash-error { border-color: #d4a0a0; color: var(--danger); }

.panel {
    background: var(--card);
    border: 1px solid var(--line);
    padding: 1.1rem 1.15rem;
    box-shadow: var(--shadow);
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    align-items: end;
    margin-bottom: 1rem;
}

.toolbar form {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    align-items: end;
    flex: 1;
}

label {
    display: grid;
    gap: 0.25rem;
    font-size: 0.82rem;
    color: var(--muted);
}

input[type="text"],
input[type="email"],
input[type="url"],
input[type="tel"],
input[type="search"],
select,
textarea {
    font: inherit;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    padding: 0.55rem 0.65rem;
    min-width: 0;
    width: 100%;
}

textarea { min-height: 7rem; resize: vertical; }

.form-grid {
    display: grid;
    gap: 0.85rem;
}

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

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.6rem;
    margin-top: 1rem;
    align-items: center;
}

.btn {
    appearance: none;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    font: inherit;
    font-size: 0.95rem;
    padding: 0.55rem 0.9rem;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

.btn:hover { filter: brightness(1.05); color: #fff; }

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

.btn-danger {
    background: transparent;
    color: var(--danger);
    border-color: #d4a0a0;
}

.tabs {
    display: flex;
    gap: 0.4rem;
    margin: 0 0 1rem;
    flex-wrap: wrap;
}

.tab {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--ink);
    text-decoration: none;
    font-size: 0.9rem;
}

.tab.is-active {
    background: var(--ink);
    border-color: var(--ink);
    color: #fff;
}

.list-legend {
    margin: 0 0 0.85rem;
    font-size: 0.88rem;
    line-height: 1.4;
    max-width: 42rem;
}

.list-legend strong { color: var(--ink); font-weight: 600; }

.contractor-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid var(--line);
    background: var(--card);
}


.contractor-row + .contractor-row { border-top: 1px solid var(--line); }

.contractor-row {
    display: flex;
    align-items: stretch;
    gap: 0;
}

.contractor-row .contractor-main {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 0.75rem;
    padding: 0.75rem 0.9rem;
    text-decoration: none;
    color: inherit;
    align-items: baseline;
    min-width: 0;
}

.contractor-row .contractor-main:hover { background: #f7f3ea; }

.contractor-row .c-call {
    display: inline-flex;
    align-items: center;
    padding: 0 0.9rem;
    border-left: 1px solid var(--line);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--accent);
    white-space: nowrap;
}

.contractor-row .c-call:hover {
    background: #e8f0e4;
    color: var(--accent);
}

.c-name { font-weight: 600; }
.c-type { color: var(--muted); font-size: 0.9rem; }
.c-rating { font-variant-numeric: tabular-nums; color: var(--accent-2); font-size: 0.9rem; }

@media (max-width: 560px) {
    .contractor-row .contractor-main {
        grid-template-columns: 1fr auto;
        grid-template-areas:
            "name rating"
            "type rating";
    }
    .c-name { grid-area: name; }
    .c-type { grid-area: type; }
    .c-rating { grid-area: rating; align-self: center; }
}

.call-row { margin: 0 0 1rem; }

.btn-call {
    background: var(--accent);
    border-color: var(--accent);
    font-size: 1.05rem;
    padding: 0.7rem 1.1rem;
}

.phone-link { font-weight: 600; }

.meta-list {
    display: grid;
    gap: 0.55rem;
    margin: 0 0 1rem;
}

.meta-list div {
    display: grid;
    grid-template-columns: 7.5rem 1fr;
    gap: 0.5rem;
    padding-bottom: 0.45rem;
    border-bottom: 1px solid var(--line);
    font-size: 0.95rem;
}

.meta-list dt, .meta-list .k { color: var(--muted); }

@media (max-width: 560px) {
    .meta-list div {
        grid-template-columns: 1fr;
        gap: 0.15rem;
    }
}

.stars {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.4rem;
    width: 100%;
}

.stars button {
    border: 1px solid var(--line);
    background: #fff;
    padding: 0.55rem 0.25rem;
    cursor: pointer;
    font: inherit;
    min-height: 3rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
    line-height: 1.1;
}

.stars .star-num {
    font-size: 0.85rem;
    font-weight: 600;
}

.stars .star-icon {
    font-size: 1.15rem;
    line-height: 1;
}

.stars button.is-selected {
    background: var(--accent-2);
    border-color: var(--accent-2);
    color: #fff;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card);
    border: 1px solid var(--line);
    font-size: 0.92rem;
}

.table th, .table td {
    text-align: left;
    padding: 0.65rem 0.75rem;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
}

.table th { color: var(--muted); font-weight: 600; font-size: 0.8rem; }

.table-users {
    width: 100%;
    table-layout: fixed;
}

.table-users th,
.table-users td {
    white-space: nowrap;
    vertical-align: middle;
}

.table-users th:nth-child(1),
.table-users td:nth-child(1) { width: 16%; }

.table-users th:nth-child(2),
.table-users td:nth-child(2) { width: 12%; }

.table-users th:nth-child(3),
.table-users td:nth-child(3) { width: 16%; }

.table-users th:nth-child(4),
.table-users td:nth-child(4) { width: 8%; }

.table-users th:nth-child(5),
.table-users td:nth-child(5) { width: 6%; }

.table-users th:nth-child(6),
.table-users td:nth-child(6) { width: 10%; }

.table-users th:nth-child(7),
.table-users td:nth-child(7) { width: 32%; }

.table-users td.cell-address,
.table-users td.cell-email,
.table-users td.cell-phone,
.table-users td.cell-joined {
    overflow: hidden;
    text-overflow: ellipsis;
}

.table-users td.cell-actions {
    overflow: hidden;
}

.row-actions {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    align-items: center;
    justify-content: flex-end;
}

.row-actions form {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.3rem;
    margin: 0;
}

.row-actions .btn {
    padding: 0.3rem 0.5rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

@media (max-width: 800px) {
    .table-users {
        table-layout: auto;
        border: 0;
        background: transparent;
    }

    .table-users thead {
        display: none;
    }

    .table-users tbody {
        display: grid;
        gap: 0.75rem;
    }

    .table-users tr {
        display: grid;
        gap: 0.45rem;
        padding: 0.85rem 0.9rem;
        background: var(--card);
        border: 1px solid var(--line);
        box-shadow: var(--shadow);
    }

    .table-users th,
    .table-users td {
        display: grid;
        grid-template-columns: 7rem 1fr;
        gap: 0.5rem;
        width: auto !important;
        padding: 0.2rem 0;
        border: 0;
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        align-items: start;
    }

    .table-users td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 0.8rem;
        font-weight: 600;
    }

    .table-users td.cell-actions {
        grid-template-columns: 1fr;
    }

    .table-users td.cell-actions::before {
        margin-bottom: 0.25rem;
    }

    .row-actions {
        flex-wrap: wrap;
        justify-content: flex-start;
    }

    .row-actions form {
        flex-wrap: wrap;
    }

    .row-actions .btn {
        padding: 0.45rem 0.65rem;
        font-size: 0.85rem;
    }
}

.muted { color: var(--muted); }
.empty { padding: 1.25rem; color: var(--muted); border: 1px dashed var(--line); }

html.is-waiting,
html.is-waiting * {
    cursor: wait !important;
}

button:disabled,
input[type="submit"]:disabled {
    opacity: 0.65;
    cursor: wait !important;
}
