:root {
    --ink: #1c2a24;
    --spruce: #1f4a45;
    --spruce-deep: #14332f;
    --copper: #c46b3a;
    --copper-dark: #9a4e28;
    --paper: #f4efe6;
    --card: #fffaf3;
    --line: #d9d0c3;
    --muted: #5d6a64;
    --danger: #9b2c2c;
    --ok: #2f6f4e;
    --shadow: 0 18px 40px rgba(20, 51, 47, 0.08);
    --sans: "Source Sans 3", "Segoe UI", sans-serif;
    --serif: "Source Serif 4", Georgia, serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background:
        radial-gradient(1200px 500px at 10% -10%, #e7efe8 0%, transparent 50%),
        var(--paper);
    color: var(--ink);
    font-family: var(--sans);
    font-size: 17px;
    line-height: 1.5;
}

h1, h2, h3 {
    font-family: var(--serif);
    font-weight: 650;
    letter-spacing: -0.02em;
    line-height: 1.15;
    margin: 0 0 0.4em;
}

h1 { font-size: clamp(2rem, 4vw, 3.1rem); }
h2 { font-size: 1.35rem; }

/* FocusOnNavigate focuses h1 after routing; hide the browser focus ring. */
h1:focus,
h1:focus-visible {
    outline: none;
}

.route-focus {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.route-focus:focus,
.route-focus:focus-visible {
    outline: none;
}

a { color: var(--spruce); }
a:hover { color: var(--copper-dark); }

.shell { min-height: 100vh; display: flex; flex-direction: column; }
.shell-app { flex-direction: row; align-items: stretch; }

.topbar, .app-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
}

.topbar { border-bottom: 1px solid var(--line); }

.brand, .brand-rail {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    text-decoration: none;
    color: inherit;
}

.brand strong, .brand-rail strong { display: block; font-family: var(--serif); font-size: 1.15rem; }
.brand em, .brand-rail em { display: block; font-style: normal; color: var(--muted); font-size: 0.85rem; }

img.brand-mark {
    width: 2.1rem;
    height: 2.1rem;
    border-radius: 0.55rem;
    display: block;
    flex-shrink: 0;
}

.brand-logo, .brand-logo-preview {
    width: 2.4rem;
    height: 2.4rem;
    object-fit: contain;
    border-radius: 0.45rem;
    background: #fff;
}

.brand-logo-preview { width: 4.5rem; height: 4.5rem; }

.shell-sender { background: var(--paper); }

.brand-contact {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1.1rem;
    margin-bottom: 0.45rem;
}

.catalog-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
    margin: 1rem 0 1.5rem;
}

.catalog-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    padding: 1.3rem 1.4rem 1.5rem;
    box-shadow: var(--shadow);
}

.catalog-card.is-current { outline: 2px solid var(--spruce); }

.catalog-card .price {
    font-family: var(--serif);
    font-size: 2rem;
    margin: 0.4rem 0 0.7rem;
}

.catalog-card .price span {
    font-family: var(--sans);
    font-size: 0.95rem;
    color: var(--muted);
    margin-left: 0.2rem;
}

.color-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.75rem;
}

.color-row input[type="color"] {
    padding: 0.2rem;
    height: 2.6rem;
    cursor: pointer;
}

.logo-block { margin-top: 1rem; display: flex; gap: 1rem; align-items: center; }
.plan-pick { border: 0; padding: 0; margin: 1rem 0; }
.plan-pick legend { font-weight: 700; margin-bottom: 0.35rem; }

.top-links { display: flex; gap: 1.25rem; font-weight: 600; }
.top-links a { text-decoration: none; }

.page { width: min(960px, calc(100% - 2rem)); margin: 1.5rem auto 3rem; }
.page-app { width: min(1100px, calc(100% - 2.5rem)); margin: 0 auto 3rem; padding-top: 1rem; }

