:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1c2333;
  --muted: #6a7489;
  --line: #e2e6ee;
  --primary: #2952cc;
  --primary-soft: #e8eefc;
  --danger: #c62f3b;
  --danger-soft: #fdecee;
  --ok: #1f8a4c;
  --warn: #b7791f;
  --radius: 12px;
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
h2 { margin: 0 0 4px; font-size: 20px; }
h3 { margin: 18px 0 6px; font-size: 15px; }
code, pre { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
pre { background: #10172a; color: #e6ebf5; padding: 12px; border-radius: 8px; overflow-x: auto; white-space: pre-wrap; word-break: break-all; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); min-height: 1em; }
.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; align-items: flex-start; }
.row.end { justify-content: flex-end; }
.col { display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }

input, select, textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; font: inherit; background: #fff; color: inherit; }
textarea { font-family: ui-monospace, Consolas, monospace; font-size: 14px; }
label { display: block; margin: 10px 0; font-weight: 500; }
label input, label select, label textarea { margin-top: 4px; font-weight: 400; }
label.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; margin: 8px 0; }
label.check input { width: auto; margin-top: 3px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 9px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text); font: inherit; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #c4cbd8; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn.big { padding: 13px 20px; font-size: 16px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #f0c2c6; }
.btn.ghost { background: transparent; }
.btn.file { margin: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }
.container { max-width: 1180px; margin: 0 auto; padding: 20px 16px 60px; }

.topbar { display: flex; justify-content: space-between; align-items: center; padding: 12px 20px; background: #fff; border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 5; }
.topbar-right { display: flex; gap: 10px; align-items: center; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 18px; }
.brand.big { font-size: 26px; }
.brand .org { font-weight: 400; color: var(--muted); font-size: 15px; }
.logo { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--primary); color: #fff; font-weight: 800; }
.pill { background: var(--primary-soft); color: var(--primary); padding: 4px 10px; border-radius: 99px; font-size: 13px; font-weight: 600; }

.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; }
.login-card .btn { width: 100%; margin-top: 6px; }

.exam { border-width: 2px; }
.exam.active { border-color: var(--danger); background: var(--danger-soft); }
.exam-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.badge { background: var(--danger); color: #fff; padding: 6px 12px; border-radius: 99px; font-weight: 700; font-size: 13px; animation: pulse 1.6s infinite; }
@keyframes pulse { 50% { opacity: .65; } }
.exam-form { margin-top: 8px; }
.exam-actions { margin-top: 12px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; }
.seg label { margin: 0; padding: 8px 14px; cursor: pointer; font-weight: 500; display: flex; gap: 6px; align-items: center; }
.seg label + label { border-left: 1px solid var(--line); }
.seg input { width: auto; margin: 0; }

.tabs { display: flex; gap: 4px; margin: 4px 0 12px; overflow-x: auto; }
.tabs button { border: none; background: transparent; padding: 10px 14px; border-radius: 8px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button.active { background: #fff; color: var(--primary); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line); }

.table-wrap { overflow-x: auto; margin-top: 12px; }
table.devices { width: 100%; border-collapse: collapse; }
.devices th, .devices td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.devices th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); }
.devices td.actions { text-align: right; }
.devices td.actions .btn { margin-left: 4px; }
.status { display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #aab2c2; }
.dot.on { background: var(--ok); }
.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef1f6; color: var(--muted); }
.tag.warn { background: #fdf3e1; color: var(--warn); }
.tag.exam { background: var(--danger-soft); color: var(--danger); }
.tag.err { background: var(--danger-soft); color: var(--danger); }
.empty { text-align: center; padding: 30px; color: var(--muted); }

.apps-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 6px; margin: 12px 0; }
.app-item { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; cursor: pointer; margin: 0; font-weight: 400; }
.app-item input { width: auto; margin: 0; }
.app-item.on { border-color: var(--primary); background: var(--primary-soft); }
.app-item small { display: block; color: var(--muted); font-size: 12px; word-break: break-all; }
.manual { margin-top: 14px; }
.manual summary { cursor: pointer; color: var(--primary); font-weight: 500; }
.manual .row { margin-top: 8px; }
.presets { margin: 10px 0; }

.wallpaper { display: flex; gap: 20px; flex-wrap: wrap; margin-top: 12px; }
.wp-preview { width: 360px; max-width: 100%; aspect-ratio: 16 / 10; border-radius: 10px; border: 1px solid var(--line); background: #eef1f6 center / cover no-repeat; display: grid; place-items: center; }

.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.code { font: 700 32px ui-monospace, Consolas, monospace; letter-spacing: .08em; margin: 6px 0 10px; }
.steps { padding-left: 20px; margin: 6px 0; }
.qr { display: inline-block; padding: 10px; background: #fff; border: 1px solid var(--line); border-radius: 10px; min-height: 60px; }
.qr img { display: block; width: 280px; height: 280px; image-rendering: pixelated; }

dialog { border: none; border-radius: var(--radius); padding: 22px; width: min(420px, calc(100vw - 32px)); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
dialog::backdrop { background: rgba(15, 20, 35, .45); }
dialog h3 { margin-top: 0; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(30px); background: #1c2333; color: #fff; padding: 11px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translateX(-50%); }
.toast.err { background: var(--danger); }

@media (max-width: 760px) {
  .grid2 { grid-template-columns: 1fr; }
  .topbar { padding: 10px 16px; }
  .brand .org { display: none; }
  .exam-actions .btn { width: 100%; }
}
