diff --git a/docs/ADMIN_V2_BASELINE.md b/docs/ADMIN_V2_BASELINE.md
index 244e694..bee75e1 100644
--- a/docs/ADMIN_V2_BASELINE.md
+++ b/docs/ADMIN_V2_BASELINE.md
@@ -162,6 +162,13 @@
- CI: `py_compile *.py`, `bash -n scripts/*.sh`, `py_compile scripts/*.py`, весь `tests/`.
- Тесты: `tests/test_requirements_split.py` — 3 passed.
+## 4.17. P2.1a/b — оболочка v2
+
+- `static/admin2/index.html`, `app.js`, `router.js`, `styles.css`, vendor Preact/htm; 5 разделов.
+- Абсолютные импорты `/static/admin2/...`; CSP без `unsafe-inline`; deep link `/admin/v2/customers` и F5.
+- Тесты: `tests/test_admin_v2_shell.py` — 3 passed (deep link, 5 разделов, отсутствие inline).
+- Backend-маршрут `/admin/v2` — P2.2, пока статика не подключена к main.
+
## 5. Следующий шаг
P0.0 design-gate → P0.1 backup/restore → P0.2 (release `feat/topup` отдельно, не в рамках выравнивания).
diff --git a/docs/PLAN_2026-11-06_admin_v2.md b/docs/PLAN_2026-11-06_admin_v2.md
index c4cb522..7e53b01 100644
--- a/docs/PLAN_2026-11-06_admin_v2.md
+++ b/docs/PLAN_2026-11-06_admin_v2.md
@@ -12,6 +12,7 @@
- P0.1 — прод-бэкап `2026-11-06_1632.gz` (2,7 МБ gz / 12 МБ), `integrity_check=ok`, users 24, messages 5397; `SMETA_USER/PASS` заданы (env-вход — реальный); индекс на копии 46 мс. Админка на копии открыта (`/admin` 200, users/stats/overview 200). Осталось: 5 вопросов владельца.
- P0.2 — выравнивание сделано; pre-release `feat/topup` проверен: 155 тестов зелёные, отчёт `docs/ADMIN_V2_TOPUP_PRERELEASE.md`; **релиз не начинался** (нужен go/no-go и тест-магазин).
- **P0.5 — готово:** спайк в `sandbox/admin-spike/`; Preact+htm: 8,7 КБ gzip, 106 строк, 37,2 мс; vanilla: 3,3 КБ, 116 строк, 34,5 мс; CSP 0 ошибок у обоих; решение — Preact+htm, fallback vanilla; ревью Зайкой 3 круга, последний без дефектов. `docs/ADMIN_V2_DECISIONS.md`.
+- **P2.1a/b — готово:** оболочка `/static/admin2/` (5 разделов, Preact+htm, абсолютные импорты), deep link + F5, CSP без inline, 3 теста; Зайка P2 (дубли путей/заголовков) исправлены.
- **P1.8b — готово:** `requirements-dev.txt` (pytest+playwright) и `requirements-prod-test.txt` (pytest без браузера); прод `requirements.txt` не тронут; 3 теста.
- **P1.10 — готово:** CI уже гоняет весь `tests/`; добавлена проверка синтаксиса `scripts/*.sh`/`scripts/*.py`.
- **P1.8 — частично:** `predeploy.sh` (prod только с копией и pytest, realpath+inode, migrate→gate→pytest; dev — полный набор), `deploy.sh --no-pull/--check/ROLLBACK_TAG/ROLLBACK_FLOOR` с отказом ниже/вне пола и `pip install` после отката. 7 тестов; Зайка P1 (exit-код, фиктивный тест HEAD, пол) исправлены.
diff --git a/static/admin2/app.js b/static/admin2/app.js
new file mode 100644
index 0000000..6674f86
--- /dev/null
+++ b/static/admin2/app.js
@@ -0,0 +1,34 @@
+import { h, render } from '/static/admin2/vendor/preact.module.js';
+import htm from '/static/admin2/vendor/htm.module.js';
+import { SECTIONS, sectionFromPath, hrefFor } from '/static/admin2/router.js';
+
+const html = htm.bind(h);
+const TITLES = {
+ today: ["Мой день", "Что требует внимания сегодня"],
+ customers: ["Клиенты", "Кто платит, кто ушёл и кого надо вернуть"],
+ money: ["Деньги", "Поступления, поток и обязательства"],
+ work: ["Работа", "Очередь, прогоны и сбои"],
+ system: ["Система", "Здоровье службы и настройки"],
+};
+const section = sectionFromPath(location.pathname);
+const [title, subtitle] = TITLES[section]
+ || [SECTIONS.find(([key]) => key === section)?.[1] || 'Раздел', ''];
+
+const App = () => html`
+
+
+
+
${title}
${subtitle}
+
+
Раздел готовится
+
Оболочка v2. Данные и действия подключит следующий этап.
+
+
+
`;
+
+render(html`<${App} />`, document.getElementById('app'));
diff --git a/static/admin2/index.html b/static/admin2/index.html
new file mode 100644
index 0000000..fef5f07
--- /dev/null
+++ b/static/admin2/index.html
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+Кокпит — smeta-web
+
+
+
+
+
+
+
diff --git a/static/admin2/router.js b/static/admin2/router.js
new file mode 100644
index 0000000..f4bb9da
--- /dev/null
+++ b/static/admin2/router.js
@@ -0,0 +1,20 @@
+export const BASE = "/admin/v2";
+export const SECTIONS = [
+ ["today", "Мой день", BASE],
+ ["customers", "Клиенты", `${BASE}/customers`],
+ ["money", "Деньги", `${BASE}/money`],
+ ["work", "Работа", `${BASE}/work`],
+ ["system", "Система", `${BASE}/system`],
+];
+
+export function sectionFromPath(pathname) {
+ const clean = (pathname || "").replace(/\/+$/, "");
+ if (clean === BASE || clean === `${BASE}/today`) return "today";
+ const found = SECTIONS.find(([, , href]) => clean === href);
+ return found ? found[0] : "today";
+}
+
+export function hrefFor(section) {
+ const found = SECTIONS.find(([key]) => key === section);
+ return found ? found[2] : BASE;
+}
diff --git a/static/admin2/styles.css b/static/admin2/styles.css
new file mode 100644
index 0000000..0fd6c1a
--- /dev/null
+++ b/static/admin2/styles.css
@@ -0,0 +1,17 @@
+:root{--bg:#f5f6f8;--card:#fff;--ink:#1b2433;--muted:#667085;--line:#e3e7ee;--accent:#2457d6;--side:#111827}
+*{box-sizing:border-box}
+body{margin:0;background:var(--bg);color:var(--ink);font:14px/1.45 -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,sans-serif}
+.shell{display:flex;min-height:100vh}
+.side{width:220px;background:var(--side);color:#cfd6e4;padding:18px 12px;display:flex;flex-direction:column;gap:4px}
+.brand{color:#fff;text-decoration:none;font-weight:700;font-size:16px;padding:6px 10px 16px}
+.brand span{color:#7ea2ff}
+.nav-link{color:#cfd6e4;text-decoration:none;padding:9px 10px;border-radius:8px}
+.nav-link:hover{background:#1f2937;color:#fff}
+.nav-link.active{background:#2457d6;color:#fff}
+.main{flex:1;min-width:0;padding:22px 26px}
+.top h1{margin:0 0 4px;font-size:22px}
+.top p{margin:0 0 18px;color:var(--muted)}
+.card{background:var(--card);border:1px solid var(--line);border-radius:12px;padding:18px;max-width:760px}
+.card h2{margin:0 0 6px;font-size:16px}
+.card p{margin:0;color:var(--muted)}
+@media (max-width:720px){.shell{flex-direction:column}.side{width:auto;flex-direction:row;flex-wrap:wrap;align-items:center}.brand{padding:4px 10px;width:100%}.main{padding:16px}}
diff --git a/static/admin2/vendor/HTM-LICENSE b/static/admin2/vendor/HTM-LICENSE
new file mode 100644
index 0000000..f107611
--- /dev/null
+++ b/static/admin2/vendor/HTM-LICENSE
@@ -0,0 +1,202 @@
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright 2018 Google Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
\ No newline at end of file
diff --git a/static/admin2/vendor/PREACT-LICENSE b/static/admin2/vendor/PREACT-LICENSE
new file mode 100644
index 0000000..da5389a
--- /dev/null
+++ b/static/admin2/vendor/PREACT-LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) 2015-present Jason Miller
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
diff --git a/static/admin2/vendor/htm.module.js b/static/admin2/vendor/htm.module.js
new file mode 100644
index 0000000..4a6228f
--- /dev/null
+++ b/static/admin2/vendor/htm.module.js
@@ -0,0 +1 @@
+var n=function(t,s,r,e){var u;s[0]=0;for(var h=1;h=5&&((e||!n&&5===r)&&(h.push(r,0,e,s),r=6),n&&(h.push(r,n,0,s),r=6)),e=""},a=0;a"===t?(r=1,e=""):e=t+e[0]:u?t===u?u="":e+=t:'"'===t||"'"===t?u=t:">"===t?(p(),r=1):r&&("="===t?(r=5,s=e,e=""):"/"===t&&(r<5||">"===n[a][l+1])?(p(),3===r&&(h=h[0]),r=h,(h=h[0]).push(2,0,r),r=0):" "===t||"\t"===t||"\n"===t||"\r"===t?(p(),r=2):e+=t),3===r&&"!--"===e&&(r=4,h=h[0])}return p(),h}(s)),r),arguments,[])).length>1?r:r[0]}
diff --git a/static/admin2/vendor/preact.module.js b/static/admin2/vendor/preact.module.js
new file mode 100644
index 0000000..b862f2f
--- /dev/null
+++ b/static/admin2/vendor/preact.module.js
@@ -0,0 +1,2 @@
+var n,l,u,t,i,r,o,e,f,c,s,a,h,p={},v=[],y=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,d=Array.isArray;function w(n,l){for(var u in l)n[u]=l[u];return n}function _(n){n&&n.parentNode&&n.parentNode.removeChild(n)}function g(l,u,t){var i,r,o,e={};for(o in u)"key"==o?i=u[o]:"ref"==o?r=u[o]:e[o]=u[o];if(arguments.length>2&&(e.children=arguments.length>3?n.call(arguments,2):t),"function"==typeof l&&null!=l.defaultProps)for(o in l.defaultProps)void 0===e[o]&&(e[o]=l.defaultProps[o]);return m(l,e,i,r,null)}function m(n,t,i,r,o){var e={type:n,props:t,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__c:null,constructor:void 0,__v:null==o?++u:o,__i:-1,__u:0};return null==o&&null!=l.vnode&&l.vnode(e),e}function b(){return{current:null}}function k(n){return n.children}function x(n,l){this.props=n,this.context=l}function C(n,l){if(null==l)return n.__?C(n.__,n.__i+1):null;for(var u;lu&&i.sort(e));P.__r=0}function $(n,l,u,t,i,r,o,e,f,c,s){var a,h,y,d,w,_,g=t&&t.__k||v,m=l.length;for(f=I(u,l,g,f,m),a=0;a0?m(o.type,o.props,o.key,o.ref?o.ref:null,o.__v):o).__=n,o.__b=n.__b+1,e=null,-1!==(c=o.__i=L(o,u,f,a))&&(a--,(e=u[c])&&(e.__u|=2)),null==e||null===e.__v?(-1==c&&h--,"function"!=typeof o.type&&(o.__u|=4)):c!=f&&(c==f-1?h--:c==f+1?h++:(c>f?h--:h++,o.__u|=4))):n.__k[r]=null;if(a)for(r=0;r(null!=f&&0==(2&f.__u)?1:0))for(i=u-1,r=u+1;i>=0||r=0){if((f=l[i])&&0==(2&f.__u)&&o==f.key&&e===f.type)return i;i--}if(r2&&(f.children=arguments.length>3?n.call(arguments,2):t),m(l.type,f,i||l.key,r||l.ref,null)}function J(n,l){var u={__c:l="__cC"+h++,__:n,Consumer:function(n,l){return n.children(l)},Provider:function(n){var u,t;return this.getChildContext||(u=new Set,(t={})[l]=this,this.getChildContext=function(){return t},this.componentWillUnmount=function(){u=null},this.shouldComponentUpdate=function(n){this.props.value!==n.value&&u.forEach(function(n){n.__e=!0,M(n)})},this.sub=function(n){u.add(n);var l=n.componentWillUnmount;n.componentWillUnmount=function(){u&&u.delete(n),l&&l.call(n)}}),n.children}};return u.Provider.__=u.Consumer.contextType=u}n=v.slice,l={__e:function(n,l,u,t){for(var i,r,o;l=l.__;)if((i=l.__c)&&!i.__)try{if((r=i.constructor)&&null!=r.getDerivedStateFromError&&(i.setState(r.getDerivedStateFromError(n)),o=i.__d),null!=i.componentDidCatch&&(i.componentDidCatch(n,t||{}),o=i.__d),o)return i.__E=i}catch(l){n=l}throw n}},u=0,t=function(n){return null!=n&&null==n.constructor},x.prototype.setState=function(n,l){var u;u=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=w({},this.state),"function"==typeof n&&(n=n(w({},u),this.props)),n&&w(u,n),null!=n&&this.__v&&(l&&this._sb.push(l),M(this))},x.prototype.forceUpdate=function(n){this.__v&&(this.__e=!0,n&&this.__h.push(n),M(this))},x.prototype.render=k,i=[],o="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,e=function(n,l){return n.__v.__b-l.__v.__b},P.__r=0,f=/(PointerCapture)$|Capture$/i,c=0,s=O(!1),a=O(!0),h=0;export{x as Component,k as Fragment,G as cloneElement,J as createContext,g as createElement,b as createRef,g as h,E as hydrate,t as isValidElement,l as options,D as render,H as toChildArray};
+//# sourceMappingURL=preact.module.js.map
diff --git a/tests/test_admin_v2_shell.py b/tests/test_admin_v2_shell.py
new file mode 100644
index 0000000..0eb1cbb
--- /dev/null
+++ b/tests/test_admin_v2_shell.py
@@ -0,0 +1,84 @@
+"""Оболочка admin v2: 5 разделов, deep link, F5, CSP без inline."""
+import functools
+import http.server
+import os
+import socketserver
+import sys
+import threading
+from pathlib import Path
+
+import pytest
+
+ROOT = Path(__file__).resolve().parent.parent
+sys.path.insert(0, str(ROOT))
+sys.path.insert(0, str(ROOT / "tests"))
+pytest.importorskip("playwright.sync_api", reason="playwright не установлен")
+from test_admin_design_ui import browser # noqa: E402,F401
+
+
+class Handler(http.server.SimpleHTTPRequestHandler):
+ def __init__(self, *a, **kw):
+ super().__init__(*a, directory=str(ROOT), **kw)
+
+ def do_GET(self):
+ if self.path == "/admin/v2" or self.path.startswith("/admin/v2/"):
+ return self._file(ROOT / "static" / "admin2" / "index.html")
+ return super().do_GET()
+
+ def _file(self, path: Path):
+ data = path.read_bytes()
+ self.send_response(200)
+ self.send_header("Content-Type", "text/html; charset=utf-8")
+ self.send_header("Content-Length", str(len(data)))
+ self.end_headers()
+ self.wfile.write(data)
+
+ def log_message(self, *a):
+ return
+
+
+@pytest.fixture(scope="module")
+def site():
+ class Quiet(socketserver.ThreadingTCPServer):
+ allow_reuse_address = True
+ daemon_threads = True
+
+ srv = Quiet(("127.0.0.1", 0), Handler)
+ threading.Thread(target=srv.serve_forever, daemon=True).start()
+ yield f"http://127.0.0.1:{srv.server_address[1]}"
+ srv.shutdown()
+
+
+def test_deep_link_customers_and_f5(browser, site):
+ page = browser.new_page()
+ errors = []
+ page.on("pageerror", lambda e: errors.append(str(e)))
+ page.goto(site + "/admin/v2/customers")
+ page.wait_for_selector("h1")
+ assert page.locator("h1").inner_text() == "Клиенты"
+ assert page.locator(".nav-link.active").inner_text() == "Клиенты"
+ page.reload()
+ page.wait_for_selector("h1")
+ assert page.locator("h1").inner_text() == "Клиенты"
+ assert errors == []
+ page.close()
+
+
+def test_five_sections_navigate(browser, site):
+ page = browser.new_page()
+ page.goto(site + "/admin/v2")
+ page.wait_for_selector("h1")
+ assert page.locator("h1").inner_text() == "Мой день"
+ assert page.locator(".nav-link").count() == 5
+ page.click('a[href="/admin/v2/money"]')
+ page.wait_for_selector("h1")
+ assert page.locator("h1").inner_text() == "Деньги"
+ assert page.url.endswith("/admin/v2/money")
+ page.close()
+
+
+def test_shell_has_no_inline_or_unsafe_csp():
+ html = (ROOT / "static" / "admin2" / "index.html").read_text(encoding="utf-8")
+ assert "unsafe-inline" not in html
+ assert "