:root {
    --bg: #eef3f8;
    --panel: #ffffff;
    --panel-soft: #f7f9fc;
    --text: #152033;
    --muted: #64748b;
    --line: #d8e0ea;
    --brand: #2949c7;
    --brand-dark: #102b86;
    --danger: #dc3545;
    --success: #0f9f6e;
    --shadow: 0 18px 48px rgba(15, 23, 42, .12);
}

* { box-sizing: border-box; }
body {
    margin: 0;
    min-height: 100vh;
    color: var(--text);
    background:
        linear-gradient(rgba(41, 73, 199, .03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(41, 73, 199, .03) 1px, transparent 1px),
        var(--bg);
    background-size: 32px 32px;
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; text-decoration: none; }
button, input, textarea {
    font: inherit;
}

button {
    border: 0;
    min-height: 42px;
    padding: 0 18px;
    color: #fff;
    background: var(--brand);
    font-weight: 800;
    cursor: pointer;
}
button:hover { background: var(--brand-dark); }
button:disabled { opacity: .45; cursor: not-allowed; }
.primary { background: var(--brand); }
.danger { background: var(--danger); }
.publish { background: #111827; }

input, textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 13px 14px;
    outline: none;
}
select {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text);
    padding: 13px 14px;
    outline: none;
}
input:focus, textarea:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 3px rgba(41, 73, 199, .14);
}
textarea {
    min-height: 520px;
    resize: vertical;
    font-family: "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
    line-height: 1.55;
    tab-size: 4;
}
code {
    padding: 2px 6px;
    background: rgba(41, 73, 199, .08);
    color: var(--brand-dark);
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 28px;
}
.login-card {
    width: min(440px, 100%);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 34px;
}
.brand-mark {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    background: var(--brand);
    color: #fff;
    font-weight: 900;
    margin-bottom: 18px;
}
.login-card h1 { margin: 0 0 8px; }
.login-card p { margin: 0 0 26px; color: var(--muted); line-height: 1.5; }
.stack { display: grid; gap: 16px; }
.stack label { display: grid; gap: 8px; font-weight: 800; color: #334155; }

.topbar {
    height: 68px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    background: #06151f;
    color: #fff;
    border-bottom: 3px solid var(--brand);
}
.topbar div {
    display: flex;
    align-items: baseline;
    gap: 12px;
}
.topbar strong { font-size: 22px; }
.topbar span { color: #cbd5e1; }
.topbar nav {
    display: flex;
    align-items: center;
    gap: 18px;
}
.topbar nav a {
    padding: 10px 14px;
    background: rgba(255,255,255,.12);
}

.app-shell {
    display: grid;
    grid-template-columns: 290px minmax(0, 1fr);
    gap: 24px;
    padding: 24px;
}
.sidebar, .panel, .hero {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
}
.sidebar {
    min-height: calc(100vh - 116px);
    padding: 18px;
}
.sidebar h2 {
    margin: 4px 0 16px;
    font-size: 15px;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--muted);
}
.site-link {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid transparent;
    margin-bottom: 10px;
    background: var(--panel-soft);
}
.site-link.active {
    border-color: var(--brand);
    background: rgba(41, 73, 199, .08);
}
.site-link span { font-weight: 900; }
.site-link small { color: var(--muted); }
.policy-box {
    margin-top: 22px;
    padding: 14px;
    background: #ecfdf5;
    border: 1px solid #bbf7d0;
    color: #065f46;
}
.policy-box p { margin: 8px 0 0; line-height: 1.45; }

.workspace { min-width: 0; }
.hero {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 28px;
    margin-bottom: 20px;
}
.eyebrow {
    display: inline-block;
    color: var(--brand);
    font-weight: 900;
    margin-bottom: 8px;
}
.hero h1 {
    margin: 0 0 8px;
    font-size: clamp(30px, 4vw, 48px);
    letter-spacing: 0;
}
.hero p { margin: 0; color: var(--muted); }
.license {
    min-width: 210px;
    padding: 14px;
    color: #fff;
    background: var(--danger);
    text-align: right;
}
.license.ok { background: var(--success); }
.license strong, .license span { display: block; }
.license span { margin-top: 4px; opacity: .9; font-size: 13px; }

.grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 20px;
}
.panel { min-width: 0; }
.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    min-height: 70px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
}
.panel-header h2 { margin: 0; font-size: 18px; }
.preview-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--brand);
    font-weight: 800;
    font-size: 13px;
}
.create-form {
    display: grid;
    grid-template-columns: minmax(120px, 1fr) auto;
    gap: 8px;
}
.file-list {
    max-height: 690px;
    overflow: auto;
    padding: 12px;
}
.file-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 12px;
    border: 1px solid var(--line);
    background: #fff;
    margin-bottom: 8px;
}
.file-row.active {
    border-color: var(--brand);
    background: rgba(41, 73, 199, .07);
}
.file-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 800;
}
.file-row small { color: var(--muted); white-space: nowrap; }
.editor-form { padding: 18px; }
.editor-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 14px;
}
.delete-form {
    display: flex;
    justify-content: flex-start;
    padding: 0 18px 18px;
}
.alert {
    padding: 14px 16px;
    margin-bottom: 16px;
    border: 1px solid;
    font-weight: 800;
}
.alert.success {
    background: #ecfdf5;
    color: #065f46;
    border-color: #bbf7d0;
}
.alert.error {
    background: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}
.empty {
    color: var(--muted);
    padding: 12px;
}
.empty.big {
    min-height: 520px;
    display: grid;
    place-items: center;
    text-align: center;
}

.admin-shell {
    width: min(1320px, calc(100% - 48px));
    margin: 24px auto;
}
.admin-create {
    margin-bottom: 22px;
}
.user-form {
    display: grid;
    gap: 14px;
    padding: 18px;
}
.user-form label {
    display: grid;
    gap: 8px;
    font-weight: 800;
    color: #334155;
}
.user-form.compact {
    grid-template-columns: repeat(3, minmax(180px, 1fr));
    align-items: end;
}
.site-checks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    padding: 12px;
    background: var(--panel-soft);
    border: 1px solid var(--line);
}
.site-checks label,
.inline-check {
    display: flex !important;
    align-items: center;
    gap: 8px !important;
    color: var(--text) !important;
}
.site-checks input,
.inline-check input {
    width: auto;
}
.users-list {
    display: grid;
    gap: 18px;
}
.user-card {
    overflow: hidden;
}
.user-inline-actions {
    display: flex;
    gap: 10px;
    padding: 0 18px 18px;
}
.user-inline-actions input {
    max-width: 340px;
}
.badge {
    padding: 7px 10px;
    color: #fff;
    background: var(--danger);
    font-weight: 900;
    font-size: 12px;
}
.badge.ok {
    background: var(--success);
}

@media (max-width: 980px) {
    .user-form.compact { grid-template-columns: 1fr; }
    .user-inline-actions { flex-direction: column; }
    .user-inline-actions input { max-width: none; }
}

@media (max-width: 980px) {
    .app-shell, .grid { grid-template-columns: 1fr; }
    .sidebar { min-height: auto; }
    .hero { align-items: flex-start; flex-direction: column; }
    .license { text-align: left; width: 100%; }
}
