:root {
  --bg: #f3f6fb;
  --panel: #ffffff;
  --text: #18212f;
  --muted: #6b778c;
  --line: #e3e8f0;
  --primary: #246bfd;
  --primary-dark: #174fc5;
  --success: #14804a;
  --warning: #9a6700;
  --danger: #c9362b;
  --info: #1769aa;
  --sidebar: #111827;
  --radius: 12px;
  --shadow: 0 7px 24px rgba(26, 39, 66, .07);
}
* { box-sizing: border-box; }
html { min-height: 100%; }
body { margin: 0; min-height: 100vh; font: 14px/1.55 system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif; color: var(--text); background: var(--bg); }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.app { min-height: 100vh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar { position: sticky; top: 0; height: 100vh; padding: 24px 16px; background: var(--sidebar); color: white; overflow-y: auto; }
.brand { display: flex; gap: 11px; align-items: center; margin: 0 8px 25px; font-weight: 750; font-size: 16px; }
.brand-mark { display: grid; place-items: center; width: 35px; height: 35px; border-radius: 10px; background: linear-gradient(145deg,#44a4ff,#246bfd); box-shadow: 0 6px 15px #0c47c9aa; }
.nav { display: grid; gap: 4px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 9px; color: #cbd5e1; }
.nav a:hover, .nav a.active { color: #fff; background: #253044; }
.nav-icon { width: 20px; text-align: center; }
.sidebar-foot { margin-top: 25px; padding: 15px 10px 0; border-top: 1px solid #2b3649; color: #94a3b8; font-size: 12px; }
.main { min-width: 0; }
.topbar { height: 67px; display: flex; align-items: center; justify-content: space-between; padding: 0 28px; background: #fff; border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 0; font-size: 20px; }
.top-actions { display: flex; gap: 10px; align-items: center; color: var(--muted); }
.menu-toggle { display: none; border: 0; background: transparent; font-size: 23px; }
.content { padding: 25px 28px 50px; max-width: 1600px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h2 { margin: 0 0 4px; font-size: 22px; }
.page-head p { margin: 0; color: var(--muted); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 17px 19px; border-bottom: 1px solid var(--line); }
.card-head h3 { margin: 0; font-size: 16px; }
.card-body { padding: 19px; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats { display: grid; grid-template-columns: repeat(6, minmax(130px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat { padding: 17px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.stat-label { color: var(--muted); font-size: 12px; }
.stat-value { margin-top: 4px; font-size: 26px; font-weight: 750; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 13px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { color: var(--muted); font-size: 12px; font-weight: 650; background: #fafbfc; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.status { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 650; background: #edf1f7; color: #526071; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-online, .status-success, .status-sent { background: #e7f8ef; color: var(--success); }
.status-error, .status-failed, .status-abandoned { background: #ffefee; color: var(--danger); }
.status-cooldown, .status-pending, .status-blocked { background: #fff6db; color: var(--warning); }
.status-offline, .status-scheduled_offline { background: #edf1f7; color: #607087; }
.status-invisible { background: #eaf5ff; color: var(--info); }
.badge { display: inline-block; padding: 2px 7px; border-radius: 6px; background: #edf3ff; color: var(--primary-dark); font-size: 12px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 13px; border: 1px solid transparent; border-radius: 8px; font-weight: 650; background: #fff; color: var(--text); }
.btn:hover { filter: brightness(.97); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { border-color: var(--line); }
.btn-danger { color: var(--danger); border-color: #f2c6c2; background: #fff8f7; }
.btn-sm { min-height: 30px; padding: 4px 9px; font-size: 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.actions form { margin: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 15px 18px; }
.field { min-width: 0; }
.field.full { grid-column: 1 / -1; }
label { display: block; margin: 0 0 6px; font-weight: 650; }
.hint { margin-top: 5px; color: var(--muted); font-size: 12px; }
input[type=text], input[type=password], input[type=number], input[type=tel], input[type=time], input[type=file], select, textarea { width: 100%; border: 1px solid #ccd5e2; border-radius: 8px; background: #fff; color: var(--text); padding: 9px 11px; outline: none; }
textarea { min-height: 92px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px #246bfd1c; }
.risk-meter { width: 180px; height: 8px; overflow: hidden; border-radius: 99px; background: #edf1f7; }
.risk-meter > span { display: block; height: 100%; background: linear-gradient(90deg,#20a866,#e5a100,#d74336); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 500; margin: 0; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.checks { display: flex; flex-wrap: wrap; gap: 14px 20px; }
.form-actions { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 9px; padding-top: 3px; }
.alert { margin-bottom: 15px; padding: 11px 14px; border-radius: 9px; border: 1px solid; }
.alert-success { color: #0e6238; background: #eaf9f1; border-color: #bce8d0; }
.alert-error { color: #9d2920; background: #fff0ef; border-color: #f0c0bc; }
.alert-warning { color: #725000; background: #fff7dc; border-color: #eedb9b; }
.alert-info { color: #135b91; background: #eaf5ff; border-color: #bddcf5; }
.empty { padding: 35px 20px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; word-break: break-all; }
.preview { white-space: pre-wrap; max-width: 520px; word-break: break-word; }
details.editor { border-top: 1px solid var(--line); }
details.editor > summary { list-style: none; cursor: pointer; padding: 13px 19px; color: var(--primary); font-weight: 650; }
details.editor > summary::-webkit-details-marker { display: none; }
details.editor[open] > summary { border-bottom: 1px solid var(--line); background: #f8faff; }
.item-card + .item-card { margin-top: 16px; }
.item-summary { padding: 16px 19px; display: flex; gap: 15px; align-items: center; justify-content: space-between; }
.item-title { font-weight: 700; }
.item-meta { display: flex; flex-wrap: wrap; gap: 7px 14px; color: var(--muted); margin-top: 4px; }
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 20% 15%,#e5efff,#f5f7fb 45%,#edf2f8); }
.login-card { width: min(420px, 100%); padding: 30px; background: #fff; border-radius: 16px; box-shadow: 0 20px 60px rgba(29,47,82,.15); border: 1px solid #e3e8f0; }
.login-card h1 { margin: 13px 0 5px; font-size: 23px; }
.login-card p { margin: 0 0 23px; color: var(--muted); }
.login-card .field { margin-bottom: 15px; }
.login-card .btn { width: 100%; margin-top: 5px; }
.steps { display: grid; grid-template-columns: repeat(3, 1fr); margin-bottom: 20px; gap: 8px; }
.step { text-align: center; color: var(--muted); font-size: 12px; }
.step span { display: grid; place-items: center; width: 28px; height: 28px; margin: 0 auto 5px; border-radius: 50%; background: #e7ebf1; }
.step.active { color: var(--primary); font-weight: 700; }
.step.active span { color: #fff; background: var(--primary); }
.code { display: block; padding: 10px 12px; background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; font-family: ui-monospace, monospace; }
@media (max-width: 1150px) { .stats { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 800px) {
  .app { display: block; }
  .sidebar { position: fixed; z-index: 20; left: -260px; width: 236px; transition: left .2s; box-shadow: 10px 0 30px #0003; }
  body.nav-open .sidebar { left: 0; }
  .menu-toggle { display: block; }
  .topbar { padding: 0 16px; }
  .content { padding: 18px 14px 40px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .field.full, .form-actions { grid-column: auto; }
  .stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .page-head { align-items: stretch; flex-direction: column; }
  .page-head .btn { align-self: flex-start; }
  .item-summary { align-items: flex-start; flex-direction: column; }
}
@media (max-width: 430px) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: 13px; }
  .stat-value { font-size: 22px; }
  .top-actions .admin-name { display: none; }
}
