:root {
    --ink: #101828;
    --muted: #667085;
    --line: #e8eaef;
    --paper: #f5f6fa;
    --white: #ffffff;
    --blue: #2f6fed;
    --blue-2: #1d4ed8;
    --blue-soft: #eef3ff;
    --rail: #0b1220;
    --ok: #12b76a;
    --warn: #f79009;
    --bad: #f04438;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06);
    --radius: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body.app {
    margin: 0;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    background: var(--paper);
    color: var(--ink);
    display: grid;
    grid-template-columns: 76px 1fr;
}
a { color: inherit; }
button, input, textarea, select { font-family: inherit; }
.rail {
    background: var(--rail);
    color: #98a2b3;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0 12px;
    min-height: 100vh;
    position: sticky;
    top: 0;
}
.rail-logo {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    background: linear-gradient(180deg, #4c8dff, var(--blue));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    text-decoration: none;
    letter-spacing: -.04em;
    box-shadow: 0 8px 18px rgba(47, 111, 237, .35);
    margin-bottom: 18px;
}
.rail-nav {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    padding: 0 10px;
    flex: 1;
}
.rail-nav a {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    color: #98a2b3;
    border-radius: 12px;
    padding: 10px 4px 8px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .02em;
}
.rail-nav a svg { width: 22px; height: 22px; }
.rail-nav a:hover { color: #e7ebf3; background: rgba(255,255,255,.06); }
.rail-nav a.is-on { color: #fff; background: rgba(47, 111, 237, .22); }
.rail-badge {
    position: absolute;
    top: 6px;
    right: 10px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    border-radius: 99px;
    background: #f04438;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    font-style: normal;
}
.rail-foot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}
.rail-foot form { margin: 0; }
.rail-status, .rail-out {
    border: 0;
    background: transparent;
    color: #98a2b3;
    cursor: pointer;
    padding: 0;
}
.rail-ava {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #1d2939;
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 700;
    position: relative;
}
.rail-status.is-online .rail-ava::after {
    content: "";
    position: absolute;
    right: 0;
    bottom: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--ok);
    border: 2px solid var(--rail);
}
.rail-out { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 10px; }
.rail-out svg { width: 18px; height: 18px; }
.rail-out:hover { background: rgba(255,255,255,.06); color: #fff; }

.stage { min-width: 0; min-height: 100vh; }
.stage.is-flush { display: flex; flex-direction: column; background: #fff; }
.stage.is-page { padding: 28px 32px 56px; max-width: 1120px; }
.flash {
    margin: 16px 20px 0;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}
.stage.is-page .flash { margin: 0 0 16px; }
.flash.ok { background: #ecfdf3; color: #067647; }
.flash.bad { background: #fef3f2; color: #b42318; }

.page-head { margin-bottom: 22px; }
.page-head h1 { margin: 0; font-size: 28px; letter-spacing: -.04em; }
.page-head p { margin: 6px 0 0; color: var(--muted); }
.page-head-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
}

.stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin: 0 0 14px;
}
.stats-4 { grid-template-columns: repeat(4, 1fr); }
.stats article, .card {
    background: var(--white);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.stats article { padding: 18px 18px 16px; }
.stats span { color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: .02em; }
.stats strong { display: block; font-size: 28px; letter-spacing: -.04em; margin-top: 8px; }
.card { padding: 22px; margin-bottom: 16px; }
.card h2 { margin: 0 0 8px; font-size: 18px; letter-spacing: -.02em; }
.hint, .sub, .lead { color: var(--muted); font-size: 14px; line-height: 1.55; }
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-size: 13px; font-weight: 600; color: #344054; }
input[type=number], input[type=text], input[type=email], input[type=password], input[type=time], input[type=color], textarea, select {
    border: 1px solid #e4e7ec;
    background: #fff;
    color: var(--ink);
    border-radius: 12px;
    padding: 11px 13px;
    font: inherit;
    font-weight: 500;
    width: 100%;
    transition: border-color .15s, box-shadow .15s;
}
textarea { resize: vertical; min-height: 88px; line-height: 1.55; }
input:hover, textarea:hover, select:hover { border-color: #d0d5dd; }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 4px rgba(47, 111, 237, .14);
}
.check { flex-direction: row; align-items: center; gap: 8px; font-weight: 600; }
.mint, .btn-primary, .tiny, .btn-save {
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font: inherit;
    font-weight: 700;
}
.mint, .btn-save {
    background: var(--blue);
    color: #fff;
    padding: 11px 18px;
    box-shadow: 0 8px 16px rgba(47, 111, 237, .22);
}
.mint { width: 100%; }
.btn-save:hover, .mint:hover { background: var(--blue-2); }
.btn-save.sm { padding: 9px 14px; box-shadow: none; font-size: 13px; }
.btn-save[href] { display: inline-flex; align-items: center; text-decoration: none; }
.ghost, .btn {
    background: #fff;
    color: var(--ink);
    border: 1px solid var(--line);
    border-radius: 11px;
    padding: 10px 14px;
    cursor: pointer;
    font: inherit;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
.tiny {
    background: var(--blue-soft);
    color: var(--blue);
    padding: 8px 12px;
    text-decoration: none;
    display: inline-block;
    margin: 8px 8px 0 0;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }
.page-split {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 18px;
    align-items: start;
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.side-form { position: sticky; top: 20px; }
.form-card { margin-bottom: 0; }
.form-stack { display: grid; gap: 14px; margin-top: 14px; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
.form-grid.cols-title { grid-template-columns: minmax(0, 1fr) 120px; }
.field { display: flex; flex-direction: column; gap: 7px; margin: 0; font-size: 12px; font-weight: 700; color: #475467; }
.field > span { letter-spacing: .01em; }
.sheet {
    max-width: 860px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 18px;
    box-shadow: 0 8px 30px rgba(16, 24, 40, .04);
    overflow: hidden;
}
.sheet-create { scroll-margin-top: 12px; }
.sheet > form { display: none; }
.sheet-create, .sheet-row { border-bottom: 1px solid #f0f2f5; }
.sheet-create:last-child, .sheet-row:last-of-type { border-bottom: 0; }
.sheet-create summary, .sheet-row summary {
    list-style: none;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 18px;
    cursor: pointer;
    user-select: none;
}
.sheet-create summary::-webkit-details-marker,
.sheet-row summary::-webkit-details-marker { display: none; }
.sheet-create summary:hover, .sheet-row summary:hover { background: #fafbff; }
.sheet-row[open] summary { background: #f8f9fd; border-bottom: 1px solid #eef0f4; }
.plus {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    background: var(--blue-soft);
    color: var(--blue);
    display: grid;
    place-items: center;
    font-size: 18px;
    font-weight: 700;
    flex: none;
}
.sheet-create summary span:last-child { font-weight: 700; color: var(--blue); }
.idx {
    width: 28px;
    color: #98a2b3;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: .04em;
    flex: none;
}
.row-main { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 4px; }
.row-main strong { font-size: 14px; letter-spacing: -.02em; }
.row-chips, .row-preview { color: var(--muted); font-size: 12px; }
.row-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.row-chips em {
    font-style: normal;
    font-weight: 600;
    background: #f2f4f8;
    color: #475467;
    border-radius: 999px;
    padding: 2px 8px;
}
.row-preview {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d0d5dd;
    flex: none;
}
.dot.on { background: #12b76a; box-shadow: 0 0 0 3px rgba(18, 183, 106, .16); }
.chev { width: 18px; height: 18px; color: #98a2b3; flex: none; transition: transform .18s; }
.sheet-row[open] .chev, .sheet-create[open] .chev { transform: rotate(180deg); }
.sheet-edit { display: grid; gap: 12px; padding: 6px 18px 18px 58px; }
.sheet-create .sheet-edit { padding-left: 58px; }
.title-row { display: grid; grid-template-columns: 1fr 72px; gap: 8px; }
.title-input {
    font-size: 16px !important;
    font-weight: 700 !important;
    padding: 8px 0 !important;
    border: 0 !important;
    border-bottom: 1px solid #eaecf0 !important;
    border-radius: 0 !important;
    background: transparent !important;
    box-shadow: none !important;
}
.title-input:focus { border-bottom-color: var(--blue) !important; }
.sort-input { text-align: center; }
.chipbox {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    min-height: 44px;
    padding: 8px 10px;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    background: #fff;
    cursor: text;
}
.chipbox:focus-within { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(47, 111, 237, .14); }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    border: 0;
    background: var(--blue-soft);
    color: var(--blue);
    border-radius: 999px;
    padding: 4px 8px 4px 10px;
    font: inherit;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
}
.chip i { font-style: normal; opacity: .55; font-weight: 800; }
.chip-type {
    flex: 1;
    min-width: 140px;
    border: 0 !important;
    box-shadow: none !important;
    background: transparent !important;
    padding: 4px 2px !important;
    width: auto !important;
}
.sheet-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}
.sheet-actions-right { display: flex; align-items: center; gap: 8px; }
.sheet-empty { padding: 28px 18px; text-align: center; color: var(--muted); font-weight: 600; }
.btn-text {
    border: 0;
    background: transparent;
    color: var(--muted);
    font: inherit;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    padding: 6px 8px;
    border-radius: 8px;
}
.btn-text:hover { background: #f2f4f7; color: var(--ink); }
.btn-text.danger { color: #d92d20; }
.btn-text.danger:hover { background: #fef3f2; }
.kw-row { display: flex; flex-wrap: wrap; gap: 6px; }
.kw-row em {
    font-style: normal;
    font-size: 11px;
    font-weight: 700;
    background: var(--blue-soft);
    color: var(--blue);
    border-radius: 999px;
    padding: 3px 8px;
}
.switch {
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    gap: 10px;
    margin: 0;
    cursor: pointer;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    user-select: none;
}
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch i {
    width: 42px;
    height: 24px;
    background: #d0d5dd;
    border-radius: 99px;
    position: relative;
    flex: none;
    transition: background .18s;
}
.switch i:before {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    top: 3px;
    left: 3px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, .2);
    transition: transform .18s;
}
.switch input:checked + i { background: var(--blue); }
.switch input:checked + i:before { transform: translateX(18px); }
.hours-switch { margin: 8px 0 16px; }
.color-pair {
    display: grid;
    grid-template-columns: 48px 1fr;
    gap: 8px;
    align-items: center;
}
.color-pair input[type=color] {
    width: 48px;
    height: 44px;
    padding: 4px;
    border-radius: 12px;
    cursor: pointer;
    background: #f4f6fb;
}
.settings-form { display: grid; gap: 14px; margin-bottom: 16px; }
.form-sticky-bar {
    display: flex;
    justify-content: flex-end;
    position: sticky;
    bottom: 16px;
    z-index: 5;
}
.empty-card {
    background: #fff;
    border: 1px dashed #d0d5dd;
    border-radius: 16px;
    padding: 28px;
    text-align: center;
    color: var(--muted);
    font-weight: 600;
}
.tpl-body { margin: 0; color: #344054; line-height: 1.55; white-space: pre-wrap; }
.text-link { color: var(--blue); font-weight: 700; text-decoration: none; }
.text-link:hover { text-decoration: underline; }
.env {
    background: #0b1220;
    color: #d0d5dd;
    padding: 14px 16px;
    border-radius: 12px;
    overflow: auto;
    font-size: 13px;
}
.cta {
    display: block;
    text-decoration: none;
    color: #fff;
    background: linear-gradient(180deg, #4c8dff, var(--blue));
    border-radius: 16px;
    padding: 16px 18px;
    margin: 8px 0 16px;
    box-shadow: 0 10px 24px rgba(47, 111, 237, .22);
}
.cta span { display: block; font-size: 13px; opacity: .85; }
.kicker { margin: 0; letter-spacing: .16em; font-size: 11px; color: var(--blue); font-weight: 800; }

body.login-body {
    display: grid;
    place-items: center;
    min-height: 100vh;
    margin: 0;
    font-family: "Plus Jakarta Sans", system-ui, sans-serif;
    background:
        radial-gradient(900px 420px at 12% -10%, rgba(47,111,237,.18), transparent 50%),
        radial-gradient(700px 380px at 100% 110%, rgba(16,24,40,.08), transparent 45%),
        #eef1f6;
    color: var(--ink);
}
.login-card {
    width: min(420px, 92%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 22px;
    padding: 32px 28px;
    box-shadow: 0 24px 60px rgba(16, 24, 40, .12);
}
.login-mark {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(180deg, #4c8dff, var(--blue));
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 800;
    margin-bottom: 16px;
}
.login-card h1 { margin: 8px 0 6px; font-size: 28px; letter-spacing: -.04em; }
.login-card .mint { margin-top: 6px; }

@media (max-width: 980px) {
    .stats, .stats-4, .split, .form-grid.cols-2 { grid-template-columns: 1fr 1fr; }
    .page-split { grid-template-columns: 1fr; }
    .side-form { position: static; }
}
@media (max-width: 860px) {
    body.app {
        grid-template-columns: 1fr;
        padding-bottom: 72px;
    }
    .rail {
        position: fixed;
        z-index: 40;
        left: 0; right: 0; bottom: 0; top: auto;
        min-height: 0;
        height: 64px;
        flex-direction: row;
        padding: 0 8px;
        justify-content: space-between;
        border-top: 1px solid #1d2939;
    }
    .rail-logo, .rail-foot { display: none; }
    .rail-nav {
        flex-direction: row;
        justify-content: space-around;
        padding: 0;
        width: 100%;
    }
    .rail-nav a { flex: 1; padding: 8px 0; }
    .stage.is-page { padding: 18px 16px 88px; }
    .form-sticky-bar { bottom: 80px; }
}
@media (max-width: 640px) {
    .stats, .stats-4, .split, .form-grid.cols-2, .form-grid.cols-title, .title-row { grid-template-columns: 1fr; }
    .rule-foot { flex-direction: column; align-items: stretch; }
    .btn-save { width: 100%; justify-content: center; }
    .sheet-edit, .sheet-create .sheet-edit { padding-left: 18px; }
    .page-head-row { flex-direction: column; align-items: flex-start; }
}
