/* SetLocale – design system. Tokens first, components after. */
:root {
  --bg: #f6f7fb; --surface: #ffffff; --surface-2: #f1f3f9; --border: #e3e6ef; --border-strong: #cfd4e2;
  --text: #0f172a; --text-2: #475569; --text-3: #8591a8;
  --brand: #4f46e5; --brand-600: #4338ca; --brand-50: #eef2ff; --brand-ink: #ffffff;
  --ok: #059669; --ok-bg: #ecfdf5; --warn: #b45309; --warn-bg: #fffbeb; --err: #dc2626; --err-bg: #fef2f2;
  --radius: 12px; --radius-sm: 8px; --shadow: 0 1px 2px rgba(15,23,42,.05), 0 4px 16px rgba(15,23,42,.05);
  --shadow-lg: 0 10px 40px rgba(15,23,42,.18);
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sidebar: 248px; --topbar: 60px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0b1020; --surface: #121933; --surface-2: #19213f; --border: #243055; --border-strong: #33416e;
  --text: #e8ecf8; --text-2: #aab4d0; --text-3: #7783a6;
  --brand: #818cf8; --brand-600: #6366f1; --brand-50: #1b2147; --brand-ink: #0b1020;
  --ok: #34d399; --ok-bg: #0f2a24; --warn: #fbbf24; --warn-bg: #2b2210; --err: #f87171; --err-bg: #2d1518;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.25); --shadow-lg: 0 10px 40px rgba(0,0,0,.55);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.55 var(--font); background: var(--bg); color: var(--text); }
a { color: var(--brand); text-decoration: none; } a:hover { text-decoration: underline; }
h1,h2,h3 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 1em; } hr { border: 0; border-top: 1px solid var(--border); margin: 1.2rem 0; }
code, .mono { font-family: var(--mono); font-size: .86em; }
.ic { flex: none; vertical-align: -3px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); } .small { font-size: .85rem; }
.right { margin-left: auto; } .nowrap { white-space: nowrap; } .center { text-align: center; }
.stack > * + * { margin-top: 1rem; } .row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.grid { display: grid; gap: 1rem; } .grid.c2 { grid-template-columns: repeat(2, 1fr); } .grid.c3 { grid-template-columns: repeat(3, 1fr); } .grid.c4 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 900px) { .grid.c3, .grid.c4 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px) { .grid.c2, .grid.c3, .grid.c4 { grid-template-columns: 1fr; } }

/* ---------- shell ---------- */
.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar); display: flex; align-items: center; gap: 1rem; padding: 0 1.25rem;
  background: color-mix(in srgb, var(--surface) 88%, transparent); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 700; color: var(--text); font-size: 1.05rem; } .brand:hover { text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #6366f1, #8b5cf6); }
.topnav { display: flex; gap: .25rem; margin-left: 1rem; } .topnav a { color: var(--text-2); padding: .4rem .7rem; border-radius: 8px; font-weight: 500; } .topnav a:hover { background: var(--surface-2); text-decoration: none; }
.search-btn { display: flex; align-items: center; gap: .6rem; min-width: 260px; padding: .45rem .75rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--text-3); cursor: pointer; font: inherit; }
.search-btn:hover { border-color: var(--border-strong); } kbd { font: 600 .72rem var(--font); padding: .1rem .4rem; border: 1px solid var(--border-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--text-2); margin-left: auto; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.menu { position: relative; } .menu > summary { list-style: none; cursor: pointer; } .menu > summary::-webkit-details-marker { display: none; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 8px); min-width: 220px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: .4rem; z-index: 40; }
.menu-pop a, .menu-pop button { display: flex; align-items: center; gap: .6rem; width: 100%; padding: .55rem .7rem; border-radius: 8px; color: var(--text); background: none; border: 0; font: inherit; cursor: pointer; text-align: left; }
.menu-pop a:hover, .menu-pop button:hover { background: var(--surface-2); text-decoration: none; } .menu-pop .who { padding: .6rem .7rem; border-bottom: 1px solid var(--border); margin-bottom: .3rem; }
.avatar { width: 32px; height: 32px; border-radius: 50%; object-fit: cover; background: var(--surface-2); }
.langsw a { padding: .25rem .5rem; border-radius: 6px; font-weight: 600; font-size: .8rem; color: var(--text-3); } .langsw a.on { background: var(--brand-50); color: var(--brand); text-decoration: none; }

