:root {
    --bg: #0f0e14;
    --surface: #1a1824;
    --surface2: #232130;
    --line: #322e42;
    --fg: #f2f0f8;
    --muted: #9c98ae;
    --accent: #7c5cff;
    --ok: #22b573;
    --err: #e5484d;
    --radius: 12px;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--bg);
    color: var(--fg);
    font-family: Vazirmatn, "Segoe UI", Tahoma, system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.7;
}

body.centered {
    display: flex;
    min-height: 100vh;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

/* ------------------------------------------------------------- هدر */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand strong { display: block; font-size: 16px; }
.brand span { display: block; color: var(--muted); font-size: 12.5px; }

.logo {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: contain;
    background: var(--surface2);
}
.logo.big { width: 68px; height: 68px; }

.topbar nav { display: flex; gap: 8px; }

main { max-width: 980px; margin: 0 auto; padding: 24px; }

.foot {
    max-width: 980px;
    margin: 0 auto;
    padding: 8px 24px 40px;
    color: var(--muted);
    font-size: 12.5px;
}

/* ------------------------------------------------------------ دکمه */
.btn {
    display: inline-block;
    border: 1px solid var(--line);
    background: var(--surface2);
    color: var(--fg);
    padding: 9px 16px;
    border-radius: 10px;
    text-decoration: none;
    font: inherit;
    font-size: 14px;
    cursor: pointer;
    transition: filter .15s ease;
}
.btn:hover { filter: brightness(1.15); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.ghost { background: transparent; }
.btn.block { width: 100%; }

/* ------------------------------------------------------------ فرم */
.login {
    width: 100%;
    max-width: 380px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 28px;
    text-align: center;
}
.login h1 { font-size: 19px; margin: 14px 0 4px; }
.login .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login label { display: block; text-align: right; margin-bottom: 14px; font-size: 13px; }

.settings { display: flex; flex-direction: column; gap: 20px; }

.group {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 18px 20px 8px;
}
.group h2 {
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 16px;
    margin: 0 0 4px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--line);
}
.group h2 .ico { font-size: 18px; }
.group h2 small { color: var(--muted); font-weight: 400; font-size: 12px; }
.group-help { color: var(--muted); font-size: 13px; margin: 10px 0 0; }

.field { margin: 16px 0; }
.lbl { display: block; font-size: 13.5px; font-weight: 600; margin-bottom: 5px; }
.help { color: var(--muted); font-size: 12.5px; margin: 4px 0 0; }

input[type=text],
input[type=password],
input[type=number],
input[type=file],
textarea {
    width: 100%;
    background: var(--surface2);
    border: 1px solid var(--line);
    color: var(--fg);
    border-radius: 9px;
    padding: 9px 12px;
    font: inherit;
    font-size: 14px;
}
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; line-height: 1.7; }
textarea.code {
    font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
    font-size: 13px;
}

/* ------------------------------------------- فیلد دوزبانه */
.langs { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.langbox { position: relative; }
.langtag {
    position: absolute;
    top: 7px;
    inset-inline-end: 10px;
    font-size: 11px;
    color: var(--muted);
    pointer-events: none;
    z-index: 1;
}
.langbox input, .langbox textarea { padding-top: 22px; }
.langbox.en input, .langbox.en textarea { direction: ltr; text-align: left; }

@media (max-width: 640px) {
    .langs { grid-template-columns: 1fr; }
}

/* -------------------------------------------------------- سوییچ */
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.track {
    width: 46px;
    height: 26px;
    border-radius: 999px;
    background: var(--surface2);
    border: 1px solid var(--line);
    position: relative;
    transition: background .18s ease, border-color .18s ease;
    flex: 0 0 auto;
}
.thumb {
    position: absolute;
    top: 2px;
    inset-inline-start: 2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--muted);
    transition: transform .18s ease, background .18s ease;
}
.switch input:checked + .track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .track .thumb { background: #fff; transform: translateX(-20px); }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }
.switchlabel { font-size: 13px; color: var(--muted); }

/* --------------------------------------------------------- لوگو */
.imagepick { display: flex; flex-direction: column; gap: 10px; }
.imagepick .preview {
    width: 96px;
    height: 96px;
    border-radius: 14px;
    object-fit: contain;
    background: var(--surface2);
    border: 1px solid var(--line);
}

/* -------------------------------------------------------- هشدار */
.alert {
    border-radius: 10px;
    padding: 11px 14px;
    margin: 0 0 18px;
    font-size: 13.5px;
    border: 1px solid;
}
.alert.ok { background: rgba(34, 181, 115, .12); border-color: var(--ok); color: #7fe0b0; }
.alert.error { background: rgba(229, 72, 77, .12); border-color: var(--err); color: #ffa0a2; }
.alert code { display: block; margin-top: 6px; font-size: 12px; opacity: .85; }

.savebar {
    position: sticky;
    bottom: 0;
    display: flex;
    gap: 10px;
    padding: 14px 0;
    background: linear-gradient(to top, var(--bg) 65%, transparent);
}
.savebar .btn { min-width: 140px; }
