[hidden] { display: none !important; }
:root { --font: 'Segoe UI Variable Text', 'Segoe UI', Inter, system-ui, -apple-system, sans-serif; --bg: #f3f3f3; --card: #fbfbfb; --line: #e5e5e5; --text: #1b1b1b; --muted: #616161; --accent: #005fb8; --accent-h: #0a6cc7; --danger: #c42b1c; --ok: #0f7b0f; --warn: #9d5d00; }
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
h1 { font-size: 28px; font-weight: 600; margin: 4px 0 18px; }
h2 { font-size: 20px; font-weight: 600; margin: 0 0 12px; }
h3 { font-size: 15px; font-weight: 600; margin: 0 0 10px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.err { color: var(--danger); margin: 8px 0 0; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px; border-radius: 5px; border: 1px solid #d1d1d1; border-bottom-color: #bdbdbd; background: #fff; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background-color .12s; }
.btn:hover { background: #f6f6f6; } .btn:active { background: #f0f0f0; color: #5d5d5d; }
.btn.primary { background: var(--accent); border-color: #0050a0; color: #fff; } .btn.primary:hover { background: var(--accent-h); }
.btn.subtle { background: transparent; border-color: transparent; } .btn.subtle:hover { background: rgba(0,0,0,.05); }
.btn.danger { color: #fff; background: var(--danger); border-color: #a62417; } .btn.subtle.danger { color: var(--danger); background: transparent; }
.btn:disabled { opacity: .5; cursor: default; }
input[type=text], input[type=url], input[type=number], input:not([type]), select { height: 34px; padding: 0 10px; border: 1px solid #d6d6d6; border-bottom: 1px solid #8a8a8a; border-radius: 5px; background: #fff; min-width: 0; }
input:focus, select:focus { outline: none; border-bottom: 2px solid var(--accent); }
input.num { width: 84px; }
.row { display: flex; gap: 8px; align-items: center; margin: 10px 0; } .row input { flex: 1; } .row.gap { flex-wrap: wrap; }
.btns { display: flex; flex-wrap: wrap; gap: 8px; }
.sep { height: 1px; background: var(--line); margin: 20px 0; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(640px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 32px; box-shadow: 0 2px 8px rgba(0,0,0,.04); }
.brand { display: flex; gap: 12px; align-items: center; margin-bottom: 18px; }
.brand img { width: 40px; height: 40px; border-radius: 8px; }
.brand b { display: block; font-size: 14px; } .brand small { color: var(--muted); font-size: 12px; }

/* layout */
.app { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.nav { padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; }
.nav .brand { padding: 0 8px; }
#navList { display: flex; flex-direction: column; gap: 2px; }
.nav-item { position: relative; display: flex; align-items: center; gap: 12px; height: 38px; padding: 0 14px; border-radius: 5px; cursor: pointer; border: 0; background: transparent; text-align: left; width: 100%; }
.nav-item:hover { background: rgba(0,0,0,.04); }
.nav-item.on { background: rgba(0,0,0,.06); font-weight: 500; }
.nav-item.on::before { content: ''; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--accent); }
.nav-item svg { width: 18px; height: 18px; }
.logout { margin-top: auto; align-self: flex-start; }
.main { padding: 28px 40px 60px; max-width: 1240px; width: 100%; }
.offline { background: #fff4ce; border: 1px solid #f1d491; color: #5c4400; padding: 10px 14px; border-radius: 6px; margin-bottom: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; margin-bottom: 12px; }
.card.flush { padding: 0; overflow: auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; } .grid2 > .card { margin: 0 0 12px; }
@media (max-width: 1000px) { .grid2 { grid-template-columns: 1fr; } .app { grid-template-columns: 1fr; } .nav { position: static; height: auto; } }

.status { display: inline-flex; align-items: center; gap: 8px; padding: 6px 12px; border-radius: 999px; background: #f0f0f0; font-weight: 500; }
.status::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: #8a8a8a; }
.status.ok { background: #dff6dd; color: #0e5a0e; } .status.ok::before { background: var(--ok); }
.status.warn { background: #fff4ce; color: #5c4400; } .status.warn::before { background: #c08000; }
.status.bad { background: #fde7e9; color: #8a1c12; } .status.bad::before { background: var(--danger); }
.kpis { display: flex; gap: 18px; color: var(--muted); font-size: 13px; } .kpis b { color: var(--text); font-size: 15px; }
.preview { position: relative; width: 100%; aspect-ratio: 16 / 9; background: #000; border-radius: 6px; overflow: hidden; margin-top: 10px; }
.preview iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }

/* rules table */
table.rules { width: 100%; border-collapse: collapse; }
.rules th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 12px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rules td { padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.rules tr:last-child td { border-bottom: 0; }
.rules tr.off td:not(:first-child) { opacity: .5; }
.src { display: flex; align-items: center; gap: 10px; } .src img { width: 30px; height: 30px; object-fit: contain; }
.src .evi { width: 30px; height: 30px; border-radius: 6px; background: #eef3fa; display: grid; place-items: center; font-size: 13px; font-weight: 600; color: var(--accent); }
.src small { display: block; color: var(--muted); font-size: 12px; }
.pill { display: inline-block; padding: 3px 10px; border-radius: 999px; background: #eef3fa; color: #0b4a8c; font-size: 12.5px; font-weight: 500; white-space: nowrap; }
.pill.red { background: #fde7e9; color: #8a1c12; } .pill.green { background: #dff6dd; color: #0e5a0e; }
.prog { width: 110px; height: 6px; border-radius: 3px; background: #e8e8e8; overflow: hidden; } .prog i { display: block; height: 100%; background: var(--accent); }
.acts { display: flex; gap: 4px; justify-content: flex-end; }
.toggle { position: relative; width: 40px; height: 20px; border-radius: 10px; border: 1px solid #8a8a8a; background: #fff; cursor: pointer; padding: 0; }
.toggle::after { content: ''; position: absolute; left: 3px; top: 3px; width: 12px; height: 12px; border-radius: 50%; background: #5d5d5d; transition: transform .15s; }
.toggle.on { background: var(--accent); border-color: var(--accent); } .toggle.on::after { background: #fff; transform: translateX(20px); }
.empty { padding: 28px; text-align: center; color: var(--muted); }

/* forms */
.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 6px; } .form label > span, .gift-field > span { font-weight: 500; }
.form label.check { display: flex; align-items: center; gap: 10px; } .form label.check input { width: 18px; height: 18px; accent-color: var(--accent); }
.gift-field { display: grid; gap: 6px; }
.gift-pick { border: 1px solid #d6d6d6; border-radius: 6px; background: #fff; }
.gift-pick .gp-top { display: flex; gap: 8px; padding: 8px; border-bottom: 1px solid var(--line); align-items: center; }
.gift-pick .gp-top input { flex: 1; }
.gift-pick .gp-sel { display: flex; align-items: center; gap: 8px; font-weight: 500; white-space: nowrap; }
.gift-pick .gp-sel img { width: 26px; height: 26px; }
.gift-pick .gp-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 4px; max-height: 260px; overflow: auto; padding: 8px; }
.gp-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 4px; border-radius: 6px; border: 1px solid transparent; background: transparent; cursor: pointer; font-size: 12px; text-align: center; }
.gp-item:hover { background: #f3f6fa; } .gp-item.on { border-color: var(--accent); background: #eaf2fb; }
.gp-item img { width: 40px; height: 40px; object-fit: contain; }
.gp-item small { color: var(--muted); }
.gp-any { font-weight: 600; color: var(--accent); }
.dlg { border: 1px solid var(--line); border-radius: 8px; padding: 0; width: min(640px, 94vw); box-shadow: 0 16px 48px rgba(0,0,0,.2); }
.dlg::backdrop { background: rgba(0,0,0,.3); }
.dlg form { padding: 24px; background: #fff; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding-top: 6px; }

/* controls */
.kv { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px; } .kv b { font-size: 22px; font-weight: 600; }
.mirror { background: #0f0f0f; border-radius: 8px; padding: 18px; overflow-x: auto; }
.danger-zone { display: flex; justify-content: flex-end; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 10px; margin-bottom: 12px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 14px 16px; } .stat small { color: var(--muted); display: block; } .stat b { font-size: 24px; font-weight: 600; }
.feed { list-style: none; margin: 0; padding: 0; max-height: 420px; overflow: auto; }
.feed li { display: flex; gap: 12px; padding: 7px 0; border-bottom: 1px solid var(--line); font-size: 13px; } .feed time { color: var(--muted); width: 70px; flex: none; }
.toast { position: fixed; right: 24px; bottom: 24px; background: #1b1b1b; color: #fff; padding: 10px 16px; border-radius: 6px; box-shadow: 0 8px 24px rgba(0,0,0,.25); z-index: 10; }
.toast.bad { background: var(--danger); }