.layout { display: flex; min-height: calc(100vh - var(--topbar)); }
.sidebar { width: var(--sidebar); flex: none; padding: 1rem .75rem; border-right: 1px solid var(--border); background: var(--surface); position: sticky; top: var(--topbar); height: calc(100vh - var(--topbar)); overflow: auto; }
.nav-badge { margin-left: auto; min-width: 20px; padding: 0 .4rem; height: 20px; line-height: 20px; border-radius: 99px; background: var(--err); color: #fff; font-size: .72rem; font-weight: 700; text-align: center; }
.sidebar h6 { margin: 1.2rem .7rem .4rem; font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); }
.sidebar a { position: relative; display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 9px; color: var(--text-2); font-weight: 500; }
.sidebar a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; } .sidebar a.active { background: var(--brand-50); color: var(--brand); }
.main { flex: 1; min-width: 0; padding: 1.75rem clamp(1rem, 3vw, 2.5rem) 3rem; } .container { max-width: 1180px; margin: 0 auto; } .narrow { max-width: 720px; }
.sidebar-toggle { display: none; }
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 35; left: 0; top: var(--topbar); transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow-lg); }
  body.nav-open .sidebar { transform: none; } .sidebar-toggle { display: inline-grid; } .topnav, .search-btn span, .search-btn kbd { display: none; } .search-btn { min-width: 0; padding: .45rem; }
}
.page-head { display: flex; align-items: flex-start; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; } .page-head h1 { margin: 0; } .page-head .actions { margin-left: auto; display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .85rem; color: var(--text-3); margin-bottom: .35rem; } .crumbs a { color: var(--text-2); }
footer.site { padding: 1.5rem; text-align: center; color: var(--text-3); font-size: .85rem; border-top: 1px solid var(--border); }

