/* Jobber Visit Relay -- one stylesheet, no build step. */

:root {
    --bg: #f6f7f9;
    --surface: #ffffff;
    --surface-2: #f0f2f5;
    --border: #dfe3e8;
    --text: #16191d;
    --muted: #6b7280;
    --accent: #1f6f43;
    --accent-soft: #e6f3ec;
    --danger: #b42318;
    --danger-soft: #fdeceb;
    --warn: #a15c07;
    --warn-soft: #fdf3e2;
    --radius: 10px;
    --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #14171a;
        --surface: #1c2024;
        --surface-2: #23282d;
        --border: #333a41;
        --text: #e8eaed;
        --muted: #9aa3ad;
        --accent: #4ea87a;
        --accent-soft: #16301f;
        --danger: #f27c72;
        --danger-soft: #3a1e1c;
        --warn: #e0a94a;
        --warn-soft: #362a15;
    }
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.wrap { max-width: 960px; margin: 0 auto; padding: 0 1.25rem; }

/* ---------------------------------------------------------------- header */

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin-bottom: 1.75rem;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 60px;
    flex-wrap: wrap;
}

.brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-weight: 650;
    color: var(--text);
    text-decoration: none;
}

.brand-mark {
    display: grid;
    place-items: center;
    width: 30px; height: 30px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    font-size: 12px;
    letter-spacing: .5px;
}

.nav { display: flex; align-items: center; gap: 1.1rem; }
.nav a, .linklike {
    color: var(--muted);
    text-decoration: none;
    font-size: .92rem;
}
.nav a:hover, .linklike:hover { color: var(--text); }

.linklike {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    cursor: pointer;
}

/* -------------------------------------------------------- account switch */

.account-switch { position: relative; }
.account-switch summary {
    display: flex;
    align-items: center;
    gap: .3rem;
    cursor: pointer;
    color: var(--text);
    font-size: .88rem;
    list-style: none;
    padding: .35rem .65rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface-2);
}
.account-switch summary::-webkit-details-marker { display: none; }
.account-switch summary::after {
    content: '';
    width: 6px;
    height: 6px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg) translateY(-2px);
    margin-left: .1rem;
}
.account-switch summary:hover { border-color: var(--muted); }
.account-switch[open] summary { border-color: var(--accent); }

.account-switch-menu {
    position: absolute;
    right: 0;
    top: calc(100% + .5rem);
    z-index: 10;
    min-width: 220px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .6rem .7rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .16);
}

.account-switch-menu form { margin: 0; }
.account-switch-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: .3rem 0;
    color: var(--text);
}
.account-switch-menu a {
    display: block;
    padding: .3rem 0;
    color: var(--muted);
    text-decoration: none;
    font-size: .88rem;
}
.account-switch-menu a:hover { color: var(--text); }
.account-switch-menu hr {
    border: 0;
    border-top: 1px solid var(--border);
    margin: .5rem 0;
}

.inline { display: inline; }

/* ----------------------------------------------------------------- cards */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.4rem;
    margin-bottom: 1.25rem;
}

.card h2, .card h1 { margin: 0 0 .35rem; font-size: 1.1rem; }
.card h1 { font-size: 1.35rem; }
.card > p:first-of-type { margin-top: 0; }

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: .9rem;
}

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

h3 { font-size: .95rem; margin: 1.4rem 0 .5rem; }

/* ---------------------------------------------------------------- pills */

.pill {
    display: inline-block;
    padding: .18rem .55rem;
    border-radius: 999px;
    font-size: .76rem;
    font-weight: 600;
    letter-spacing: .01em;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}

.pill-ok { background: var(--accent-soft); color: var(--accent); }
.pill-bad { background: var(--danger-soft); color: var(--danger); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }

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

.btn {
    display: inline-block;
    padding: .5rem .9rem;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text);
    font: inherit;
    font-size: .9rem;
    text-decoration: none;
    cursor: pointer;
}

.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); }
.btn-sm { padding: .3rem .6rem; font-size: .82rem; }

/* ----------------------------------------------------------------- forms */

label { display: block; font-size: .86rem; font-weight: 600; margin-bottom: .3rem; }

input[type=text], input[type=url], input[type=password], input[type=number], select, textarea {
    width: 100%;
    padding: .5rem .6rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
    font-size: .92rem;
}

textarea { font-family: var(--mono); font-size: .84rem; min-height: 140px; resize: vertical; }
select[multiple] { min-height: 96px; }

.field { margin-bottom: .9rem; }
.field .hint { font-weight: 400; color: var(--muted); font-size: .8rem; margin-top: .25rem; }

.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }

.check { display: flex; align-items: flex-start; gap: .5rem; margin-bottom: .5rem; }
.check input { margin-top: .25rem; }
.check label { font-weight: 400; margin: 0; }

/* ----------------------------------------------------------------- table */

table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: .55rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }

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

/* ------------------------------------------------------------------ code */

.code {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .8rem;
    font-family: var(--mono);
    font-size: .82rem;
    overflow-x: auto;
    white-space: pre;
    margin: 0;
}

code { font-family: var(--mono); font-size: .86em; background: var(--surface-2); padding: .1rem .3rem; border-radius: 4px; }

.copyrow { display: flex; gap: .5rem; align-items: stretch; }
.copyrow input { font-family: var(--mono); font-size: .82rem; }

/* ----------------------------------------------------------------- flash */

.flash {
    padding: .7rem .9rem;
    border-radius: 8px;
    margin-bottom: 1rem;
    font-size: .92rem;
    border: 1px solid transparent;
}

.flash-success { background: var(--accent-soft); color: var(--accent); border-color: currentColor; }
.flash-error { background: var(--danger-soft); color: var(--danger); border-color: currentColor; }
.flash-info { background: var(--surface); color: var(--muted); border-color: var(--border); }

/* ----------------------------------------------------------------- stats */

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: .75rem; }
.stat { background: var(--surface-2); border-radius: 8px; padding: .7rem .8rem; }
.stat b { display: block; font-size: 1.4rem; line-height: 1.2; }
.stat span { font-size: .78rem; color: var(--muted); }

/* --------------------------------------------------------------- details */

details.branch { border: 1px solid var(--border); border-radius: 8px; padding: .7rem .9rem; margin-bottom: .7rem; }
details.branch summary { cursor: pointer; font-weight: 600; }
details.branch[open] summary { margin-bottom: .8rem; }

.footer {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    color: var(--muted);
    font-size: .8rem;
    padding-top: .5rem;
    padding-bottom: 2.5rem;
    flex-wrap: wrap;
}

.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { display: flex; gap: .6rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.checklist li:last-child { border-bottom: 0; }
.checklist .state { flex: none; width: 1.2rem; }

.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
