:root {
    --bg: #f3f4f6;
    --panel: #ffffff;
    --line: #e2e5e9;
    --ink: #1b1e24;
    --muted: #6b7280;
    --accent: #15355c;
    --accent-ink: #ffffff;
    --gold: #c9a24a;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

a { color: var(--accent); text-decoration: none; }

.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #17181c;
}

.login-card {
    width: 320px;
    background: var(--panel);
    border-radius: 10px;
    padding: 28px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, .35);
}

.login-card h1 { font-size: 18px; margin: 4px 0 8px; }

.brand {
    font-weight: 700;
    letter-spacing: .08em;
    font-size: 15px;
    color: var(--ink);
}

.brand span {
    margin-left: 8px;
    font-weight: 500;
    letter-spacing: .02em;
    color: var(--gold);
    font-size: 12px;
    text-transform: uppercase;
}

.topbar {
    background: #17181c;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 20px;
    border-bottom: 2px solid var(--gold);
}

.topbar .brand { color: #fff; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.topbar .user { color: #cbd2da; font-size: 12px; letter-spacing: .04em; text-transform: uppercase; }

.layout {
    display: grid;
    grid-template-columns: 280px minmax(0, 1fr);
    align-items: start;
    max-width: 1400px;
    margin: 0 auto;
    padding: 18px;
    gap: 18px;
}

.sidebar { position: sticky; top: 18px; display: flex; flex-direction: column; gap: 16px; }

.group { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 8px; }

.group-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    padding: 6px 8px;
}

.tpl {
    display: block;
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--ink);
    border: 1px solid transparent;
}

.tpl strong { display: block; font-size: 13px; font-weight: 600; }
.tpl span { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }
.tpl:hover { background: #f2f5f9; }
.tpl.active { background: #eaf0f8; border-color: #c9d7ea; }
.tpl.recent strong { font-size: 12px; }

.main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }

.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; }
.page-head h1 { font-size: 22px; margin: 0; }
.sub { margin: 4px 0 0; color: var(--muted); }

.price-chip {
    background: #17181c;
    color: #fff;
    border-radius: 6px;
    padding: 7px 12px;
    font-weight: 600;
    font-size: 13px;
    white-space: nowrap;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card h2 { font-size: 14px; margin: 0; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }

.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }

.editor { display: flex; flex-direction: column; gap: 16px; }

.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid2.tight { grid-template-columns: 100px minmax(0, 1fr); gap: 8px; }

label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 600; }

input[type="text"], input[type="email"], input[type="date"], input[type="number"], select, textarea {
    border: 1px solid #cfd5dc;
    border-radius: 6px;
    padding: 8px 10px;
    font: inherit;
    font-size: 14px;
    color: var(--ink);
    background: #fff;
    width: 100%;
}

input:focus, textarea:focus { outline: 2px solid #bfd2ea; outline-offset: -1px; }

textarea {
    resize: vertical;
    line-height: 1.55;
    font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
    font-size: 13px;
    min-height: 420px;
}

.more { border-top: 1px solid var(--line); padding-top: 12px; }
.more summary {
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
    letter-spacing: .04em;
    text-transform: uppercase;
    list-style: none;
}
.more summary::-webkit-details-marker { display: none; }
.more summary::before { content: "+ "; }
.more[open] summary::before { content: "– "; }
.more summary:hover { color: var(--ink); }
.more > * + * { margin-top: 12px; }

.hint { color: var(--muted); font-size: 12px; margin: 0; }
.hint code { background: #eef1f5; border-radius: 4px; padding: 0 4px; }

.actions { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }

.btn {
    display: inline-block;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 9px 16px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    background: #e8ebef;
    color: var(--ink);
}

.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #1d4676; }
.btn-ghost { background: transparent; border-color: #cfd5dc; color: var(--ink); }
.btn-ghost:hover { background: #eef1f5; }
.topbar .btn-ghost { color: #e7ebf0; border-color: #3a3d44; }
.topbar .btn-ghost:hover { background: #26282e; }

.link { font-size: 13px; }

.alert {
    background: #fbecec;
    border: 1px solid #f0c4c4;
    color: #8a1f1f;
    border-radius: 6px;
    padding: 10px 12px;
    margin: 0;
}

.preview iframe {
    width: 100%;
    height: 900px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
}

@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; padding: 12px; }
    .sidebar { position: static; order: 2; }
    .grid2 { grid-template-columns: 1fr; }
    .grid2.tight { grid-template-columns: 100px minmax(0, 1fr); }
    .page-head { flex-direction: column; align-items: flex-start; }
    .preview iframe { height: 640px; }
}
