* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #1c1c1e;
  --surface: #2c2c2e;
  --surface2: #3a3a3c;
  --accent: #0a84ff;
  --green: #30d158;
  --red: #ff453a;
  --yellow: #ffd60a;
  --text: #f2f2f7;
  --text2: #aeaeb2;
  --radius: 12px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { max-width: 480px; margin: 0 auto; padding-bottom: 20px; }

header {
  padding: 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--surface2);
  position: sticky;
  top: 0;
  z-index: 10;
}

header h1 { font-size: 18px; margin-bottom: 12px; }

nav { display: flex; gap: 8px; }

.tab {
  flex: 1;
  padding: 8px;
  border: none;
  border-radius: 8px;
  background: var(--surface2);
  color: var(--text2);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}
.tab.active { background: var(--accent); color: #fff; }

.tab-content { display: none; padding: 16px; }
.tab-content.active { display: block; }

/* Карточка роутера */
.router-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.router-card:active { background: var(--surface2); }

.router-card-header { display: flex; align-items: center; justify-content: space-between; }
.router-name { font-weight: 600; font-size: 16px; }
.router-ip { font-size: 12px; color: var(--text2); margin-top: 2px; }

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
}
.badge-green { background: rgba(48,209,88,.15); color: var(--green); }
.badge-red { background: rgba(255,69,58,.15); color: var(--red); }
.badge-gray { background: var(--surface2); color: var(--text2); }

/* Форма */
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text2); margin-bottom: 6px; }
.form-group input {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-size: 15px;
}
.form-group input:focus { outline: none; border-color: var(--accent); }
.form-group.row { display: flex; gap: 12px; }
.form-group.row > div { flex: 1; }

.btn {
  width: 100%;
  padding: 14px;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary { background: var(--accent); color: #fff; }
.btn.green { background: var(--green); color: #fff; }
.btn.red { background: var(--red); color: #fff; }
.btn.secondary { background: var(--surface2); color: var(--text); }

/* Оверлей деталей */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 100;
  display: flex;
  align-items: flex-end;
}
.overlay.hidden { display: none; }
.overlay-content {
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  padding: 20px 16px 32px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  position: relative;
}
.close-btn {
  position: absolute;
  top: 12px; right: 16px;
  background: var(--surface2);
  border: none;
  color: var(--text2);
  width: 30px; height: 30px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 14px;
}

.detail-title { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.detail-sub { font-size: 13px; color: var(--text2); margin-bottom: 20px; }

.section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text2);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 18px 0 8px;
}

/* Аудит */
.audit-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--surface2);
}
.audit-item:last-child { border-bottom: none; }
.audit-icon { font-size: 18px; flex-shrink: 0; }
.audit-label { flex: 1; font-size: 14px; }
.audit-detail { font-size: 12px; color: var(--text2); }

/* Кнопки шаблонов */
.template-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface2);
  border-radius: 8px;
  margin-bottom: 8px;
  border: none;
  color: var(--text);
  width: 100%;
  cursor: pointer;
  font-size: 14px;
  text-align: left;
  transition: opacity 0.2s;
}
.template-btn:active { opacity: 0.7; }
.template-btn .arrow { color: var(--text2); }

/* Создать пользователя */
.user-form { margin-top: 8px; }
.user-form input {
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid var(--surface2);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  margin-bottom: 8px;
}

/* Danger zone */
.danger-btn {
  width: 100%;
  padding: 12px;
  margin-top: 8px;
  background: rgba(255,69,58,.1);
  border: 1px solid rgba(255,69,58,.3);
  border-radius: 8px;
  color: var(--red);
  font-size: 14px;
  cursor: pointer;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface2);
  color: var(--text);
  padding: 12px 20px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 200;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,.4);
}
.toast.hidden { display: none; }

.loading { text-align: center; color: var(--text2); padding: 40px 0; }
.spinner { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.empty { text-align: center; color: var(--text2); padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
