:root {
    --cream: #F7F3EC;
    --card: #FDFCF9;
    --ink: #1E2725;
    --muted: #4A5450;
    --faint: #6B746F;
    --line: #E5DECF;
    --line-soft: #EFE9DC;
    --teal: #0F5C5A;
    --teal-hover: #0A423F;
    --gold: #E8B75A;
    --gold-bg: #FBEFD9;
    --gold-deep: #8A5A12;
    --green: #4E7D52;
    --mint-bg: #E8F0EE;
    --red: #C0554A;
    --red-bg: #F9E9E7;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--cream);
    color: var(--ink);
    line-height: 1.6;
    font-size: 16px;
}

a { color: var(--teal); }

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    padding: 0.9rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.topbar__brand { font-weight: 700; font-size: 1.1rem; color: var(--ink); text-decoration: none; }
.topbar__brand span { color: var(--teal); }
.topbar__nav { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.topbar__nav a { color: var(--muted); text-decoration: none; font-size: 0.95rem; }
.topbar__nav a:hover, .topbar__nav a.is-active { color: var(--teal); }

.wrap { max-width: 880px; margin: 0 auto; padding: 2rem 1.25rem 4rem; }
.wrap--narrow { max-width: 480px; }
.wrap--wide { max-width: 1100px; }

.page-title { font-size: 1.7rem; margin-bottom: 0.35rem; }
.page-sub { color: var(--muted); margin-bottom: 1.75rem; }

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1.25rem;
}
.card h2 { font-size: 1.15rem; margin-bottom: 0.75rem; }

.flash {
    background: var(--mint-bg);
    border: 1px solid var(--green);
    color: var(--green);
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}
.flash--error { background: var(--red-bg); border-color: var(--red); color: var(--red); }
.flash--warn { background: var(--gold-bg); border-color: var(--gold); color: var(--gold-deep); }

label { display: block; font-weight: 600; font-size: 0.95rem; margin-bottom: 0.3rem; }
.field { margin-bottom: 1.15rem; }
.field .hint { font-weight: 400; color: var(--faint); font-size: 0.85rem; margin-top: 0.2rem; }
input[type="text"], input[type="email"], input[type="password"], input[type="url"],
input[type="number"], textarea, select {
    width: 100%;
    padding: 0.65rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    font: inherit;
    color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--teal);
    box-shadow: 0 0 0 3px rgba(15, 92, 90, 0.12);
}
.error-text { color: var(--red); font-size: 0.85rem; margin-top: 0.25rem; }

.btn {
    display: inline-block;
    background: var(--teal);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 0.7rem 1.4rem;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}
.btn:hover { background: var(--teal-hover); }
.btn--ghost { background: transparent; color: var(--teal); border: 1px solid var(--teal); }
.btn--ghost:hover { background: var(--mint-bg); }
.btn--small { padding: 0.4rem 0.9rem; font-size: 0.88rem; }

.badge {
    display: inline-block;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.15rem 0.6rem;
    border-radius: 99px;
    white-space: nowrap;
}
.badge--new { background: var(--gold-bg); color: var(--gold-deep); }
.badge--in_progress { background: var(--mint-bg); color: var(--teal); }
.badge--needs_input { background: var(--red-bg); color: var(--red); }
.badge--done { background: var(--line-soft); color: var(--faint); }
.badge--active { background: var(--mint-bg); color: var(--green); }
.badge--past_due { background: var(--red-bg); color: var(--red); }
.badge--cancelled { background: var(--line-soft); color: var(--faint); }
.badge--onboarding { background: var(--gold-bg); color: var(--gold-deep); }
.badge--building { background: var(--mint-bg); color: var(--teal); }
.badge--preview { background: var(--gold-bg); color: var(--gold-deep); }
.badge--live { background: var(--mint-bg); color: var(--green); }
.badge--draft { background: var(--gold-bg); color: var(--gold-deep); }
.badge--submitted { background: var(--mint-bg); color: var(--green); }