/* ---------- components ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-body { padding: 1.25rem; } .card-head { display: flex; align-items: center; gap: .75rem; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); } .card-head h2 { margin: 0; }
.stat { padding: 1.1rem 1.25rem; } .stat .n { font-size: 1.9rem; font-weight: 700; letter-spacing: -.02em; } .stat .l { color: var(--text-2); font-size: .85rem; display: flex; align-items: center; gap: .4rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .5rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: 600 .92rem var(--font); cursor: pointer; transition: .12s; white-space: nowrap; }
.btn:hover { background: var(--surface-2); text-decoration: none; } .btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .btn.primary:hover { background: var(--brand-600); }
.btn.danger { color: var(--err); } .btn.danger:hover { background: var(--err-bg); } .btn.sm { padding: .3rem .65rem; font-size: .82rem; border-radius: 8px; } .btn.block { width: 100%; } .btn.ghost { border-color: transparent; background: transparent; }
label.field { display: block; font-weight: 600; font-size: .86rem; margin-bottom: .35rem; }
.input, select.input, textarea.input { width: 100%; padding: .6rem .8rem; border: 1px solid var(--border-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; outline: none; transition: .12s; }
.input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 22%, transparent); } textarea.input { resize: vertical; min-height: 80px; }
.field-row { margin-bottom: 1rem; } .hint { font-size: .8rem; color: var(--text-3); margin-top: .3rem; }
.pw { position: relative; } .pw .input { padding-right: 2.6rem; } .pw button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); }
.meter { height: 5px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: .5rem; } .meter i { display: block; height: 100%; width: 0; background: var(--err); transition: .2s; }
.alert { padding: .75rem 1rem; border-radius: 10px; border: 1px solid; margin-bottom: 1rem; display: flex; gap: .6rem; align-items: flex-start; }
.alert.err { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 35%, transparent); color: var(--err); }
.alert.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 35%, transparent); color: var(--ok); }
.alert.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 35%, transparent); color: var(--warn); }
.alert ul { margin: 0; padding-left: 1.1rem; }
.field-err { color: var(--err); font-size: .82rem; margin-top: .3rem; display: block; }
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .12rem .55rem; border-radius: 99px; font-size: .75rem; font-weight: 600; background: var(--surface-2); color: var(--text-2); }
.badge.ok { background: var(--ok-bg); color: var(--ok); } .badge.warn { background: var(--warn-bg); color: var(--warn); } .badge.err { background: var(--err-bg); color: var(--err); } .badge.brand { background: var(--brand-50); color: var(--brand); }
.chip { display: inline-flex; padding: .1rem .5rem; border-radius: 6px; background: var(--brand-50); color: var(--brand); font-size: .78rem; font-weight: 600; } .chip:hover { text-decoration: none; }
.table-wrap { overflow: auto; } table.t { width: 100%; border-collapse: collapse; } .t th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-3); padding: .65rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.t td { padding: .7rem 1rem; border-bottom: 1px solid var(--border); vertical-align: top; } .t tr:last-child td { border-bottom: 0; } .t tbody tr:hover { background: color-mix(in srgb, var(--brand-50) 50%, transparent); }
.empty { text-align: center; padding: 3rem 1rem; color: var(--text-2); } .empty .ic { opacity: .5; margin-bottom: .5rem; }
.pager { display: flex; align-items: center; gap: .5rem; justify-content: center; padding: 1rem; color: var(--text-2); }
.toolbar { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-bottom: 1rem; } .toolbar .input { max-width: 340px; }
.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1.25rem; } .tabs a { padding: .6rem .9rem; color: var(--text-2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; } .tabs a.on { color: var(--brand); border-color: var(--brand); } .tabs a:hover { text-decoration: none; color: var(--text); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; } .progress i { display: block; height: 100%; background: linear-gradient(90deg, #6366f1, #8b5cf6); }
.token-box { display: flex; gap: .5rem; align-items: center; padding: .7rem .9rem; border: 1px dashed var(--brand); border-radius: 10px; background: var(--brand-50); } .token-box code { flex: 1; word-break: break-all; font-size: .95rem; color: var(--text); }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; } .bars i { flex: 1; background: linear-gradient(180deg, #818cf8, #6366f1); border-radius: 4px 4px 0 0; min-height: 3px; opacity: .85; }

/* row actions: equal-height buttons, even spacing, right aligned */
.row-actions { display: flex; align-items: center; justify-content: flex-end; gap: .5rem; }
.btn.sm { min-height: 34px; padding: .35rem .8rem; }
.btn.soft { background: var(--brand-50); border-color: transparent; color: var(--brand); }
.btn.soft:hover { background: color-mix(in srgb, var(--brand) 18%, var(--brand-50)); }
.btn.outline-quiet { background: transparent; color: var(--text-2); }
.btn.outline-quiet:hover { color: var(--text); background: var(--surface-2); }
td.actions-cell { width: 1%; white-space: nowrap; vertical-align: middle; }
.t td { vertical-align: middle; }

