:root {
    --bg: #f5f6f9;
    --surface: #ffffff;
    --text: #1d2433;
    --muted: #5b6475;
    --line: #e1e5ee;
    --accent: #3b5bdb;
    --accent-text: #ffffff;
    --ok: #1f9d6b;
    --off: #8a93a6;
    --danger: #c92a2a;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12151c;
        --surface: #1b2029;
        --text: #e8ebf2;
        --muted: #9aa3b5;
        --line: #2a3140;
        --accent: #6c8cff;
        --accent-text: #0e1220;
        --ok: #3ccf94;
        --off: #7b849a;
        --danger: #ff6b6b;
    }
}

* { box-sizing: border-box; }

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

.sp-brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    letter-spacing: .2px;
    color: var(--text);
    text-decoration: none;
}

.sp-brand-mark {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    background: var(--accent);
    display: inline-block;
}

.sp-auth-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.sp-auth { width: 100%; max-width: 400px; }
.sp-auth .sp-brand { margin-bottom: 18px; }

.sp-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 28px 24px;
}

.sp-title { margin: 0 0 4px; font-size: 22px; line-height: 1.25; }
.sp-sub { margin: 0 0 22px; color: var(--muted); }

.sp-field { margin-bottom: 16px; }
.sp-field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.sp-field input {
    width: 100%;
    padding: 11px 12px;
    font: inherit;
    color: var(--text);
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: 10px;
}
.sp-field input:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }
.sp-field input.is-invalid { border-color: var(--danger); }
.sp-error { color: var(--danger); font-size: 13px; margin-top: 6px; }

.sp-btn {
    width: 100%;
    padding: 12px 14px;
    font: inherit;
    font-weight: 600;
    color: var(--accent-text);
    background: var(--accent);
    border: 0;
    border-radius: 10px;
    cursor: pointer;
}
.sp-btn:hover { filter: brightness(1.06); }

.sp-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
}

.sp-user { display: flex; align-items: center; gap: 14px; }
.sp-user form { margin: 0; }
.sp-user-name { color: var(--muted); font-size: 14px; }
.sp-link {
    font: inherit;
    color: var(--accent);
    background: none;
    border: 0;
    padding: 0;
    cursor: pointer;
}

.sp-main { max-width: 1040px; margin: 0 auto; padding: 28px 20px 48px; }
.sp-head { margin-bottom: 22px; }

.sp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }

.sp-site {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    padding: 18px;
}
.sp-site-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.sp-site h2 { margin: 0; font-size: 16px; }
.sp-domain { display: inline-block; margin-top: 8px; color: var(--accent); text-decoration: none; word-break: break-all; }
.sp-domain:hover { text-decoration: underline; }

.sp-badge {
    flex: none;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 9px;
    border-radius: 999px;
    border: 1px solid currentColor;
}
.sp-badge.is-on { color: var(--ok); }
.sp-badge.is-off { color: var(--off); }

.sp-empty {
    display: grid;
    gap: 4px;
    padding: 28px;
    text-align: center;
    background: var(--surface);
    border: 1px dashed var(--line);
    border-radius: 14px;
    color: var(--muted);
}
.sp-empty strong { color: var(--text); }

.sp-captcha { display: flex; flex-direction: column; align-items: center; min-height: 78px; }


.sp-top { flex-wrap: wrap; }
.sp-nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; margin-left: 18px; }
.sp-nav a { padding: 6px 12px; border-radius: 8px; color: var(--muted); text-decoration: none; }
.sp-nav a:hover { color: var(--text); background: var(--bg); }
.sp-nav a.is-active { color: var(--text); background: var(--bg); font-weight: 600; }

.sp-head-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.sp-btn-inline { width: auto; display: inline-block; text-decoration: none; }
.sp-btn-quiet { background: var(--bg); color: var(--text); border: 1px solid var(--line); }
.sp-btn-danger { background: var(--danger); color: #fff; }
.sp-muted { color: var(--muted); }
.sp-mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }

