@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url(fonts/dm-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 600; font-display: swap; src: url(fonts/dm-sans-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url(fonts/dm-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Mono'; font-weight: 400; font-display: swap; src: url(fonts/dm-mono-latin-400-normal.woff2) format('woff2'); }

:root {
  --accent: #c9406e; --accent-hover: #b0345e; --accent-soft: #f8e6ed;
  --bg: #f6f6f7; --surface: #ffffff; --surface-2: #f1f1f3; --text: #17171a; --muted: #6b6b75;
  --border: #e3e3e8; --danger: #c62828; --ok: #2e7d32; --warn: #b26a00;
  --radius: 8px; --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.05);
  --font: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --mono: 'DM Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #131316; --surface: #1c1c21; --surface-2: #26262c; --text: #ececf0; --muted: #9a9aa6;
  --border: #33333b; --accent-soft: #3a1e29; --shadow: 0 1px 2px rgba(0,0,0,.3), 0 4px 16px rgba(0,0,0,.3);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: var(--font); font-size: 15px; line-height: 1.45; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .6em; }
h1 { font-size: 24px; } h2 { font-size: 19px; } h3 { font-size: 16px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.mono { font-family: var(--mono); }

/* Кнопки в фирменных цветах */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: inherit; font-weight: 600; font-size: 14px;
  padding: 9px 16px; border-radius: var(--radius); border: 1.5px solid var(--accent); background: var(--accent); color: #fff;
  cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .15s, border-color .15s, opacity .15s; }
.btn:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.secondary { background: var(--surface); color: var(--accent); }
.btn.secondary:hover { background: var(--accent-soft); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--text); font-weight: 500; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.danger { background: var(--surface); color: var(--danger); border-color: var(--danger); }
.btn.danger:hover { background: rgba(198,40,40,.08); }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn.block { width: 100%; }

/* Поля */
label { display: block; font-size: 13px; font-weight: 600; margin: 12px 0 5px; }
input[type=text], input[type=email], input[type=password], input[type=search], select, textarea {
  width: 100%; font: inherit; color: var(--text); background: var(--surface); border: 1.5px solid var(--border);
  border-radius: var(--radius); padding: 9px 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { min-height: 90px; resize: vertical; }
.check { display: flex; align-items: center; gap: 8px; font-weight: 400; font-size: 14px; margin: 6px 0; cursor: pointer; }
.check input { width: 16px; height: 16px; accent-color: var(--accent); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow); padding: 20px; }
.msg { padding: 10px 12px; border-radius: var(--radius); font-size: 14px; margin: 12px 0; }
.msg.error { background: rgba(198,40,40,.1); color: var(--danger); }
.msg.ok { background: rgba(46,125,50,.1); color: var(--ok); }
.msg.info { background: var(--accent-soft); color: var(--text); }

/* Шапка */
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 12px; padding: 10px 20px;
  background: var(--surface); border-bottom: 1px solid var(--border); }
.topbar .logo { height: 30px; display: block; }
.topbar .spacer { flex: 1; }
.topbar .title { font-weight: 600; color: var(--muted); font-size: 14px; }
.logo-dark { display: none !important; } :root[data-theme="dark"] .logo-dark { display: block !important; } :root[data-theme="dark"] .logo-light { display: none !important; }

/* Вход */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.auth { width: 100%; max-width: 380px; }
.auth .logo { height: 40px; margin: 0 auto 18px; display: block; }
.auth h1 { font-size: 20px; text-align: center; }
.auth .btn.block { margin-top: 16px; }
.codebox { font-family: var(--mono); font-size: 15px; background: var(--surface-2); padding: 10px; border-radius: var(--radius); word-break: break-all; }

/* Плитки */
.main { max-width: 1200px; margin: 0 auto; padding: 24px 20px 60px; }
.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 18px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 340px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.tile { position: relative; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  cursor: pointer; transition: border-color .15s, box-shadow .15s, transform .15s; user-select: none; }
.tile:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.tile.dragging { opacity: .4; } .tile.drop-target { outline: 2px dashed var(--accent); outline-offset: 2px; }
.tile .icon { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); display: grid; place-items: center;
  overflow: hidden; margin-bottom: 10px; font-weight: 700; color: var(--accent); font-size: 18px; }
.tile .icon img { width: 100%; height: 100%; object-fit: contain; }
.tile .name { font-weight: 600; margin-bottom: 4px; }
.tile .desc { color: var(--muted); font-size: 13px; }
.tile .badge { position: absolute; top: 10px; left: 10px; font-size: 11px; background: var(--surface-2); color: var(--muted); padding: 1px 6px; border-radius: 6px; }
.tile .menu-btn { position: absolute; top: 8px; right: 8px; border: 0; background: transparent; color: var(--muted); font-size: 18px;
  width: 30px; height: 30px; border-radius: 6px; cursor: pointer; }
.tile .menu-btn:hover { background: var(--surface-2); color: var(--text); }
.empty { text-align: center; padding: 60px 20px; color: var(--muted); }

/* Выпадающее меню */
.menu { position: absolute; z-index: 50; min-width: 220px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: block; width: 100%; text-align: left; font: inherit; font-size: 14px; background: none; border: 0;
  color: var(--text); padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.menu button:hover { background: var(--surface-2); }
.menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }

/* Приложения внутри платформы */
.dock { position: fixed; inset: 56px 0 0 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column; }
.dock-tabs { display: flex; gap: 4px; padding: 6px 12px; background: var(--surface); border-bottom: 1px solid var(--border); align-items: center; }
.dock-tab { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 14px; border: 1px solid transparent; }
.dock-tab.active { background: var(--accent-soft); border-color: var(--accent); }
.dock-tab .x { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 16px; padding: 0 2px; }
.dock-frames { flex: 1; position: relative; }
.dock-frames iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }

/* Модальные окна */
.modal-bg { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; }
.modal .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.help-text { white-space: pre-wrap; }

/* Админка */
.admin-layout { display: grid; grid-template-columns: 200px 1fr; gap: 20px; max-width: 1300px; margin: 0 auto; padding: 24px 20px 60px; }
.side a { display: block; padding: 8px 12px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; margin-bottom: 2px; }
.side a.active, .side a:hover { background: var(--accent-soft); color: var(--accent); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr:hover td { background: var(--surface-2); }
.tag { display: inline-block; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: var(--surface-2); margin: 1px 2px 1px 0; }
.tag.red { background: rgba(198,40,40,.12); color: var(--danger); } .tag.pink { background: var(--accent-soft); color: var(--accent); }
.checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0 12px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.table-wrap { overflow-x: auto; }
@media (max-width: 760px) {
  .admin-layout { grid-template-columns: 1fr; }
  .side { display: flex; gap: 4px; overflow-x: auto; }
  .grid2 { grid-template-columns: 1fr; }
}