.list-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--line-soft);
}
.list-row:last-child { border-bottom: none; }
.list-row a { font-weight: 600; text-decoration: none; }
.list-row .meta { color: var(--faint); font-size: 0.85rem; }

.steps-nav { display: flex; gap: 0.5rem; margin-bottom: 1.5rem; flex-wrap: wrap; }
.steps-nav__item {
    flex: 1;
    min-width: 110px;
    text-align: center;
    font-size: 0.82rem;
    padding: 0.45rem 0.5rem;
    border-radius: 8px;
    background: var(--line-soft);
    color: var(--faint);
}
.steps-nav__item.is-current { background: var(--teal); color: #fff; font-weight: 600; }
.steps-nav__item.is-done { background: var(--mint-bg); color: var(--teal); }

.thread { display: flex; flex-direction: column; gap: 0.9rem; margin-bottom: 1.5rem; }
.msg {
    max-width: 85%;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    white-space: pre-wrap;
    font-size: 0.95rem;
}
.msg--client { align-self: flex-end; background: var(--teal); color: #fff; border-bottom-right-radius: 4px; }
.msg--admin { align-self: flex-start; background: var(--card); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .msg__meta { font-size: 0.75rem; opacity: 0.75; margin-top: 0.35rem; }

.admin .msg--client { align-self: flex-start; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 12px 12px 12px 4px; }
.admin .msg--admin { align-self: flex-end; background: var(--teal); color: #fff; border: none; border-radius: 12px 12px 4px 12px; }

table.data { width: 100%; border-collapse: collapse; }
table.data th, table.data td { text-align: left; padding: 0.6rem 0.75rem; border-bottom: 1px solid var(--line-soft); font-size: 0.93rem; }
table.data th { color: var(--faint); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.03em; }

.def-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1.5rem; }
@media (max-width: 640px) { .def-grid { grid-template-columns: 1fr; } }
.def-grid .field { margin-bottom: 1rem; }

.brief-answer { margin-bottom: 1rem; }
.brief-answer dt { font-weight: 600; font-size: 0.88rem; color: var(--muted); }
.brief-answer dd { white-space: pre-wrap; }

.footer-note { text-align: center; color: var(--faint); font-size: 0.85rem; margin-top: 2rem; }

/* Traffic dashboard */
.traffic-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.tabs { display: inline-flex; background: var(--line-soft); border-radius: 10px; padding: 3px; }
.tabs a { padding: 0.35rem 0.9rem; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 0.9rem; font-weight: 600; }
.tabs a:hover { color: var(--teal); }
.tabs a.is-active { background: var(--card); color: var(--teal); box-shadow: 0 1px 2px rgba(0,0,0,0.08); }
#traffic-body { transition: opacity 0.15s; }
#traffic-body.is-loading { opacity: 0.6; }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1.25rem; margin-bottom: 1.25rem; }
@media (max-width: 860px) { .kpis { grid-template-columns: 1fr 1fr; } }
.kpi { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 1.1rem 1.25rem; }
.kpi__label { color: var(--faint); font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi__value { font-size: 2rem; font-weight: 700; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi__value .delta { font-size: 0.9rem; vertical-align: middle; }
.kpi__meta { color: var(--faint); font-size: 0.82rem; }
.kpi .spark { display: block; width: 100%; margin: 0.4rem 0 0.2rem; }
table.traffic .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
table.traffic td { vertical-align: top; }
table.traffic .meta, .card > .meta { color: var(--faint); font-size: 0.82rem; }
.delta { font-size: 0.8rem; font-weight: 600; color: var(--faint); white-space: nowrap; }
.delta--up { color: var(--green); }
.delta--down { color: var(--red); }
.live-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--green); margin-right: 0.35rem; }
.spark__line { fill: none; stroke: var(--teal); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.spark__base { stroke: var(--line); stroke-width: 1; }
.spark__dot { fill: var(--teal); stroke: var(--card); stroke-width: 2; }
.spark__hit { fill: transparent; }
.spark__hit:hover { fill: var(--line-soft); fill-opacity: 0.6; }