.sp-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.sp-toolbar input, .sp-toolbar select, .sp-field select, .sp-field textarea {
    font: inherit; color: var(--text); background: var(--surface);
    border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.sp-toolbar input[type="search"] { flex: 1; min-width: 180px; }
.sp-field select, .sp-field textarea { width: 100%; }
.sp-field textarea:focus, .sp-field select:focus, .sp-toolbar *:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.sp-field small { display: block; margin-top: 5px; }

.sp-tablewrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow-x: auto; }
.sp-table { width: 100%; border-collapse: collapse; }
.sp-table th, .sp-table td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.sp-table tr:last-child td { border-bottom: 0; }
.sp-table th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sp-table a { color: var(--text); font-weight: 600; text-decoration: none; }
.sp-table a:hover { color: var(--accent); }
.sp-actions { text-align: right; white-space: nowrap; }
.sp-badge.is-draft { color: var(--muted); }
.sp-pager { display: flex; align-items: center; justify-content: center; gap: 16px; margin-top: 16px; }

.sp-form-wide { max-width: 820px; }
.sp-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.sp-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 640px) { .sp-grid2 { grid-template-columns: 1fr; } }
.sp-checks { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.sp-check { display: inline-flex; align-items: center; gap: 8px; font-weight: 400; }
.sp-formfoot { margin-top: 8px; }
.sp-note { background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--accent); border-radius: 10px; padding: 12px 14px; margin-bottom: 18px; color: var(--muted); }

.sp-toasts { position: fixed; right: 16px; bottom: 16px; display: grid; gap: 8px; z-index: 50; max-width: min(380px, calc(100vw - 32px)); }
.sp-toast { background: var(--surface); color: var(--text); border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(0,0,0,.18); transition: opacity .25s, transform .25s; }
.sp-toast-warning { border-left-color: #e8a21a; }
.sp-toast-error { border-left-color: var(--danger); }
.sp-toast.is-out { opacity: 0; transform: translateY(6px); }

.sp-confirm { position: fixed; inset: 0; background: rgba(10, 14, 22, .55); display: grid; place-items: center; z-index: 60; padding: 16px; }
.sp-confirm-card { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 24px; width: min(420px, 100%); }
.sp-confirm-card p { margin: 0 0 18px; font-size: 16px; }
.sp-confirm-row { display: flex; justify-content: flex-end; gap: 8px; }

.sp-upload { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; background: var(--surface); border: 1px dashed var(--line); border-radius: 14px; padding: 14px; margin-bottom: 18px; }
.sp-upload input[type="file"] { flex: 1; min-width: 220px; color: var(--muted); }
.sp-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.sp-media { display: grid; gap: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px; text-decoration: none; color: var(--text); }
.sp-media:hover { border-color: var(--accent); }
.sp-media-thumb { aspect-ratio: 1 / 1; border-radius: 8px; background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.sp-media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.sp-media-type { font-style: normal; color: var(--muted); font-size: 13px; }
.sp-media-name { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-media-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: start; }
.sp-media-preview img { max-width: 100%; border-radius: 12px; border: 1px solid var(--line); }
@media (max-width: 760px) { .sp-media-detail { grid-template-columns: 1fr; } }
.sp-h2 { font-size: 17px; margin: 32px 0 12px; }

.sp-events { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.sp-events li { border-left: 2px solid var(--line); padding-left: 12px; }

.sp-editor { background: var(--surface); border-radius: 10px; }
.sp-editor .ql-container { min-height: 260px; font: inherit; font-size: 15px; }
.sp-editor .ql-toolbar, .sp-editor .ql-container { border-color: var(--line); }
.sp-editor .ql-snow .ql-stroke { stroke: var(--muted); }
.sp-editor .ql-snow .ql-fill { fill: var(--muted); }
.sp-editor .ql-snow .ql-picker { color: var(--muted); }