/* inline translation editor */
.kv { min-width: 190px; } .kv textarea { width: 100%; border: 1px solid transparent; background: transparent; padding: .35rem .5rem; border-radius: 8px; font: inherit; color: var(--text); resize: none; overflow: hidden; min-height: 34px; line-height: 1.4; }
.kv textarea:hover { border-color: var(--border); } .kv textarea:focus { outline: none; border-color: var(--brand); background: var(--surface); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 20%, transparent); }
.kv textarea.empty-v { background: var(--warn-bg); } .kv textarea.saving { border-color: var(--warn); } .kv textarea.saved { border-color: var(--ok); } .kv textarea.failed { border-color: var(--err); }
.kv textarea[readonly] { cursor: default; } .keycell { min-width: 210px; } .keycell .k { font-family: var(--mono); font-size: .85rem; font-weight: 600; word-break: break-all; }
.lang-pick { display: flex; flex-wrap: wrap; gap: .35rem; } .lang-pick label { cursor: pointer; } .lang-pick input { position: absolute; opacity: 0; } .lang-pick span { display: inline-block; padding: .22rem .6rem; border-radius: 99px; border: 1px solid var(--border-strong); font-size: .8rem; font-weight: 600; color: var(--text-2); } .lang-pick input:checked + span { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); } .lang-pick input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }

/* dialog, palette, toast */
dialog { border: 0; padding: 0; border-radius: 16px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg); width: min(520px, calc(100vw - 2rem)); } dialog::backdrop { background: rgba(8,12,28,.55); backdrop-filter: blur(2px); }
.dlg-head { display: flex; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); } .dlg-head h3 { margin: 0; } .dlg-body { padding: 1.25rem; } .dlg-foot { padding: 1rem 1.25rem; border-top: 1px solid var(--border); display: flex; gap: .5rem; justify-content: flex-end; }
#palette { width: min(640px, calc(100vw - 2rem)); margin-top: 12vh; } #palette input { width: 100%; border: 0; border-bottom: 1px solid var(--border); padding: 1rem 1.25rem; font: inherit; font-size: 1.05rem; background: transparent; color: var(--text); outline: none; }
#palette ul { list-style: none; margin: 0; padding: .4rem; max-height: 50vh; overflow: auto; } #palette li a { display: block; padding: .6rem .8rem; border-radius: 9px; color: var(--text); } #palette li a:hover, #palette li a.sel { background: var(--brand-50); text-decoration: none; } #palette .hint { padding: 1rem 1.25rem; margin: 0; }
#toasts { position: fixed; right: 1rem; bottom: 1rem; z-index: 100; display: grid; gap: .5rem; } .toast { background: var(--text); color: var(--bg); padding: .7rem 1rem; border-radius: 10px; box-shadow: var(--shadow-lg); animation: tin .2s; max-width: 380px; } .toast.err { background: var(--err); color: #fff; } @keyframes tin { from { opacity: 0; transform: translateY(8px); } }

/* auth + landing */
.auth-wrap { min-height: calc(100vh - var(--topbar)); display: grid; place-items: center; padding: 2rem 1rem; background: radial-gradient(900px 400px at 50% -10%, color-mix(in srgb, var(--brand) 14%, transparent), transparent); }
.auth-card { width: min(440px, 100%); padding: 2rem; } .auth-card h1 { font-size: 1.45rem; } .auth-icon { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); margin-bottom: 1rem; } .auth-icon.ok { background: var(--ok-bg); color: var(--ok); } .auth-icon.err { background: var(--err-bg); color: var(--err); }
.hero { text-align: center; padding: 4.5rem 1rem 3rem; background: radial-gradient(900px 380px at 50% -10%, color-mix(in srgb, var(--brand) 18%, transparent), transparent); }
.hero h1 { font-size: clamp(2rem, 5vw, 3.2rem); max-width: 16ch; margin: 0 auto .8rem; letter-spacing: -.03em; } .hero p { max-width: 56ch; margin: 0 auto 1.6rem; color: var(--text-2); font-size: 1.08rem; }
.feature { padding: 1.3rem; } .feature .ic-wrap { width: 40px; height: 40px; border-radius: 11px; display: grid; place-items: center; background: var(--brand-50); color: var(--brand); margin-bottom: .8rem; }
pre.code { background: #0b1020; color: #e8ecf8; padding: 1rem 1.2rem; border-radius: 12px; overflow: auto; font: .85rem/1.6 var(--mono); margin: 0; }