.hero { margin-bottom: 1.5rem; }
.lede { font-size: 1.15rem; color: var(--muted); max-width: 42rem; }
.eyebrow {
    text-transform: uppercase;
    letter-spacing: 0.14em;
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--copper-dark);
    margin: 0 0 0.35rem;
}

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    padding: 1.25rem 1.4rem;
    box-shadow: var(--shadow);
    margin-bottom: 1rem;
}

.narrow { max-width: 34rem; }

label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; margin: 0.75rem 0; }
input, textarea, select {
    font: inherit;
    padding: 0.7rem 0.8rem;
    border: 1px solid var(--line);
    border-radius: 0.7rem;
    background: #fff;
    color: var(--ink);
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--spruce); border-color: transparent; }

.code-input { font-family: ui-monospace, monospace; letter-spacing: 0.12em; text-transform: uppercase; font-size: 1.2rem; }

.btn, .ghost {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    padding: 0.7rem 1.2rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
    border: 0;
    text-decoration: none;
}

.btn { background: var(--spruce); color: #f7f3ea; }
.btn:hover { background: var(--spruce-deep); color: #fff; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ghost { background: transparent; color: var(--spruce); border: 1px solid var(--line); }

.linkish {
    background: none;
    border: 0;
    color: var(--spruce);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    padding: 0;
}

.hint, .fine, .site-foot, .empty, .fine-inline { color: var(--muted); }
.fine { font-size: 0.95rem; }
.site-foot { padding: 1.5rem; font-size: 0.88rem; border-top: 1px solid var(--line); }
.error { color: var(--danger); font-weight: 600; }
.req { color: var(--danger); margin-left: 0.15rem; }
label.missing input { border-color: var(--danger); }
.field-alerts {
    color: var(--danger);
    border: 1px solid var(--danger);
    border-radius: 0.8rem;
    padding: 0.8rem 1rem;
    margin: 0.75rem 0;
}
.field-alerts p { margin: 0; font-weight: 700; }
.confirm-note {
    color: var(--ink);
    border: 1px solid var(--line);
    background: var(--paper);
    border-radius: 0.8rem;
    padding: 0.8rem 1rem;
    margin: 0.75rem 0;
}
.confirm-note p { margin: 0 0 0.75rem; }
.field-alerts ul { margin: 0.4rem 0 0; padding-left: 1.2rem; }
.ok { color: var(--ok); font-weight: 600; margin-left: 0.5rem; }

.demo-callout, .demo-otp {
    margin-top: 1rem;
    padding: 0.9rem 1rem;
    background: #eef4ef;
    border-radius: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
}

.demo-otp { font-size: 1.05rem; }
code { font-family: ui-monospace, SFMono-Regular, monospace; background: #ece6da; padding: 0.1em 0.35em; border-radius: 0.3em; }

.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.check { display: flex; flex-direction: row; align-items: center; font-weight: 500; gap: 0.6rem; }
.check input { width: auto; }
.check label { margin: 0; font-weight: 500; }

.timer { font-variant-numeric: tabular-nums; }

.file-attach.is-uploading input[type="file"] { display: none; }
.upload-progress { margin: 0.75rem 0; }
.upload-progress p { margin: 0 0 0.45rem; font-weight: 600; }
.upload-progress progress {
    width: 100%;
    height: 0.7rem;
    accent-color: var(--spruce);
}
.file-list { list-style: none; padding: 0; margin: 1rem 0 0; }
.file-list li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.65rem 0;
    border-top: 1px solid var(--line);
}

.queue-tabs { display: flex; gap: 0.75rem; align-items: center; margin: 0 0 1rem; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.pairing-code strong {
    font-size: 1.35rem;
    letter-spacing: 0.12em;
    font-family: ui-monospace, Consolas, monospace;
}

.pill {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: #ece6da;
    font-size: 0.82rem;
    font-weight: 700;
}
.pill-ready { background: #e4f0d9; color: #2a5a28; }
.pill-imported { background: #e7eef6; color: #234; }
.pill-importqueued { background: #e8e4f6; color: #3a2a6a; }
.pill-pendingstanding { background: #f8e7c9; color: #7a4a10; }
.pill-active { background: #e4f0d9; color: #2a5a28; }
.pill-oneoff { background: #f3e4d6; color: #7a3f18; }
.pill-disabled { background: #eee; color: #666; }

.rail {
    width: 260px;
    flex: none;
    background: var(--spruce-deep);
    color: #e8efe9;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1.2rem 1rem 1.4rem;
}

.rail a { color: #e8efe9; text-decoration: none; }
.rail .brand em { color: #b7c7c2; }
.rail-nav { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 1.5rem; }
.rail-nav a { padding: 0.45rem 0.6rem; border-radius: 0.5rem; }
.rail-nav a.active { background: rgba(255,255,255,0.12); }
.rail-label {
    margin: 1rem 0 0.3rem;
    font-size: 0.7rem;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #9fb3ad;
}
.rail-user { margin-top: auto; padding-top: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.rail-version { font-size: 0.75rem; opacity: 0.75; }
.rail-user .linkish { color: #f0c7a8; text-align: left; }

.app-main { flex: 1; min-width: 0; }
.app-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-end; padding: 1.5rem 1.25rem 0.5rem; }

.meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; }
.meta dt { color: var(--muted); font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; }
.meta dd { margin: 0.15rem 0 0; font-weight: 600; }

.walkthrough { margin: 2.25rem 0 1rem; }
.walkthrough h2 { margin-top: 0.2rem; }
.walkthrough-shot {
    margin: 1.5rem 0 0;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 1.1rem;
    padding: 0.85rem 0.85rem 1rem;
    box-shadow: var(--shadow);
}
.walkthrough-shot img {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 0.7rem;
    border: 1px solid var(--line);
    background: #ece6da;
}
.walkthrough-shot figcaption {
    margin: 0.75rem 0.35rem 0.15rem;
    color: var(--muted);
    font-size: 0.98rem;
}

.site-foot a { font-weight: 600; }

.icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.2rem;
    height: 2.2rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 0.6rem;
    background: #fff;
    color: var(--spruce);
    cursor: pointer;
}
.icon-btn svg { width: 1.2rem; height: 1.2rem; }
.icon-btn:hover { background: #eef4ef; }
.idle-back { z-index: 40; }
.modal-back {
    position: fixed;
    inset: 0;
    background: rgba(28, 36, 32, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 20;
}
.log-detail { max-width: 40rem; width: 100%; max-height: 80vh; overflow: auto; }
.edit-panel { max-width: 36rem; width: 100%; max-height: 85vh; overflow: auto; }
.log-body {
    white-space: pre-wrap;
    word-break: break-word;
    background: #f7f3ea;
    border-radius: 0.6rem;
    padding: 0.8rem 1rem;
    margin: 0.3rem 0 1rem;
}

.ticket header { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; margin-bottom: 0.5rem; }
.boot { padding: 3rem; text-align: center; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#blazor-error-ui {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 0.8rem 1rem;
    background: var(--danger);
    color: white;
}
#blazor-error-ui.show { display: block; }

.period-row, .stat-row { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.stat-btn, .row-btn {
    border: 1px solid var(--line);
    background: var(--card);
    color: var(--ink);
    font: inherit;
    text-align: left;
    cursor: pointer;
    border-radius: 12px;
}
.stat-btn { padding: 0.7rem 0.9rem; min-width: 8.5rem; }
.stat-btn strong, .row-btn strong { display: block; font-size: 1.25rem; color: var(--spruce); }
.stat-btn small { display: block; color: var(--muted); }
.stat-btn[aria-pressed="true"], .row-btn[aria-pressed="true"] { border-color: var(--spruce); }
.row-btn { background: none; border: 0; padding: 0; border-radius: 0; }
.usage-table td { vertical-align: top; }

@media (max-width: 860px) {
    .shell-app { flex-direction: column; }
    .rail { width: auto; min-height: 0; }
    .rail-nav { flex-direction: row; flex-wrap: wrap; }
    .grid-3, .grid-2 { grid-template-columns: 1fr; }
    .app-head { flex-direction: column; align-items: flex-start; }
    .topbar { flex-wrap: wrap; }
}
